aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-05 15:54:37 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-05 15:54:37 +0200
commit55821e04c188997d258645975220828e195d0df4 (patch)
tree9a85831aa55c35c2fa69122220f7c873d73a9143
parentb161295d0b53a5ae194e236b0a7c662e9ac2ff9a (diff)
downloadwallabag-55821e04c188997d258645975220828e195d0df4.tar.gz
wallabag-55821e04c188997d258645975220828e195d0df4.tar.zst
wallabag-55821e04c188997d258645975220828e195d0df4.zip
share email +twitter / class messages
-rwxr-xr-xinc/3rdparty/class.messages.php231
-rw-r--r--inc/poche/Poche.class.php27
-rw-r--r--inc/poche/Tools.class.php11
-rw-r--r--inc/poche/config.inc.php5
-rw-r--r--index.php3
-rw-r--r--tpl/_bookmarklet.twig2
-rw-r--r--tpl/_head.twig4
-rw-r--r--tpl/_menu.twig7
-rw-r--r--tpl/_messages.twig5
-rwxr-xr-xtpl/css/messages.css13
-rw-r--r--tpl/css/style-dark.css4
-rw-r--r--tpl/css/style-light.css8
-rw-r--r--tpl/css/style.css6
-rw-r--r--tpl/home.twig41
-rwxr-xr-xtpl/img/dark/twitter.pngbin0 -> 300 bytes
-rwxr-xr-xtpl/img/light/envelop.pngbin0 -> 285 bytes
-rwxr-xr-xtpl/img/light/twitter.pngbin0 -> 297 bytes
-rwxr-xr-xtpl/img/messages/close.pngbin0 -> 662 bytes
-rwxr-xr-xtpl/img/messages/cross.pngbin0 -> 655 bytes
-rwxr-xr-xtpl/img/messages/help.pngbin0 -> 786 bytes
-rwxr-xr-xtpl/img/messages/tick.pngbin0 -> 537 bytes
-rwxr-xr-xtpl/img/messages/warning.pngbin0 -> 666 bytes
-rw-r--r--tpl/js/poche.js57
-rw-r--r--tpl/layout.twig1
-rw-r--r--tpl/view.twig26
25 files changed, 339 insertions, 112 deletions
diff --git a/inc/3rdparty/class.messages.php b/inc/3rdparty/class.messages.php
new file mode 100755
index 00000000..e60bd3a1
--- /dev/null
+++ b/inc/3rdparty/class.messages.php
@@ -0,0 +1,231 @@
1<?php
2//--------------------------------------------------------------------------------------------------
3// Session-Based Flash Messages v1.0
4// Copyright 2012 Mike Everhart (http://mikeeverhart.net)
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17//
18//------------------------------------------------------------------------------
19// Description:
20//------------------------------------------------------------------------------
21//
22// Stores messages in Session data to be easily retrieved later on.
23// This class includes four different types of messages:
24// - Success
25// - Error
26// - Warning
27// - Information
28//
29// See README for basic usage instructions, or see samples/index.php for more advanced samples
30//
31//--------------------------------------------------------------------------------------------------
32// Changelog
33//--------------------------------------------------------------------------------------------------
34//
35// 2011-05-15 - v1.0 - Initial Version
36//
37//--------------------------------------------------------------------------------------------------
38
39class Messages {
40
41 //-----------------------------------------------------------------------------------------------
42 // Class Variables
43 //-----------------------------------------------------------------------------------------------
44 var $msgId;
45 var $msgTypes = array( 'help', 'info', 'warning', 'success', 'error' );
46 var $msgClass = 'messages';
47 var $msgWrapper = "<div class='%s %s'><a href='#' class='closeMessage'>X</a>\n%s</div>\n";
48 var $msgBefore = '<p>';
49 var $msgAfter = "</p>\n";
50
51
52 /**
53 * Constructor
54 * @author Mike Everhart
55 */
56 public function __construct() {
57
58 // Generate a unique ID for this user and session
59 $this->msgId = md5(uniqid());
60
61 // Create the session array if it doesnt already exist
62 if( !array_key_exists('flash_messages', $_SESSION) ) $_SESSION['flash_messages'] = array();
63
64 }
65
66 /**
67 * Add a message to the queue
68 *
69 * @author Mike Everhart
70 *
71 * @param string $type The type of message to add
72 * @param string $message The message
73 * @param string $redirect_to (optional) If set, the user will be redirected to this URL
74 * @return bool
75 *
76 */
77 public function add($type, $message, $redirect_to=null) {
78
79 if( !isset($_SESSION['flash_messages']) ) return false;
80
81 if( !isset($type) || !isset($message[0]) ) return false;
82
83 // Replace any shorthand codes with their full version
84 if( strlen(trim($type)) == 1 ) {
85 $type = str_replace( array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type );
86
87 // Backwards compatibility...
88 } elseif( $type == 'information' ) {
89 $type = 'info';
90 }
91
92 // Make sure it's a valid message type
93 if( !in_array($type, $this->msgTypes) ) die('"' . strip_tags($type) . '" is not a valid message type!' );
94
95 // If the session array doesn't exist, create it
96 if( !array_key_exists( $type, $_SESSION['flash_messages'] ) ) $_SESSION['flash_messages'][$type] = array();
97
98 $_SESSION['flash_messages'][$type][] = $message;
99
100 if( !is_null($redirect_to) ) {
101 header("Location: $redirect_to");
102 exit();
103 }
104
105 return true;
106
107 }
108
109 //-----------------------------------------------------------------------------------------------
110 // display()
111 // print queued messages to the screen
112 //-----------------------------------------------------------------------------------------------
113 /**
114 * Display the queued messages
115 *
116 * @author Mike Everhart
117 *
118 * @param string $type Which messages to display
119 * @param bool $print True = print the messages on the screen
120 * @return mixed
121 *
122 */
123 public function display($type='all', $print=true) {
124 $messages = '';
125 $data = '';
126
127 if( !isset($_SESSION['flash_messages']) ) return false;
128
129 if( $type == 'g' || $type == 'growl' ) {
130 $this->displayGrowlMessages();
131 return true;
132 }
133
134 // Print a certain type of message?
135 if( in_array($type, $this->msgTypes) ) {
136 foreach( $_SESSION['flash_messages'][$type] as $msg ) {
137 $messages .= $this->msgBefore . $msg . $this->msgAfter;
138 }
139
140 $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
141
142 // Clear the viewed messages
143 $this->clear($type);
144
145 // Print ALL queued messages
146 } elseif( $type == 'all' ) {
147 foreach( $_SESSION['flash_messages'] as $type => $msgArray ) {
148 $messages = '';
149 foreach( $msgArray as $msg ) {
150 $messages .= $this->msgBefore . $msg . $this->msgAfter;
151 }
152 $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
153 }
154
155 // Clear ALL of the messages
156 $this->clear();
157
158 // Invalid Message Type?
159 } else {
160 return false;
161 }
162
163 // Print everything to the screen or return the data
164 if( $print ) {
165 echo $data;
166 } else {
167 return $data;
168 }
169 }
170
171
172 /**
173 * Check to see if there are any queued error messages
174 *
175 * @author Mike Everhart
176 *
177 * @return bool true = There ARE error messages
178 * false = There are NOT any error messages
179 *
180 */
181 public function hasErrors() {
182 return empty($_SESSION['flash_messages']['error']) ? false : true;
183 }
184
185 /**
186 * Check to see if there are any ($type) messages queued
187 *
188 * @author Mike Everhart
189 *
190 * @param string $type The type of messages to check for
191 * @return bool
192 *
193 */
194 public function hasMessages($type=null) {
195 if( !is_null($type) ) {
196 if( !empty($_SESSION['flash_messages'][$type]) ) return $_SESSION['flash_messages'][$type];
197 } else {
198 foreach( $this->msgTypes as $type ) {
199 if( !empty($_SESSION['flash_messages']) ) return true;
200 }
201 }
202 return false;
203 }
204
205 /**
206 * Clear messages from the session data
207 *
208 * @author Mike Everhart
209 *
210 * @param string $type The type of messages to clear
211 * @return bool
212 *
213 */
214 public function clear($type='all') {
215 if( $type == 'all' ) {
216 unset($_SESSION['flash_messages']);
217 } else {
218 unset($_SESSION['flash_messages'][$type]);
219 }
220 return true;
221 }
222
223 public function __toString() { return $this->hasMessages(); }
224
225 public function __destruct() {
226 //$this->clear();
227 }
228
229
230} // end class
231?> \ No newline at end of file
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index f9bcf85b..80bf6919 100644
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -12,6 +12,7 @@ class Poche
12{ 12{
13 public $store; 13 public $store;
14 public $tpl; 14 public $tpl;
15 public $messages;
15 16
16 function __construct($storage_type) 17 function __construct($storage_type)
17 { 18 {
@@ -41,6 +42,9 @@ class Poche
41 'cache' => CACHE, 42 'cache' => CACHE,
42 )); 43 ));
43 $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); 44 $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
45 # filter to display domain name of an url
46 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
47 $this->tpl->addFilter($filter);
44 48
45 Tools::initPhp(); 49 Tools::initPhp();
46 Session::init(); 50 Session::init();
@@ -113,10 +117,12 @@ class Poche
113 case 'toggle_fav' : 117 case 'toggle_fav' :
114 $this->store->favoriteById($id); 118 $this->store->favoriteById($id);
115 Tools::logm('mark as favorite link #' . $id); 119 Tools::logm('mark as favorite link #' . $id);
120 Tools::redirect();
116 break; 121 break;
117 case 'toggle_archive' : 122 case 'toggle_archive' :
118 $this->store->archiveById($id); 123 $this->store->archiveById($id);
119 Tools::logm('archive link #' . $id); 124 Tools::logm('archive link #' . $id);
125 Tools::redirect();
120 break; 126 break;
121 default: 127 default:
122 break; 128 break;
@@ -174,16 +180,21 @@ class Poche
174 180
175 public function updatePassword() 181 public function updatePassword()
176 { 182 {
177 if (isset($_POST['password']) && isset($_POST['password_repeat'])) { 183 if (MODE_DEMO) {
178 if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { 184 $this->messages->add('i', 'in demo mode, you can\'t update your password');
179 if (!MODE_DEMO) { 185 Tools::logm('in demo mode, you can\'t do this');
186 }
187 else {
188 if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
189 if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
180 Tools::logm('password updated'); 190 Tools::logm('password updated');
191 $this->messages->add('s', 'your password has been updated');
181 $this->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login'])); 192 $this->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login']));
182 Session::logout(); 193 Session::logout();
183 Tools::redirect(); 194 Tools::redirect();
184 } 195 }
185 else { 196 else {
186 Tools::logm('in demo mode, you can\'t do this'); 197 $this->messages->add('e', 'the two fields have to be filled & the password must be the same in the two fields');
187 } 198 }
188 } 199 }
189 } 200 }
@@ -194,7 +205,7 @@ class Poche
194 if (!empty($_POST['login']) && !empty($_POST['password'])) { 205 if (!empty($_POST['login']) && !empty($_POST['password'])) {
195 if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) { 206 if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) {
196 Tools::logm('login successful'); 207 Tools::logm('login successful');
197 208 $this->messages->add('s', 'login successful, welcome to your poche');
198 if (!empty($_POST['longlastingsession'])) { 209 if (!empty($_POST['longlastingsession'])) {
199 $_SESSION['longlastingsession'] = 31536000; 210 $_SESSION['longlastingsession'] = 31536000;
200 $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession']; 211 $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
@@ -205,9 +216,11 @@ class Poche
205 session_regenerate_id(true); 216 session_regenerate_id(true);
206 Tools::redirect($referer); 217 Tools::redirect($referer);
207 } 218 }
219 $this->messages->add('e', 'login failed, bad login or password');
208 Tools::logm('login failed'); 220 Tools::logm('login failed');
209 Tools::redirect(); 221 Tools::redirect();
210 } else { 222 } else {
223 $this->messages->add('e', 'login failed, you have to fill all fields');
211 Tools::logm('login failed'); 224 Tools::logm('login failed');
212 Tools::redirect(); 225 Tools::redirect();
213 } 226 }
@@ -215,6 +228,7 @@ class Poche
215 228
216 public function logout() 229 public function logout()
217 { 230 {
231 $this->messages->add('s', 'logout successful, see you soon!');
218 Tools::logm('logout'); 232 Tools::logm('logout');
219 Session::logout(); 233 Session::logout();
220 Tools::redirect(); 234 Tools::redirect();
@@ -244,6 +258,7 @@ class Poche
244 # the second <ol> is for read links 258 # the second <ol> is for read links
245 $read = 1; 259 $read = 1;
246 } 260 }
261 $this->messages->add('s', 'import from instapaper completed');
247 Tools::logm('import from instapaper completed'); 262 Tools::logm('import from instapaper completed');
248 Tools::redirect(); 263 Tools::redirect();
249 } 264 }
@@ -272,6 +287,7 @@ class Poche
272 # the second <ul> is for read links 287 # the second <ul> is for read links
273 $read = 1; 288 $read = 1;
274 } 289 }
290 $this->messages->add('s', 'import from pocket completed');
275 Tools::logm('import from pocket completed'); 291 Tools::logm('import from pocket completed');
276 Tools::redirect(); 292 Tools::redirect();
277 } 293 }
@@ -300,6 +316,7 @@ class Poche
300 if ($url->isCorrect()) 316 if ($url->isCorrect())
301 $this->action('add', $url); 317 $this->action('add', $url);
302 } 318 }
319 $this->messages->add('s', 'import from Readability completed');
303 Tools::logm('import from Readability completed'); 320 Tools::logm('import from Readability completed');
304 Tools::redirect(); 321 Tools::redirect();
305 } 322 }
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php
index 834940ff..7bc8830a 100644
--- a/inc/poche/Tools.class.php
+++ b/inc/poche/Tools.class.php
@@ -210,4 +210,15 @@ class Tools
210 { 210 {
211 return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default); 211 return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default);
212 } 212 }
213
214 public static function getDomain($url)
215 {
216 $pieces = parse_url($url);
217 $domain = isset($pieces['host']) ? $pieces['host'] : '';
218 if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
219 return $regs['domain'];
220 }
221
222 return FALSE;
223 }
213} \ No newline at end of file 224} \ No newline at end of file
diff --git a/inc/poche/config.inc.php b/inc/poche/config.inc.php
index 27be1857..d49df190 100644
--- a/inc/poche/config.inc.php
+++ b/inc/poche/config.inc.php
@@ -15,6 +15,7 @@ define ('CONVERT_LINKS_FOOTNOTES', FALSE);
15define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); 15define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
16define ('DOWNLOAD_PICTURES', FALSE); 16define ('DOWNLOAD_PICTURES', FALSE);
17define ('SHARE_TWITTER', TRUE); 17define ('SHARE_TWITTER', TRUE);
18define ('SHARE_MAIL', TRUE);
18define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX'); 19define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX');
19define ('ABS_PATH', 'assets/'); 20define ('ABS_PATH', 'assets/');
20define ('TPL', './tpl'); 21define ('TPL', './tpl');
@@ -34,9 +35,11 @@ require_once './inc/store/store.class.php';
34require_once './inc/store/' . $storage_type . '.class.php'; 35require_once './inc/store/' . $storage_type . '.class.php';
35require_once './vendor/autoload.php'; 36require_once './vendor/autoload.php';
36require_once './inc/3rdparty/simple_html_dom.php'; 37require_once './inc/3rdparty/simple_html_dom.php';
38require_once './inc/3rdparty/class.messages.php';
37 39
38if (DOWNLOAD_PICTURES) { 40if (DOWNLOAD_PICTURES) {
39 require_once './inc/poche/pochePictures.php'; 41 require_once './inc/poche/pochePictures.php';
40} 42}
41 43
42$poche = new Poche($storage_type); \ No newline at end of file 44$poche = new Poche($storage_type);
45$poche->messages = new Messages(); \ No newline at end of file
diff --git a/index.php b/index.php
index 19774bb6..dd70a989 100644
--- a/index.php
+++ b/index.php
@@ -61,5 +61,8 @@ else {
61 $tpl_file = 'login.twig'; 61 $tpl_file = 'login.twig';
62} 62}
63 63
64# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
65$tpl_vars = array_merge($tpl_vars, array('messages' => $poche->messages->display()));
66
64# Aaaaaaand action ! 67# Aaaaaaand action !
65echo $poche->tpl->render($tpl_file, $tpl_vars); \ No newline at end of file 68echo $poche->tpl->render($tpl_file, $tpl_vars); \ No newline at end of file
diff --git a/tpl/_bookmarklet.twig b/tpl/_bookmarklet.twig
index 0878e079..0595d57e 100644
--- a/tpl/_bookmarklet.twig
+++ b/tpl/_bookmarklet.twig
@@ -4,7 +4,7 @@
4 +'<html>' 4 +'<html>'
5 +'<head>' 5 +'<head>'
6 +'<title>poche it !</title>' 6 +'<title>poche it !</title>'
7 +'<link rel="icon" href="{$poche_url}img/favicon.ico" />' 7 +'<link rel="icon" href="{{poche_url}}tpl/img/favicon.ico" />'
8 +'</head>' 8 +'</head>'
9 +'<body>' 9 +'<body>'
10 +'<script>' 10 +'<script>'
diff --git a/tpl/_head.twig b/tpl/_head.twig
index ad96e9d1..9e82437f 100644
--- a/tpl/_head.twig
+++ b/tpl/_head.twig
@@ -4,7 +4,5 @@
4 <link rel="apple-touch-icon-precomposed" href="./tpl/img/apple-touch-icon-precomposed.png"> 4 <link rel="apple-touch-icon-precomposed" href="./tpl/img/apple-touch-icon-precomposed.png">
5 <link rel="stylesheet" href="./tpl/css/knacss.css" media="all"> 5 <link rel="stylesheet" href="./tpl/css/knacss.css" media="all">
6 <link rel="stylesheet" href="./tpl/css/style.css" media="all"> 6 <link rel="stylesheet" href="./tpl/css/style.css" media="all">
7 <!-- Light Theme -->
8 <link rel="stylesheet" href="./tpl/css/style-light.css" media="all" title="light-style"> 7 <link rel="stylesheet" href="./tpl/css/style-light.css" media="all" title="light-style">
9 <!-- Dark Theme --> 8 <link rel="stylesheet" href="./tpl/css/messages.css" media="all"> \ No newline at end of file
10 <link rel="alternate stylesheet" href="./tpl/css/style-dark.css" media="all" title="dark-style"> \ No newline at end of file
diff --git a/tpl/_menu.twig b/tpl/_menu.twig
new file mode 100644
index 00000000..699d6a0c
--- /dev/null
+++ b/tpl/_menu.twig
@@ -0,0 +1,7 @@
1 <ul id="links">
2 <li><a href="./" {% if view == 'home' %}class="current"{% endif %}>{% trans "home" %}</a></li>
3 <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
4 <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
5 <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
6 <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
7 </ul> \ No newline at end of file
diff --git a/tpl/_messages.twig b/tpl/_messages.twig
new file mode 100644
index 00000000..c9f01b55
--- /dev/null
+++ b/tpl/_messages.twig
@@ -0,0 +1,5 @@
1 <ul id="messages">
2 {% for message in messages %}
3 <li>{{ message|e }}</li>
4 {% endfor %}
5 </ul> \ No newline at end of file
diff --git a/tpl/css/messages.css b/tpl/css/messages.css
new file mode 100755
index 00000000..702fac49
--- /dev/null
+++ b/tpl/css/messages.css
@@ -0,0 +1,13 @@
1.messages { width: 100%; -moz-border-radius: 4px; border-radius: 4px; display: block; padding: 10px 0; margin: 10px auto 10px; clear: both; }
2.messages a.closeMessage { margin: -14px -8px 0 0; display:none; width: 16px; height: 16px; float: right; background: url(../img/messages/close.png) no-repeat; }
3/*.messages:hover a.closeMessage { visibility:visible; }*/
4.messages p { margin: 3px 0 3px 10px !important; padding: 0 10px 0 23px !important; font-size: 14px; line-height: 16px; }
5.messages.error { border: 1px solid #C42608; color: #c00 !important; background: #FFF0EF; }
6.messages.error p { background: url(../img/messages/cross.png ) no-repeat 0px 50%; color:#c00 !important; }
7.messages.success {background: #E0FBCC; border: 1px solid #6DC70C; }
8.messages.success p { background: url(../img/messages/tick.png) no-repeat 0px 50%; color: #2B6301 !important; }
9.messages.warning { background: #FFFCD3; border: 1px solid #EBCD41; color: #000; }
10.messages.warning p { background: url(../img/messages/warning.png ) no-repeat 0px 50%; color: #5F4E01; }
11.messages.information, .messages.info { background: #DFEBFB; border: 1px solid #82AEE7; }
12.messages.information p, .messages.info p { background: url(../img/messages/help.png ) no-repeat 0px 50%; color: #064393; }
13.messages.information a { text-decoration: underline; } \ No newline at end of file
diff --git a/tpl/css/style-dark.css b/tpl/css/style-dark.css
index 0fcced24..49fe1011 100644
--- a/tpl/css/style-dark.css
+++ b/tpl/css/style-dark.css
@@ -65,6 +65,10 @@ a.archive-off span:hover {
65 background: url('../img/dark/checkmark-on.png') no-repeat; 65 background: url('../img/dark/checkmark-on.png') no-repeat;
66} 66}
67 67
68a.twitter span {
69 background: url('../img/dark/twitter.png') no-repeat;
70}
71
68/*** ***/ 72/*** ***/
69/*** ARTICLE PAGE ***/ 73/*** ARTICLE PAGE ***/
70 74
diff --git a/tpl/css/style-light.css b/tpl/css/style-light.css
index c1d98326..5d584eb3 100644
--- a/tpl/css/style-light.css
+++ b/tpl/css/style-light.css
@@ -75,6 +75,14 @@ a.archive-off span:hover {
75 background: url('../img/light/checkmark-on.png') no-repeat; 75 background: url('../img/light/checkmark-on.png') no-repeat;
76} 76}
77 77
78a.twitter span {
79 background: url('../img/light/twitter.png') no-repeat;
80}
81
82a.email span {
83 background: url('../img/light/envelop.png') no-repeat;
84}
85
78/*** ***/ 86/*** ***/
79/*** ARTICLE PAGE ***/ 87/*** ARTICLE PAGE ***/
80 88
diff --git a/tpl/css/style.css b/tpl/css/style.css
index 6b9f6aca..333a0b77 100644
--- a/tpl/css/style.css
+++ b/tpl/css/style.css
@@ -47,6 +47,10 @@ header h1 {
47 cursor: pointer; 47 cursor: pointer;
48} 48}
49 49
50ul#messages {
51
52}
53
50#main, #article { 54#main, #article {
51 margin: 0 auto; 55 margin: 0 auto;
52} 56}
@@ -99,6 +103,7 @@ input[type=submit].delete {
99} 103}
100 104
101.tools { 105.tools {
106 float: right;
102 text-align: right; 107 text-align: right;
103} 108}
104 109
@@ -121,7 +126,6 @@ input[type=submit].delete {
121 top: 0px; 126 top: 0px;
122 right: 0px; 127 right: 0px;
123 width: 100%; 128 width: 100%;
124 text-align: left;
125} 129}
126 130
127#article .tools ul li{ 131#article .tools ul li{
diff --git a/tpl/home.twig b/tpl/home.twig
index 49ef9050..6d0f1a66 100644
--- a/tpl/home.twig
+++ b/tpl/home.twig
@@ -1,38 +1,35 @@
1{% extends "layout.twig" %} 1{% extends "layout.twig" %}
2{% block title %}{% trans "home" %}{% endblock %} 2{% block title %}{% trans "home" %}{% endblock %}
3{% block menu %} 3{% block menu %}
4 <ul id="links"> 4{% include '_menu.twig' %}
5 <li><a href="./" {% if view == 'home' %}class="current"{% endif %}>{% trans "home" %}</a></li>
6 <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
7 <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
8 <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
9 <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
10 </ul>
11{% endblock %} 5{% endblock %}
12{% block precontent %} 6{% block precontent %}
13 <ul id="sort"> 7 <ul id="sort">
14 <li><img src="./tpl/img/up.png" onclick="sort_links('{{ view }}', 'ia');" title="{% trans "by date asc" %}" /> {% trans "by date" %} <img src="./tpl/img/down.png" onclick="sort_links('{{ view }}', 'id');" title="{% trans "by date desc" %}" /></li> 8 <li><a href="./?sort=ia"><img src="./tpl/img/up.png" title="{% trans "by date asc" %}" /></a> {% trans "by date" %} <a href="./?sort=id"><img src="./tpl/img/down.png" title="{% trans "by date desc" %}" /></a></li>
15 <li><img src="./tpl/img/up.png" onclick="sort_links('{{ view }}', 'ta');" title="{% trans "by title asc" %}" /> {% trans "by title" %} <img src="./tpl/img/down.png" onclick="sort_links('{{ view }}', 'td');" title="{% trans "by title desc" %}" /></li> 9 <li><a href="./?sort=ta"><img src="./tpl/img/up.png" title="{% trans "by title asc" %}" /></a> {% trans "by title" %} <a href="./?sort=td"><img src="./tpl/img/down.png" title="{% trans "by title desc" %}" /></a></li>
16 </ul> 10 </ul>
17{% endblock %} 11{% endblock %}
12{% block messages %}
13{% include '_messages.twig' %}
14{% endblock %}
18{% block content %} 15{% block content %}
19 <div id="content"> 16 <div id="content">
20 {% for entry in entries %} 17 {% for entry in entries %}
21 <div id="entry-{{ entry.id|e }}" class="entrie mb2"> 18 <div id="entry-{{ entry.id|e }}" class="entrie mb2">
22 <span class="content"> 19 <span class="content">
23 <h2 class="h6-like"> 20 <h2 class="h6-like">
24 <a href="index.php?&view=view&id={{ entry.id|e }}">{{ entry.title|e }}</a> 21 <a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|e }}</a>
25 </h2> 22 </h2>
26 <div class="tools"> 23 <div class="tools">
27 <ul> 24 <ul>
28 <li> 25 <li>
29 <a title="{% trans "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> 26 <a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li>
30 <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" onclick="toggle_favorite(this, {{ entry.id|e }})"><span></span></a></li> 27 <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li>
31 <li><form method="post" 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="{% trans "toggle delete" %}" /></form> 28 <li><form method="post" 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="{% trans "toggle delete" %}" /></form>
32 </li> 29 </li>
33 </ul> 30 </ul>
34 </div> 31 </div>
35 <div class="url">{{ entry.url|e }}</div> 32 <div class="url">{{ entry.url | e | getDomain }}</div>
36 </span> 33 </span>
37 </div> 34 </div>
38 {% endfor %} 35 {% endfor %}
@@ -41,22 +38,6 @@
41 38
42{% block js %} 39{% block js %}
43 <script type="text/javascript" src="./tpl/js/jquery-1.9.1.min.js"></script> 40 <script type="text/javascript" src="./tpl/js/jquery-1.9.1.min.js"></script>
44 <script type="text/javascript" src="./tpl/js/poche.js"></script>
45 <script type="text/javascript" src="./tpl/js/jquery.masonry.min.js"></script> 41 <script type="text/javascript" src="./tpl/js/jquery.masonry.min.js"></script>
46 <script type="text/javascript"> 42 <script type="text/javascript">$(window).load(function(){var e=3,t=function(){e=$(window).width()>640?3:$(window).width()>320?2:1};t();$(window).resize(t);$("#content").masonry({itemSelector:".entrie",columnWidth:function(t){return t/e}})})</script>
47 $( window ).load( function()
48 {
49 var columns = 3,
50 setColumns = function() { columns = $( window ).width() > 640 ? 3 : $( window ).width() > 320 ? 2 : 1; };
51
52 setColumns();
53 $( window ).resize( setColumns );
54
55 $( '#content' ).masonry(
56 {
57 itemSelector: '.entrie',
58 columnWidth: function( containerWidth ) { return containerWidth / columns; }
59 });
60 });
61 </script>
62{% endblock %} \ No newline at end of file 43{% endblock %} \ No newline at end of file
diff --git a/tpl/img/dark/twitter.png b/tpl/img/dark/twitter.png
new file mode 100755
index 00000000..4595affb
--- /dev/null
+++ b/tpl/img/dark/twitter.png
Binary files differ
diff --git a/tpl/img/light/envelop.png b/tpl/img/light/envelop.png
new file mode 100755
index 00000000..6be1c886
--- /dev/null
+++ b/tpl/img/light/envelop.png
Binary files differ
diff --git a/tpl/img/light/twitter.png b/tpl/img/light/twitter.png
new file mode 100755
index 00000000..cfcfe419
--- /dev/null
+++ b/tpl/img/light/twitter.png
Binary files differ
diff --git a/tpl/img/messages/close.png b/tpl/img/messages/close.png
new file mode 100755
index 00000000..731aa018
--- /dev/null
+++ b/tpl/img/messages/close.png
Binary files differ
diff --git a/tpl/img/messages/cross.png b/tpl/img/messages/cross.png
new file mode 100755
index 00000000..1514d51a
--- /dev/null
+++ b/tpl/img/messages/cross.png
Binary files differ
diff --git a/tpl/img/messages/help.png b/tpl/img/messages/help.png
new file mode 100755
index 00000000..5c870176
--- /dev/null
+++ b/tpl/img/messages/help.png
Binary files differ
diff --git a/tpl/img/messages/tick.png b/tpl/img/messages/tick.png
new file mode 100755
index 00000000..a9925a06
--- /dev/null
+++ b/tpl/img/messages/tick.png
Binary files differ
diff --git a/tpl/img/messages/warning.png b/tpl/img/messages/warning.png
new file mode 100755
index 00000000..628cf2da
--- /dev/null
+++ b/tpl/img/messages/warning.png
Binary files differ
diff --git a/tpl/js/poche.js b/tpl/js/poche.js
deleted file mode 100644
index b4eac11c..00000000
--- a/tpl/js/poche.js
+++ /dev/null
@@ -1,57 +0,0 @@
1function toggle_favorite(element, id) {
2 $(element).toggleClass('fav-off');
3 $.ajax ({
4 url: "index.php?action=toggle_fav",
5 data:{id:id}
6 });
7}
8
9function toggle_archive(element, id, view_article) {
10 $(element).toggleClass('archive-off');
11 $.ajax ({
12 url: "index.php?action=toggle_archive",
13 data:{id:id}
14 });
15 var obj = $('#entry-'+id);
16
17 // on vient de la vue de l'article, donc pas de gestion de grille
18 if (view_article != 1) {
19 $('#content').masonry('remove',obj);
20 $('#content').masonry('reloadItems');
21 $('#content').masonry('reload');
22 }
23}
24
25function sort_links(view, sort) {
26 $.get('index.php', { view: view, sort: sort }, function(data) {
27 $('#content').html(data);
28 });
29}
30
31
32// ---------- Swith light or dark view
33function setActiveStyleSheet(title) {
34 var i, a, main;
35 for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
36 if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
37 a.disabled = true;
38 if(a.getAttribute("title") == title) a.disabled = false;
39 }
40 }
41}
42$('#themeswitch').click(function() {
43 // we want the dark
44 if ($('body').hasClass('light-style')) {
45 setActiveStyleSheet('dark-style');
46 $('body').addClass('dark-style');
47 $('body').removeClass('light-style');
48 $('#themeswitch').text('light');
49 // we want the light
50 } else if ($('body').hasClass('dark-style')) {
51 setActiveStyleSheet('light-style');
52 $('body').addClass('light-style');
53 $('body').removeClass('dark-style');
54 $('#themeswitch').text('dark');
55 }
56 return false;
57});
diff --git a/tpl/layout.twig b/tpl/layout.twig
index cbe965fd..9dc83efe 100644
--- a/tpl/layout.twig
+++ b/tpl/layout.twig
@@ -17,6 +17,7 @@
17 <div id="main"> 17 <div id="main">
18 {% block menu %}{% endblock %} 18 {% block menu %}{% endblock %}
19 {% block precontent %}{% endblock %} 19 {% block precontent %}{% endblock %}
20 {% block messages %}{% endblock %}
20 {% block content %}{% endblock %} 21 {% block content %}{% endblock %}
21 {% block js %}{% endblock %} 22 {% block js %}{% endblock %}
22 </div> 23 </div>
diff --git a/tpl/view.twig b/tpl/view.twig
index bf9a9af9..692f9555 100644
--- a/tpl/view.twig
+++ b/tpl/view.twig
@@ -1,42 +1,40 @@
1{% extends "layout.twig" %} 1{% extends "layout.twig" %}
2{% block title %}{% trans "home" %}{% endblock %} 2{% block title %}{% trans "home" %}{% endblock %}
3 3{% block messages %}
4{% include '_messages.twig' %}
5{% endblock %}
4{% block content %} 6{% block content %}
5 <div id="article" class="w600p"> 7 <div id="article" class="w600p">
6 <div class="backhome">
7 <a href="./" title="{% trans "back to home" %}">&larr;</a>
8 </div>
9 <div class="tools"> 8 <div class="tools">
10 <ul> 9 <ul>
11 {% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title}}%20{{ entry.url|e }}%20via%20@getpoche" target="_blank" class="tool twitter"><span></span></a></li>{% endif %} 10 <li><a href="./" title="{% trans "back to home" %}" class="tool">&larr;</a></li>
12 <li><a title="{% trans "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> 11 <li><a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li>
13 <li><a href="#" id="themeswitch">{% trans "dark" %}</a></li> 12 <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li>
14 <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" onclick="toggle_favorite(this, {{ entry.id|e }})"><span></span></a></li>
15 <li><form method="post" style="display: inline;" action="index.php"><input type="hidden" name="token" id="token" value="{{ token }}" /><input type="hidden" id="view" name="view" value="index" /><input type="hidden" id="action" name="action" value="delete" /><input type="hidden" id="id" name="id" value="{{ entry.id|e }}" /><input type="submit" class="delete" title="{% trans "toggle delete" %}" /></form></li> 13 <li><form method="post" style="display: inline;" action="index.php"><input type="hidden" name="token" id="token" value="{{ token }}" /><input type="hidden" id="view" name="view" value="index" /><input type="hidden" id="action" name="action" value="delete" /><input type="hidden" id="id" name="id" value="{{ entry.id|e }}" /><input type="submit" class="delete" title="{% trans "toggle delete" %}" /></form></li>
16 <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li> 14 {% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title}}%20{{ entry.url|e }}%20via%20@getpoche" target="_blank" class="tool twitter"><span></span></a></li>{% endif %}
15 {% if constant('SHARE_MAIL') == 1 %}<li><a href="mailto:?subject={{ entry.title|e }}&body={{ entry.url|e }} via @getpoche" class="tool email"><span></span></a></li>{% endif %}
17 </ul> 16 </ul>
18 </div> 17 </div>
19 <header class="mbm"> 18 <header class="mbm">
20 <h1><a href="{{ entry.url|e }}">{{ entry.title|e }}</a></h1> 19 <h1>{{ entry.title|e }}</h1>
21 <div class="vieworiginal txtright small"><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{% trans "view original" %}</a></div> 20 <div class="vieworiginal txtright small"><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{{ entry.url | e | getDomain }}</a></div>
22 </header> 21 </header>
23 <article> 22 <article>
24 <div id="readityourselfcontent"> 23 <div id="readityourselfcontent">
25 {{ content | raw }} 24 {{ content | raw }}
26 </div> 25 </div>
27 </article> 26 </article>
28 <div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{% trans "view original" %}</a></div> 27 <div class="vieworiginal txtright small"><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{{ entry.url | e | getDomain }}</a></div>
29 <div class="backhome"> 28 <div class="backhome">
30 <a href="./" title="{% trans "back to home" %}">&larr;</a> 29 <a href="./" title="{% trans "back to home" %}">&larr;</a>
31 <a href="#" title="{% trans "back to top" %}">&uarr;</a> 30 <a href="#" title="{% trans "back to top" %}">&uarr;</a>
32 </div> 31 </div>
33 <div class="support"> 32 <div class="support">
34 {% trans "this article appears wrong?" %} <a href="https://github.com/inthepoche/poche/issues/new">{% trans "create an issue" %}</a> {% trans "or" %} <a href="mailto:support@inthepoche.com">{% trans "contact us by mail" %}</a> 33 {% trans "this article appears wrong?" %} <a href="https://github.com/inthepoche/poche/issues/new">{% trans "create an issue" %}</a> {% trans "or" %} <a href="mailto:support@inthepoche.com?subject=Wrong display in poche&body={{ entry.url|e }}">{% trans "contact us by mail" %}</a>
35 </div> 34 </div>
36 </div> 35 </div>
37{% endblock %} 36{% endblock %}
38 37
39{% block js %} 38{% block js %}
40 <script type="text/javascript" src="./tpl/js/jquery-1.9.1.min.js"></script> 39 <script type="text/javascript" src="./tpl/js/jquery-1.9.1.min.js"></script>
41 <script type="text/javascript" src="./tpl/js/poche.js"></script>
42{% endblock %} \ No newline at end of file 40{% endblock %} \ No newline at end of file