From 63c35580c7d60e2278ee6fe9ba2d4440ff0308d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Sun, 4 Aug 2013 22:35:08 +0200 Subject: [PATCH] twig implementation --- README.md | 33 ++++++----- inc/poche/Poche.class.php | 115 ++++++++++++++++++++------------------ inc/poche/Tools.class.php | 5 ++ index.php | 34 +++++------ tpl/_footer.twig | 2 +- tpl/config.twig | 6 +- tpl/export.twig | 2 +- tpl/js/poche.js | 2 +- tpl/login.twig | 4 +- 9 files changed, 107 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index b44e7d36..09f48b17 100644 --- a/README.md +++ b/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 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. \ No newline at end of file diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 9e407d41..5c3eda80 100644 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -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(); } - public function import($from) + private function importFromInstapaper() { - if ($from == 'pocket') { - $html = new simple_html_dom(); - $html->load_file('./ril_export.html'); + Tools::logm('import from instapaper completed'); + Tools::redirect(); + } - $read = 0; - $errors = array(); - foreach($html->find('ul') as $ul) + 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) { - 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); - } + $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