mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-23 17:42:15 -05:00
twig implementation
This commit is contained in:
parent
c765c3679f
commit
63c35580c7
31
README.md
31
README.md
@ -1,5 +1,5 @@
|
|||||||
# poche
|
# 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)
|
![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)
|
[![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
|
## Requirements & installation
|
||||||
You have to install [sqlite for php](http://www.php.net/manual/en/book.sqlite.php) on your server.
|
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.
|
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
|
## Security
|
||||||
You **have** to protect your db/poche.sqlite file. Modify the virtual host of your website to add this condition :
|
You **have** to protect your db/poche.sqlite file. Modify the virtual host of your website to add this condition :
|
||||||
@ -46,9 +46,8 @@ location ~ /(db) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Import from Pocket
|
## Usage
|
||||||
|
See the documentation on our website : [inthepoche.com](http://inthepoche.com).
|
||||||
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.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
Copyright © 2010-2013 Nicolas Lœuillet <nicolas@loeuillet.org>
|
Copyright © 2010-2013 Nicolas Lœuillet <nicolas@loeuillet.org>
|
||||||
|
@ -118,8 +118,6 @@ class Poche
|
|||||||
$this->store->archiveById($id);
|
$this->store->archiveById($id);
|
||||||
Tools::logm('archive link #' . $id);
|
Tools::logm('archive link #' . $id);
|
||||||
break;
|
break;
|
||||||
case 'import':
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -131,18 +129,6 @@ class Poche
|
|||||||
|
|
||||||
switch ($view)
|
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':
|
case 'config':
|
||||||
Tools::logm('config view');
|
Tools::logm('config view');
|
||||||
break;
|
break;
|
||||||
@ -224,9 +210,14 @@ class Poche
|
|||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function import($from)
|
private function importFromInstapaper()
|
||||||
|
{
|
||||||
|
Tools::logm('import from instapaper completed');
|
||||||
|
Tools::redirect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function importFromPocket()
|
||||||
{
|
{
|
||||||
if ($from == 'pocket') {
|
|
||||||
$html = new simple_html_dom();
|
$html = new simple_html_dom();
|
||||||
$html->load_file('./ril_export.html');
|
$html->load_file('./ril_export.html');
|
||||||
|
|
||||||
@ -237,14 +228,11 @@ class Poche
|
|||||||
foreach($ul->find('li') as $li)
|
foreach($ul->find('li') as $li)
|
||||||
{
|
{
|
||||||
$a = $li->find('a');
|
$a = $li->find('a');
|
||||||
$url = new Url($a[0]->href);
|
$url = new Url(base64_encode($a[0]->href));
|
||||||
$this->action('add', $url);
|
$this->action('add', $url);
|
||||||
if ($read == '1') {
|
if ($read == '1') {
|
||||||
$last_id = $this->store->lastInsertId();
|
$last_id = $this->store->getLastId();
|
||||||
$sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?";
|
$this->store->archiveById($last_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>
|
# Pocket génère un fichier HTML avec deux <ul>
|
||||||
@ -252,31 +240,50 @@ class Poche
|
|||||||
# Le second concerne les éléments archivés
|
# Le second concerne les éléments archivés
|
||||||
$read = 1;
|
$read = 1;
|
||||||
}
|
}
|
||||||
logm('import from pocket completed');
|
Tools::logm('import from pocket completed');
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
}
|
}
|
||||||
else if ($from == 'readability') {
|
|
||||||
|
private function importFromReadability()
|
||||||
|
{
|
||||||
# TODO finaliser tout ça ici
|
# TODO finaliser tout ça ici
|
||||||
$str_data = file_get_contents("readability");
|
# noms des variables + gestion des articles lus
|
||||||
|
$str_data = file_get_contents("./readability");
|
||||||
$data = json_decode($str_data,true);
|
$data = json_decode($str_data,true);
|
||||||
|
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
$url = '';
|
$url = '';
|
||||||
foreach ($value as $key2 => $value2) {
|
foreach ($value as $key2 => $value2) {
|
||||||
if ($key2 == 'article__url') {
|
if ($key2 == 'article__url') {
|
||||||
$url = new Url($value2);
|
$url = new Url(base64_encode($value2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($url != '')
|
if ($url->isCorrect())
|
||||||
action_to_do('add', $url);
|
$this->action('add', $url);
|
||||||
}
|
}
|
||||||
logm('import from Readability completed');
|
Tools::logm('import from Readability completed');
|
||||||
Tools::redirect();
|
Tools::redirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function import($from)
|
||||||
|
{
|
||||||
|
if ($from == 'pocket') {
|
||||||
|
$this->importFromPocket();
|
||||||
|
}
|
||||||
|
else if ($from == 'readability') {
|
||||||
|
$this->importFromReadability();
|
||||||
|
}
|
||||||
|
else if ($from == 'instapaper') {
|
||||||
|
$this->importFromInstapaper();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function export()
|
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);
|
return sha1($string . SALT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function checkVar($var)
|
||||||
|
{
|
||||||
|
return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : '');
|
||||||
|
}
|
||||||
}
|
}
|
32
index.php
32
index.php
@ -11,15 +11,20 @@
|
|||||||
include dirname(__FILE__).'/inc/poche/config.inc.php';
|
include dirname(__FILE__).'/inc/poche/config.inc.php';
|
||||||
|
|
||||||
#XSRF protection with token
|
#XSRF protection with token
|
||||||
// if (!empty($_POST)) {
|
if (!empty($_POST)) {
|
||||||
// if (!Session::isToken($_POST['token'])) {
|
if (!Session::isToken($_POST['token'])) {
|
||||||
// die(_('Wrong token'));
|
die(_('Wrong token'));
|
||||||
// // TODO remettre le test
|
// TODO remettre le test
|
||||||
// }
|
}
|
||||||
// unset($_SESSION['tokens']);
|
unset($_SESSION['tokens']);
|
||||||
// }
|
}
|
||||||
|
|
||||||
$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
|
$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'])) {
|
if (isset($_GET['login'])) {
|
||||||
# hello you
|
# hello you
|
||||||
@ -36,15 +41,9 @@ elseif (isset($_GET['config'])) {
|
|||||||
elseif (isset($_GET['import'])) {
|
elseif (isset($_GET['import'])) {
|
||||||
$poche->import($_GET['from']);
|
$poche->import($_GET['from']);
|
||||||
}
|
}
|
||||||
|
elseif (isset($_GET['export'])) {
|
||||||
# Aaaaaaand action !
|
$poche->export();
|
||||||
$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'] : '');
|
|
||||||
|
|
||||||
$tpl_vars = array(
|
$tpl_vars = array(
|
||||||
'referer' => $referer,
|
'referer' => $referer,
|
||||||
@ -64,4 +63,5 @@ else {
|
|||||||
$tpl_file = 'login.twig';
|
$tpl_file = 'login.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Aaaaaaand action !
|
||||||
echo $poche->tpl->render($tpl_file, $tpl_vars);
|
echo $poche->tpl->render($tpl_file, $tpl_vars);
|
@ -1,3 +1,3 @@
|
|||||||
<footer class="mr2 mt3 smaller">
|
<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>
|
</footer>
|
@ -40,11 +40,11 @@
|
|||||||
<p>{% trans "Please execute the import script locally, it can take a very long time." %}</p>
|
<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>{% trans "More infos in the official doc:" %} <a href="http://inthepoche.com/?pages/Documentation">inthepoche.com</a></p>
|
||||||
<p><ul>
|
<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=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=readability">{% trans "import from Readability" %}</a> (you must have a "readability" file on your server)</li>
|
||||||
</ul></p>
|
</ul></p>
|
||||||
|
|
||||||
<h2>{% trans "Export your poche datas" %}</h2>
|
<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>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -1 +1 @@
|
|||||||
export {$export}
|
{{ export }}
|
@ -23,7 +23,7 @@ function toggle_archive(element, id, view_article) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sort_links(view, sort) {
|
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);
|
$('#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 %} />
|
<input class="col" type="password" id="password" name="password" placeholder="Password" tabindex="2" {% if demo == 1 %}value="poche"{% endif %} />
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<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">
|
<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>
|
<small class="inbl">{% trans "(Do not check on public computers)" %}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user