]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
share email +twitter / class messages
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Mon, 5 Aug 2013 13:54:37 +0000 (15:54 +0200)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Mon, 5 Aug 2013 13:54:37 +0000 (15:54 +0200)
25 files changed:
inc/3rdparty/class.messages.php [new file with mode: 0755]
inc/poche/Poche.class.php
inc/poche/Tools.class.php
inc/poche/config.inc.php
index.php
tpl/_bookmarklet.twig
tpl/_head.twig
tpl/_menu.twig [new file with mode: 0644]
tpl/_messages.twig [new file with mode: 0644]
tpl/css/messages.css [new file with mode: 0755]
tpl/css/style-dark.css
tpl/css/style-light.css
tpl/css/style.css
tpl/home.twig
tpl/img/dark/twitter.png [new file with mode: 0755]
tpl/img/light/envelop.png [new file with mode: 0755]
tpl/img/light/twitter.png [new file with mode: 0755]
tpl/img/messages/close.png [new file with mode: 0755]
tpl/img/messages/cross.png [new file with mode: 0755]
tpl/img/messages/help.png [new file with mode: 0755]
tpl/img/messages/tick.png [new file with mode: 0755]
tpl/img/messages/warning.png [new file with mode: 0755]
tpl/js/poche.js [deleted file]
tpl/layout.twig
tpl/view.twig

