1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-11-27 11:22:17 -05:00

Merge pull request #132 from inthepoche/dev

merge with beta2
This commit is contained in:
Nicolas Lœuillet 2013-08-12 05:14:04 -07:00
commit 667009727a
14 changed files with 54 additions and 22 deletions

View File

@ -810,7 +810,8 @@ class Readability
return $this->grabArticle($this->body); return $this->grabArticle($this->body);
} }
else { else {
return false; # this line was commented by Nicolas Lœuillet 8/8/13 due to some urls not parsed
// return false;
} }
} }
return $articleContent; return $articleContent;

View File

@ -184,6 +184,13 @@ class Database {
return $entries; return $entries;
} }
public function updateContent($id, $content, $user_id) {
$sql_action = 'UPDATE entries SET content = ? WHERE id=? AND user_id=?';
$params_action = array($content, $id, $user_id);
$query = $this->executeQuery($sql_action, $params_action);
return $query;
}
public function add($url, $title, $content, $user_id) { public function add($url, $title, $content, $user_id) {
$sql_action = 'INSERT INTO entries ( url, title, content, user_id ) VALUES (?, ?, ?, ?)'; $sql_action = 'INSERT INTO entries ( url, title, content, user_id ) VALUES (?, ?, ?, ?)';
$params_action = array($url, $title, $content, $user_id); $params_action = array($url, $title, $content, $user_id);

View File

@ -18,6 +18,11 @@ class Poche
function __construct() function __construct()
{ {
if (file_exists('./install') && !DEBUG_POCHE) {
Tools::logm('folder /install exists');
die('To install your poche with sqlite, copy /install/poche.sqlite in /db and delete the folder /install. you have to delete the /install folder before using poche.');
}
$this->store = new Database(); $this->store = new Database();
$this->init(); $this->init();
$this->messages = new Messages(); $this->messages = new Messages();
@ -31,11 +36,6 @@ class Poche
private function init() private function init()
{ {
if (file_exists('./install') && !DEBUG_POCHE) {
Tools::logm('folder /install exists');
die('the folder /install exists, you have to delete it before using poche.');
}
Tools::initPhp(); Tools::initPhp();
Session::init(); Session::init();
@ -69,6 +69,10 @@ class Poche
$filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
$this->tpl->addFilter($filter); $this->tpl->addFilter($filter);
# filter for reading time
$filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
$this->tpl->addFilter($filter);
# Pagination # Pagination
$this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p'); $this->pagination = new Paginator($this->user->getConfigValue('pager'), 'p');
} }
@ -122,6 +126,8 @@ class Poche
$last_id = $this->store->getLastId($sequence); $last_id = $this->store->getLastId($sequence);
if (DOWNLOAD_PICTURES) { if (DOWNLOAD_PICTURES) {
$content = filtre_picture($parametres_url['content'], $url->getUrl(), $last_id); $content = filtre_picture($parametres_url['content'], $url->getUrl(), $last_id);
Tools::logm('updating content article');
$this->store->updateContent($last_id, $content, $this->user->getId());
} }
if (!$import) { if (!$import) {
$this->messages->add('s', _('the link has been added successfully')); $this->messages->add('s', _('the link has been added successfully'));
@ -213,7 +219,7 @@ class Poche
); );
} }
else { else {
Tools::logm('error in view call : entry is NULL'); Tools::logm('error in view call : entry is null');
} }
break; break;
default: # home view default: # home view

View File

@ -170,6 +170,7 @@ class Tools
preg_match('#charset="?(.*)"#si', $meta[0], $encoding); preg_match('#charset="?(.*)"#si', $meta[0], $encoding);
# if charset is found set it otherwise, set it to utf-8 # if charset is found set it otherwise, set it to utf-8
$html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8'; $html_charset = (!empty($encoding[1])) ? strtolower($encoding[1]) : 'utf-8';
if (empty($encoding[1])) $encoding[1] = 'utf-8';
} else { } else {
$html_charset = 'utf-8'; $html_charset = 'utf-8';
$encoding[1] = ''; $encoding[1] = '';
@ -223,4 +224,13 @@ class Tools
return FALSE; return FALSE;
} }
public static function getReadingTime($text) {
$word = str_word_count(strip_tags($text));
$minutes = floor($word / 200);
$seconds = floor($word % 200 / (200 / 60));
$time = array('minutes' => $minutes, 'seconds' => $seconds);
return $minutes;
}
} }

View File

@ -18,7 +18,7 @@ define ('STORAGE_PASSWORD', 'postgres'); # leave blank for sqlite
define ('POCHE_VERSION', '1.0-beta1'); define ('POCHE_VERSION', '1.0-beta1');
define ('MODE_DEMO', FALSE); define ('MODE_DEMO', FALSE);
define ('DEBUG_POCHE', TRUE); define ('DEBUG_POCHE', FALSE);
define ('CONVERT_LINKS_FOOTNOTES', FALSE); define ('CONVERT_LINKS_FOOTNOTES', FALSE);
define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE); define ('REVERT_FORCED_PARAGRAPH_ELEMENTS', FALSE);
define ('DOWNLOAD_PICTURES', FALSE); define ('DOWNLOAD_PICTURES', FALSE);

View File

