diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-07-10 13:17:04 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2014-07-10 13:17:04 +0200 |
commit | 6400371ff93782d25cdbd50aa224c70145b3890a (patch) | |
tree | 93e09a9851eb04d55b6b77d209ea8c0331b88950 | |
parent | c710f977b2659e866aba0e6a436485649834f2c4 (diff) | |
download | wallabag-6400371ff93782d25cdbd50aa224c70145b3890a.tar.gz wallabag-6400371ff93782d25cdbd50aa224c70145b3890a.tar.zst wallabag-6400371ff93782d25cdbd50aa224c70145b3890a.zip |
I removed my previous commit. We have to create a new branch for that.
-rwxr-xr-x | inc/poche/Database.class.php | 22 | ||||
-rwxr-xr-x | inc/poche/Poche.class.php | 8 | ||||
-rwxr-xr-x | inc/poche/Tools.class.php | 14 | ||||
-rw-r--r-- | install/poche.sqlite | bin | 393216 -> 393216 bytes | |||
-rwxr-xr-x | themes/baggy/home.twig | 9 | ||||
-rwxr-xr-x | themes/baggy/view.twig | 4 |
6 files changed, 30 insertions, 27 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index a222ed39..11cccb72 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php | |||
@@ -398,21 +398,6 @@ class Database { | |||
398 | return $query; | 398 | return $query; |
399 | } | 399 | } |
400 | 400 | ||
401 | |||
402 | private function _getDomain($url) | ||
403 | { | ||
404 | return parse_url($url, PHP_URL_HOST); | ||
405 | } | ||
406 | |||
407 | private function _getReadingTime($text) { | ||
408 | $word = str_word_count(strip_tags($text)); | ||
409 | $minutes = floor($word / 200); | ||
410 | $seconds = floor($word % 200 / (200 / 60)); | ||
411 | $time = array('minutes' => $minutes, 'seconds' => $seconds); | ||
412 | |||
413 | return $minutes; | ||
414 | } | ||
415 | |||
416 | /** | 401 | /** |
417 | * | 402 | * |
418 | * @param string $url | 403 | * @param string $url |
@@ -422,12 +407,9 @@ class Database { | |||
422 | * @return integer $id of inserted record | 407 | * @return integer $id of inserted record |
423 | */ | 408 | */ |
424 | public function add($url, $title, $content, $user_id, $isFavorite=0, $isRead=0) { | 409 | public function add($url, $title, $content, $user_id, $isFavorite=0, $isRead=0) { |
425 | $readingTime = $this->_getReadingTime($content); | 410 | $sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read ) VALUES (?, ?, ?, ?, ?, ?)'; |
426 | $domainName = $this->_getDomain($url); | 411 | $params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead); |
427 | $date = date('Y-m-d H:i:s'); | ||
428 | 412 | ||
429 | $sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read, date, reading_time, domain_name ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; | ||
430 | $params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead, $date, $readingTime, $domainName); | ||
431 | if ( !$this->executeQuery($sql_action, $params_action) ) { | 413 | if ( !$this->executeQuery($sql_action, $params_action) ) { |
432 | $id = null; | 414 | $id = null; |
433 | } | 415 | } |
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index e8c32024..09a9f5ff 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -232,6 +232,14 @@ class Poche | |||
232 | 232 | ||
233 | $this->tpl = new Twig_Environment($loaderChain, $twigParams); | 233 | $this->tpl = new Twig_Environment($loaderChain, $twigParams); |
234 | $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); | 234 | $this->tpl->addExtension(new Twig_Extensions_Extension_I18n()); |
235 | |||
236 | # filter to display domain name of an url | ||
237 | $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); | ||
238 | $this->tpl->addFilter($filter); | ||
239 | |||
240 | # filter for reading time | ||
241 | $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); | ||
242 | $this->tpl->addFilter($filter); | ||
235 | } | 243 | } |
236 | 244 | ||
237 | public function createNewUser() { | 245 | public function createNewUser() { |
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index 13f48903..cc01f403 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php | |||
@@ -214,6 +214,20 @@ class Tools | |||
214 | return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default); | 214 | return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default); |
215 | } | 215 | } |
216 | 216 | ||
217 | public static function getDomain($url) | ||
218 | { | ||
219 | return parse_url($url, PHP_URL_HOST); | ||
220 | } | ||
221 | |||
222 | public static function getReadingTime($text) { | ||
223 | $word = str_word_count(strip_tags($text)); | ||
224 | $minutes = floor($word / 200); | ||
225 | $seconds = floor($word % 200 / (200 / 60)); | ||
226 | $time = array('minutes' => $minutes, 'seconds' => $seconds); | ||
227 | |||
228 | return $minutes; | ||
229 | } | ||
230 | |||
217 | public static function getDocLanguage($userlanguage) { | 231 | public static function getDocLanguage($userlanguage) { |
218 | $lang = explode('.', $userlanguage); | 232 | $lang = explode('.', $userlanguage); |
219 | return str_replace('_', '-', $lang[0]); | 233 | return str_replace('_', '-', $lang[0]); |
diff --git a/install/poche.sqlite b/install/poche.sqlite index 4c0f8139..f2b79b68 100644 --- a/install/poche.sqlite +++ b/install/poche.sqlite | |||
Binary files differ | |||
diff --git a/themes/baggy/home.twig b/themes/baggy/home.twig index b819d801..3942d3bf 100755 --- a/themes/baggy/home.twig +++ b/themes/baggy/home.twig | |||
@@ -40,17 +40,16 @@ | |||
40 | {% for entry in entries %} | 40 | {% for entry in entries %} |
41 | <div id="entry-{{ entry.id|e }}" class="entrie"{% if listmode %} style="width:100%; margin-left:0;"{% endif %}> | 41 | <div id="entry-{{ entry.id|e }}" class="entrie"{% if listmode %} style="width:100%; margin-left:0;"{% endif %}> |
42 | <h2><a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2> | 42 | <h2><a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2> |
43 | <div>{{ entry.date }}</div> | 43 | {% if entry.content| getReadingTime > 0 %} |
44 | {% if entry.reading_time > 0 %} | 44 | <div class="estimatedTime"><a target="_blank" title="{% trans "estimated reading time:" %} {{ entry.content| getReadingTime }} min" class="tool reading-time"><span>{% trans "estimated reading time :" %} {{ entry.content| getReadingTime }} min</span></div> |
45 | <div class="estimatedTime"><a target="_blank" title="{% trans "estimated reading time:" %} {{ entry.reading_time }} min" class="tool reading-time"><span>{% trans "estimated reading time :" %} {{ entry.reading_time }} min</span></div> | ||
46 | {% else %} | 45 | {% else %} |
47 | <div class="estimatedTime"><a target="_blank" title="{% trans "estimated reading time:" %} {{ entry.reading_time }} min" class="tool reading-time"><span>{% trans "estimated reading time :" %} <small class="inferieur"><</small> 1 min</span></div> | 46 | <div class="estimatedTime"><a target="_blank" title="{% trans "estimated reading time:" %} {{ entry.content| getReadingTime }} min" class="tool reading-time"><span>{% trans "estimated reading time :" %} <small class="inferieur"><</small> 1 min</span></div> |
48 | {% endif %} | 47 | {% endif %} |
49 | <ul class="tools links"> | 48 | <ul class="tools links"> |
50 | <li><a title="{% trans "Toggle mark as read" %}" class="tool icon-check icon {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span>{% trans "Toggle mark as read" %}</span></a></li> | 49 | <li><a title="{% trans "Toggle mark as read" %}" class="tool icon-check icon {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="./?action=toggle_archive&id={{ entry.id|e }}"><span>{% trans "Toggle mark as read" %}</span></a></li> |
51 | <li><a title="{% trans "toggle favorite" %}" class="tool icon-star icon {% if entry.is_fav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span>{% trans "toggle favorite" %}</span></a></li> | 50 | <li><a title="{% trans "toggle favorite" %}" class="tool icon-star icon {% if entry.is_fav == 0 %}fav-off{% else %}fav{% endif %}" href="./?action=toggle_fav&id={{ entry.id|e }}"><span>{% trans "toggle favorite" %}</span></a></li> |
52 | <li><a title="{% trans "delete" %}" class="tool delete icon-trash icon" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li> | 51 | <li><a title="{% trans "delete" %}" class="tool delete icon-trash icon" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li> |
53 | <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.domain_name }}</span></a></li> | 52 | <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link icon-link icon"><span>{{ entry.url | e | getDomain }}</span></a></li> |
54 | </ul> | 53 | </ul> |
55 | <p>{{ entry.content|striptags|slice(0, 300) }}...</p> | 54 | <p>{{ entry.content|striptags|slice(0, 300) }}...</p> |
56 | </div> | 55 | </div> |
diff --git a/themes/baggy/view.twig b/themes/baggy/view.twig index 1244b742..af97407d 100755 --- a/themes/baggy/view.twig +++ b/themes/baggy/view.twig | |||
@@ -2,12 +2,12 @@ | |||
2 | {% block menu %} | 2 | {% block menu %} |
3 | {% include '_menu.twig' %} | 3 | {% include '_menu.twig' %} |
4 | {% endblock %} | 4 | {% endblock %} |
5 | {% block title %}{{ entry.title|raw }} ({{ entry.domain_name }}){% endblock %} | 5 | {% block title %}{{ entry.title|raw }} ({{ entry.url | e | getDomain }}){% endblock %} |
6 | {% block content %} | 6 | {% block content %} |
7 | <div id="article_toolbar"> | 7 | <div id="article_toolbar"> |
8 | <ul class="links"> | 8 | <ul class="links"> |
9 | <li class="topPosF"><a href="#top" title="{% trans "Back to top" %}" class="tool top icon icon-arrow-up-thick"><span>{% trans "Back to top" %}</span></a></li> | 9 | <li class="topPosF"><a href="#top" title="{% trans "Back to top" %}" class="tool top icon icon-arrow-up-thick"><span>{% trans "Back to top" %}</span></a></li> |
10 | <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.url }}</span></a></li> | 10 | <li><a href="{{ entry.url|e }}" target="_blank" title="{% trans "original" %} : {{ entry.title|e }}" class="tool link icon icon-link"><span>{{ entry.url | e | getDomain }}</span></a></li> |
11 | <li><a title="{% trans "Mark as read" %}" class="tool icon icon-check {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="javascript: void(null);" id="markAsRead"><span>{% trans "Toggle mark as read" %}</span></a></li> | 11 | <li><a title="{% trans "Mark as read" %}" class="tool icon icon-check {% if entry.is_read == 0 %}archive-off{% else %}archive{% endif %}" href="javascript: void(null);" id="markAsRead"><span>{% trans "Toggle mark as read" %}</span></a></li> |
12 | <li><a title="{% trans "Favorite" %}" class="tool icon icon-star {% if entry.is_fav == 0 %}fav-off{% else %}fav{% endif %}" href="javascript: void(null);" id="setFav"><span>{% trans "Toggle favorite" %}</span></a></li> | 12 | <li><a title="{% trans "Favorite" %}" class="tool icon icon-star {% if entry.is_fav == 0 %}fav-off{% else %}fav{% endif %}" href="javascript: void(null);" id="setFav"><span>{% trans "Toggle favorite" %}</span></a></li> |
13 | <li><a title="{% trans "Delete" %}" class="tool delete icon icon-trash" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans "Delete" %}</span></a></li> | 13 | <li><a title="{% trans "Delete" %}" class="tool delete icon icon-trash" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans "Delete" %}</span></a></li> |