diff --git a/inc/3rdparty/class.messages.php b/inc/3rdparty/class.messages.php
new file mode 100755 (executable)
index 0000000..e60bd3a
--- /dev/null
@@ -0,0 +1,231 @@
+<?php\r
+//--------------------------------------------------------------------------------------------------\r
+// Session-Based Flash Messages v1.0\r
+// Copyright 2012 Mike Everhart (http://mikeeverhart.net)\r
+//\r
+//   Licensed under the Apache License, Version 2.0 (the "License");\r
+//   you may not use this file except in compliance with the License.\r
+//   You may obtain a copy of the License at\r
+//\r
+//     http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+//   Unless required by applicable law or agreed to in writing, software\r
+//   distributed under the License is distributed on an "AS IS" BASIS,\r
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+//   See the License for the specific language governing permissions and\r
+//      limitations under the License.\r
+//      \r
+//------------------------------------------------------------------------------\r
+// Description:\r
+//------------------------------------------------------------------------------\r
+//\r
+//     Stores messages in Session data to be easily retrieved later on.\r
+//     This class includes four different types of messages:\r
+//  - Success\r
+//  - Error\r
+//  - Warning\r
+//  - Information\r
+// \r
+//  See README for basic usage instructions, or see samples/index.php for more advanced samples\r
+//\r
+//--------------------------------------------------------------------------------------------------\r
+// Changelog\r
+//--------------------------------------------------------------------------------------------------\r
+// \r
+//     2011-05-15 - v1.0 - Initial Version\r
+//\r
+//--------------------------------------------------------------------------------------------------\r
+\r
+class Messages {\r
+       \r
+       //-----------------------------------------------------------------------------------------------\r
+       // Class Variables\r
+       //-----------------------------------------------------------------------------------------------       \r
+       var $msgId;\r
+       var $msgTypes = array( 'help', 'info', 'warning', 'success', 'error' );\r
+       var $msgClass = 'messages';\r
+       var $msgWrapper = "<div class='%s %s'><a href='#' class='closeMessage'>X</a>\n%s</div>\n";\r
+       var $msgBefore = '<p>';\r
+       var $msgAfter = "</p>\n";\r
+\r
+       \r
+       /**\r
+        * Constructor\r
+        * @author Mike Everhart\r
+        */\r
+       public function __construct() {\r
+       \r
+               // Generate a unique ID for this user and session\r
+               $this->msgId = md5(uniqid());\r
+               \r
+               // Create the session array if it doesnt already exist\r
+               if( !array_key_exists('flash_messages', $_SESSION) ) $_SESSION['flash_messages'] = array();\r
+               \r
+       }\r
+       \r
+       /**\r
+        * Add a message to the queue\r
+        * \r
+        * @author Mike Everhart\r
+        * \r
+        * @param  string   $type               The type of message to add\r
+        * @param  string   $message            The message\r
+        * @param  string   $redirect_to        (optional) If set, the user will be redirected to this URL\r
+        * @return  bool \r
+        * \r
+        */\r
+       public function add($type, $message, $redirect_to=null) {\r
+               \r
+               if( !isset($_SESSION['flash_messages']) ) return false;\r
+               \r
+               if( !isset($type) || !isset($message[0]) ) return false;\r
+\r
+               // Replace any shorthand codes with their full version\r
+               if( strlen(trim($type)) == 1 ) {\r
+                       $type = str_replace( array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type );\r
+               \r
+               // Backwards compatibility...\r
+               } elseif( $type == 'information' ) {\r
+                       $type = 'info'; \r
+               }\r
+               \r
+               // Make sure it's a valid message type\r
+               if( !in_array($type, $this->msgTypes) ) die('"' . strip_tags($type) . '" is not a valid message type!' );\r
+               \r
+               // If the session array doesn't exist, create it\r
+               if( !array_key_exists( $type, $_SESSION['flash_messages'] ) ) $_SESSION['flash_messages'][$type] = array();\r
+               \r
+               $_SESSION['flash_messages'][$type][] = $message;\r
+\r
+               if( !is_null($redirect_to) ) {\r
+                       header("Location: $redirect_to");\r
+                       exit();\r
+               }\r
+               \r
+               return true;\r
+               \r
+       }\r
+       \r
+       //-----------------------------------------------------------------------------------------------\r
+       // display()\r
+       // print queued messages to the screen\r
+       //-----------------------------------------------------------------------------------------------\r
+       /**\r
+        * Display the queued messages\r
+        * \r
+        * @author Mike Everhart\r
+        * \r
+        * @param  string   $type     Which messages to display\r
+        * @param  bool         $print    True  = print the messages on the screen\r
+        * @return mixed              \r
+        * \r
+        */\r
+       public function display($type='all', $print=true) {\r
+               $messages = '';\r
+               $data = '';\r
+               \r
+               if( !isset($_SESSION['flash_messages']) ) return false;\r
+               \r
+               if( $type == 'g' || $type == 'growl' ) {\r
+                       $this->displayGrowlMessages();\r
+                       return true;\r
+               }\r
+               \r
+               // Print a certain type of message?\r
+               if( in_array($type, $this->msgTypes) ) {\r
+                       foreach( $_SESSION['flash_messages'][$type] as $msg ) {\r
+                               $messages .= $this->msgBefore . $msg . $this->msgAfter;\r
+                       }\r
+\r
+                       $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);\r
+                       \r
+                       // Clear the viewed messages\r
+                       $this->clear($type);\r
+               \r
+               // Print ALL queued messages\r
+               } elseif( $type == 'all' ) {\r
+                       foreach( $_SESSION['flash_messages'] as $type => $msgArray ) {\r
+                               $messages = '';\r
+                               foreach( $msgArray as $msg ) {\r
+                                       $messages .= $this->msgBefore . $msg . $this->msgAfter; \r
+                               }\r
+                               $data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);\r
+                       }\r
+                       \r
+                       // Clear ALL of the messages\r
+                       $this->clear();\r
+               \r
+               // Invalid Message Type?\r
+               } else { \r
+                       return false;\r
+               }\r
+               \r
+               // Print everything to the screen or return the data\r
+               if( $print ) { \r
+                       echo $data; \r
+               } else { \r
+                       return $data; \r
+               }\r
+       }\r
+       \r
+       \r
+       /**\r
+        * Check to  see if there are any queued error messages\r
+        * \r
+        * @author Mike Everhart\r
+        * \r
+        * @return bool  true  = There ARE error messages\r
+        *               false = There are NOT any error messages\r
+        * \r
+        */\r
+       public function hasErrors() { \r
+               return empty($_SESSION['flash_messages']['error']) ? false : true;      \r
+       }\r
+       \r
+       /**\r
+        * Check to see if there are any ($type) messages queued\r
+        * \r
+        * @author Mike Everhart\r
+        * \r
+        * @param  string   $type     The type of messages to check for\r
+        * @return bool                   \r
+        * \r
+        */\r
+       public function hasMessages($type=null) {\r
+               if( !is_null($type) ) {\r
+                       if( !empty($_SESSION['flash_messages'][$type]) ) return $_SESSION['flash_messages'][$type];     \r
+               } else {\r
+                       foreach( $this->msgTypes as $type ) {\r
+                               if( !empty($_SESSION['flash_messages']) ) return true;  \r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+       \r
+       /**\r
+        * Clear messages from the session data\r
+        * \r
+        * @author Mike Everhart\r
+        * \r
+        * @param  string   $type     The type of messages to clear\r
+        * @return bool \r
+        * \r
+        */\r
+       public function clear($type='all') { \r
+               if( $type == 'all' ) {\r
+                       unset($_SESSION['flash_messages']); \r
+               } else {\r
+                       unset($_SESSION['flash_messages'][$type]);\r
+               }\r
+               return true;\r
+       }\r
+       \r
+       public function __toString() { return $this->hasMessages();     }\r
+\r
+       public function __destruct() {\r
+               //$this->clear();\r
+       }\r
+\r
+\r
+} // end class\r
+?>
\ No newline at end of file
index f9bcf85bf71693902dac5f2734f0ec3b63ffc8b3..80bf6919cbed0377de4bca50670e119a3937b5b5 100644 (file)
@@ -12,6 +12,7 @@ class Poche
 {
     public $store;
     public $tpl;
+    public $messages;
 
     function __construct($storage_type)
     {
@@ -41,6 +42,9 @@ class Poche
             'cache' => CACHE,
         ));
         $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
+        # filter to display domain name of an url
+        $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
+        $this->tpl->addFilter($filter);
 
         Tools::initPhp();
         Session::init();
@@ -113,10 +117,12 @@ class Poche
             case 'toggle_fav' :
                 $this->store->favoriteById($id);
                 Tools::logm('mark as favorite link #' . $id);
+                Tools::redirect();
                 break;
             case 'toggle_archive' :
                 $this->store->archiveById($id);
                 Tools::logm('archive link #' . $id);
+                Tools::redirect();
                 break;
             default:
                 break;
@@ -174,16 +180,21 @@ class Poche
 
     public function updatePassword()
     {
-        if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
-            if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
-                if (!MODE_DEMO) {
+        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');
+        }
+        else {
+            if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
+                if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
                     Tools::logm('password updated');
+                    $this->messages->add('s', 'your password has been updated');
                     $this->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login']));
                     Session::logout();
                     Tools::redirect();
                 }
                 else {
-                    Tools::logm('in demo mode, you can\'t do this');
+                    $this->messages->add('e', 'the two fields have to be filled & the password must be the same in the two fields');
                 }
             }
         }
@@ -194,7 +205,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');
                 if (!empty($_POST['longlastingsession'])) {
                     $_SESSION['longlastingsession'] = 31536000;
                     $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
@@ -205,9 +216,11 @@ class Poche
                 session_regenerate_id(true);
                 Tools::redirect($referer);
             }
+            $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');
             Tools::logm('login failed');
             Tools::redirect();
         }
