mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-27 11:22:17 -05:00
new fields in database, reading time / date and domain name are stored
This commit is contained in:
parent
4247b37551
commit
5425b0dd82
@ -398,6 +398,21 @@ class Database {
|
|||||||
return $query;
|
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
|
* @param string $url
|
||||||
@ -407,8 +422,12 @@ class Database {
|
|||||||
* @return integer $id of inserted record
|
* @return integer $id of inserted record
|
||||||
*/
|
*/
|
||||||
public function add($url, $title, $content, $user_id, $isFavorite=0, $isRead=0) {
|
public function add($url, $title, $content, $user_id, $isFavorite=0, $isRead=0) {
|
||||||
$sql_action = 'INSERT INTO entries ( url, title, content, user_id, is_fav, is_read ) VALUES (?, ?, ?, ?, ?, ?)';
|
$readingTime = $this->_getReadingTime($content);
|
||||||
$params_action = array($url, $title, $content, $user_id, $isFavorite, $isRead);
|
$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, 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) ) {
|
if ( !$this->executeQuery($sql_action, $params_action) ) {
|
||||||
$id = null;
|
$id = null;
|
||||||
}
|
}
|
||||||
|
@ -232,14 +232,6 @@ class Poche
|
|||||||
|
|
||||||
$this->tpl = new Twig_Environment($loaderChain, $twigParams);
|
$this->tpl = new Twig_Environment($loaderChain, $twigParams);
|
||||||
$this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
|
$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() {
|
public function createNewUser() {
|
||||||
|
@ -214,20 +214,6 @@ class Tools
|
|||||||
return ((isset ($_REQUEST["$var"])) ? htmlentities($_REQUEST["$var"]) : $default);
|
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) {
|
public static function getDocLanguage($userlanguage) {
|
||||||
$lang = explode('.', $userlanguage);
|
$lang = explode('.', $userlanguage);
|
||||||
return str_replace('_', '-', $lang[0]);
|
return str_replace('_', '-', $lang[0]);
|
||||||
|
BIN
install/poche.sqlite
Executable file → Normal file
BIN
install/poche.sqlite
Executable file → Normal file
Binary file not shown.
@ -40,16 +40,17 @@
|
|||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
<div id="entry-{{ entry.id|e }}" class="entrie"{% if listmode %} style="width:100%; margin-left:0;"{% endif %}>
|
<div id="entry-{{ entry.id|e }}" class="entrie"{% if listmode %} style="width:100%; margin-left:0;"{% endif %}>
|
||||||
<h2><a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
|
<h2><a href="index.php?view=view&id={{ entry.id|e }}">{{ entry.title|raw }}</a></h2>
|
||||||
{% if entry.content| getReadingTime > 0 %}
|
<div>{{ entry.date }}</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 :" %} {{ entry.content| getReadingTime }} min</span></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>
|
||||||
{% else %}
|
{% else %}
|
||||||
<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>
|
<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>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<ul class="tools links">
|
<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&id={{ entry.id|e }}"><span>{% trans "Toggle mark as read" %}</span></a></li>
|
<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>
|
||||||
<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>
|
<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>
|
||||||
<li><a title="{% trans "delete" %}" class="tool delete icon-trash icon" href="./?action=delete&id={{ entry.id|e }}"><span>{% trans "delete" %}</span></a></li>
|
<li><a title="{% trans "delete" %}" class="tool delete icon-trash icon" href="./?action=delete&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.url | e | getDomain }}</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>
|
||||||
</ul>
|
</ul>
|
||||||
<p>{{ entry.content|striptags|slice(0, 300) }}...</p>
|
<p>{{ entry.content|striptags|slice(0, 300) }}...</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user