share email +twitter / class messages
231
inc/3rdparty/class.messages.php
vendored
Executable file
@ -0,0 +1,231 @@
|
||||
<?php
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Session-Based Flash Messages v1.0
|
||||
// Copyright 2012 Mike Everhart (http://mikeeverhart.net)
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
// Description:
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Stores messages in Session data to be easily retrieved later on.
|
||||
// This class includes four different types of messages:
|
||||
// - Success
|
||||
// - Error
|
||||
// - Warning
|
||||
// - Information
|
||||
//
|
||||
// See README for basic usage instructions, or see samples/index.php for more advanced samples
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
// Changelog
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// 2011-05-15 - v1.0 - Initial Version
|
||||
//
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
class Messages {
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// Class Variables
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
var $msgId;
|
||||
var $msgTypes = array( 'help', 'info', 'warning', 'success', 'error' );
|
||||
var $msgClass = 'messages';
|
||||
var $msgWrapper = "<div class='%s %s'><a href='#' class='closeMessage'>X</a>\n%s</div>\n";
|
||||
var $msgBefore = '<p>';
|
||||
var $msgAfter = "</p>\n";
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @author Mike Everhart
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
// Generate a unique ID for this user and session
|
||||
$this->msgId = md5(uniqid());
|
||||
|
||||
// Create the session array if it doesnt already exist
|
||||
if( !array_key_exists('flash_messages', $_SESSION) ) $_SESSION['flash_messages'] = array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message to the queue
|
||||
*
|
||||
* @author Mike Everhart
|
||||
*
|
||||
* @param string $type The type of message to add
|
||||
* @param string $message The message
|
||||
* @param string $redirect_to (optional) If set, the user will be redirected to this URL
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public function add($type, $message, $redirect_to=null) {
|
||||
|
||||
if( !isset($_SESSION['flash_messages']) ) return false;
|
||||
|
||||
if( !isset($type) || !isset($message[0]) ) return false;
|
||||
|
||||
// Replace any shorthand codes with their full version
|
||||
if( strlen(trim($type)) == 1 ) {
|
||||
$type = str_replace( array('h', 'i', 'w', 'e', 's'), array('help', 'info', 'warning', 'error', 'success'), $type );
|
||||
|
||||
// Backwards compatibility...
|
||||
} elseif( $type == 'information' ) {
|
||||
$type = 'info';
|
||||
}
|
||||
|
||||
// Make sure it's a valid message type
|
||||
if( !in_array($type, $this->msgTypes) ) die('"' . strip_tags($type) . '" is not a valid message type!' );
|
||||
|
||||
// If the session array doesn't exist, create it
|
||||
if( !array_key_exists( $type, $_SESSION['flash_messages'] ) ) $_SESSION['flash_messages'][$type] = array();
|
||||
|
||||
$_SESSION['flash_messages'][$type][] = $message;
|
||||
|
||||
if( !is_null($redirect_to) ) {
|
||||
header("Location: $redirect_to");
|
||||
exit();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
// display()
|
||||
// print queued messages to the screen
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Display the queued messages
|
||||
*
|
||||
* @author Mike Everhart
|
||||
*
|
||||
* @param string $type Which messages to display
|
||||
* @param bool $print True = print the messages on the screen
|
||||
* @return mixed
|
||||
*
|
||||
*/
|
||||
public function display($type='all', $print=true) {
|
||||
$messages = '';
|
||||
$data = '';
|
||||
|
||||
if( !isset($_SESSION['flash_messages']) ) return false;
|
||||
|
||||
if( $type == 'g' || $type == 'growl' ) {
|
||||
$this->displayGrowlMessages();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Print a certain type of message?
|
||||
if( in_array($type, $this->msgTypes) ) {
|
||||
foreach( $_SESSION['flash_messages'][$type] as $msg ) {
|
||||
$messages .= $this->msgBefore . $msg . $this->msgAfter;
|
||||
}
|
||||
|
||||
$data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
|
||||
|
||||
// Clear the viewed messages
|
||||
$this->clear($type);
|
||||
|
||||
// Print ALL queued messages
|
||||
} elseif( $type == 'all' ) {
|
||||
foreach( $_SESSION['flash_messages'] as $type => $msgArray ) {
|
||||
$messages = '';
|
||||
foreach( $msgArray as $msg ) {
|
||||
$messages .= $this->msgBefore . $msg . $this->msgAfter;
|
||||
}
|
||||
$data .= sprintf($this->msgWrapper, $this->msgClass, $type, $messages);
|
||||
}
|
||||
|
||||
// Clear ALL of the messages
|
||||
$this->clear();
|
||||
|
||||
// Invalid Message Type?
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Print everything to the screen or return the data
|
||||
if( $print ) {
|
||||
echo $data;
|
||||
} else {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check to see if there are any queued error messages
|
||||
*
|
||||
* @author Mike Everhart
|
||||
*
|
||||
* @return bool true = There ARE error messages
|
||||
* false = There are NOT any error messages
|
||||
*
|
||||
*/
|
||||
public function hasErrors() {
|
||||
return empty($_SESSION['flash_messages']['error']) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if there are any ($type) messages queued
|
||||
*
|
||||
* @author Mike Everhart
|
||||
*
|
||||
* @param string $type The type of messages to check for
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public function hasMessages($type=null) {
|
||||
if( !is_null($type) ) {
|
||||
if( !empty($_SESSION['flash_messages'][$type]) ) return $_SESSION['flash_messages'][$type];
|
||||
} else {
|
||||
foreach( $this->msgTypes as $type ) {
|
||||
if( !empty($_SESSION['flash_messages']) ) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear messages from the session data
|
||||
*
|
||||
* @author Mike Everhart
|
||||
*
|
||||
* @param string $type The type of messages to clear
|
||||
* @return bool
|
||||
*
|
||||
*/
|
||||
public function clear($type='all') {
|
||||
if( $type == 'all' ) {
|
||||
unset($_SESSION['flash_messages']);
|
||||
} else {
|
||||
unset($_SESSION['flash_messages'][$type]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function __toString() { return $this->hasMessages(); }
|
||||
|
||||
public function __destruct() {
|
||||
//$this->clear();
|
||||
}
|
||||
|
||||
|
||||
} // end class
|
||||
?>
|
@ -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 (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'] != "") {
|
||||
if (!MODE_DEMO) {
|
||||
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();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
$poche->messages = new Messages();
|
@ -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);
|
@ -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>'
|
||||
|
@ -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">
|
||||
<link rel="stylesheet" href="./tpl/css/messages.css" media="all">
|
7
tpl/_menu.twig
Normal file
@ -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>
|
5
tpl/_messages.twig
Normal file
@ -0,0 +1,5 @@
|
||||
<ul id="messages">
|
||||
{% for message in messages %}
|
||||
<li>{{ message|e }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
13
tpl/css/messages.css
Executable file
@ -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; }
|
||||
.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; }
|
@ -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 ***/
|
||||
|
||||
|
@ -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 ***/
|
||||
|
||||
|
@ -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{
|
||||
|
@ -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 %}
|
||||
@ -41,22 +38,6 @@
|
||||
|
||||
{% 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 %}
|
BIN
tpl/img/dark/twitter.png
Executable file
After Width: | Height: | Size: 300 B |
BIN
tpl/img/light/envelop.png
Executable file
After Width: | Height: | Size: 285 B |
BIN
tpl/img/light/twitter.png
Executable file
After Width: | Height: | Size: 297 B |
BIN
tpl/img/messages/close.png
Executable file
After Width: | Height: | Size: 662 B |
BIN
tpl/img/messages/cross.png
Executable file
After Width: | Height: | Size: 655 B |
BIN
tpl/img/messages/help.png
Executable file
After Width: | Height: | Size: 786 B |
BIN
tpl/img/messages/tick.png
Executable file
After Width: | Height: | Size: 537 B |
BIN
tpl/img/messages/warning.png
Executable file
After Width: | Height: | Size: 666 B |
@ -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;
|
||||
});
|
@ -17,6 +17,7 @@
|
||||
<div id="main">
|
||||
{% block menu %}{% endblock %}
|
||||
{% block precontent %}{% endblock %}
|
||||
{% block messages %}{% endblock %}
|
||||
{% block content %}{% endblock %}
|
||||
{% block js %}{% endblock %}
|
||||
</div>
|
||||
|
@ -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" %}">←</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">←</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" %}">←</a>
|
||||
<a href="#" title="{% trans "back to top" %}">↑</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 %}
|