@@ -215,6 +228,7 @@ class Poche
 
     public function logout()
     {
+        $this->messages->add('s', 'logout successful, see you soon!');
         Tools::logm('logout');
         Session::logout();
         Tools::redirect();
@@ -244,6 +258,7 @@ class Poche
             # the second <ol> is for read links
             $read = 1;
         }
+        $this->messages->add('s', 'import from instapaper completed');
         Tools::logm('import from instapaper completed');
         Tools::redirect();
     }
@@ -272,6 +287,7 @@ class Poche
             # the second <ul> is for read links
             $read = 1;
         }
+        $this->messages->add('s', 'import from pocket completed');
         Tools::logm('import from pocket completed');
         Tools::redirect();
     }
@@ -300,6 +316,7 @@ class Poche
             if ($url->isCorrect())
                 $this->action('add', $url);
         }
+        $this->messages->add('s', 'import from Readability completed');
         Tools::logm('import from Readability completed');
         Tools::redirect();
     }
index 834940ffb4ec98359a53bd753f173d3a621e2bbb..7bc8830a5cdbb69eba3324d5b5856431027ab5ad 100644 (file)
@@ -210,4 +210,15 @@ class Tools
     {
         return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default);
     }
+
+    public static function getDomain($url)
+    {
+      $pieces = parse_url($url);
+      $domain = isset($pieces['host']) ? $pieces['host'] : '';
+      if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
+        return $regs['domain'];
+      }
+      
+      return FALSE;
+    }
 }
