mirror of
https://github.com/moparisthebest/wallabag
synced 2024-12-23 15:58:55 -05:00
twig implementation
This commit is contained in:
parent
c765c3679f
commit
63c35580c7
33
README.md
33
README.md
@ -1,5 +1,5 @@
|
||||
# poche
|
||||
Abandon Pocket, Instapaper and other Readability service : adopt poche. It is the same, but it is open source.
|
||||
Abandon Pocket, Instapaper and other Readability service : adopt poche. It is the same, but it is open source. Moreover, you can migrate from Pocket & Readability.
|
||||
|
||||
![poche](http://inthepoche.com/img/logo.png)
|
||||
|
||||
@ -11,23 +11,23 @@ To get news from poche, [follow us on twitter](http://twitter.com/getpoche) or [
|
||||
|
||||
[![flattr](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/1265480/poche-a-read-it-later-open-source-system)
|
||||
|
||||
## Usage
|
||||
You can easily add a "poched" page with the bookmarklet.
|
||||
|
||||
poche save the entire content of a poched links : text and pictures are stored on your server.
|
||||
|
||||
You can :
|
||||
* read a page in a comfortable reading view
|
||||
* archive a link
|
||||
* put a link in favorite
|
||||
* delete a link
|
||||
|
||||
## Requirements & installation
|
||||
You have to install [sqlite for php](http://www.php.net/manual/en/book.sqlite.php) on your server.
|
||||
|
||||
[PHP cURL](http://www.php.net/manual/en/book.curl.php) & [tidy_parse_string](http://www.php.net/manual/en/tidy.parsestring.php) are recommended.
|
||||
|
||||
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** !
|
||||
Install composer in your project :
|
||||
```bash
|
||||
curl -s http://getcomposer.org/installer | php
|
||||
```
|
||||
Install via composer :
|
||||
```bash
|
||||
php composer.phar install
|
||||
```
|
||||
|
||||
That's all, you can use poche !
|
||||
|
||||
## Security
|
||||
You **have** to protect your db/poche.sqlite file. Modify the virtual host of your website to add this condition :
|
||||
@ -46,12 +46,11 @@ location ~ /(db) {
|
||||
}
|
||||
```
|
||||
|
||||
## Import from Pocket
|
||||
|
||||
If you want to import your Pocket datas, [export them here](https://getpocket.com/export). Put the HTML file in your poche directory, execute import.php file locally by following instructions. Be careful, the script can take a very long time.
|
||||
## Usage
|
||||
See the documentation on our website : [inthepoche.com](http://inthepoche.com).
|
||||
|
||||
## License
|
||||
Copyright © 2010-2013 Nicolas Lœuillet <nicolas@loeuillet.org>
|
||||
This work is free. You can redistribute it and/or modify it under the
|
||||
terms of the Do What The Fuck You Want To Public License, Version 2,
|
||||
as published by Sam Hocevar. See the COPYING file for more details.
|
||||
as published by Sam Hocevar. See the COPYING file for more details.
|
@ -118,8 +118,6 @@ class Poche
|
||||
$this->store->archiveById($id);
|
||||
Tools::logm('archive link #' . $id);
|
||||
break;
|
||||
case 'import':
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -131,18 +129,6 @@ class Poche
|
||||
|
||||
switch ($view)
|
||||
{
|
||||
case 'install':
|
||||
Tools::logm('install mode');
|
||||
break;
|
||||
case 'import';
|
||||
Tools::logm('import mode');
|
||||
break;
|
||||
case 'export':
|
||||
$entries = $this->store->retrieveAll();
|
||||
// $tpl->assign('export', Tools::renderJson($entries));
|
||||
// $tpl->draw('export');
|
||||
Tools::logm('export view');
|
||||
break;
|
||||
case 'config':
|
||||
Tools::logm('config view');
|
||||
break;
|
||||
@ -224,59 +210,80 @@ class Poche
|
||||
Tools::redirect();
|
||||
}
|
||||
|
||||
private function importFromInstapaper()
|
||||
{
|
||||
Tools::logm('import from instapaper completed');
|
||||
Tools::redirect();
|
||||
}
|
||||
|
||||
private function importFromPocket()
|
||||
{
|
||||
$html = new simple_html_dom();
|
||||
$html->load_file('./ril_export.html');
|
||||
|
||||
$read = 0;
|
||||
$errors = array();
|
||||
foreach($html->find('ul') as $ul)
|
||||
{
|
||||
foreach($ul->find('li') as $li)
|
||||
{
|
||||
$a = $li->find('a');
|
||||
$url = new Url(base64_encode($a[0]->href));
|
||||
$this->action('add', $url);
|
||||
if ($read == '1') {
|
||||
$last_id = $this->store->getLastId();
|
||||
$this->store->archiveById($last_id);
|
||||
}
|
||||
}
|
||||
# Pocket génère un fichier HTML avec deux <ul>
|
||||
# Le premier concerne les éléments non lus
|
||||
# Le second concerne les éléments archivés
|
||||
$read = 1;
|
||||
}
|
||||
Tools::logm('import from pocket completed');
|
||||
Tools::redirect();
|
||||
}
|
||||
|
||||
private function importFromReadability()
|
||||
{
|
||||
# TODO finaliser tout ça ici
|
||||
# noms des variables + gestion des articles lus
|
||||
$str_data = file_get_contents("./readability");
|
||||
$data = json_decode($str_data,true);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$url = '';
|
||||
foreach ($value as $key2 => $value2) {
|
||||
if ($key2 == 'article__url') {
|
||||
$url = new Url(base64_encode($value2));
|
||||
}
|
||||
}
|
||||
if ($url->isCorrect())
|
||||
$this->action('add', $url);
|
||||
}
|
||||
Tools::logm('import from Readability completed');
|
||||
Tools::redirect();
|
||||
}
|
||||
|
||||
public function import($from)
|
||||
{
|
||||
if ($from == 'pocket') {
|
||||
$html = new simple_html_dom();
|
||||
$html->load_file('./ril_export.html');
|
||||
|
||||
$read = 0;
|
||||
$errors = array();
|
||||
foreach($html->find('ul') as $ul)
|
||||
{
|
||||
foreach($ul->find('li') as $li)
|
||||
{
|
||||
$a = $li->find('a');
|
||||
$url = new Url($a[0]->href);
|
||||
$this->action('add', $url);
|
||||
if ($read == '1') {
|
||||
$last_id = $this->store->lastInsertId();
|
||||
$sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?";
|
||||
$params_update = array($last_id);
|
||||
$query_update = $this->store->prepare($sql_update);
|
||||
$query_update->execute($params_update);
|
||||
}
|
||||
}
|
||||
# Pocket génère un fichier HTML avec deux <ul>
|
||||
# Le premier concerne les éléments non lus
|
||||
# Le second concerne les éléments archivés
|
||||
$read = 1;
|
||||
}
|
||||
logm('import from pocket completed');
|
||||
Tools::redirect();
|
||||
$this->importFromPocket();
|
||||
}
|
||||
else if ($from == 'readability') {
|
||||
# TODO finaliser tout ça ici
|
||||
$str_data = file_get_contents("readability");
|
||||
$data = json_decode($str_data,true);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$url = '';
|
||||
foreach ($value as $key2 => $value2) {
|
||||
if ($key2 == 'article__url') {
|
||||
$url = new Url($value2);
|
||||
}
|
||||
}
|
||||
if ($url != '')
|
||||
action_to_do('add', $url);
|
||||
}
|
||||
logm('import from Readability completed');
|
||||
Tools::redirect();
|
||||
$this->importFromReadability();
|
||||
}
|
||||
else if ($from == 'instapaper') {
|
||||
$this->importFromInstapaper();
|
||||
}
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
|
||||
$entries = $this->store->retrieveAll();
|
||||
echo $this->tpl->render('export.twig', array(
|
||||
'export' => Tools::renderJson($entries),
|
||||
));
|
||||
Tools::logm('export view');
|
||||
}
|
||||
}
|
@ -205,4 +205,9 @@ class Tools
|
||||
{
|
||||
return sha1($string . SALT);
|
||||
}
|
||||
|
||||
public static function checkVar($var)
|
||||
{
|
||||
return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : '');
|
||||
}
|
||||
}
|
34
index.php
34
index.php
@ -10,16 +10,21 @@
|
||||
|
||||
include dirname(__FILE__).'/inc/poche/config.inc.php';
|
||||
|
||||
# XSRF protection with token
|
||||
// if (!empty($_POST)) {
|
||||
// if (!Session::isToken($_POST['token'])) {
|
||||
// die(_('Wrong token'));
|
||||
// // TODO remettre le test
|
||||
// }
|
||||
// unset($_SESSION['tokens']);
|
||||
// }
|
||||
#XSRF protection with token
|
||||
if (!empty($_POST)) {
|
||||
if (!Session::isToken($_POST['token'])) {
|
||||
die(_('Wrong token'));
|
||||
// TODO remettre le test
|
||||
}
|
||||
unset($_SESSION['tokens']);
|
||||
}
|
||||
|
||||
$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
||||
$view = Tools::checkVar('view');
|
||||
$action = Tools::checkVar('action');
|
||||
$id = Tools::checkVar('id');
|
||||
$_SESSION['sort'] = Tools::checkVar('sort');
|
||||
$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
|
||||
|
||||
if (isset($_GET['login'])) {
|
||||
# hello you
|
||||
@ -36,15 +41,9 @@ elseif (isset($_GET['config'])) {
|
||||
elseif (isset($_GET['import'])) {
|
||||
$poche->import($_GET['from']);
|
||||
}
|
||||
|
||||
# Aaaaaaand action !
|
||||
$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home';
|
||||
$full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes';
|
||||
$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
|
||||
$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
|
||||
$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
|
||||
|
||||
$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
|
||||
elseif (isset($_GET['export'])) {
|
||||
$poche->export();
|
||||
}
|
||||
|
||||
$tpl_vars = array(
|
||||
'referer' => $referer,
|
||||
@ -64,4 +63,5 @@ else {
|
||||
$tpl_file = 'login.twig';
|
||||
}
|
||||
|
||||
# Aaaaaaand action !
|
||||
echo $poche->tpl->render($tpl_file, $tpl_vars);
|
@ -1,3 +1,3 @@
|
||||
<footer class="mr2 mt3 smaller">
|
||||
<p>powered by <a href="http://inthepoche.com">poche</a></p>
|
||||
<p>{% trans "powered by" %} <a href="http://inthepoche.com">poche</a></p>
|
||||
</footer>
|
@ -40,11 +40,11 @@
|
||||
<p>{% trans "Please execute the import script locally, it can take a very long time." %}</p>
|
||||
<p>{% trans "More infos in the official doc:" %} <a href="http://inthepoche.com/?pages/Documentation">inthepoche.com</a></p>
|
||||
<p><ul>
|
||||
<li><a href="/?import&from=pocket">{% trans "import from Pocket" %}</a> (you must have a "ril_export.html" file on your server)</li>
|
||||
<li><a href="/?import&from=readability">{% trans "import from Readability" %}</a> (you must have a "readability" file on your server)</li>
|
||||
<li><a href="./?import&from=pocket">{% trans "import from Pocket" %}</a> (you must have a "ril_export.html" file on your server)</li>
|
||||
<li><a href="./?import&from=readability">{% trans "import from Readability" %}</a> (you must have a "readability" file on your server)</li>
|
||||
</ul></p>
|
||||
|
||||
<h2>{% trans "Export your poche datas" %}</h2>
|
||||
<p><a href="?view=export" target="_blank">{% trans "Click here" %}</a> {% trans "to export your poche datas." %}</p>
|
||||
<p><a href="./?export" target="_blank">{% trans "Click here" %}</a> {% trans "to export your poche datas." %}</p>
|
||||
</div>
|
||||
{% endblock %}
|
@ -1 +1 @@
|
||||
export {$export}
|
||||
{{ export }}
|
@ -23,7 +23,7 @@ function toggle_archive(element, id, view_article) {
|
||||
}
|
||||
|
||||
function sort_links(view, sort) {
|
||||
$.get('index.php', { view: view, sort: sort, full_head: 'no' }, function(data) {
|
||||
$.get('index.php', { view: view, sort: sort }, function(data) {
|
||||
$('#content').html(data);
|
||||
});
|
||||
}
|
||||
|
@ -16,9 +16,9 @@
|
||||
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2" {% if demo == 1 %}value="poche"{% endif %} />
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col w150p">{% trans "Stay signed in" %}</label>
|
||||
<label class="col w150p" for="longlastingsession">{% trans "Stay signed in" %}</label>
|
||||
<div class="col">
|
||||
<input type="checkbox" name="longlastingsession" tabindex="3">
|
||||
<input type="checkbox" id="longlastingsession" name="longlastingsession" tabindex="3">
|
||||
<small class="inbl">{% trans "(Do not check on public computers)" %}</small>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user