@ -7,3 +7,5 @@
<link rel="stylesheet" href="./tpl/css/style-{{ constant('THEME') }}.css" media="all" title="{{ constant('THEME') }} theme"> <link rel="stylesheet" href="./tpl/css/style-{{ constant('THEME') }}.css" media="all" title="{{ constant('THEME') }} theme">
<link rel="stylesheet" href="./tpl/css/messages.css" media="all"> <link rel="stylesheet" href="./tpl/css/messages.css" media="all">
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<script src="./tpl/js/jquery-2.0.3.min.js"></script>
<script type="text/javascript">$(document).ready(function(){$("body").prepend('<a href="#top" class="top_link" title="{% trans "back to top" %}"><img src="./tpl/img/{{ constant("THEME") }}/backtotop.png" alt={% trans "back to top" %}"/></a>');$(".top_link").css({position:"fixed",right:"15px",bottom:"15px",display:"none",padding:"20px",background:"#ccc","-moz-border-radius":"40px","-webkit-border-radius":"40px","border-radius":"40px",opacity:"0.9","z-index":"2000"});$(window).scroll(function(){posScroll=$(document).scrollTop();if(posScroll>=400)$(".top_link").fadeIn(600);else $(".top_link").fadeOut(600)})})</script>

View File

@ -20,7 +20,7 @@
<p><ul> <p><ul>
<li>{% trans "your version" %} : <strong>{{ constant('POCHE_VERSION') }}</strong></li> <li>{% trans "your version" %} : <strong>{{ constant('POCHE_VERSION') }}</strong></li>
<li>{% trans "latest stable version" %} : {{ prod }}. {% if compare_prod == -1 %}<strong><a href="http://inthepoche.com/?pages/T%C3%A9l%C3%A9charger-poche">{% trans "a more recent stable version is available." %}</a></strong>{% else %}{% trans "you are up to date." %}{% endif %}</li> <li>{% trans "latest stable version" %} : {{ prod }}. {% if compare_prod == -1 %}<strong><a href="http://inthepoche.com/?pages/T%C3%A9l%C3%A9charger-poche">{% trans "a more recent stable version is available." %}</a></strong>{% else %}{% trans "you are up to date." %}{% endif %}</li>
<li>{% trans "latest dev version" %} : {{ dev }}. {% if compare_dev == -1 %}<strong><a href="http://inthepoche.com/?pages/T%C3%A9l%C3%A9charger-poche">{% trans "a more recent development version is available." %}</a></strong>{% else %}{% trans "you are up to date." %}{% endif %}</li> {% if constant('DEBUG_POCHE') == 1 %}<li>{% trans "latest dev version" %} : {{ dev }}. {% if compare_dev == -1 %}<strong><a href="http://inthepoche.com/?pages/T%C3%A9l%C3%A9charger-poche">{% trans "a more recent development version is available." %}</a></strong>{% else %}{% trans "you are up to date." %}{% endif %}</li>{% endif %}
</ul> </ul>
</p> </p>

View File

@ -120,11 +120,6 @@ header h1 {
height: 16px; height: 16px;
} }
#main .entrie .url {
font-size: 13px;
}
/*** ***/ /*** ***/
/*** ARTICLE PAGE ***/ /*** ARTICLE PAGE ***/
@ -242,3 +237,7 @@ a, a:hover, a:visited {
footer { footer {
clear: both; clear: both;
} }
.reading-time {
font-size: 0.8em;
}

View File

@ -19,6 +19,7 @@
<a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li> <a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li>
<li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li> <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li>
<li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li> <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li>
<li class="reading-time">{{ entry.content| getReadingTime }} min</li>
</li> </li>
</ul> </ul>
<p>{{ entry.content|striptags|slice(0, 300) }}...</p> <p>{{ entry.content|striptags|slice(0, 300) }}...</p>

BIN
tpl/img/light/backtotop.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 1.3 KiB

6
tpl/js/jquery-2.0.3.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -5,12 +5,12 @@
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<html> <html>
<head> <head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> <meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=10"> <meta http-equiv="X-UA-Compatible" content="IE=10">
<title>{% block title %}{% endblock %} - poche</title> <title>{% block title %}{% endblock %} - poche</title>
{% include '_head.twig' %} {% include '_head.twig' %}
{% include '_bookmarklet.twig' %} {% include '_bookmarklet.twig' %}
</head> </head>
<body> <body>
{% include '_top.twig' %} {% include '_top.twig' %}
@ -24,6 +24,6 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
</div> </div>
{% include '_footer.twig' %} {% include '_footer.twig' %}
</body> </body>
</html> </html>

View File

@ -5,7 +5,7 @@
<div class="tools"> <div class="tools">
<ul class="tools"> <ul class="tools">
<li> <li>
<li><a href="{{ referer }}" title="{% trans "back to home" %}" class="tool back"><span></span></a></li> <li><a href="./" title="{% trans "back to home" %}" class="tool back"><span></span></a></li>
<a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li> <a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li>
<li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li> <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li>
<li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li> <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li>
@ -25,8 +25,8 @@
<div class="tools"> <div class="tools">
<ul class="tools"> <ul class="tools">
<li> <li>
<li><a href="{{ referer }}" title="{% trans "back to home" %}" class="tool back"><span></span></a></li> <li><a href="./?" title="{% trans "back to home" %}" class="tool back"><span></span></a></li>
<li><a href="#" title="{% trans "back to top" %}" class="tool top"><span></span></a></li> <li><a href="#top" title="{% trans "back to top" %}" class="tool top"><span></span></a></li>
<a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li> <a title="{% trans "toggle mark as read" %}" class="tool archive {% if entry.is_read == 0 %}archive-off{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span></span></a></li>
<li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li> <li><a title="{% trans "toggle favorite" %}" class="tool fav {% if entry.is_fav == 0 %}fav-off{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span></span></a></li>
<li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li> <li><a title="{% trans "delete" %}" class="tool delete" href="./?action=delete&id={{ entry.id|e }}"><span></span></a></li>