\ No newline at end of file
index 27be1857c535502d368032ab37380505ef3a3db2..d49df19045e07c85057257d71922e8fb039addb3 100644 (file)
@@ -15,6 +15,7 @@ define ('CONVERT_LINKS_FOOTNOTES', FALSE);
 define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
 define ('DOWNLOAD_PICTURES', FALSE);
 define ('SHARE_TWITTER', TRUE);
+define ('SHARE_MAIL', TRUE);
 define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX');
 define ('ABS_PATH', 'assets/');
 define ('TPL', './tpl');
@@ -34,9 +35,11 @@ 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';
 
 if (DOWNLOAD_PICTURES) {
     require_once './inc/poche/pochePictures.php';
 }
 
-$poche = new Poche($storage_type);
\ No newline at end of file
+$poche = new Poche($storage_type);
+$poche->messages = new Messages();
\ No newline at end of file
index 19774bb67912714c9bda873141985b0e3ce5cf62..dd70a989d897ebd5b6cbb51bb1e251818f51a779 100644 (file)
--- a/index.php
+++ b/index.php
@@ -61,5 +61,8 @@ else {
     $tpl_file = 'login.twig';
 }
 
+# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
+$tpl_vars = array_merge($tpl_vars, array('messages' => $poche->messages->display()));
+
 # Aaaaaaand action !
 echo $poche->tpl->render($tpl_file, $tpl_vars);
\ No newline at end of file
index 0878e0796dc2278fb7bfb9d5f7993299763c2b2b..0595d57e53dcda5ade04d215e273e6b2757da88e 100644 (file)
@@ -4,7 +4,7 @@
             +'<html>'
               +'<head>'
             +'<title>poche it !</title>'
-            +'<link rel="icon" href="{$poche_url}img/favicon.ico" />'
+            +'<link rel="icon" href="{{poche_url}}tpl/img/favicon.ico" />'
               +'</head>'
               +'<body>'
             +'<script>'
index ad96e9d1e9a2985f7e218f9dd87c7ea195b796af..9e82437f4f6ba499ac4f95b47ca9b99a72487fa8 100644 (file)
@@ -4,7 +4,5 @@
         <link rel="apple-touch-icon-precomposed" href="./tpl/img/apple-touch-icon-precomposed.png">
         <link rel="stylesheet" href="./tpl/css/knacss.css" media="all">
         <link rel="stylesheet" href="./tpl/css/style.css" media="all">
-        <!-- Light Theme -->
         <link rel="stylesheet" href="./tpl/css/style-light.css" media="all" title="light-style">
