mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-29 20:41:03 +00:00
twig implementation
This commit is contained in:
parent
c67e13e04b
commit
8cbb2a8802
7 changed files with 86 additions and 90 deletions
|
@ -205,19 +205,6 @@ body.article {
|
|||
}
|
||||
}
|
||||
|
||||
/*** ***/
|
||||
/*** MESSAGES ***/
|
||||
|
||||
.messages { width: 100%; -moz-border-radius: 4px; border-radius: 4px; display: block; padding: 10px 0; margin: 10px auto 10px; clear: both; }
|
||||
.messages a.closeMessage { margin: -14px -8px 0 0; display:none; width: 16px; height: 16px; float: right; background: url(../img/messages/close.png) no-repeat; }
|
||||
/*.messages:hover a.closeMessage { visibility:visible; }*/
|
||||
.messages p { margin: 3px 0 3px 10px !important; padding: 0 10px 0 23px !important; font-size: 14px; line-height: 16px; }
|
||||
.messages.error { border: 1px solid #C42608; color: #c00 !important; background: #FFF0EF; }
|
||||
.messages.error p { background: url(../img/messages/cross.png ) no-repeat 0px 50%; color:#c00 !important; }
|
||||
.messages.success {background: #E0FBCC; border: 1px solid #6DC70C; }
|
||||
.messages.success p { background: url(../img/messages/tick.png) no-repeat 0px 50%; color: #2B6301 !important; }
|
||||
.messages.warning { background: #FFFCD3; border: 1px solid #EBCD41; color: #000; }
|
||||
.messages.warning p { background: url(../img/messages/warning.png ) no-repeat 0px 50%; color: #5F4E01; }
|
||||
.messages.information, .messages.info { background: #DFEBFB; border: 1px solid #82AEE7; }
|
||||
.messages.information p, .messages.info p { background: url(../img/messages/help.png ) no-repeat 0px 50%; color: #064393; }
|
||||
.messages.information a { text-decoration: underline; }
|
||||
.messages {
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
define ('POCHE_VERSION', '0.3');
|
||||
define ('MODE_DEMO', FALSE);
|
||||
define ('DEBUG_POCHE', TRUE);
|
||||
define ('DEBUG_POCHE', FALSE);
|
||||
define ('CONVERT_LINKS_FOOTNOTES', FALSE);
|
||||
define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
|
||||
define ('DOWNLOAD_PICTURES', FALSE);
|
||||
|
@ -21,7 +21,7 @@ define ('LOCALE', './locale');
|
|||
define ('CACHE', './cache');
|
||||
define ('LANG', 'fr_FR.UTF8');
|
||||
|
||||
$storage_type = 'sqlite'; # sqlite or file
|
||||
$storage_type = 'sqlite'; # sqlite, file
|
||||
|
||||
# /!\ Be careful if you change the lines below /!\
|
||||
|
||||
|
@ -75,4 +75,6 @@ if(!$store->isInstalled())
|
|||
}
|
||||
|
||||
$_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin();
|
||||
$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword();
|
||||
$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword();
|
||||
|
||||
pocheTools::initPhp();
|
|
@ -134,10 +134,12 @@ function fetch_url_content($url)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
function display_view($view, $id = 0, $full_head = 'yes')
|
||||
function display_view($view, $id = 0)
|
||||
{
|
||||
global $tpl, $store;
|
||||
|
||||
$tpl_vars = array();
|
||||
|
||||
switch ($view)
|
||||
{
|
||||
case 'install':
|
||||
|
@ -186,21 +188,25 @@ function display_view($view, $id = 0, $full_head = 'yes')
|
|||
break;
|
||||
default: # home view
|
||||
$entries = $store->getEntriesByView($view);
|
||||
$tpl->assign('entries', $entries);
|
||||
$tpl_vars = array(
|
||||
'entries' => $entries,
|
||||
);
|
||||
|
||||
if ($full_head == 'yes') {
|
||||
$tpl->assign('load_all_js', 1);
|
||||
$tpl->draw('head');
|
||||
$tpl->draw('home');
|
||||
}
|
||||
// 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');
|
||||
}
|
||||
// $tpl->draw('entries');
|
||||
// if ($full_head == 'yes') {
|
||||
// $tpl->draw('js');
|
||||
// $tpl->draw('footer');
|
||||
// }
|
||||
break;
|
||||
}
|
||||
|
||||
return $tpl_vars;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
23
index.php
23
index.php
|
@ -10,12 +10,12 @@
|
|||
|
||||
include dirname(__FILE__).'/inc/config.php';
|
||||
|
||||
pocheTools::initPhp();
|
||||
$errors = array();
|
||||
|
||||
# XSRF protection with token
|
||||
if (!empty($_POST)) {
|
||||
if (!Session::isToken($_POST['token'])) {
|
||||
die(_('Wrong token.'));
|
||||
die(_('Wrong token'));
|
||||
}
|
||||
unset($_SESSION['tokens']);
|
||||
}
|
||||
|
@ -23,10 +23,11 @@ if (!empty($_POST)) {
|
|||
$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
||||
|
||||
if (isset($_GET['login'])) {
|
||||
// Login
|
||||
if (!empty($_POST['login']) && !empty($_POST['password'])) {
|
||||
if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) {
|
||||
pocheTools::logm('login successful');
|
||||
$errors[]['value'] = _('login successful');
|
||||
|
||||
if (!empty($_POST['longlastingsession'])) {
|
||||
$_SESSION['longlastingsession'] = 31536000;
|
||||
$_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
|
||||
|
@ -35,11 +36,10 @@ if (isset($_GET['login'])) {
|
|||
session_set_cookie_params(0); // when browser closes
|
||||
}
|
||||
session_regenerate_id(true);
|
||||
|
||||
pocheTools::redirect($referer);
|
||||
}
|
||||
pocheTools::logm('login failed');
|
||||
die(_("Login failed !"));
|
||||
$errors[]['value'] = _('Login failed !');
|
||||
} else {
|
||||
pocheTools::logm('login failed');
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ elseif (isset($_GET['config'])) {
|
|||
}
|
||||
|
||||
# Traitement des paramètres et déclenchement des actions
|
||||
$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'index';
|
||||
$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home';
|
||||
$full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes';
|
||||
$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
|
||||
$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
|
||||
|
@ -75,20 +75,23 @@ $id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id
|
|||
$url = (isset ($_GET['url'])) ? $_GET['url'] : '';
|
||||
|
||||
$tpl_vars = array(
|
||||
'isLogged' => Session::isLogged(),
|
||||
'referer' => $referer,
|
||||
'view' => $view,
|
||||
'poche_url' => pocheTools::getUrl(),
|
||||
'demo' => MODE_DEMO,
|
||||
'title' => _('poche, a read it later open source system'),
|
||||
'token' => Session::getToken(),
|
||||
'errors' => $errors,
|
||||
);
|
||||
|
||||
$tpl_file = 'home.twig';
|
||||
|
||||
if (Session::isLogged()) {
|
||||
action_to_do($action, $url, $id);
|
||||
display_view($view, $id, $full_head);
|
||||
$tpl_vars = array_merge($tpl_vars, display_view($view, $id));
|
||||
}
|
||||
else {
|
||||
$template = $twig->loadTemplate('login.twig');
|
||||
$tpl_file = 'login.twig';
|
||||
}
|
||||
|
||||
echo $template->render($tpl_vars);
|
||||
echo $twig->render($tpl_file, $tpl_vars);
|
|
@ -1,21 +1,41 @@
|
|||
<body class="light-style">
|
||||
<header>
|
||||
<h1><a href="index.php"><img src="./img/logo.png" alt="logo poche" /></a>poche</h1>
|
||||
</header>
|
||||
<div id="main">
|
||||
{% extends "layout.twig" %}
|
||||
|
||||
{% block title %}Home{% endblock %}
|
||||
{% block menu %}
|
||||
<ul id="links">
|
||||
<li><a href="index.php" {if="$view == 'index'"}class="current"{/if}>home</a></li>
|
||||
<li><a href="?view=fav" {if="$view == 'fav'"}class="current"{/if}>favorites</a></li>
|
||||
<li><a href="?view=archive" {if="$view == 'archive'"}class="current"{/if}>archive</a></li>
|
||||
<li><a href="?view=config" {if="$view == 'config'"}class="current"{/if}>config</a></li>
|
||||
<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>
|
||||
</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="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>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
{include="messages"}
|
||||
{% 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>
|
||||
</h2>
|
||||
<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>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="url">{{ entry.url|e }}</div>
|
||||
</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -9,50 +9,18 @@
|
|||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=10">
|
||||
<title>{% block title %}{% endblock %} - poche</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>
|
||||
{% include '_head.twig' %}
|
||||
{% include '_bookmarklet.twig' %}
|
||||
</head>
|
||||
<body class="light-style">
|
||||
<header>
|
||||
<h1><a href="/"><img src="./img/logo.png" alt="logo poche" /></a>poche</h1>
|
||||
</header>
|
||||
{% include '_top.twig' %}
|
||||
<div id="main">
|
||||
{% block menu %}{% endblock %}
|
||||
{% block precontent %}{% endblock %}
|
||||
{% block messages %}{% endblock %}
|
||||
{% block content %}{% endblock %}
|
||||
{% block js %}{% endblock %}
|
||||
</div>
|
||||
<footer class="mr2 mt3 smaller">
|
||||
<p>powered by <a href="http://inthepoche.com">poche</a></p>
|
||||
</footer>
|
||||
|
||||
{% include '_footer.twig' %}
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,15 @@
|
|||
{% extends "layout.twig" %}
|
||||
|
||||
{% block title %}Login{% endblock %}
|
||||
{% block messages %}
|
||||
<div class="messages">
|
||||
<ul>
|
||||
{% for error in errors %}
|
||||
<li>{{ error.value|e }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<form method="post" action="?login" name="loginform">
|
||||
<fieldset class="w500p center">
|
||||
|
|
Loading…
Reference in a new issue