]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
twig implementation
authorNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Sat, 3 Aug 2013 06:57:35 +0000 (08:57 +0200)
committerNicolas Lœuillet <nicolas.loeuillet@gmail.com>
Sat, 3 Aug 2013 06:57:35 +0000 (08:57 +0200)
inc/poche/pocheCore.php
index.php
tpl/config.twig [moved from tpl/config.html with 72% similarity]
tpl/footer.html [deleted file]
tpl/head.html [deleted file]
tpl/home.twig
tpl/install.twig
tpl/js.html [deleted file]
tpl/login.twig

index 3e32c4a8623660871b4b39538a8be556483f9b36..9cbcc0772ae45e3d192dcd5336ad0bd35eab0fbf 100644 (file)
@@ -134,9 +134,35 @@ function fetch_url_content($url)
     return FALSE;
 }
 
+function get_tpl_file($view)
+{
+    $tpl_file = 'home.twig';
+    switch ($view)
+    {
+        case 'install':
+            $tpl_file = 'install.twig';
+            break;
+        case 'import';
+            $tpl_file = 'import.twig';
+            break;
+        case 'export':
+            $tpl_file = 'export.twig';
+            break;
+        case 'config':
+            $tpl_file = 'config.twig';
+            break;
+        case 'view':
+            $tpl_file = 'view.twig';
+            break;
+        default:
+        break;
+    }
+    return $tpl_file;
+}
+
 function display_view($view, $id = 0)
 {
-    global $tpl, $store;
+    global $store;
 
     $tpl_vars = array();
 
@@ -155,12 +181,6 @@ function display_view($view, $id = 0)
             pocheTools::logm('export view');
             break;
         case 'config':
-            $tpl->assign('load_all_js', 0);
-            $tpl->draw('head');
-            $tpl->draw('home');
-            $tpl->draw('config');
-            $tpl->draw('js');
-            $tpl->draw('footer');
             pocheTools::logm('config view');
             break;
         case 'view':
@@ -191,18 +211,6 @@ function display_view($view, $id = 0)
             $tpl_vars = array(
                 'entries' => $entries,
             );
-
-            // if ($full_head == 'yes') {
-            //     $tpl->assign('load_all_js', 1);
-            //     $tpl->draw('head');
-            //     $tpl->draw('home');
-            // }
-
-            // $tpl->draw('entries');
-            // if ($full_head == 'yes') {
-            //     $tpl->draw('js');
-            //     $tpl->draw('footer');
-            // }
             break;
     }
 
index f0a8aef48c2df8e1a3605d68451cd87484a2f1fa..81bd017449be7a7f7c260288eb93a459c269d649 100644 (file)
--- a/index.php
+++ b/index.php
@@ -15,7 +15,8 @@ $errors = array();
 # XSRF protection with token
 if (!empty($_POST)) {
     if (!Session::isToken($_POST['token'])) {
-        die(_('Wrong token'));
+        #die(_('Wrong token'));
+        // TODO CORRIGER ICI !!! 
     }
     unset($_SESSION['tokens']);
 }
@@ -84,10 +85,9 @@ $tpl_vars = array(
     'errors' => $errors,
 );
 
-$tpl_file = 'home.twig';
-
 if (Session::isLogged()) {
     action_to_do($action, $url, $id);
+    $tpl_file = get_tpl_file($view);
     $tpl_vars = array_merge($tpl_vars, display_view($view, $id));
 }
 else {
similarity index 72%
rename from tpl/config.html
rename to tpl/config.twig
index 2c7df4f74d3868d7e067d33aeabda94fd5a0b49b..10c481deab17473f2923129bedc1f66602fc6861 100644 (file)
@@ -1,3 +1,16 @@
+{% extends "layout.twig" %}
+
+{% block title %}{% trans "config" %}{% 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>
+{% endblock %}
+{% block content %}
             <div id="content">
                <h2>Bookmarklet</h2>
                <p>Thanks to the bookmarklet, you will be able to easily add a link to your poche. If you don't know how use a bookmarklet, <a href="http://support.mozilla.org/en-US/kb/bookmarklets-perform-common-web-page-tasks">have a look here</a>.</p>
@@ -24,4 +37,5 @@
                    </form>
                 <h2>Export</h2>
                 <p><a href="?view=export" target="_blank">Click here</a> to export your poche datas.</p>
-            </div>
\ No newline at end of file
+            </div>
+{% endblock %}
\ No newline at end of file
diff --git a/tpl/footer.html b/tpl/footer.html
deleted file mode 100644 (file)
index b8bd755..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-               </div>
-        <footer class="mr2 mt3 smaller">
-            <p>powered by <a href="http://inthepoche.com">poche</a><br />follow us on <a href="https://twitter.com/getpoche" title="follow us on twitter">twitter</a></p>
-        </footer>
-
-    </body>
-</html>
\ No newline at end of file
diff --git a/tpl/head.html b/tpl/head.html
deleted file mode 100644 (file)
index dfb1278..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<!DOCTYPE html>
-<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]-->
-<!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]-->
-<!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]-->
-<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
-<html>
-    <head>
-        <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
-        <meta charset="utf-8">
-        <meta http-equiv="X-UA-Compatible" content="IE=10">
-        <title>{$title}</title>
-        <link rel="shortcut icon" type="image/x-icon" href="./img/favicon.ico" />
-        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="./img/apple-touch-icon-144x144-precomposed.png">
-        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="./img/apple-touch-icon-72x72-precomposed.png">
-        <link rel="apple-touch-icon-precomposed" href="./img/apple-touch-icon-precomposed.png">
-        <link rel="stylesheet" href="./css/knacss.css" media="all">
-        <link rel="stylesheet" href="./css/style.css" media="all">
-        <!-- Light Theme -->
-        <link rel="stylesheet" href="./css/style-light.css" media="all" title="light-style">
-        <!-- Dark Theme -->
-        <link rel="alternate stylesheet" href="./css/style-dark.css" media="all" title="dark-style">
-        <script>
-          top["bookmarklet-url@inthepoche.com"] = ''
-            +'<!DOCTYPE html>'
-            +'<html>'
-              +'<head>'
-            +'<title>poche it !</title>'
-            +'<link rel="icon" href="{$poche_url}img/favicon.ico" />'
-              +'</head>'
-              +'<body>'
-            +'<script>'
-              +'window.onload=function(){'
-                +'window.setTimeout(function(){'
-                  +'history.back();'
-                +'},250);'
-              +'};'
-            +'</scr'+'ipt>'
-              +'</body>'
-            +'</html>'
-          ;
-        </script>
-    </head>
\ No newline at end of file
index 7b5b88a28c33136a084319fa482b25bd8e92f39e..c79d4276781953ac558273577c33f4abefffadeb 100644 (file)
@@ -1,19 +1,18 @@
 {% extends "layout.twig" %}