-        <!-- Dark Theme -->
-        <link rel="alternate stylesheet" href="./tpl/css/style-dark.css" media="all" title="dark-style">
\ No newline at end of file
+        <link rel="stylesheet" href="./tpl/css/messages.css" media="all">
\ No newline at end of file
diff --git a/tpl/_menu.twig b/tpl/_menu.twig
new file mode 100644 (file)
index 0000000..699d6a0
--- /dev/null
@@ -0,0 +1,7 @@
+            <ul id="links">
+                <li><a href="./" {% if view == 'home' %}class="current"{% endif %}>{% trans "home" %}</a></li>
+                <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
+                <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
+                <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
+                <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
+            </ul>
\ No newline at end of file
diff --git a/tpl/_messages.twig b/tpl/_messages.twig
new file mode 100644 (file)
index 0000000..c9f01b5
--- /dev/null
@@ -0,0 +1,5 @@
+            <ul id="messages">
+            {% for message in messages %}
+                <li>{{ message|e }}</li>
+            {% endfor %}
+            </ul>
\ No newline at end of file
diff --git a/tpl/css/messages.css b/tpl/css/messages.css
new file mode 100755 (executable)
index 0000000..702fac4
--- /dev/null
@@ -0,0 +1,13 @@
+.messages { width: 100%; -moz-border-radius: 4px; border-radius: 4px; display: block; padding: 10px 0; margin: 10px auto 10px; clear: both; }\r
+.messages a.closeMessage { margin: -14px -8px 0 0; display:none; width: 16px; height: 16px; float: right; background: url(../img/messages/close.png) no-repeat; }\r
+/*.messages:hover a.closeMessage { visibility:visible; }*/\r
+.messages p { margin: 3px 0 3px 10px !important; padding: 0 10px 0 23px !important; font-size: 14px; line-height: 16px; }\r
+.messages.error { border: 1px solid #C42608; color: #c00 !important; background: #FFF0EF; }\r
+.messages.error p { background: url(../img/messages/cross.png ) no-repeat 0px 50%; color:#c00 !important; }\r
+.messages.success {background: #E0FBCC; border: 1px solid #6DC70C; } \r
+.messages.success p { background: url(../img/messages/tick.png) no-repeat 0px 50%; color: #2B6301 !important; }\r
+.messages.warning { background: #FFFCD3; border: 1px solid #EBCD41; color: #000; }\r
+.messages.warning p { background: url(../img/messages/warning.png ) no-repeat 0px 50%; color: #5F4E01; }\r
+.messages.information, .messages.info { background: #DFEBFB; border: 1px solid #82AEE7; }\r
+.messages.information p, .messages.info p { background: url(../img/messages/help.png ) no-repeat 0px 50%; color: #064393; }\r
+.messages.information a { text-decoration: underline; }
\ No newline at end of file
index 0fcced246ff17cd3fc0749ec98cc2373cdbd3f43..49fe101197e6a196f03c46ac064dc64d4297b842 100644 (file)
@@ -65,6 +65,10 @@ a.archive-off span:hover {
     background: url('../img/dark/checkmark-on.png') no-repeat;
 }
 
+a.twitter span {
+    background: url('../img/dark/twitter.png') no-repeat;
+}
+
 /*** ***/
 /*** ARTICLE PAGE ***/
 
index c1d98326d41b0c1a41d62fc5d6898f23920c53de..5d584eb35acb6718fe18378426b6021b69cbb02a 100644 (file)
@@ -75,6 +75,14 @@ a.archive-off span:hover {
     background: url('../img/light/checkmark-on.png') no-repeat;
 }
 
+a.twitter span {
+    background: url('../img/light/twitter.png') no-repeat;
+}
+
+a.email span {
+    background: url('../img/light/envelop.png') no-repeat;
+}
+
 /*** ***/
 /*** ARTICLE PAGE ***/
 
index 6b9f6aca78ad0ed0a9cd6c7a89f612c25a352b71..333a0b776f1329920ece4daf1185f7300a1b2248 100644 (file)
@@ -47,6 +47,10 @@ header h1 {
     cursor: pointer;
 }
 
+ul#messages {
+    
+}
+
 #main, #article {
     margin: 0 auto;
 }
@@ -99,6 +103,7 @@ input[type=submit].delete {
 }
 
 .tools {
+    float: right;
     text-align: right;
 }
 
@@ -121,7 +126,6 @@ input[type=submit].delete {
     top: 0px;
     right: 0px;
     width: 100%;
-    text-align: left;
 }
 
 #article .tools ul li{
index 49ef9050499fc6e95bde30c5eb6e801f1b74f784..6d0f1a66c8177780ff0c6ad7884b4eb4316aa2e5 100644 (file)
@@ -1,38 +1,35 @@
 {% extends "layout.twig" %}
 {% block title %}{% trans "home" %}{% endblock %}
 {% block menu %}
-            <ul id="links">
-                <li><a href="./" {% if view == 'home' %}class="current"{% endif %}>{% trans "home" %}</a></li>
-                <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
-                <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
-                <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
-                <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
-            </ul>
+{% include '_menu.twig' %}
 {% endblock %}
 {% block precontent %}
             <ul id="sort">
-                <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>
-                <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>
+                <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>
+                <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>
             </ul>
 {% endblock %}
+{% block messages %}
+{% include '_messages.twig' %}
+{% endblock %}
 {% block content %}
             <div id="content">
                 {% for entry in entries %}
                     <div id="entry-{{ entry.id|e }}" class="entrie mb2">
                         <span class="content">
                             <h2 class="h6-like">
-                                <a href="index.php?&view=view&id={{ entry.id|e }}">{{ entry.title|e }}</a>
+                                <a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|e }}</a>
                             </h2>
                             <div class="tools">
                                 <ul>
                                     <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>
-                                        <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>
+                                        <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>
+                                        <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>
                                         <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>
                                     </li>
                                 </ul>
                             </div>
-                            <div class="url">{{ entry.url|e }}</div>
+                            <div class="url">{{ entry.url | e | getDomain }}</div>
                         </span>
                     </div>
                 {% endfor %}
 
 {% block js %}
             <script type="text/javascript" src="./tpl/js/jquery-1.9.1.min.js"></script>
-            <script type="text/javascript" src="./tpl/js/poche.js"></script>
             <script type="text/javascript" src="./tpl/js/jquery.masonry.min.js"></script>
-            <script type="text/javascript">
-                $( window ).load( function()
-                {
-                    var columns    = 3,
-                        setColumns = function() { columns = $( window ).width() > 640 ? 3 : $( window ).width() > 320 ? 2 : 1; };
-
-                    setColumns();
-                    $( window ).resize( setColumns );
-
-                    $( '#content' ).masonry(
-                    {
-                        itemSelector: '.entrie',
-                        columnWidth:  function( containerWidth ) { return containerWidth / columns; }
-                    });
-                });
-            </script>
+            <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>
 {% 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 (executable)
index 0000000..4595aff
Binary files /dev/null and b/tpl/img/dark/twitter.png differ
diff --git a/tpl/img/light/envelop.png b/tpl/img/light/envelop.png
new file mode 100755 (executable)
index 0000000..6be1c88
Binary files /dev/null and b/tpl/img/light/envelop.png differ
diff --git a/tpl/img/light/twitter.png b/tpl/img/light/twitter.png
new file mode 100755 (executable)
index 0000000..cfcfe41
Binary files /dev/null and b/tpl/img/light/twitter.png differ
diff --git a/tpl/img/messages/close.png b/tpl/img/messages/close.png
new file mode 100755 (executable)
index 0000000..731aa01
Binary files /dev/null and b/tpl/img/messages/close.png differ
diff --git a/tpl/img/messages/cross.png b/tpl/img/messages/cross.png
new file mode 100755 (executable)
index 0000000..1514d51
Binary files /dev/null and b/tpl/img/messages/cross.png differ
diff --git a/tpl/img/messages/help.png b/tpl/img/messages/help.png
new file mode 100755 (executable)
index 0000000..5c87017
Binary files /dev/null and b/tpl/img/messages/help.png differ
diff --git a/tpl/img/messages/tick.png b/tpl/img/messages/tick.png
new file mode 100755 (executable)
index 0000000..a9925a0
Binary files /dev/null and b/tpl/img/messages/tick.png differ
diff --git a/tpl/img/messages/warning.png b/tpl/img/messages/warning.png
new file mode 100755 (executable)
index 0000000..628cf2d
Binary files /dev/null and b/tpl/img/messages/warning.png differ
diff --git a/tpl/js/poche.js b/tpl/js/poche.js
deleted file mode 100644 (file)
index b4eac11..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-function toggle_favorite(element, id) {
-    $(element).toggleClass('fav-off');
-    $.ajax ({
-        url: "index.php?action=toggle_fav",
-        data:{id:id}
-    });
-}
-
-function toggle_archive(element, id, view_article) {
-    $(element).toggleClass('archive-off');
-    $.ajax ({
-        url: "index.php?action=toggle_archive",
-        data:{id:id}
-    });
-    var obj = $('#entry-'+id);
-
-    // on vient de la vue de l'article, donc pas de gestion de grille
-    if (view_article != 1) {
-        $('#content').masonry('remove',obj);
-        $('#content').masonry('reloadItems');
-        $('#content').masonry('reload');
-    }
-}
-
-function sort_links(view, sort) {
-    $.get('index.php', { view: view, sort: sort }, function(data) {
-      $('#content').html(data);
-    });
-}
-
-
-// ---------- Swith light or dark view
-function setActiveStyleSheet(title) {
-       var i, a, main;
-       for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
-               if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
-                       a.disabled = true;
-                       if(a.getAttribute("title") == title) a.disabled = false;
-               }
-       }
-}
-$('#themeswitch').click(function() {
-       // we want the dark
-       if ($('body').hasClass('light-style')) {
-               setActiveStyleSheet('dark-style');
-               $('body').addClass('dark-style');
-               $('body').removeClass('light-style');
-               $('#themeswitch').text('light');
-       // we want the light
-       } else if ($('body').hasClass('dark-style')) {
-               setActiveStyleSheet('light-style');
-               $('body').addClass('light-style');
-               $('body').removeClass('dark-style');
-               $('#themeswitch').text('dark');
-       }
-       return false;
-});
index cbe965fda9e665917659e5a3fdc43db8fabb3eaa..9dc83efe3186118c378624b46757389ce7bbcf56 100644 (file)
@@ -17,6 +17,7 @@
         <div id="main">
             {% block menu %}{% endblock %}
             {% block precontent %}{% endblock %}
+            {% block messages %}{% endblock %}
             {% block content %}{% endblock %}
             {% block js %}{% endblock %}
         </div>
index bf9a9af916e3504cf2bf2ec9b754bc41209dcc34..692f95551fe7ca238db4162fe0e5bde10ce90174 100644 (file)
@@ -1,42 +1,40 @@
 {% extends "layout.twig" %}
 {% block title %}{% trans "home" %}{% endblock %}
-
+{% block messages %}
+{% include '_messages.twig' %}
+{% endblock %}
 {% block content %}
         <div id="article" class="w600p">
-               <div class="backhome">
-                       <a href="./" title="{% trans "back to home" %}">&larr;</a>
-               </div>
             <div class="tools">
                 <ul>
-                    {% 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 %}
-                    <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>
-                    <li><a href="#" id="themeswitch">{% trans "dark" %}</a></li>
-                    <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>
+                    <li><a href="./" title="{% trans "back to home" %}" class="tool">&larr;</a></li>
+                    <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>
+                    <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>
                     <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>
-                    <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
+                    {% 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 %}
+                    {% 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 %}
                 </ul>
             </div>
             <header class="mbm">
-                <h1><a href="{{ entry.url|e }}">{{ entry.title|e }}</a></h1>
-                <div class="vieworiginal txtright small"><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{% trans "view original" %}</a></div>
+                <h1>{{ entry.title|e }}</h1>
+                <div class="vieworiginal txtright small"><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{{ entry.url | e | getDomain }}</a></div>
             </header>
             <article>
                 <div id="readityourselfcontent">
                     {{ content | raw }}
                 </div>
             </article>
-            <div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{% trans "view original" %}</a></div>
+            <div class="vieworiginal txtright small"><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}">{{ entry.url | e | getDomain }}</a></div>
             <div class="backhome">
                 <a href="./" title="{% trans "back to home" %}">&larr;</a>
                 <a href="#" title="{% trans "back to top" %}">&uarr;</a>
             </div>
             <div class="support">
-                {% 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>
+                {% 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>
             </div>
         </div>
 {% endblock %}
 
 {% block js %}
             <script type="text/javascript" src="./tpl/js/jquery-1.9.1.min.js"></script>
-            <script type="text/javascript" src="./tpl/js/poche.js"></script>
 {% endblock %}
\ No newline at end of file