aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 08:57:35 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 08:57:35 +0200
commit2b840e0cfb63a453bea67a98541f3df9c273c5f5 (patch)
tree8c5aa51ba6481f29f9734373d6abd55917d1a671
parent8cbb2a88024969f7efd90f8053f3b0805fa2f8fa (diff)
downloadwallabag-2b840e0cfb63a453bea67a98541f3df9c273c5f5.tar.gz
wallabag-2b840e0cfb63a453bea67a98541f3df9c273c5f5.tar.zst
wallabag-2b840e0cfb63a453bea67a98541f3df9c273c5f5.zip
twig implementation
-rw-r--r--inc/poche/pocheCore.php46
-rw-r--r--index.php6
-rw-r--r--tpl/config.twig (renamed from tpl/config.html)16
-rw-r--r--tpl/footer.html7
-rw-r--r--tpl/head.html42
-rw-r--r--tpl/home.twig45
-rw-r--r--tpl/install.twig2
-rw-r--r--tpl/js.html22
-rw-r--r--tpl/login.twig2
9 files changed, 80 insertions, 108 deletions
diff --git a/inc/poche/pocheCore.php b/inc/poche/pocheCore.php
index 3e32c4a8..9cbcc077 100644
--- a/inc/poche/pocheCore.php
+++ b/inc/poche/pocheCore.php
@@ -134,9 +134,35 @@ function fetch_url_content($url)
134 return FALSE; 134 return FALSE;
135} 135}
136 136
137function get_tpl_file($view)
138{
139 $tpl_file = 'home.twig';
140 switch ($view)
141 {
142 case 'install':
143 $tpl_file = 'install.twig';
144 break;
145 case 'import';
146 $tpl_file = 'import.twig';
147 break;
148 case 'export':
149 $tpl_file = 'export.twig';
150 break;
151 case 'config':
152 $tpl_file = 'config.twig';
153 break;
154 case 'view':
155 $tpl_file = 'view.twig';
156 break;
157 default:
158 break;
159 }
160 return $tpl_file;
161}
162
137function display_view($view, $id = 0) 163function display_view($view, $id = 0)
138{ 164{
139 global $tpl, $store; 165 global $store;
140 166
141 $tpl_vars = array(); 167 $tpl_vars = array();
142 168
@@ -155,12 +181,6 @@ function display_view($view, $id = 0)
155 pocheTools::logm('export view'); 181 pocheTools::logm('export view');
156 break; 182 break;
157 case 'config': 183 case 'config':
158 $tpl->assign('load_all_js', 0);
159 $tpl->draw('head');
160 $tpl->draw('home');
161 $tpl->draw('config');
162 $tpl->draw('js');
163 $tpl->draw('footer');
164 pocheTools::logm('config view'); 184 pocheTools::logm('config view');
165 break; 185 break;
166 case 'view': 186 case 'view':
@@ -191,18 +211,6 @@ function display_view($view, $id = 0)
191 $tpl_vars = array( 211 $tpl_vars = array(
192 'entries' => $entries, 212 'entries' => $entries,
193 ); 213 );
194
195 // if ($full_head == 'yes') {
196 // $tpl->assign('load_all_js', 1);
197 // $tpl->draw('head');
198 // $tpl->draw('home');
199 // }
200
201 // $tpl->draw('entries');
202 // if ($full_head == 'yes') {
203 // $tpl->draw('js');
204 // $tpl->draw('footer');
205 // }
206 break; 214 break;
207 } 215 }
208 216
diff --git a/index.php b/index.php
index f0a8aef4..81bd0174 100644
--- a/index.php
+++ b/index.php
@@ -15,7 +15,8 @@ $errors = array();
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 // TODO CORRIGER ICI !!!
19 } 20 }
20 unset($_SESSION['tokens']); 21 unset($_SESSION['tokens']);
21} 22}
@@ -84,10 +85,9 @@ $tpl_vars = array(
84 'errors' => $errors, 85 'errors' => $errors,
85); 86);
86 87
87$tpl_file = 'home.twig';
88
89if (Session::isLogged()) { 88if (Session::isLogged()) {
90 action_to_do($action, $url, $id); 89 action_to_do($action, $url, $id);
90 $tpl_file = get_tpl_file($view);
91 $tpl_vars = array_merge($tpl_vars, display_view($view, $id)); 91 $tpl_vars = array_merge($tpl_vars, display_view($view, $id));
92} 92}
93else { 93else {
diff --git a/tpl/config.html b/tpl/config.twig
index 2c7df4f7..10c481de 100644
--- a/tpl/config.html
+++ b/tpl/config.twig
@@ -1,3 +1,16 @@
1{% extends "layout.twig" %}
2
3{% block title %}{% trans "config" %}{% endblock %}
4{% block menu %}
5 <ul id="links">
6 <li><a href="./" {% if view == 'home' %}class="current"{% endif %}>{% trans "home" %}</a></li>
7 <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
8 <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
9 <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
10 <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
11 </ul>
12{% endblock %}
13{% block content %}
1 <div id="content"> 14 <div id="content">
2 <h2>Bookmarklet</h2> 15 <h2>Bookmarklet</h2>
3 <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> 16 <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 @@
24 </form> 37 </form>
25 <h2>Export</h2> 38 <h2>Export</h2>
26 <p><a href="?view=export" target="_blank">Click here</a> to export your poche datas.</p> 39 <p><a href="?view=export" target="_blank">Click here</a> to export your poche datas.</p>
27 </div> \ No newline at end of file 40 </div>
41{% endblock %} \ No newline at end of file
diff --git a/tpl/footer.html b/tpl/footer.html
deleted file mode 100644
index b8bd755c..00000000
--- a/tpl/footer.html
+++ /dev/null
@@ -1,7 +0,0 @@
1 </div>
2 <footer class="mr2 mt3 smaller">
3 <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>
4 </footer>
5
6 </body>
7</html> \ No newline at end of file
diff --git a/tpl/head.html b/tpl/head.html
deleted file mode 100644
index dfb12788..00000000
--- a/tpl/head.html
+++ /dev/null
@@ -1,42 +0,0 @@
1<!DOCTYPE html>
2<!--[if lte IE 6]> <html class="no-js ie6 ie67 ie678" lang="en"> <![endif]-->
3<!--[if lte IE 7]> <html class="no-js ie7 ie67 ie678" lang="en"> <![endif]-->
4<!--[if IE 8]> <html class="no-js ie8 ie678" lang="en"> <![endif]-->
5<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
6<html>
7 <head>
8 <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
9 <meta charset="utf-8">
10 <meta http-equiv="X-UA-Compatible" content="IE=10">
11 <title>{$title}</title>
12 <link rel="shortcut icon" type="image/x-icon" href="./img/favicon.ico" />
13 <link rel="apple-touch-icon-precomposed" sizes="144x144" href="./img/apple-touch-icon-144x144-precomposed.png">
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> \ No newline at end of file
diff --git a/tpl/home.twig b/tpl/home.twig
index 7b5b88a2..c79d4276 100644
--- a/tpl/home.twig
+++ b/tpl/home.twig
@@ -1,19 +1,18 @@
1{% extends "layout.twig" %} 1{% extends "layout.twig" %}
2 2{% block title %}{% trans "home" %}{% endblock %}
3{% block title %}Home{% endblock %}
4{% block menu %} 3{% block menu %}
5 <ul id="links"> 4 <ul id="links">
6 <li><a href="index.php" {% if view == 'home' %}class="current"{% endif %}>home</a></li> 5 <li><a href="./" {% if view == 'home' %}class="current"{% endif %}>{% trans "home" %}</a></li>
7 <li><a href="?view=fav" {% if view == 'fav' %}class="current"{% endif %}>favorites</a></li> 6 <li><a href="./?view=fav" {% if view == 'fav' %}class="current"{% endif %}>{% trans "favorites" %}</a></li>
8 <li><a href="?view=archive" {% if view == 'archive' %}class="current"{% endif %}>archive</a></li> 7 <li><a href="./?view=archive" {% if view == 'archive' %}class="current"{% endif %}>{% trans "archive" %}</a></li>
9 <li><a href="?view=config" {% if view == 'config' %}class="current"{% endif %}>config</a></li> 8 <li><a href="./?view=config" {% if view == 'config' %}class="current"{% endif %}>{% trans "config" %}</a></li>
10 <li><a href="?logout" title="Logout">logout</a></li> 9 <li><a href="./?logout" title="{% trans "logout" %}">{% trans "logout" %}</a></li>
11 </ul> 10 </ul>
12{% endblock %} 11{% endblock %}
13{% block precontent %} 12{% block precontent %}
14 <ul id="sort"> 13 <ul id="sort">
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> 14 <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>
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> 15 <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>
17 </ul> 16 </ul>
18{% endblock %} 17{% endblock %}
19{% block content %} 18{% block content %}
@@ -27,9 +26,9 @@
27 <div class="tools"> 26 <div class="tools">
28 <ul> 27 <ul>
29 <li> 28 <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> 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>
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> 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>
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> 31 <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>
33 </li> 32 </li>
34 </ul> 33 </ul>
35 </div> 34 </div>
@@ -38,4 +37,26 @@
38 </div> 37 </div>
39 {% endfor %} 38 {% endfor %}
40 </div> 39 </div>
40{% endblock %}
41
42{% block js %}
43 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
44 <script type="text/javascript" src="js/poche.js"></script>
45 <script type="text/javascript" src="js/jquery.masonry.min.js"></script>
46 <script type="text/javascript">
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>
41{% endblock %} \ No newline at end of file 62{% endblock %} \ No newline at end of file
diff --git a/tpl/install.twig b/tpl/install.twig
index 4342df2e..8bcede0d 100644
--- a/tpl/install.twig
+++ b/tpl/install.twig
@@ -1,5 +1,5 @@
1{% extends "layout.twig" %} 1{% extends "layout.twig" %}
2{% block title %}Installation{% endblock %} 2{% block title %}{% trans "installation" %}{% endblock %}
3{% block content %} 3{% block content %}
4 <form method="post" action="?install" name="loginform"> 4 <form method="post" action="?install" name="loginform">
5 <fieldset class="w500p center"> 5 <fieldset class="w500p center">
diff --git a/tpl/js.html b/tpl/js.html
deleted file mode 100644
index 3a51af6e..00000000
--- a/tpl/js.html
+++ /dev/null
@@ -1,22 +0,0 @@
1 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
2 <script type="text/javascript" src="js/poche.js"></script>
3
4 {if="$load_all_js == '1'"}
5 <script type="text/javascript" src="js/jquery.masonry.min.js"></script>
6 <script type="text/javascript">
7 $( window ).load( function()
8 {
9 var columns = 3,
10 setColumns = function() { columns = $( window ).width() > 640 ? 3 : $( window ).width() > 320 ? 2 : 1; };
11
12 setColumns();
13 $( window ).resize( setColumns );
14
15 $( '#content' ).masonry(
16 {
17 itemSelector: '.entrie',
18 columnWidth: function( containerWidth ) { return containerWidth / columns; }
19 });
20 });
21 </script>
22 {/if} \ No newline at end of file
diff --git a/tpl/login.twig b/tpl/login.twig
index c95a5f02..d1080530 100644
--- a/tpl/login.twig
+++ b/tpl/login.twig
@@ -1,6 +1,6 @@
1{% extends "layout.twig" %} 1{% extends "layout.twig" %}
2 2
3{% block title %}Login{% endblock %} 3{% block title %}{% trans "login to your poche" %}{% endblock %}
4{% block messages %} 4{% block messages %}
5 <div class="messages"> 5 <div class="messages">
6 <ul> 6 <ul>