aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--css/style.css19
-rw-r--r--inc/config.php8
-rw-r--r--inc/poche/pocheCore.php30
-rw-r--r--index.php23
-rw-r--r--tpl/home.twig44
-rw-r--r--tpl/layout.twig42
-rw-r--r--tpl/login.twig10
7 files changed, 86 insertions, 90 deletions
diff --git a/css/style.css b/css/style.css
index 28e18b96..69e37497 100644
--- a/css/style.css
+++ b/css/style.css
@@ -205,19 +205,6 @@ body.article {
205 } 205 }
206} 206}
207 207
208/*** ***/ 208.messages {
209/*** MESSAGES ***/ 209
210 210} \ No newline at end of file
211.messages { width: 100%; -moz-border-radius: 4px; border-radius: 4px; display: block; padding: 10px 0; margin: 10px auto 10px; clear: both; }
212.messages a.closeMessage { margin: -14px -8px 0 0; display:none; width: 16px; height: 16px; float: right; background: url(../img/messages/close.png) no-repeat; }
213/*.messages:hover a.closeMessage { visibility:visible; }*/
214.messages p { margin: 3px 0 3px 10px !important; padding: 0 10px 0 23px !important; font-size: 14px; line-height: 16px; }
215.messages.error { border: 1px solid #C42608; color: #c00 !important; background: #FFF0EF; }
216.messages.error p { background: url(../img/messages/cross.png ) no-repeat 0px 50%; color:#c00 !important; }
217.messages.success {background: #E0FBCC; border: 1px solid #6DC70C; }
218.messages.success p { background: url(../img/messages/tick.png) no-repeat 0px 50%; color: #2B6301 !important; }
219.messages.warning { background: #FFFCD3; border: 1px solid #EBCD41; color: #000; }
220.messages.warning p { background: url(../img/messages/warning.png ) no-repeat 0px 50%; color: #5F4E01; }
221.messages.information, .messages.info { background: #DFEBFB; border: 1px solid #82AEE7; }
222.messages.information p, .messages.info p { background: url(../img/messages/help.png ) no-repeat 0px 50%; color: #064393; }
223.messages.information a { text-decoration: underline; }
diff --git a/inc/config.php b/inc/config.php
index c4898cc9..b78147ab 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -10,7 +10,7 @@
10 10
11define ('POCHE_VERSION', '0.3'); 11define ('POCHE_VERSION', '0.3');
12define ('MODE_DEMO', FALSE); 12define ('MODE_DEMO', FALSE);
13define ('DEBUG_POCHE', TRUE); 13define ('DEBUG_POCHE', FALSE);
14define ('CONVERT_LINKS_FOOTNOTES', FALSE); 14define ('CONVERT_LINKS_FOOTNOTES', FALSE);
15define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); 15define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
16define ('DOWNLOAD_PICTURES', FALSE); 16define ('DOWNLOAD_PICTURES', FALSE);
@@ -21,7 +21,7 @@ define ('LOCALE', './locale');
21define ('CACHE', './cache'); 21define ('CACHE', './cache');
22define ('LANG', 'fr_FR.UTF8'); 22define ('LANG', 'fr_FR.UTF8');
23 23
24$storage_type = 'sqlite'; # sqlite or file 24$storage_type = 'sqlite'; # sqlite, file
25 25
26# /!\ Be careful if you change the lines below /!\ 26# /!\ Be careful if you change the lines below /!\
27 27
@@ -75,4 +75,6 @@ if(!$store->isInstalled())
75} 75}
76 76
77$_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin(); 77$_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin();
78$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword(); \ No newline at end of file 78$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword();
79
80pocheTools::initPhp(); \ No newline at end of file
diff --git a/inc/poche/pocheCore.php b/inc/poche/pocheCore.php
index e68696af..3e32c4a8 100644
--- a/inc/poche/pocheCore.php
+++ b/inc/poche/pocheCore.php
@@ -134,10 +134,12 @@ function fetch_url_content($url)
134 return FALSE; 134 return FALSE;
135} 135}
136 136
137function display_view($view, $id = 0, $full_head = 'yes') 137function display_view($view, $id = 0)
138{ 138{
139 global $tpl, $store; 139 global $tpl, $store;
140 140
141 $tpl_vars = array();
142
141 switch ($view) 143 switch ($view)
142 { 144 {
143 case 'install': 145 case 'install':
@@ -186,21 +188,25 @@ function display_view($view, $id = 0, $full_head = 'yes')
186 break; 188 break;
187 default: # home view 189 default: # home view
188 $entries = $store->getEntriesByView($view); 190 $entries = $store->getEntriesByView($view);
189 $tpl->assign('entries', $entries); 191 $tpl_vars = array(
192 'entries' => $entries,
193 );
190 194
191 if ($full_head == 'yes') { 195 // if ($full_head == 'yes') {
192 $tpl->assign('load_all_js', 1); 196 // $tpl->assign('load_all_js', 1);
193 $tpl->draw('head'); 197 // $tpl->draw('head');
194 $tpl->draw('home'); 198 // $tpl->draw('home');
195 } 199 // }
196 200
197 $tpl->draw('entries'); 201 // $tpl->draw('entries');
198 if ($full_head == 'yes') { 202 // if ($full_head == 'yes') {
199 $tpl->draw('js'); 203 // $tpl->draw('js');
200 $tpl->draw('footer'); 204 // $tpl->draw('footer');
201 } 205 // }
202 break; 206 break;
203 } 207 }
208
209 return $tpl_vars;
204} 210}
205 211
206/** 212/**
diff --git a/index.php b/index.php
index 4962639b..f0a8aef4 100644
--- a/index.php
+++ b/index.php
@@ -10,12 +10,12 @@
10 10
11include dirname(__FILE__).'/inc/config.php'; 11include dirname(__FILE__).'/inc/config.php';
12 12
13pocheTools::initPhp(); 13$errors = array();
14 14
15# XSRF protection with token 15# XSRF protection with token
16if (!empty($_POST)) { 16if (!empty($_POST)) {
17 if (!Session::isToken($_POST['token'])) { 17 if (!Session::isToken($_POST['token'])) {
18 die(_('Wrong token.')); 18 die(_('Wrong token'));
19 } 19 }
20 unset($_SESSION['tokens']); 20 unset($_SESSION['tokens']);
21} 21}
@@ -23,10 +23,11 @@ if (!empty($_POST)) {
23$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; 23$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
24 24
25if (isset($_GET['login'])) { 25if (isset($_GET['login'])) {
26 // Login
27 if (!empty($_POST['login']) && !empty($_POST['password'])) { 26 if (!empty($_POST['login']) && !empty($_POST['password'])) {
28 if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) { 27 if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) {
29 pocheTools::logm('login successful'); 28 pocheTools::logm('login successful');
29 $errors[]['value'] = _('login successful');
30
30 if (!empty($_POST['longlastingsession'])) { 31 if (!empty($_POST['longlastingsession'])) {
31 $_SESSION['longlastingsession'] = 31536000; 32 $_SESSION['longlastingsession'] = 31536000;
32 $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession']; 33 $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
@@ -35,11 +36,10 @@ if (isset($_GET['login'])) {
35 session_set_cookie_params(0); // when browser closes 36 session_set_cookie_params(0); // when browser closes
36 } 37 }
37 session_regenerate_id(true); 38 session_regenerate_id(true);
38
39 pocheTools::redirect($referer); 39 pocheTools::redirect($referer);
40 } 40 }
41 pocheTools::logm('login failed'); 41 pocheTools::logm('login failed');
42 die(_("Login failed !")); 42 $errors[]['value'] = _('Login failed !');
43 } else { 43 } else {
44 pocheTools::logm('login failed'); 44 pocheTools::logm('login failed');
45 } 45 }
@@ -67,7 +67,7 @@ elseif (isset($_GET['config'])) {
67} 67}
68 68
69# Traitement des paramètres et déclenchement des actions 69# Traitement des paramètres et déclenchement des actions
70$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'index'; 70$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home';
71$full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes'; 71$full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes';
72$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : ''; 72$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
73$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id'; 73$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
@@ -75,20 +75,23 @@ $id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id
75$url = (isset ($_GET['url'])) ? $_GET['url'] : ''; 75$url = (isset ($_GET['url'])) ? $_GET['url'] : '';
76 76
77$tpl_vars = array( 77$tpl_vars = array(
78 'isLogged' => Session::isLogged(),
79 'referer' => $referer, 78 'referer' => $referer,
80 'view' => $view, 79 'view' => $view,
81 'poche_url' => pocheTools::getUrl(), 80 'poche_url' => pocheTools::getUrl(),
82 'demo' => MODE_DEMO, 81 'demo' => MODE_DEMO,
83 'title' => _('poche, a read it later open source system'), 82 'title' => _('poche, a read it later open source system'),
83 'token' => Session::getToken(),
84 'errors' => $errors,
84); 85);
85 86
87$tpl_file = 'home.twig';
88
86if (Session::isLogged()) { 89if (Session::isLogged()) {
87 action_to_do($action, $url, $id); 90 action_to_do($action, $url, $id);
88 display_view($view, $id, $full_head); 91 $tpl_vars = array_merge($tpl_vars, display_view($view, $id));
89} 92}
90else { 93else {
91 $template = $twig->loadTemplate('login.twig'); 94 $tpl_file = 'login.twig';
92} 95}
93 96
94echo $template->render($tpl_vars); \ No newline at end of file 97echo $twig->render($tpl_file, $tpl_vars); \ No newline at end of file
diff --git a/tpl/home.twig b/tpl/home.twig
index 8b602a25..7b5b88a2 100644
--- a/tpl/home.twig
+++ b/tpl/home.twig
@@ -1,21 +1,41 @@
1 <body class="light-style"> 1{% extends "layout.twig" %}
2 <header> 2
3 <h1><a href="index.php"><img src="./img/logo.png" alt="logo poche" /></a>poche</h1> 3{% block title %}Home{% endblock %}
4 </header>
5 <div id="main">
6{% block menu %} 4{% block menu %}
7 <ul id="links"> 5 <ul id="links">
8 <li><a href="index.php" {if="$view == 'index'"}class="current"{/if}>home</a></li> 6 <li><a href="index.php" {% if view == 'home' %}class="current"{% endif %}>home</a></li>
9 <li><a href="?view=fav" {if="$view == 'fav'"}class="current"{/if}>favorites</a></li> 7 <li><a href="?view=fav" {% if view == 'fav' %}class="current"{% endif %}>favorites</a></li>
10 <li><a href="?view=archive" {if="$view == 'archive'"}class="current"{/if}>archive</a></li> 8 <li><a href="?view=archive" {% if view == 'archive' %}class="current"{% endif %}>archive</a></li>
11 <li><a href="?view=config" {if="$view == 'config'"}class="current"{/if}>config</a></li> 9 <li><a href="?view=config" {% if view == 'config' %}class="current"{% endif %}>config</a></li>
12 <li><a href="?logout" title="Logout">logout</a></li> 10 <li><a href="?logout" title="Logout">logout</a></li>
13 </ul> 11 </ul>
14{% endblock %} 12{% endblock %}
15{% block precontent %} 13{% block precontent %}
16 <ul id="sort"> 14 <ul id="sort">
17 <li><img src="img/up.png" onclick="sort_links('{$view}', 'ia');" title="by date asc" /> by date <img src="img/down.png" onclick="sort_links('{$view}', 'id');" title="by date desc" /></li> 15 <li><img src="img/up.png" onclick="sort_links('{{ view }}', 'ia');" title="by date asc" /> by date <img src="img/down.png" onclick="sort_links('{{ view }}', 'id');" title="by date desc" /></li>
18 <li><img src="img/up.png" onclick="sort_links('{$view}', 'ta');" title="by title asc" /> by title <img src="img/down.png" onclick="sort_links('{$view}', 'td');" title="by title desc" /></li> 16 <li><img src="img/up.png" onclick="sort_links('{{ view }}', 'ta');" title="by title asc" /> by title <img src="img/down.png" onclick="sort_links('{{ view }}', 'td');" title="by title desc" /></li>
19 </ul> 17 </ul>
20{% endblock %} 18{% endblock %}
21 {include="messages"} \ No newline at end of file 19{% block content %}
20 <div id="content">
21 {% for entry in entries %}
22 <div id="entry-{{ entry.id|e }}" class="entrie mb2">
23 <span class="content">
24 <h2 class="h6-like">
25 <a href="index.php?&view=view&id={{ entry.id|e }}">{{ entry.title|e }}</a>
26 </h2>
27 <div class="tools">
28 <ul>
29 <li>
30 <a title="toggle mark as read" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" onclick="toggle_archive(this, {{ entry.id|e }})"><span></span></a></li>
31 <li><a title="toggle favorite" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" onclick="toggle_favorite(this, {{ entry.id|e }})"><span></span></a></li>
32 <li><form method="post" onsubmit="return confirm('Are you sure?')" style="display: inline;"><input type="hidden" name="token" id="token" value="{{ token }}" /><input type="hidden" id="action" name="action" value="delete" /><input type="hidden" id="view" name="view" value="{{ view }}" /><input type="hidden" id="id" name="id" value="{{ entry.id|e }}" /><input type="submit" class="delete" title="toggle delete" /></form>
33 </li>
34 </ul>
35 </div>
36 <div class="url">{{ entry.url|e }}</div>
37 </span>
38 </div>
39 {% endfor %}
40 </div>
41{% endblock %} \ No newline at end of file
diff --git a/tpl/layout.twig b/tpl/layout.twig
index c5f52bbd..9dc83efe 100644
--- a/tpl/layout.twig
+++ b/tpl/layout.twig
@@ -9,50 +9,18 @@
9 <meta charset="utf-8"> 9 <meta charset="utf-8">
10 <meta http-equiv="X-UA-Compatible" content="IE=10"> 10 <meta http-equiv="X-UA-Compatible" content="IE=10">
11 <title>{% block title %}{% endblock %} - poche</title> 11 <title>{% block title %}{% endblock %} - poche</title>
12 <link rel="shortcut icon" type="image/x-icon" href="./img/favicon.ico" /> 12 {% include '_head.twig' %}
13 <link rel="apple-touch-icon-precomposed" sizes="144x144" href="./img/apple-touch-icon-144x144-precomposed.png"> 13 {% include '_bookmarklet.twig' %}
14 <link rel="apple-touch-icon-precomposed" sizes="72x72" href="./img/apple-touch-icon-72x72-precomposed.png">
15 <link rel="apple-touch-icon-precomposed" href="./img/apple-touch-icon-precomposed.png">
16 <link rel="stylesheet" href="./css/knacss.css" media="all">
17 <link rel="stylesheet" href="./css/style.css" media="all">
18 <!-- Light Theme -->
19 <link rel="stylesheet" href="./css/style-light.css" media="all" title="light-style">
20 <!-- Dark Theme -->
21 <link rel="alternate stylesheet" href="./css/style-dark.css" media="all" title="dark-style">
22 <script>
23 top["bookmarklet-url@inthepoche.com"] = ''
24 +'<!DOCTYPE html>'
25 +'<html>'
26 +'<head>'
27 +'<title>poche it !</title>'
28 +'<link rel="icon" href="{$poche_url}img/favicon.ico" />'
29 +'</head>'
30 +'<body>'
31 +'<script>'
32 +'window.onload=function(){'
33 +'window.setTimeout(function(){'
34 +'history.back();'
35 +'},250);'
36 +'};'
37 +'</scr'+'ipt>'
38 +'</body>'
39 +'</html>'
40 ;
41 </script>
42 </head> 14 </head>
43 <body class="light-style"> 15 <body class="light-style">
44 <header> 16 {% include '_top.twig' %}
45 <h1><a href="/"><img src="./img/logo.png" alt="logo poche" /></a>poche</h1>
46 </header>
47 <div id="main"> 17 <div id="main">
48 {% block menu %}{% endblock %} 18 {% block menu %}{% endblock %}
49 {% block precontent %}{% endblock %} 19 {% block precontent %}{% endblock %}
20 {% block messages %}{% endblock %}
50 {% block content %}{% endblock %} 21 {% block content %}{% endblock %}
51 {% block js %}{% endblock %} 22 {% block js %}{% endblock %}
52 </div> 23 </div>
53 <footer class="mr2 mt3 smaller"> 24 {% include '_footer.twig' %}
54 <p>powered by <a href="http://inthepoche.com">poche</a></p>
55 </footer>
56
57 </body> 25 </body>
58</html> \ No newline at end of file 26</html> \ No newline at end of file
diff --git a/tpl/login.twig b/tpl/login.twig
index 390718b6..c95a5f02 100644
--- a/tpl/login.twig
+++ b/tpl/login.twig
@@ -1,5 +1,15 @@
1{% extends "layout.twig" %} 1{% extends "layout.twig" %}
2
2{% block title %}Login{% endblock %} 3{% block title %}Login{% endblock %}
4{% block messages %}
5 <div class="messages">
6 <ul>
7 {% for error in errors %}
8 <li>{{ error.value|e }}</li>
9 {% endfor %}
10 </ul>
11 </div>
12{% endblock %}
3{% block content %} 13{% block content %}
4 <form method="post" action="?login" name="loginform"> 14 <form method="post" action="?login" name="loginform">
5 <fieldset class="w500p center"> 15 <fieldset class="w500p center">