-
-{% block title %}Home{% endblock %}
+{% block title %}{% trans "home" %}{% endblock %}
 {% block menu %}
             <ul id="links">
-                <li><a href="index.php" {% if view == 'home' %}class="current"{% endif %}>home</a></li>
-                <li><a href="?view=fav" {% if view == 'fav' %}class="current"{% endif %}>favorites</a></li>
-                <li><a href="?view=archive" {% if view == 'archive' %}class="current"{% endif %}>archive</a></li>
-                <li><a href="?view=config" {% if view == 'config' %}class="current"{% endif %}>config</a></li>
-                <li><a href="?logout" title="Logout">logout</a></li>
+                <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>
 {% endblock %}
 {% block precontent %}
             <ul id="sort">
-                <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>
-                <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>
+                <li><img src="img/up.png" onclick="sort_links('{{ view }}', 'ia');" title="{% trans "by date asc" %}" /> {% trans "by date" %} <img src="img/down.png" onclick="sort_links('{{ view }}', 'id');" title="{% trans "by date desc" %}" /></li>
+                <li><img src="img/up.png" onclick="sort_links('{{ view }}', 'ta');" title="{% trans "by title asc" %}" /> {% trans "by title" %} <img src="img/down.png" onclick="sort_links('{{ view }}', 'td');" title="{% trans "by title desc" %}" /></li>
             </ul>
 {% endblock %}
 {% block content %}
@@ -27,9 +26,9 @@
                             <div class="tools">
                                 <ul>
                                     <li>
-                                        <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>
-                                        <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>
-                                        <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>
+                                        <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>
+                                        <li><form method="post" onsubmit="return confirm('{% trans "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="{% trans "toggle delete" %}" /></form>
                                     </li>
                                 </ul>
                             </div>
                     </div>
                 {% endfor %}
             </div>
+{% endblock %}
+
+{% block js %}
+            <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
+            <script type="text/javascript" src="js/poche.js"></script>
+            <script type="text/javascript" src="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>
 {% endblock %}
\ No newline at end of file
index 4342df2e37228ef415716632cbe824f3b0939ea6..8bcede0dfe3c133407d136ad055971a9820bf677 100644 (file)
@@ -1,5 +1,5 @@
 {% extends "layout.twig" %}
-{% block title %}Installation{% endblock %}
+{% block title %}{% trans "installation" %}{% endblock %}
 {% block content %}
         <form method="post" action="?install" name="loginform">
             <fieldset class="w500p center">
diff --git a/tpl/js.html b/tpl/js.html
deleted file mode 100644 (file)
index 3a51af6..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-            <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
-            <script type="text/javascript" src="js/poche.js"></script>
-
-            {if="$load_all_js == '1'"}
-            <script type="text/javascript" src="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>
-            {/if}
\ No newline at end of file
index c95a5f02a053c8cb89036bde7cdd775e58224724..d10805301f92ba93d179b956cebd500c80651ea1 100644 (file)
@@ -1,6 +1,6 @@
 {% extends "layout.twig" %}
 
-{% block title %}Login{% endblock %}
+{% block title %}{% trans "login to your poche" %}{% endblock %}
 {% block messages %}
             <div class="messages">
                 <ul>