]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
I removed my previous commit. We have to create a new branch for that.
authorNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 10 Jul 2014 11:17:04 +0000 (13:17 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Thu, 10 Jul 2014 11:17:04 +0000 (13:17 +0200)
inc/poche/Database.class.php
inc/poche/Poche.class.php
inc/poche/Tools.class.php
install/poche.sqlite
themes/baggy/home.twig
themes/baggy/view.twig

index a222ed39b76017fc8b758b2d486b429f5e645f92..11cccb7238d9d6a6e16695386152a25fc6789fa8 100755 (executable)
@@ -398,21 +398,6 @@ class Database {
         return $query;
     }
 
-
-    private function _getDomain($url)
-    {
-        return parse_url($url, PHP_URL_HOST);
-    }
-
-    private 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;
-    }
-
     /**
      *
      * @param string $url
@@ -422,12 +407,9 @@ class Database {
      * @return integer $id of inserted record
      */
     public function add($url, $title, $content, $user_id, $isFavorite=0, $isRead=0) {
-        $readingTime = $this->_getReadingTime($content);
-        $domainName  = $this->_getDomain($url);
-        $date        = date('Y-m-d H:i:s');
+        $sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read ) VALUES (?, ?, ?, ?, ?, ?)';
+        $params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead);
 
-        $sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read, date, reading_time, domain_name ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)';
-        $params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead, $date, $readingTime, $domainName);
         if ( !$this->executeQuery($sql_action, $params_action) ) {
           $id = null;
         }
index e8c320249c01925302c293a405ada1f2771b06fa..09a9f5ff85276423a29b505312d2f1cec66ead8a 100755 (executable)
@@ -232,6 +232,14 @@ class Poche
 
         $this->tpl = new Twig_Environment($loaderChain, $twigParams);
         $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
+
+        # filter to display domain name of an url
+        $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
+        $this->tpl->addFilter($filter);
+
+        # filter for reading time
+        $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
+        $this->tpl->addFilter($filter);
     }
 
     public function createNewUser() {
index 13f48903cefdc80e6b9ab8eb8c5adc775e5320a0..cc01f4030498ef8127574bad949408f6a24065c2 100755 (executable)
@@ -214,6 +214,20 @@ class Tools
         return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default);
     }
 
+    public static function getDomain($url)
+    {
+        return parse_url($url, PHP_URL_HOST);
+    }
+
+    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;
+    }
+
     public static function getDocLanguage($userlanguage) {
         $lang = explode('.', $userlanguage);
         return str_replace('_', '-', $lang[0]);
index 4c0f8139590fb16a67392e0e1f2ccba17baf912c..f2b79b68f2480a6fa0ec923f225b6a24c880ed54 100644 (file)
Binary files a/install/poche.sqlite and b/install/poche.sqlite differ
index b819d801e608144441f6b0a789a97cdf5807a2dc..3942d3bf8aef4396db5f0dc4ee1541ce60e48b0e 100755 (executable)
                     {% for entry in entries %}
                 <div id="entry-{{ entry.id|e }}" class="entrie"{% if listmode %} style="width:100%; margin-left:0;"{% endif %}>
                     <h2><a href="index.php?view=view&amp;id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
-                    <div>{{ entry.date }}</div>
-                    {% if entry.reading_time > 0 %}
-                        <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>
+                    {% if entry.content| getReadingTime > 0 %}
+                        <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>
                     {% else %}
-                        <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>
+                        <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>
                     {% endif %}
                     <ul class="tools links">
                         <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&amp;id={{ entry.id|e }}"><span>{% trans "Toggle mark as read" %}</span></a></li>
                         <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&amp;id={{ entry.id|e }}"><span>{% trans "toggle favorite" %}</span></a></li>
                         <li><a title="{% trans "delete" %}" class="tool delete icon-trash icon" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li>
-                        <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>
+                        <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>
                     </ul>
                     <p>{{ entry.content|striptags|slice(0, 300) }}...</p>
                 </div>
index 1244b7423d3aaaccbcc6bf362f01baad40684216..af97407d076f2ad800f5a44ab4049d8792601b66 100755 (executable)
@@ -2,12 +2,12 @@
 {% block menu %}
 {% include '_menu.twig' %}
 {% endblock %}
-{% block title %}{{ entry.title|raw }} ({{ entry.domain_name }}){% endblock %}
+{% block title %}{{ entry.title|raw }} ({{ entry.url | e | getDomain }}){% endblock %}
 {% block content %}
         <div id="article_toolbar">
             <ul class="links">
                 <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>
-                <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>
+                <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>
                 <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>
                 <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>
                 <li><a title="{% trans "Delete" %}" class="tool delete icon icon-trash" href="./?action=delete&amp;id={{ entry.id|e }}"><span>{% trans "Delete" %}</span></a></li>