# 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)
[![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 :
}
```
-## 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.
\ No newline at end of file
$this->store->archiveById($id);
Tools::logm('archive link #' . $id);
break;
- case 'import':
- break;
default:
break;
}
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;
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 <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();
+ # 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;
}
- else if ($from == 'readability') {
- # TODO finaliser tout ça ici
- $str_data = file_get_contents("readability");
- $data = json_decode($str_data,true);
+ Tools::logm('import from pocket completed');
+ Tools::redirect();
+ }
- foreach ($data as $key => $value) {
- $url = '';
- foreach ($value as $key2 => $value2) {
- if ($key2 == 'article__url') {
- $url = new Url($value2);
- }
+ 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 != '')
- action_to_do('add', $url);
}
- logm('import from Readability completed');
- Tools::redirect();
+ if ($url->isCorrect())
+ $this->action('add', $url);
}
+ Tools::logm('import from Readability completed');
+ Tools::redirect();
}
- public function export()
+ public function import($from)
{
+ if ($from == 'pocket') {
+ $this->importFromPocket();
+ }
+ else if ($from == 'readability') {
+ $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');
}
}
\ No newline at end of file
{
return sha1($string . SALT);
}
+
+ public static function checkVar($var)
+ {
+ return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : '');
+ }
}
\ No newline at end of file
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
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,
$tpl_file = 'login.twig';
}
+# Aaaaaaand action !
echo $poche->tpl->render($tpl_file, $tpl_vars);
\ No newline at end of file
<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>
\ No newline at end of file
<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 %}
\ No newline at end of file
-export {$export}
\ No newline at end of file
+{{ export }}
\ No newline at end of file
}
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);
});
}
<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>