1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-01 17:38:38 +00:00

new design, pagination & more

This commit is contained in:
Nicolas Lœuillet 2013-08-05 21:56:32 +02:00
parent 55821e04c1
commit 6a361945ea
31 changed files with 467 additions and 371 deletions

View file

@ -13,11 +13,13 @@ class Poche
public $store;
public $tpl;
public $messages;
public $pagination;
function __construct($storage_type)
{
$this->store = new $storage_type();
$this->init();
$this->messages = new Messages();
# installation
if(!$this->store->isInstalled())
@ -46,6 +48,8 @@ class Poche
$filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
$this->tpl->addFilter($filter);
$this->pagination = new Paginator(PAGINATION, 'p');
Tools::initPhp();
Session::init();
}
@ -54,7 +58,7 @@ class Poche
{
Tools::logm('poche still not installed');
echo $this->tpl->render('install.twig', array(
'token' => Session::getToken(),
'token' => Session::getToken()
));
if (isset($_GET['install'])) {
if (($_POST['password'] == $_POST['password_repeat'])
@ -62,6 +66,11 @@ class Poche
# let's rock, install poche baby !
$this->store->install($_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']));
Session::logout();
Tools::logm('poche is now installed');
Tools::redirect();
}
else {
Tools::logm('error during installation');
Tools::redirect();
}
}
@ -89,30 +98,32 @@ class Poche
if (DOWNLOAD_PICTURES) {
$content = filtre_picture($parametres_url['content'], $url->getUrl(), $last_id);
}
#$msg->add('s', _('the link has been added successfully'));
$this->messages->add('s', _('the link has been added successfully'));
}
else {
#$msg->add('e', _('error during insertion : the link wasn\'t added'));
$this->messages->add('e', _('error during insertion : the link wasn\'t added'));
Tools::logm('error during insertion : the link wasn\'t added');
}
}
else {
#$msg->add('e', _('error during url preparation : the link wasn\'t added'));
$this->messages->add('e', _('error during fetching content : the link wasn\'t added'));
Tools::logm('error during content fetch');
}
Tools::redirect();
break;
case 'delete':
if ($this->store->deleteById($id)) {
if (DOWNLOAD_PICTURES) {
remove_directory(ABS_PATH . $id);
}
#$msg->add('s', _('the link has been deleted successfully'));
$this->messages->add('s', _('the link has been deleted successfully'));
Tools::logm('delete link #' . $id);
}
else {
#$msg->add('e', _('the link wasn\'t deleted'));
$this->messages->add('e', _('the link wasn\'t deleted'));
Tools::logm('error : can\'t delete link #' . $id);
}
Tools::redirect();
break;
case 'toggle_fav' :
$this->store->favoriteById($id);
@ -169,9 +180,14 @@ class Poche
break;
default: # home view
$entries = $this->store->getEntriesByView($view);
$this->pagination->set_total(count($entries));
$page_links = $this->pagination->page_links('?view=' . $view . '&sort=' . $_SESSION['sort'] . '&');
$datas = $this->store->getEntriesByView($view, $this->pagination->get_limit());
$tpl_vars = array(
'entries' => $entries,
'entries' => $datas,
'page_links' => $page_links,
);
Tools::logm('display ' . $view . ' view');
break;
}
@ -183,6 +199,7 @@ class Poche
if (MODE_DEMO) {
$this->messages->add('i', 'in demo mode, you can\'t update your password');
Tools::logm('in demo mode, you can\'t do this');
Tools::redirect('?view=config');
}
else {
if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
@ -195,6 +212,7 @@ class Poche
}
else {
$this->messages->add('e', 'the two fields have to be filled & the password must be the same in the two fields');
Tools::redirect('?view=config');
}
}
}
@ -205,7 +223,7 @@ class Poche
if (!empty($_POST['login']) && !empty($_POST['password'])) {
if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) {
Tools::logm('login successful');
$this->messages->add('s', 'login successful, welcome to your poche');
$this->messages->add('s', 'welcome to your poche');
if (!empty($_POST['longlastingsession'])) {
$_SESSION['longlastingsession'] = 31536000;
$_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
@ -216,11 +234,11 @@ class Poche
session_regenerate_id(true);
Tools::redirect($referer);
}
$this->messages->add('e', 'login failed, bad login or password');
$this->messages->add('e', 'login failed: bad login or password');
Tools::logm('login failed');
Tools::redirect();
} else {
$this->messages->add('e', 'login failed, you have to fill all fields');
$this->messages->add('e', 'login failed: you have to fill all fields');
Tools::logm('login failed');
Tools::redirect();
}
@ -228,7 +246,7 @@ class Poche
public function logout()
{
$this->messages->add('s', 'logout successful, see you soon!');
$this->messages->add('s', 'see you soon!');
Tools::logm('logout');
Session::logout();
Tools::redirect();

View file

@ -197,7 +197,7 @@ class Tools
{
if (DEBUG_POCHE) {
$t = strval(date('Y/m/d_H:i:s')) . ' - ' . $_SERVER["REMOTE_ADDR"] . ' - ' . strval($message) . "\n";
file_put_contents('./log.txt', $t, FILE_APPEND);
file_put_contents(CACHE . '/log.txt', $t, FILE_APPEND);
}
}

View file

@ -8,7 +8,7 @@
* @license http://www.wtfpl.net/ see COPYING file
*/
define ('POCHE_VERSION', '1.0-alpha');
define ('POCHE_VERSION', '1.0-beta');
define ('MODE_DEMO', FALSE);
define ('DEBUG_POCHE', FALSE);
define ('CONVERT_LINKS_FOOTNOTES', FALSE);
@ -22,24 +22,26 @@ define ('TPL', './tpl');
define ('LOCALE', './locale');
define ('CACHE', './cache');
define ('LANG', 'fr_FR.UTF8');
define ('PAGINATION', '10');
define ('THEME', 'light');
$storage_type = 'sqlite'; # sqlite, mysql, (file, not yet)
# /!\ Be careful if you change the lines below /!\
require_once './inc/poche/Tools.class.php';
require_once './inc/poche/Url.class.php';
require_once './inc/3rdparty/Session.class.php';
require_once './inc/3rdparty/class.messages.php';
require_once './inc/poche/Poche.class.php';
require_once './inc/3rdparty/Readability.php';
require_once './inc/3rdparty/Encoding.php';
require_once './inc/3rdparty/Session.class.php';
require_once './inc/store/store.class.php';
require_once './inc/store/' . $storage_type . '.class.php';
require_once './vendor/autoload.php';
require_once './inc/3rdparty/simple_html_dom.php';
require_once './inc/3rdparty/class.messages.php';
require_once './inc/3rdparty/paginator.php';
if (DOWNLOAD_PICTURES) {
require_once './inc/poche/pochePictures.php';
}
$poche = new Poche($storage_type);
$poche->messages = new Messages();
$poche = new Poche($storage_type);