mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-26 11:01:04 +00:00
twig implementation
This commit is contained in:
parent
8cbb2a8802
commit
2b840e0cfb
9 changed files with 80 additions and 108 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
||||
|
@ -38,4 +37,26 @@
|
|||
</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 %}
|
|
@ -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">
|
||||
|
|
22
tpl/js.html
22
tpl/js.html
|
@ -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}
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue