Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 85ebc80c7e | |||
| 6588517b2d | |||
| 6d37de5f82 | |||
| 9c902708da | |||
| 66ce09ba03 | |||
| 6499b26ae8 | |||
| da368cc84f | |||
| aa8c9f2a32 | |||
| baa8617364 | |||
| 494e21b4da | |||
| 0ace6cab0b | |||
| c1c9f252f7 | |||
| 2987031bc3 | |||
| 3e7188185d | |||
| 8d5aab49c1 | |||
| cdcc8d2533 | |||
| ae9571694f | |||
| 4ddbd26787 | |||
| 8444bb0600 | |||
| 29c6fd4607 | |||
| 37f2773aa5 | |||
| e682978e5b | |||
| 69ca1455d1 | |||
| 88958248fa | |||
| 2761de0184 | |||
| d2beefd27c | |||
| 8af1077265 | |||
| 9acfade829 | |||
| d3607de929 | |||
| 176d733a44 | |||
| e858ac2776 | |||
| 37c6ed4e7a | |||
| f0070a15e4 | |||
| 6f87a19714 | |||
| 44e77bfa24 | |||
| 016989b79a | |||
| a58cd56c4f | |||
| cddd8e90f4 | |||
| bbff4b57a9 | |||
| f281635c9a | |||
| 8c72b98d9d | |||
| 6a02410a9b | |||
| 2cd263e0bd | |||
| 4e97e6e8b9 | |||
| b4397510e7 | |||
| 682536a9e7 | |||
| 14890de35a | |||
| ff4d8c8c1e | |||
| bf18db78b3 |
@ -5,7 +5,9 @@ Abandon Pocket, Instapaper and other Readability service : adopt poche. It is th
|
||||
|
||||
The website of poche is [inthepoche.com](http://inthepoche.com).
|
||||
|
||||
To get news from poche, [follow us on twitter](http://twitter.com/getpoche) or [read the poche blog](http://inthepoche.com/blog).
|
||||
To test poche, a demo website is online : [demo.inthepoche.com](http://demo.inthepoche.com) (login poche, password poche).
|
||||
|
||||
To get news from poche, [follow us on twitter](http://twitter.com/getpoche) or [read the poche blog](http://inthepoche.com/blog). A Google Group is also available : [poche-users](https://groups.google.com/forum/#!forum/poche-users).
|
||||
|
||||
[](http://flattr.com/thing/1265480/poche-a-read-it-later-open-source-system)
|
||||
|
||||
@ -23,7 +25,7 @@ You can :
|
||||
## Requirements & installation
|
||||
You have to install [sqlite for php](http://www.php.net/manual/en/book.sqlite.php) on your server.
|
||||
|
||||
Get the [latest version](https://github.com/nicosomb/poche) of poche on github. Unzip it and upload it on your server. poche must have write access on assets, cache and db directories.
|
||||
Get the [latest version](https://github.com/inthepoche/poche) of poche on github. Unzip it and upload it on your server. poche must have write access on assets, cache and db directories.
|
||||
|
||||
That's all, **poche works** !
|
||||
|
||||
|
||||
90
css/style-dark.css
Normal file
@ -0,0 +1,90 @@
|
||||
/*** GENERAL ***/
|
||||
body {
|
||||
color: #fff;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
a, a:hover, a:visited {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#main ul#links li a.current {
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#links a:hover, .backhome a:hover{
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
input[type=submit].delete {
|
||||
background : url('../img/dark/remove.png') no-repeat center center;
|
||||
color : transparent;
|
||||
}
|
||||
|
||||
#main .entrie {
|
||||
color: #fff;
|
||||
background-color: #000;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
#main .entrie h2 a:hover {
|
||||
color: #29B1E3;
|
||||
}
|
||||
|
||||
a.fav span {
|
||||
background: url('../img/dark/star-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav span:hover {
|
||||
background: url('../img/dark/star-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav-off span {
|
||||
background: url('../img/dark/star-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav-off span:hover {
|
||||
background: url('../img/dark/star-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive span {
|
||||
background: url('../img/dark/checkmark-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive span:hover {
|
||||
background: url('../img/dark/checkmark-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive-off span {
|
||||
background: url('../img/dark/checkmark-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive-off span:hover {
|
||||
background: url('../img/dark/checkmark-on.png') no-repeat;
|
||||
}
|
||||
|
||||
/*** ***/
|
||||
/*** ARTICLE PAGE ***/
|
||||
|
||||
body.article {
|
||||
color: #fff;
|
||||
background-color: #0d0d0d;
|
||||
}
|
||||
|
||||
#article header {
|
||||
border-bottom: 1px solid #222222;
|
||||
}
|
||||
|
||||
#article article {
|
||||
border-bottom: 1px solid #222222;
|
||||
}
|
||||
|
||||
.vieworiginal a {
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.entrie {
|
||||
background-color: #fff;
|
||||
}
|
||||
100
css/style-light.css
Normal file
@ -0,0 +1,100 @@
|
||||
/*** GENERAL ***/
|
||||
body {
|
||||
color: #222222;
|
||||
background-color: #F1F1F1;
|
||||
}
|
||||
|
||||
a, a:hover, a:visited {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.bouton {
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
border: none;
|
||||
}
|
||||
.bouton:hover {
|
||||
background-color: #222222;
|
||||
color: #F1F1F1;
|
||||
}
|
||||
|
||||
#main ul#links li a.current {
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#links a:hover, .backhome a:hover{
|
||||
background-color: #040707;
|
||||
color: #F1F1F1;
|
||||
}
|
||||
|
||||
input[type=submit].delete {
|
||||
background : url('../img/light/remove.png') no-repeat center center;
|
||||
color : transparent;
|
||||
}
|
||||
|
||||
#main .entrie {
|
||||
color: #2e2e2e;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
#main .entrie h2 a:hover {
|
||||
color: #F5BE00;
|
||||
}
|
||||
|
||||
a.fav span {
|
||||
background: url('../img/light/star-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav span:hover {
|
||||
background: url('../img/light/star-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav-off span {
|
||||
background: url('../img/light/star-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav-off span:hover {
|
||||
background: url('../img/light/star-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive span {
|
||||
background: url('../img/light/checkmark-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive span:hover {
|
||||
background: url('../img/light/checkmark-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive-off span {
|
||||
background: url('../img/light/checkmark-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive-off span:hover {
|
||||
background: url('../img/light/checkmark-on.png') no-repeat;
|
||||
}
|
||||
|
||||
/*** ***/
|
||||
/*** ARTICLE PAGE ***/
|
||||
|
||||
body.article {
|
||||
color: #222222;
|
||||
background-color: #F1F1F1;
|
||||
}
|
||||
|
||||
#article header {
|
||||
border-bottom: 1px solid #222222;
|
||||
}
|
||||
|
||||
#article article {
|
||||
border-bottom: 1px solid #222222;
|
||||
}
|
||||
|
||||
.vieworiginal a {
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.entrie {
|
||||
background-color: #fff;
|
||||
}
|
||||
@ -1,20 +1,17 @@
|
||||
/*** GENERAL ***/
|
||||
body {
|
||||
color: #222222;
|
||||
font: 20px/1.3em Palatino,Georgia,serif;
|
||||
background-color: #F1F1F1;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
|
||||
a, a:hover, a:visited {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
header {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bouton {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
#main ul#links {
|
||||
padding: 0;
|
||||
list-style-type: none;
|
||||
@ -28,8 +25,6 @@ header {
|
||||
#main ul#links li a.current {
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
background-color: #040707;
|
||||
color: #F1F1F1;
|
||||
}
|
||||
|
||||
#main ul#sort {
|
||||
@ -58,19 +53,12 @@ header {
|
||||
#links a:hover, .backhome a:hover{
|
||||
-webkit-border-radius: 2px;
|
||||
border-radius: 2px;
|
||||
background-color: #040707;
|
||||
color: #F1F1F1;
|
||||
}
|
||||
|
||||
footer {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/*** ***/
|
||||
/*** LOGIN FORM ***/
|
||||
ul#login li {
|
||||
list-style-type: none;
|
||||
}
|
||||
/*** ***/
|
||||
/*** LINKS DISPLAY ***/
|
||||
|
||||
@ -80,11 +68,9 @@ ul#login li {
|
||||
}
|
||||
|
||||
input[type=submit].delete {
|
||||
background : url('../img/remove.png') no-repeat center center;
|
||||
width : 16px;
|
||||
height :16px;
|
||||
border : none;
|
||||
color : transparent;
|
||||
cursor: pointer;
|
||||
font-size : 0;
|
||||
}
|
||||
@ -94,8 +80,6 @@ input[type=submit].delete {
|
||||
}
|
||||
|
||||
#main .entrie {
|
||||
color: rgb(46, 46, 46);
|
||||
background-color: #ffffff;
|
||||
padding: 15px;
|
||||
min-height: 8em;
|
||||
border: 1px solid;
|
||||
@ -105,10 +89,6 @@ input[type=submit].delete {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#main .entrie h2 a:hover {
|
||||
color: #F5BE00;
|
||||
}
|
||||
|
||||
.tools {
|
||||
text-align: right;
|
||||
}
|
||||
@ -145,62 +125,23 @@ input[type=submit].delete {
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
a.fav span {
|
||||
background: url('../img/star-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav span:hover {
|
||||
background: url('../img/star-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav-off span {
|
||||
background: url('../img/star-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.fav-off span:hover {
|
||||
background: url('../img/star-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive span {
|
||||
background: url('../img/checkmark-on.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive span:hover {
|
||||
background: url('../img/checkmark-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive-off span {
|
||||
background: url('../img/checkmark-off.png') no-repeat;
|
||||
}
|
||||
|
||||
a.archive-off span:hover {
|
||||
background: url('../img/checkmark-on.png') no-repeat;
|
||||
}
|
||||
|
||||
/*** ***/
|
||||
/*** ARTICLE PAGE ***/
|
||||
|
||||
body.article {
|
||||
color: #222222;
|
||||
font: 20px/1.3em Palatino,Georgia,serif;
|
||||
background-color: #F1F1F1;
|
||||
}
|
||||
|
||||
#article header {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #222222;
|
||||
}
|
||||
|
||||
#article header a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#article article {
|
||||
border-bottom: 1px solid #222222;
|
||||
}
|
||||
|
||||
.vieworiginal a {
|
||||
color: #888888;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@ -256,4 +197,19 @@ 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; }
|
||||
|
||||
BIN
img/dark/checkmark-off.png
Normal file
|
After Width: | Height: | Size: 267 B |
BIN
img/dark/checkmark-on.png
Normal file
|
After Width: | Height: | Size: 221 B |
BIN
img/dark/down.png
Normal file
|
After Width: | Height: | Size: 223 B |
BIN
img/dark/logo.png
Normal file
|
After Width: | Height: | Size: 786 B |
BIN
img/dark/remove.png
Normal file
|
After Width: | Height: | Size: 265 B |
BIN
img/dark/star-off.png
Normal file
|
After Width: | Height: | Size: 330 B |
BIN
img/dark/star-on.png
Normal file
|
After Width: | Height: | Size: 277 B |
BIN
img/dark/up.png
Normal file
|
After Width: | Height: | Size: 225 B |
|
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 277 B |
|
Before Width: | Height: | Size: 235 B After Width: | Height: | Size: 235 B |
|
Before Width: | Height: | Size: 252 B After Width: | Height: | Size: 252 B |
|
Before Width: | Height: | Size: 314 B After Width: | Height: | Size: 314 B |
|
Before Width: | Height: | Size: 281 B After Width: | Height: | Size: 281 B |
BIN
img/messages/close.png
Normal file
|
After Width: | Height: | Size: 662 B |
BIN
img/messages/cross.png
Normal file
|
After Width: | Height: | Size: 655 B |
BIN
img/messages/help.png
Normal file
|
After Width: | Height: | Size: 786 B |
BIN
img/messages/tick.png
Normal file
|
After Width: | Height: | Size: 537 B |
BIN
img/messages/warning.png
Normal file
|
After Width: | Height: | Size: 666 B |
@ -107,4 +107,3 @@ class JSLikeHTMLElement extends DOMElement
|
||||
return '['.$this->tagName.']';
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <support@inthepoche.com>
|
||||
* @copyright 2013
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
class MyTool
|
||||
{
|
||||
public static function initPhp()
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
/**
|
||||
* Arc90's Readability ported to PHP for FiveFilters.org
|
||||
* Based on readability.js version 1.7.1 (without multi-page support)
|
||||
* Updated to allow HTML5 parsing with html5lib
|
||||
* Updated with lightClean mode to preserve more images and youtube/vimeo/viddler embeds
|
||||
* ------------------------------------------------------
|
||||
* Original URL: http://lab.arc90.com/experiments/readability/js/readability.js
|
||||
* Arc90's project URL: http://lab.arc90.com/experiments/readability/
|
||||
@ -10,7 +12,7 @@
|
||||
* More information: http://fivefilters.org/content-only/
|
||||
* License: Apache License, Version 2.0
|
||||
* Requires: PHP5
|
||||
* Date: 2011-07-22
|
||||
* Date: 2012-09-19
|
||||
*
|
||||
* Differences between the PHP port and the original
|
||||
* ------------------------------------------------------
|
||||
@ -62,14 +64,8 @@ $r->init();
|
||||
echo $r->articleContent->innerHTML;
|
||||
*/
|
||||
|
||||
|
||||
class Readability
|
||||
{
|
||||
/* constants */
|
||||
const FLAG_STRIP_UNLIKELYS = 1;
|
||||
const FLAG_WEIGHT_CLASSES = 2;
|
||||
const FLAG_CLEAN_CONDITIONALLY = 4;
|
||||
|
||||
public $version = '1.7.1-without-multi-page';
|
||||
public $convertLinksToFootnotes = false;
|
||||
public $revertForcedParagraphElements = true;
|
||||
@ -78,9 +74,10 @@ class Readability
|
||||
public $dom;
|
||||
public $url = null; // optional - URL where HTML was retrieved
|
||||
public $debug = false;
|
||||
public $lightClean = true; // preserves more content (experimental) added 2012-09-19
|
||||
protected $body = null; //
|
||||
protected $bodyCache = null; // Cache the body HTML in case we need to re-use it later
|
||||
protected $flags = self::FLAG_CLEAN_CONDITIONALLY; // 1 | 2 | 4; // Start with all flags set.
|
||||
protected $flags = 7; // 1 | 2 | 4; // Start with all flags set.
|
||||
protected $success = false; // indicates whether we were able to extract or not
|
||||
|
||||
/**
|
||||
@ -88,37 +85,47 @@ class Readability
|
||||
* Defined up here so we don't instantiate them repeatedly in loops.
|
||||
**/
|
||||
public $regexps = array(
|
||||
'unlikelyCandidates' => '/combx|comment|comments|community|disqus|extra|foot|header|menu|remark|rss|shoutbox|sidebar|sponsor|ad-break|agegate|pagination|pager|popup|tweet|twitter/i',
|
||||
'unlikelyCandidates' => '/combx|comment|community|disqus|extra|foot|header|menu|remark|rss|shoutbox|sidebar|sponsor|ad-break|agegate|pagination|pager|popup/i',
|
||||
'okMaybeItsACandidate' => '/and|article|body|column|main|shadow/i',
|
||||
'positive' => '/article|body|content|entry|hentry|main|page|pagination|post|text|blog|story/i',
|
||||
'negative' => '/combx|comment|comments|com-|contact|foot|footer|footnote|masthead|media|meta|outbrain|promo|related|scroll|shoutbox|sidebar|sponsor|shopping|tags|tool|widget/i',
|
||||
'divToPElements' => '/<(a|blockquote|dl|div|ol|p|pre|table|ul)/i',
|
||||
'positive' => '/article|body|content|entry|hentry|main|page|attachment|pagination|post|text|blog|story/i',
|
||||
'negative' => '/combx|comment|com-|contact|foot|footer|_nav|footnote|masthead|media|meta|outbrain|promo|related|scroll|shoutbox|sidebar|sponsor|shopping|tags|tool|widget/i',
|
||||
'divToPElements' => '/<(a|blockquote|dl|div|img|ol|p|pre|table|ul)/i',
|
||||
'replaceBrs' => '/(<br[^>]*>[ \n\r\t]*){2,}/i',
|
||||
'replaceFonts' => '/<(\/?)font[^>]*>/i',
|
||||
// 'trimRe' => '/^\s+|\s+$/g', // PHP has trim()
|
||||
'normalize' => '/\s{2,}/',
|
||||
'killBreaks' => '/(<br\s*\/?>(\s| ?)*){1,}/',
|
||||
'video' => '/http:\/\/(www\.)?(youtube|vimeo|dailymotion)\.com/i',
|
||||
'video' => '!//(player\.|www\.)?(youtube|vimeo|viddler)\.com!i',
|
||||
'skipFootnoteLink' => '/^\s*(\[?[a-z0-9]{1,2}\]?|^|edit|citation needed)\s*$/i'
|
||||
);
|
||||
|
||||
/* constants */
|
||||
const FLAG_STRIP_UNLIKELYS = 1;
|
||||
const FLAG_WEIGHT_CLASSES = 2;
|
||||
const FLAG_CLEAN_CONDITIONALLY = 4;
|
||||
|
||||
/**
|
||||
* Create instance of Readability
|
||||
* @param string UTF-8 encoded string
|
||||
* @param string (optional) URL associated with HTML (used for footnotes)
|
||||
* @param string which parser to use for turning raw HTML into a DOMDocument (either 'libxml' or 'html5lib')
|
||||
*/
|
||||
function __construct($html, $url=null)
|
||||
function __construct($html, $url=null, $parser='libxml')
|
||||
{
|
||||
$this->url = $url;
|
||||
/* Turn all double br's into p's */
|
||||
$html = preg_replace($this->regexps['replaceBrs'], '</p><p>', $html);
|
||||
$html = preg_replace($this->regexps['replaceFonts'], '<$1span>', $html);
|
||||
$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
|
||||
if (trim($html) == '') $html = '<html></html>';
|
||||
if ($parser=='html5lib' && ($this->dom = HTML5_Parser::parse($html))) {
|
||||
// all good
|
||||
} else {
|
||||
$this->dom = new DOMDocument();
|
||||
$this->dom->preserveWhiteSpace = false;
|
||||
$this->dom->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
|
||||
if (trim($html) == '') $html = '<html></html>';
|
||||
@$this->dom->loadHTML($html);
|
||||
$this->url = $url;
|
||||
}
|
||||
$this->dom->registerNodeClass('DOMElement', 'JSLikeHTMLElement');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,7 +221,7 @@ class Readability
|
||||
* Debug
|
||||
*/
|
||||
protected function dbg($msg) {
|
||||
if ($this->debug) echo '* ',$msg, '<br />', "\n";
|
||||
if ($this->debug) echo '* ',$msg, "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -421,7 +428,7 @@ class Readability
|
||||
* If there is only one h2, they are probably using it
|
||||
* as a header and not a subheader, so remove it since we already have a header.
|
||||
***/
|
||||
if ($articleContent->getElementsByTagName('h2')->length == 1) {
|
||||
if (!$this->lightClean && ($articleContent->getElementsByTagName('h2')->length == 1)) {
|
||||
$this->clean($articleContent, 'h2');
|
||||
}
|
||||
$this->clean($articleContent, 'iframe');
|
||||
@ -440,8 +447,9 @@ class Readability
|
||||
$imgCount = $articleParagraphs->item($i)->getElementsByTagName('img')->length;
|
||||
$embedCount = $articleParagraphs->item($i)->getElementsByTagName('embed')->length;
|
||||
$objectCount = $articleParagraphs->item($i)->getElementsByTagName('object')->length;
|
||||
$iframeCount = $articleParagraphs->item($i)->getElementsByTagName('iframe')->length;
|
||||
|
||||
if ($imgCount === 0 && $embedCount === 0 && $objectCount === 0 && $this->getInnerText($articleParagraphs->item($i), false) == '')
|
||||
if ($imgCount === 0 && $embedCount === 0 && $objectCount === 0 && $iframeCount === 0 && $this->getInnerText($articleParagraphs->item($i), false) == '')
|
||||
{
|
||||
$articleParagraphs->item($i)->parentNode->removeChild($articleParagraphs->item($i));
|
||||
}
|
||||
@ -565,7 +573,7 @@ class Readability
|
||||
}
|
||||
else
|
||||
{
|
||||
// EXPERIMENTAL
|
||||
/* EXPERIMENTAL */
|
||||
// TODO: change these p elements back to text nodes after processing
|
||||
for ($i = 0, $il = $node->childNodes->length; $i < $il; $i++) {
|
||||
$childNode = $node->childNodes->item($i);
|
||||
@ -735,23 +743,6 @@ class Readability
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for a special classname */
|
||||
if ($siblingNode->nodeType === XML_ELEMENT_NODE && $siblingNode->hasAttribute('class') && $siblingNode->getAttribute('class') != '')
|
||||
{
|
||||
if (preg_match($this->regexps['okMaybeItsACandidate'], $siblingNode->getAttribute('class'))) {
|
||||
$append = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for a special classname */
|
||||
if ($siblingNode->nodeType === XML_ELEMENT_NODE && $siblingNode->hasAttribute('id') && $siblingNode->getAttribute('id') != '')
|
||||
{
|
||||
if (preg_match($this->regexps['okMaybeItsACandidate'], $siblingNode->getAttribute('id'))) {
|
||||
$append = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($append)
|
||||
{
|
||||
$this->dbg('Appending node: ' . $siblingNode->nodeName);
|
||||
@ -964,13 +955,15 @@ class Readability
|
||||
* Clean a node of all elements of type "tag".
|
||||
* (Unless it's a youtube/vimeo video. People love movies.)
|
||||
*
|
||||
* Updated 2012-09-18 to preserve youtube/vimeo iframes
|
||||
*
|
||||
* @param DOMElement $e
|
||||
* @param string $tag
|
||||
* @return void
|
||||
*/
|
||||
public function clean($e, $tag) {
|
||||
$targetList = $e->getElementsByTagName($tag);
|
||||
$isEmbed = ($tag == 'object' || $tag == 'embed');
|
||||
$isEmbed = ($tag == 'iframe' || $tag == 'object' || $tag == 'embed');
|
||||
|
||||
for ($y=$targetList->length-1; $y >= 0; $y--) {
|
||||
/* Allow youtube and vimeo videos through as people usually want to see those. */
|
||||
@ -1035,6 +1028,7 @@ class Readability
|
||||
$img = $tagsList->item($i)->getElementsByTagName('img')->length;
|
||||
$li = $tagsList->item($i)->getElementsByTagName('li')->length-100;
|
||||
$input = $tagsList->item($i)->getElementsByTagName('input')->length;
|
||||
$a = $tagsList->item($i)->getElementsByTagName('a')->length;
|
||||
|
||||
$embedCount = 0;
|
||||
$embeds = $tagsList->item($i)->getElementsByTagName('embed');
|
||||
@ -1043,28 +1037,69 @@ class Readability
|
||||
$embedCount++;
|
||||
}
|
||||
}
|
||||
$embeds = $tagsList->item($i)->getElementsByTagName('iframe');
|
||||
for ($ei=0, $il=$embeds->length; $ei < $il; $ei++) {
|
||||
if (preg_match($this->regexps['video'], $embeds->item($ei)->getAttribute('src'))) {
|
||||
$embedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
$linkDensity = $this->getLinkDensity($tagsList->item($i));
|
||||
$contentLength = strlen($this->getInnerText($tagsList->item($i)));
|
||||
$toRemove = false;
|
||||
|
||||
if ( $img > $p ) {
|
||||
if ($this->lightClean) {
|
||||
$this->dbg('Light clean...');
|
||||
if ( ($img > $p) && ($img > 4) ) {
|
||||
$this->dbg(' more than 4 images and more image elements than paragraph elements');
|
||||
$toRemove = true;
|
||||
} else if ($li > $p && $tag != 'ul' && $tag != 'ol') {
|
||||
$this->dbg(' too many <li> elements, and parent is not <ul> or <ol>');
|
||||
$toRemove = true;
|
||||
} else if ( $input > floor($p/3) ) {
|
||||
$this->dbg(' too many <input> elements');
|
||||
$toRemove = true;
|
||||
} else if ($contentLength < 25 && ($img === 0 || $img > 2) ) {
|
||||
} else if ($contentLength < 25 && ($embedCount === 0 && ($img === 0 || $img > 2))) {
|
||||
$this->dbg(' content length less than 25 chars, 0 embeds and either 0 images or more than 2 images');
|
||||
$toRemove = true;
|
||||
} else if($weight < 25 && $linkDensity > 0.2) {
|
||||
$this->dbg(' weight smaller than 25 and link density above 0.2');
|
||||
$toRemove = true;
|
||||
} else if($a > 2 && ($weight >= 25 && $linkDensity > 0.5)) {
|
||||
$this->dbg(' more than 2 links and weight above 25 but link density greater than 0.5');
|
||||
$toRemove = true;
|
||||
} else if($embedCount > 3) {
|
||||
$this->dbg(' more than 3 embeds');
|
||||
$toRemove = true;
|
||||
}
|
||||
} else {
|
||||
$this->dbg('Standard clean...');
|
||||
if ( $img > $p ) {
|
||||
$this->dbg(' more image elements than paragraph elements');
|
||||
$toRemove = true;
|
||||
} else if ($li > $p && $tag != 'ul' && $tag != 'ol') {
|
||||
$this->dbg(' too many <li> elements, and parent is not <ul> or <ol>');
|
||||
$toRemove = true;
|
||||
} else if ( $input > floor($p/3) ) {
|
||||
$this->dbg(' too many <input> elements');
|
||||
$toRemove = true;
|
||||
} else if ($contentLength < 25 && ($img === 0 || $img > 2) ) {
|
||||
$this->dbg(' content length less than 25 chars and 0 images, or more than 2 images');
|
||||
$toRemove = true;
|
||||
} else if($weight < 25 && $linkDensity > 0.2) {
|
||||
$this->dbg(' weight smaller than 25 and link density above 0.2');
|
||||
$toRemove = true;
|
||||
} else if($weight >= 25 && $linkDensity > 0.5) {
|
||||
$this->dbg(' weight above 25 but link density greater than 0.5');
|
||||
$toRemove = true;
|
||||
} else if(($embedCount == 1 && $contentLength < 75) || $embedCount > 1) {
|
||||
$this->dbg(' 1 embed and content length smaller than 75 chars, or more than one embed');
|
||||
$toRemove = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($toRemove) {
|
||||
//$this->dbg('Removing: '.$tagsList->item($i)->innerHTML);
|
||||
$tagsList->item($i)->parentNode->removeChild($tagsList->item($i));
|
||||
}
|
||||
}
|
||||
@ -1100,4 +1135,3 @@ class Readability
|
||||
$this->flags = $this->flags & ~$flag;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -93,7 +93,7 @@ class Session
|
||||
// Force logout
|
||||
public static function logout()
|
||||
{
|
||||
unset($_SESSION['uid'],$_SESSION['info'],$_SESSION['expires_on'],$_SESSION['tokens']);
|
||||
unset($_SESSION['uid'],$_SESSION['info'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass']);
|
||||
}
|
||||
|
||||
// Make sure user is logged in.
|
||||
|
||||
231
inc/class.messages.php
Normal 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'></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
|
||||
?>
|
||||
@ -8,25 +8,34 @@
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
define ('POCHE_VERSION', '0.2.1');
|
||||
|
||||
if (!is_dir('db/')) {
|
||||
@mkdir('db/',0705);
|
||||
}
|
||||
|
||||
define ('DB_PATH', 'sqlite:./db/poche.sqlite');
|
||||
define ('MODE_DEMO', FALSE);
|
||||
define ('ABS_PATH', 'assets/');
|
||||
define ('CONVERT_LINKS_FOOTNOTES', TRUE);
|
||||
define ('REVERT_FORCED_PARAGRAPH_ELEMENTS',FALSE);
|
||||
define ('DOWNLOAD_PICTURES', TRUE);
|
||||
define ('SALT', '464v54gLLw928uz4zUBqkRJeiPY68zCX');
|
||||
$storage_type = 'sqlite'; # sqlite or file
|
||||
|
||||
include 'db.php';
|
||||
include 'functions.php';
|
||||
require_once 'Readability.php';
|
||||
require_once 'Encoding.php';
|
||||
require_once 'rain.tpl.class.php';
|
||||
require_once 'MyTool.class.php';
|
||||
require_once 'Session.class.php';
|
||||
require_once 'store/store.class.php';
|
||||
require_once 'store/sqlite.class.php';
|
||||
require_once 'store/file.class.php';
|
||||
require_once 'class.messages.php';
|
||||
|
||||
$db = new db(DB_PATH);
|
||||
Session::init();
|
||||
|
||||
$store = new $storage_type();
|
||||
# initialisation de RainTPL
|
||||
raintpl::$tpl_dir = './tpl/';
|
||||
raintpl::$cache_dir = './cache/';
|
||||
@ -34,3 +43,24 @@ raintpl::$base_url = get_poche_url();
|
||||
raintpl::configure('path_replace', false);
|
||||
raintpl::configure('debug', false);
|
||||
$tpl = new raintpl();
|
||||
|
||||
if(!$store->isInstalled())
|
||||
{
|
||||
logm('poche still not installed');
|
||||
$tpl->draw('install');
|
||||
if (isset($_GET['install'])) {
|
||||
if (($_POST['password'] == $_POST['password_repeat'])
|
||||
&& $_POST['password'] != "" && $_POST['login'] != "") {
|
||||
$store->install($_POST['login'], encode_string($_POST['password'] . $_POST['login']));
|
||||
Session::logout();
|
||||
MyTool::redirect();
|
||||
}
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
$_SESSION['login'] = (isset ($_SESSION['login'])) ? $_SESSION['login'] : $store->getLogin();
|
||||
$_SESSION['pass'] = (isset ($_SESSION['pass'])) ? $_SESSION['pass'] : $store->getPassword();
|
||||
|
||||
$msg = new Messages();
|
||||
$tpl->assign('msg', $msg);
|
||||
22
inc/db.php
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <nicolas@loeuillet.org>
|
||||
* @copyright 2013
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
class db {
|
||||
var $handle;
|
||||
function __construct($path) {
|
||||
$this->handle = new PDO($path);
|
||||
$this->handle->exec('CREATE TABLE IF NOT EXISTS "entries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "title" VARCHAR, "url" VARCHAR UNIQUE , "is_read" INTEGER DEFAULT 0, "is_fav" INTEGER DEFAULT 0, "content" BLOB)');
|
||||
$this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
public function getHandle() {
|
||||
return $this->handle;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <support@inthepoche.com>
|
||||
* @copyright 2013
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
/**
|
||||
* Permet de générer l'URL de poche pour le bookmarklet
|
||||
@ -15,6 +23,11 @@ function get_poche_url()
|
||||
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
|
||||
function encode_string($string)
|
||||
{
|
||||
return sha1($string . SALT);
|
||||
}
|
||||
|
||||
// function define to retrieve url content
|
||||
function get_external_file($url)
|
||||
{
|
||||
@ -31,6 +44,10 @@ function get_external_file($url)
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
|
||||
// FOR SSL do not verified certificate
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($curl, CURLOPT_AUTOREFERER, TRUE );
|
||||
|
||||
// FeedBurner requires a proper USER-AGENT...
|
||||
curl_setopt($curl, CURL_HTTP_VERSION_1_1, true);
|
||||
curl_setopt($curl, CURLOPT_ENCODING, "gzip, deflate");
|
||||
@ -46,7 +63,15 @@ function get_external_file($url)
|
||||
} else {
|
||||
|
||||
// create http context and add timeout and user-agent
|
||||
$context = stream_context_create(array('http'=>array('timeout' => $timeout,'header'=> "User-Agent: ".$useragent,/*spoot Mozilla Firefox*/'follow_location' => true)));
|
||||
$context = stream_context_create(array(
|
||||
'http'=>array('timeout' => $timeout,
|
||||
'header'=> "User-Agent: ".$useragent, /*spoot Mozilla Firefox*/
|
||||
'follow_location' => true),
|
||||
// FOR SSL do not verified certificate
|
||||
'ssl' => array('verify_peer' => false,
|
||||
'allow_self_signed' => true)
|
||||
)
|
||||
);
|
||||
|
||||
// only download page lesser than 4MB
|
||||
$data = @file_get_contents($url, false, $context, -1, 4000000); // We download at most 4 MB from source.
|
||||
@ -100,14 +125,26 @@ function prepare_url($url)
|
||||
$i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i);
|
||||
|
||||
$title = $url;
|
||||
if (!preg_match('!^https?://!i', $url))
|
||||
$url = 'http://' . $url;
|
||||
|
||||
$html = Encoding::toUTF8(get_external_file($url,15));
|
||||
// If get_external_file if not able to retrieve HTTPS content try the same URL with HTTP protocol
|
||||
if (!preg_match('!^https?://!i', $url) && (!isset($html) || strlen($html) <= 0)) {
|
||||
$url = 'http://' . $url;
|
||||
$html = Encoding::toUTF8(get_external_file($url,15));
|
||||
}
|
||||
|
||||
if (function_exists('tidy_parse_string')) {
|
||||
$tidy = tidy_parse_string($html, array(), 'UTF8');
|
||||
$tidy->cleanRepair();
|
||||
$html = $tidy->value;
|
||||
}
|
||||
|
||||
if (isset($html) and strlen($html) > 0)
|
||||
{
|
||||
$r = new Readability($html, $url);
|
||||
|
||||
$r->convertLinksToFootnotes = CONVERT_LINKS_FOOTNOTES;
|
||||
$r->revertForcedParagraphElements = REVERT_FORCED_PARAGRAPH_ELEMENTS;
|
||||
|
||||
if($r->init())
|
||||
{
|
||||
$content = $r->articleContent->innerHTML;
|
||||
@ -117,7 +154,6 @@ function prepare_url($url)
|
||||
}
|
||||
}
|
||||
|
||||
logm('error during url preparation');
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -228,20 +264,41 @@ function remove_directory($directory)
|
||||
|
||||
function display_view($view, $id = 0, $full_head = 'yes')
|
||||
{
|
||||
global $tpl;
|
||||
global $tpl, $store, $msg;
|
||||
|
||||
switch ($view)
|
||||
{
|
||||
case 'export':
|
||||
$entries = $store->retrieveAll();
|
||||
$tpl->assign('export', myTool::renderJson($entries));
|
||||
$tpl->draw('export');
|
||||
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');
|
||||
logm('config view');
|
||||
break;
|
||||
case 'view':
|
||||
$entry = get_article($id);
|
||||
$entry = $store->retrieveOneById($id);
|
||||
|
||||
if ($entry != NULL) {
|
||||
$tpl->assign('id', $entry[0]['id']);
|
||||
$tpl->assign('url', $entry[0]['url']);
|
||||
$tpl->assign('title', $entry[0]['title']);
|
||||
$tpl->assign('content', $entry[0]['content']);
|
||||
$tpl->assign('is_fav', $entry[0]['is_fav']);
|
||||
$tpl->assign('is_read', $entry[0]['is_read']);
|
||||
$tpl->assign('id', $entry['id']);
|
||||
$tpl->assign('url', $entry['url']);
|
||||
$tpl->assign('title', $entry['title']);
|
||||
$content = $entry['content'];
|
||||
if (function_exists('tidy_parse_string')) {
|
||||
$tidy = tidy_parse_string($content, array('indent'=>true, 'show-body-only' => true), 'UTF8');
|
||||
$tidy->cleanRepair();
|
||||
$content = $tidy->value;
|
||||
}
|
||||
$tpl->assign('content', $content);
|
||||
$tpl->assign('is_fav', $entry['is_fav']);
|
||||
$tpl->assign('is_read', $entry['is_read']);
|
||||
$tpl->assign('load_all_js', 0);
|
||||
$tpl->draw('view');
|
||||
}
|
||||
@ -252,7 +309,7 @@ function display_view($view, $id = 0, $full_head = 'yes')
|
||||
logm('view link #' . $id);
|
||||
break;
|
||||
default: # home view
|
||||
$entries = get_entries($view);
|
||||
$entries = $store->getEntriesByView($view);
|
||||
|
||||
$tpl->assign('entries', $entries);
|
||||
|
||||
@ -277,7 +334,7 @@ function display_view($view, $id = 0, $full_head = 'yes')
|
||||
*/
|
||||
function action_to_do($action, $url, $id = 0)
|
||||
{
|
||||
global $db;
|
||||
global $store, $msg;
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
@ -285,140 +342,53 @@ function action_to_do($action, $url, $id = 0)
|
||||
if ($url == '')
|
||||
continue;
|
||||
|
||||
if (MyTool::isUrl($url)) {
|
||||
if($parametres_url = prepare_url($url)) {
|
||||
$sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
|
||||
$params_action = array($url, $parametres_url['title'], $parametres_url['content']);
|
||||
if ($store->add($url, $parametres_url['title'], $parametres_url['content'])) {
|
||||
$last_id = $store->getLastId();
|
||||
if (DOWNLOAD_PICTURES) {
|
||||
$content = filtre_picture($parametres_url['content'], $url, $last_id);
|
||||
}
|
||||
$msg->add('s', 'the link has been added successfully');
|
||||
}
|
||||
else {
|
||||
$msg->add('e', 'error during insertion : the link wasn\'t added');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$msg->add('e', 'error during url preparation : the link wasn\'t added');
|
||||
logm('error during url preparation');
|
||||
}
|
||||
}
|
||||
else {
|
||||
$msg->add('e', 'error during url preparation : the link is not valid');
|
||||
logm($url . ' is not a valid url');
|
||||
}
|
||||
|
||||
logm('add link ' . $url);
|
||||
break;
|
||||
case 'delete':
|
||||
if ($store->deleteById($id)) {
|
||||
remove_directory(ABS_PATH . $id);
|
||||
$sql_action = "DELETE FROM entries WHERE id=?";
|
||||
$params_action = array($id);
|
||||
$msg->add('s', 'the link has been deleted successfully');
|
||||
logm('delete link #' . $id);
|
||||
}
|
||||
else {
|
||||
$msg->add('e', 'the link wasn\'t deleted');
|
||||
logm('error : can\'t delete link #' . $id);
|
||||
}
|
||||
break;
|
||||
case 'toggle_fav' :
|
||||
$sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
|
||||
$params_action = array($id);
|
||||
$store->favoriteById($id);
|
||||
logm('mark as favorite link #' . $id);
|
||||
break;
|
||||
case 'toggle_archive' :
|
||||
$sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?";
|
||||
$params_action = array($id);
|
||||
$store->archiveById($id);
|
||||
logm('archive link #' . $id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
# action query
|
||||
if (isset($sql_action))
|
||||
{
|
||||
$query = $db->getHandle()->prepare($sql_action);
|
||||
$query->execute($params_action);
|
||||
# if we add a link, we have to download pictures
|
||||
if ($action == 'add') {
|
||||
$last_id = $db->getHandle()->lastInsertId();
|
||||
if (DOWNLOAD_PICTURES) {
|
||||
$content = filtre_picture($parametres_url['content'], $url, $last_id);
|
||||
$sql_update = "UPDATE entries SET content=? WHERE id=?";
|
||||
$params_update = array($content, $last_id);
|
||||
$query_update = $db->getHandle()->prepare($sql_update);
|
||||
$query_update->execute($params_update);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
logm('action query error : '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Détermine quels liens afficher : home, fav ou archives
|
||||
*/
|
||||
function get_entries($view)
|
||||
{
|
||||
global $db;
|
||||
|
||||
switch ($_SESSION['sort'])
|
||||
{
|
||||
case 'ia':
|
||||
$order = 'ORDER BY id';
|
||||
break;
|
||||
case 'id':
|
||||
$order = 'ORDER BY id DESC';
|
||||
break;
|
||||
case 'ta':
|
||||
$order = 'ORDER BY lower(title)';
|
||||
break;
|
||||
case 'td':
|
||||
$order = 'ORDER BY lower(title) DESC';
|
||||
break;
|
||||
default:
|
||||
$order = 'ORDER BY id';
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($view)
|
||||
{
|
||||
case 'archive':
|
||||
$sql = "SELECT * FROM entries WHERE is_read=? " . $order;
|
||||
$params = array(-1);
|
||||
break;
|
||||
case 'fav' :
|
||||
$sql = "SELECT * FROM entries WHERE is_fav=? " . $order;
|
||||
$params = array(-1);
|
||||
break;
|
||||
default:
|
||||
$sql = "SELECT * FROM entries WHERE is_read=? " . $order;
|
||||
$params = array(0);
|
||||
break;
|
||||
}
|
||||
|
||||
# view query
|
||||
try
|
||||
{
|
||||
$query = $db->getHandle()->prepare($sql);
|
||||
$query->execute($params);
|
||||
$entries = $query->fetchAll();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
logm('view query error : '.$e->getMessage());
|
||||
}
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère un article en fonction d'un ID
|
||||
*/
|
||||
function get_article($id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$entry = NULL;
|
||||
$sql = "SELECT * FROM entries WHERE id=?";
|
||||
$params = array(intval($id));
|
||||
|
||||
# view article query
|
||||
try
|
||||
{
|
||||
$query = $db->getHandle()->prepare($sql);
|
||||
$query->execute($params);
|
||||
$entry = $query->fetchAll();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
logm('get article query error : '.$e->getMessage());
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
function logm($message)
|
||||
|
||||
51
inc/store/file.class.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <support@inthepoche.com>
|
||||
* @copyright 2013
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
class File extends Store {
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
}
|
||||
|
||||
public function retrieveOneById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function retrieveOneByURL($url) {
|
||||
|
||||
}
|
||||
|
||||
public function deleteById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function favoriteById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function archiveById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function getEntriesByView($view) {
|
||||
|
||||
}
|
||||
|
||||
public function getLastId() {
|
||||
|
||||
}
|
||||
|
||||
public function updateContentById($id) {
|
||||
|
||||
}
|
||||
}
|
||||
202
inc/store/sqlite.class.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <support@inthepoche.com>
|
||||
* @copyright 2013
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
class Sqlite extends Store {
|
||||
|
||||
public static $db_path = 'sqlite:./db/poche.sqlite';
|
||||
var $handle;
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->handle = new PDO(self::$db_path);
|
||||
$this->handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
private function getHandle() {
|
||||
return $this->handle;
|
||||
}
|
||||
|
||||
public function isInstalled() {
|
||||
$sql = "SELECT name FROM sqlite_sequence WHERE name=?";
|
||||
$query = $this->executeQuery($sql, array('config'));
|
||||
$hasConfig = $query->fetchAll();
|
||||
|
||||
if (count($hasConfig) == 0)
|
||||
return FALSE;
|
||||
|
||||
if (!$this->getLogin() || !$this->getPassword())
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function install($login, $password) {
|
||||
$this->getHandle()->exec('CREATE TABLE IF NOT EXISTS "config" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "name" VARCHAR UNIQUE, "value" BLOB)');
|
||||
|
||||
$this->handle->exec('CREATE TABLE IF NOT EXISTS "entries" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , "title" VARCHAR, "url" VARCHAR UNIQUE , "is_read" INTEGER DEFAULT 0, "is_fav" INTEGER DEFAULT 0, "content" BLOB)');
|
||||
|
||||
if (!$this->getLogin()) {
|
||||
$sql_login = 'INSERT INTO config ( name, value ) VALUES (?, ?)';
|
||||
$params_login = array('login', $login);
|
||||
$query = $this->executeQuery($sql_login, $params_login);
|
||||
}
|
||||
|
||||
if (!$this->getPassword()) {
|
||||
$sql_pass = 'INSERT INTO config ( name, value ) VALUES (?, ?)';
|
||||
$params_pass = array('password', $password);
|
||||
$query = $this->executeQuery($sql_pass, $params_pass);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function getLogin() {
|
||||
$sql = "SELECT value FROM config WHERE name=?";
|
||||
$query = $this->executeQuery($sql, array('login'));
|
||||
$login = $query->fetchAll();
|
||||
|
||||
return isset($login[0]['value']) ? $login[0]['value'] : FALSE;
|
||||
}
|
||||
|
||||
public function getPassword() {
|
||||
$sql = "SELECT value FROM config WHERE name=?";
|
||||
$query = $this->executeQuery($sql, array('password'));
|
||||
$pass = $query->fetchAll();
|
||||
|
||||
return isset($pass[0]['value']) ? $pass[0]['value'] : FALSE;
|
||||
}
|
||||
|
||||
public function updatePassword($password)
|
||||
{
|
||||
$sql_update = "UPDATE config SET value=? WHERE name='password'";
|
||||
$params_update = array($password);
|
||||
$query = $this->executeQuery($sql_update, $params_update);
|
||||
}
|
||||
|
||||
private function executeQuery($sql, $params) {
|
||||
try
|
||||
{
|
||||
$query = $this->getHandle()->prepare($sql);
|
||||
$query->execute($params);
|
||||
return $query;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
logm('execute query error : '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function retrieveAll() {
|
||||
$sql = "SELECT * FROM entries ORDER BY id";
|
||||
$query = $this->executeQuery($sql, array());
|
||||
$entries = $query->fetchAll();
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function retrieveOneById($id) {
|
||||
parent::__construct();
|
||||
|
||||
$entry = NULL;
|
||||
$sql = "SELECT * FROM entries WHERE id=?";
|
||||
$params = array(intval($id));
|
||||
$query = $this->executeQuery($sql, $params);
|
||||
$entry = $query->fetchAll();
|
||||
|
||||
return $entry[0];
|
||||
}
|
||||
|
||||
public function getEntriesByView($view) {
|
||||
parent::__construct();
|
||||
|
||||
switch ($_SESSION['sort'])
|
||||
{
|
||||
case 'ia':
|
||||
$order = 'ORDER BY id';
|
||||
break;
|
||||
case 'id':
|
||||
$order = 'ORDER BY id DESC';
|
||||
break;
|
||||
case 'ta':
|
||||
$order = 'ORDER BY lower(title)';
|
||||
break;
|
||||
case 'td':
|
||||
$order = 'ORDER BY lower(title) DESC';
|
||||
break;
|
||||
default:
|
||||
$order = 'ORDER BY id';
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($view)
|
||||
{
|
||||
case 'archive':
|
||||
$sql = "SELECT * FROM entries WHERE is_read=? " . $order;
|
||||
$params = array(-1);
|
||||
break;
|
||||
case 'fav' :
|
||||
$sql = "SELECT * FROM entries WHERE is_fav=? " . $order;
|
||||
$params = array(-1);
|
||||
break;
|
||||
default:
|
||||
$sql = "SELECT * FROM entries WHERE is_read=? " . $order;
|
||||
$params = array(0);
|
||||
break;
|
||||
}
|
||||
|
||||
$query = $this->executeQuery($sql, $params);
|
||||
$entries = $query->fetchAll();
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
public function add($url, $title, $content) {
|
||||
parent::__construct();
|
||||
$sql_action = 'INSERT INTO entries ( url, title, content ) VALUES (?, ?, ?)';
|
||||
$params_action = array($url, $title, $content);
|
||||
$query = $this->executeQuery($sql_action, $params_action);
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function deleteById($id) {
|
||||
parent::__construct();
|
||||
$sql_action = "DELETE FROM entries WHERE id=?";
|
||||
$params_action = array($id);
|
||||
$query = $this->executeQuery($sql_action, $params_action);
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function favoriteById($id) {
|
||||
parent::__construct();
|
||||
$sql_action = "UPDATE entries SET is_fav=~is_fav WHERE id=?";
|
||||
$params_action = array($id);
|
||||
$query = $this->executeQuery($sql_action, $params_action);
|
||||
}
|
||||
|
||||
public function archiveById($id) {
|
||||
parent::__construct();
|
||||
$sql_action = "UPDATE entries SET is_read=~is_read WHERE id=?";
|
||||
$params_action = array($id);
|
||||
$query = $this->executeQuery($sql_action, $params_action);
|
||||
}
|
||||
|
||||
public function getLastId() {
|
||||
parent::__construct();
|
||||
return $this->getHandle()->lastInsertId();
|
||||
}
|
||||
|
||||
public function updateContentById($id) {
|
||||
parent::__construct();
|
||||
$sql_update = "UPDATE entries SET content=? WHERE id=?";
|
||||
$params_update = array($content, $id);
|
||||
$query = $this->executeQuery($sql_update, $params_update);
|
||||
}
|
||||
}
|
||||
63
inc/store/store.class.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* poche, a read it later open source system
|
||||
*
|
||||
* @category poche
|
||||
* @author Nicolas Lœuillet <support@inthepoche.com>
|
||||
* @copyright 2013
|
||||
* @license http://www.wtfpl.net/ see COPYING file
|
||||
*/
|
||||
|
||||
class Store {
|
||||
function __construct() {
|
||||
|
||||
}
|
||||
|
||||
public function getLogin() {
|
||||
|
||||
}
|
||||
|
||||
public function getPassword() {
|
||||
|
||||
}
|
||||
|
||||
public function add() {
|
||||
|
||||
}
|
||||
|
||||
public function retrieveAll() {
|
||||
|
||||
}
|
||||
|
||||
public function retrieveOneById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function retrieveOneByURL($url) {
|
||||
|
||||
}
|
||||
|
||||
public function deleteById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function favoriteById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function archiveById($id) {
|
||||
|
||||
}
|
||||
|
||||
public function getEntriesByView($view) {
|
||||
|
||||
}
|
||||
|
||||
public function getLastId() {
|
||||
|
||||
}
|
||||
|
||||
public function updateContentById($id) {
|
||||
|
||||
}
|
||||
}
|
||||
30
index.php
@ -10,8 +10,8 @@
|
||||
|
||||
include dirname(__FILE__).'/inc/config.php';
|
||||
|
||||
# initialize session
|
||||
Session::init();
|
||||
myTool::initPhp();
|
||||
|
||||
# XSRF protection with token
|
||||
if (!empty($_POST)) {
|
||||
if (!Session::isToken($_POST['token'])) {
|
||||
@ -20,11 +20,14 @@ if (!empty($_POST)) {
|
||||
unset($_SESSION['tokens']);
|
||||
}
|
||||
|
||||
$ref = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
||||
|
||||
if (isset($_GET['login'])) {
|
||||
// Login
|
||||
if (!empty($_POST['login']) && !empty($_POST['password'])) {
|
||||
if (Session::login('poche', 'poche', $_POST['login'], $_POST['password'])) {
|
||||
if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) {
|
||||
logm('login successful');
|
||||
$msg->add('s', 'welcome in your poche!');
|
||||
if (!empty($_POST['longlastingsession'])) {
|
||||
$_SESSION['longlastingsession'] = 31536000;
|
||||
$_SESSION['expires_on'] = time() + $_SESSION['longlastingsession'];
|
||||
@ -34,7 +37,7 @@ if (isset($_GET['login'])) {
|
||||
}
|
||||
session_regenerate_id(true);
|
||||
|
||||
MyTool::redirect();
|
||||
MyTool::redirect($ref);
|
||||
}
|
||||
logm('login failed');
|
||||
die("Login failed !");
|
||||
@ -47,6 +50,22 @@ elseif (isset($_GET['logout'])) {
|
||||
Session::logout();
|
||||
MyTool::redirect();
|
||||
}
|
||||
elseif (isset($_GET['config'])) {
|
||||
if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
|
||||
if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
|
||||
logm('password updated');
|
||||
if (!DEMO) {
|
||||
$store->updatePassword(encode_string($_POST['password'] . $_SESSION['login']));
|
||||
$msg->add('s', 'your password has been updated');
|
||||
}
|
||||
else {
|
||||
$msg->add('i', 'in demo mode, you can\'t update password');
|
||||
}
|
||||
}
|
||||
else
|
||||
$msg->add('e', 'your password can\'t be empty and you have to repeat it in the second field');
|
||||
}
|
||||
}
|
||||
|
||||
# Traitement des paramètres et déclenchement des actions
|
||||
$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'index';
|
||||
@ -55,12 +74,11 @@ $action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['ac
|
||||
$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
|
||||
$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
|
||||
$url = (isset ($_GET['url'])) ? $_GET['url'] : '';
|
||||
$ref = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
||||
|
||||
$tpl->assign('isLogged', Session::isLogged());
|
||||
$tpl->assign('referer', $ref);
|
||||
$tpl->assign('view', $view);
|
||||
$tpl->assign('poche_url', get_poche_url());
|
||||
$tpl->assign('poche_url', myTool::getUrl());
|
||||
$tpl->assign('title', 'poche, a read it later open source system');
|
||||
|
||||
if (Session::isLogged()) {
|
||||
|
||||
29
js/poche.js
@ -23,8 +23,35 @@ function toggle_archive(element, id, view_article) {
|
||||
}
|
||||
|
||||
function sort_links(view, sort) {
|
||||
//$('#content').load('index.php', { view: view, sort: sort, full_head: 'no' } );
|
||||
$.get('index.php', { view: view, sort: sort, full_head: 'no' }, 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;
|
||||
});
|
||||
|
||||
27
tpl/config.html
Normal file
@ -0,0 +1,27 @@
|
||||
<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>
|
||||
<p>Drag & drop this link to your bookmarks bar and have fun with poche.</p>
|
||||
<p><a style="cursor: move; border: 1px dashed grey; background: white;" title="i am a bookmarklet, use me !" href="javascript:(function(){var%20url%20=%20location.href%20||%20url;window.open('{$poche_url}?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></p>
|
||||
|
||||
<h2>Password</h2>
|
||||
<form method="post" action="?config" name="loginform">
|
||||
<fieldset class="w500p">
|
||||
<div class="row">
|
||||
<label class="col w150p" for="password">New password</label>
|
||||
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col w150p" for="password_repeat">Repeat your new password</label>
|
||||
<input class="col" type="password" id="password_repeat" name="password_repeat" placeholder="Password" tabindex="3">
|
||||
</div>
|
||||
<div class="row mts txtcenter">
|
||||
<button class="bouton" type="submit" tabindex="4">Update</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="hidden" name="returnurl" value="<?php echo htmlspecialchars($referer);?>">
|
||||
<input type="hidden" name="token" value="<?php echo Session::getToken(); ?>">
|
||||
</form>
|
||||
<h2>Export</h2>
|
||||
<p><a href="?view=export" target="_blank">Click here</a> to export your poche datas.</p>
|
||||
</div>
|
||||
@ -1,3 +1,4 @@
|
||||
<div id="content">
|
||||
{loop="entries"}
|
||||
<div id="entry-{$value.id}" class="entrie mb2">
|
||||
<span class="content">
|
||||
@ -14,3 +15,4 @@
|
||||
</span>
|
||||
</div>
|
||||
{/loop}
|
||||
</div>
|
||||
1
tpl/export.html
Normal file
@ -0,0 +1 @@
|
||||
export {$export}
|
||||
@ -1,6 +1,4 @@
|
||||
</div>
|
||||
</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>
|
||||
|
||||
@ -15,9 +15,8 @@
|
||||
<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">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1><img src="./img/logo.png" alt="logo poche" />poche</h1>
|
||||
</header>
|
||||
<div id="main">
|
||||
@ -1,12 +1,19 @@
|
||||
<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">
|
||||
<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 style="cursor: move" title="i am a bookmarklet, use me !" href="javascript:(function(){var%20url%20=%20location.href%20||%20url;window.open('{$poche_url}?action=add&url='%20+%20encodeURIComponent(url),'_self');})();">poche it !</a></li>
|
||||
<li><a href="?view=config" {if="$view == 'config'"}class="current"{/if}>config</a></li>
|
||||
<li><a href="?logout" title="Logout">logout</a></li>
|
||||
</ul>
|
||||
{if condition="isset($entries)"}
|
||||
<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>
|
||||
</ul>
|
||||
<div id="content">
|
||||
{/if}
|
||||
{include="messages"}
|
||||
30
tpl/install.html
Normal file
@ -0,0 +1,30 @@
|
||||
{include="head"}
|
||||
<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">
|
||||
<form method="post" action="?install" name="loginform">
|
||||
<fieldset class="w500p center">
|
||||
<h2 class="mbs txtcenter">install your poche</h2>
|
||||
<div class="row">
|
||||
<label class="col w150p" for="login">Login</label>
|
||||
<input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col w150p" for="password">Password</label>
|
||||
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col w150p" for="password_repeat">Repeat your password</label>
|
||||
<input class="col" type="password" id="password_repeat" name="password_repeat" placeholder="Password" tabindex="3">
|
||||
</div>
|
||||
<div class="row mts txtcenter">
|
||||
<button class="bouton" type="submit" tabindex="4">Install</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="hidden" name="returnurl" value="<?php echo htmlspecialchars($referer);?>">
|
||||
<input type="hidden" name="token" value="<?php echo Session::getToken(); ?>">
|
||||
</form>
|
||||
|
||||
{include="footer"}
|
||||
@ -1,23 +1,33 @@
|
||||
{include="head"}
|
||||
<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">
|
||||
<form method="post" action="?login" name="loginform">
|
||||
<fieldset>
|
||||
<h2>login to your poche</h2>
|
||||
<ul id="login">
|
||||
<li>
|
||||
<label for="login">Login</label> <input type="text" id="login" name="login" placeholder="Login" tabindex="1">
|
||||
</li>
|
||||
<li>
|
||||
<label for="password">Password</label> <input type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
||||
</li>
|
||||
<li>
|
||||
<label><input type="checkbox" name="longlastingsession" tabindex="3"> Stay signed in (Do not check on public computers)</label>
|
||||
</li>
|
||||
<li>
|
||||
<button type="submit" tabindex="4">Sign in</button>
|
||||
</li>
|
||||
</ul>
|
||||
<fieldset class="w500p center">
|
||||
<h2 class="mbs txtcenter">login to your poche</h2>
|
||||
<div class="row">
|
||||
<label class="col w150p" for="login">Login</label>
|
||||
<input class="col" type="text" id="login" name="login" placeholder="Login" tabindex="1" autofocus />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col w150p" for="password">Password</label>
|
||||
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col w150p">Stay signed in</label>
|
||||
<div class="col">
|
||||
<input type="checkbox" name="longlastingsession" tabindex="3">
|
||||
<small class="inbl">(Do not check on public computers)</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mts txtcenter">
|
||||
<button class="bouton" type="submit" tabindex="4">Sign in</button>
|
||||
</div>
|
||||
</fieldset>
|
||||
<input type="hidden" name="returnurl" value="<?php echo htmlspecialchars($referer);?>">
|
||||
<input type="hidden" name="token" value="<?php echo Session::getToken(); ?>">
|
||||
</form>
|
||||
|
||||
{include="footer"}
|
||||
1
tpl/messages.html
Normal file
@ -0,0 +1 @@
|
||||
<div id="messages"><?php echo $msg->display(); ?></div>
|
||||
@ -15,8 +15,12 @@
|
||||
<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">
|
||||
</head>
|
||||
<body class="article">
|
||||
<body class="article light-style">
|
||||
<div id="article" class="w600p">
|
||||
<div class="backhome">
|
||||
<a href="index.php" title="back to home">←</a>
|
||||
@ -24,6 +28,7 @@
|
||||
<div class="tools">
|
||||
<ul>
|
||||
<li><a title="toggle mark as read" class="tool archive {if="$is_read == '0'"}archive-off{/if}" onclick="toggle_archive(this, {$id})"><span></span></a></li>
|
||||
<li><a href="#" id="themeswitch">dark</a></li>
|
||||
<li><a title="toggle favorite" class="tool fav {if="$is_fav == '0'"}fav-off{/if}" onclick="toggle_favorite(this, {$id})"><span></span></a></li>
|
||||
<li><form method="post" onsubmit="return confirm('Are you sure?')" style="display: inline;" action="index.php"><input type="hidden" name="token" id="token" value="<?php echo Session::getToken(); ?>" /><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="{$id}" /><input type="submit" class="delete" title="toggle delete" /></form></li>
|
||||
<li><a href="?logout" title="Logout">logout</a></li>
|
||||
@ -33,6 +38,7 @@
|
||||
<h1><a href="{$url}">{$title}</a></h1>
|
||||
<div class="vieworiginal txtright small"><a href="{$url}" target="_blank" title="original : {$title}">view original</a></div>
|
||||
</header>
|
||||
{include="messages"}
|
||||
<article>
|
||||
<div id="readityourselfcontent">
|
||||
{$content}
|
||||
@ -42,13 +48,6 @@
|
||||
<div class="backhome">
|
||||
<a href="index.php" title="back to home">←</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{include="js"}
|
||||
|
||||
<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>
|
||||
{include="footer"}
|
||||