diff options
| author | 2018-09-16 10:46:27 +0200 | |
|---|---|---|
| committer | 2018-09-16 10:46:27 +0200 | |
| commit | b323ed084620cac2222fe1c93ec05b9773eb81e6 (patch) | |
| tree | ec1057810fd3a1971f99d1ebb60b936e0c543094 /app | |
| parent | 9fa2122d4a27de7d9a207cea3dee911541b63420 (diff) | |
Improve authors (#2025)
* Links for authors and multiple authors
Favour ';' as a separator instead of ',' to better cope with
multi-author scientific articles.
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/1997 ,
https://github.com/FreshRSS/FreshRSS/issues/1968,
https://github.com/FreshRSS/FreshRSS/pull/2023
* Change i18n authors
* Update layout
* Unicode-compatible search
Example for `author:Loïc`
* author <em> styling
* Final details
* Minor spacing
Diffstat (limited to 'app')
| -rw-r--r-- | app/Models/Category.php | 2 | ||||
| -rw-r--r-- | app/Models/Entry.php | 34 | ||||
| -rw-r--r-- | app/Models/Feed.php | 2 | ||||
| -rw-r--r-- | app/Models/Search.php | 8 | ||||
| -rw-r--r-- | app/i18n/cz/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/de/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/en/gen.php | 2 | ||||
| -rwxr-xr-x | app/i18n/es/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/fr/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/he/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/it/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/kr/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/nl/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/pt-br/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/ru/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/tr/gen.php | 2 | ||||
| -rw-r--r-- | app/i18n/zh-cn/gen.php | 2 | ||||
| -rw-r--r-- | app/views/configure/display.phtml | 2 | ||||
| -rw-r--r-- | app/views/helpers/export/articles.phtml | 2 | ||||
| -rw-r--r-- | app/views/helpers/extension/configure.phtml | 2 | ||||
| -rw-r--r-- | app/views/index/normal.phtml | 17 | ||||
| -rw-r--r-- | app/views/index/reader.phtml | 16 | ||||
| -rwxr-xr-x | app/views/index/rss.phtml | 18 |
23 files changed, 84 insertions, 45 deletions
diff --git a/app/Models/Category.php b/app/Models/Category.php index 197faf942..796f39ce1 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -68,7 +68,7 @@ class FreshRSS_Category extends Minz_Model { $this->id = $value; } public function _name($value) { - $this->name = mb_strcut(trim($value), 0, 255, 'UTF-8'); + $this->name = trim($value); } public function _feeds($values) { if (!is_array($values)) { diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 48a0b1bed..09c5d8bcf 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -10,7 +10,7 @@ class FreshRSS_Entry extends Minz_Model { private $id = 0; private $guid; private $title; - private $author; + private $authors; private $content; private $link; private $date; @@ -21,17 +21,16 @@ class FreshRSS_Entry extends Minz_Model { private $feed; private $tags; - public function __construct($feedId = '', $guid = '', $title = '', $author = '', $content = '', + public function __construct($feedId = '', $guid = '', $title = '', $authors = '', $content = '', $link = '', $pubdate = 0, $is_read = false, $is_favorite = false, $tags = '') { $this->_title($title); - $this->_author($author); + $this->_authors($authors); $this->_content($content); $this->_link($link); $this->_date($pubdate); $this->_isRead($is_read); $this->_isFavorite($is_favorite); $this->_feedId($feedId); - $tags = mb_strcut($tags, 0, 1023, 'UTF-8'); $this->_tags($tags); $this->_guid($guid); } @@ -45,8 +44,12 @@ class FreshRSS_Entry extends Minz_Model { public function title() { return $this->title; } - public function author() { - return $this->author === null ? '' : $this->author; + public function authors($asString = false) { + if ($asString) { + return $this->authors == null ? '' : ';' . implode('; ', $this->authors); + } else { + return $this->authors; + } } public function content() { return $this->content; @@ -88,7 +91,7 @@ class FreshRSS_Entry extends Minz_Model { } public function tags($asString = false) { if ($asString) { - return $this->tags == '' ? '' : '#' . implode(' #', $this->tags); + return $this->tags == null ? '' : '#' . implode(' #', $this->tags); } else { return $this->tags; } @@ -97,7 +100,7 @@ class FreshRSS_Entry extends Minz_Model { public function hash() { if ($this->hash === null) { //Do not include $this->date because it may be automatically generated when lacking - $this->hash = md5($this->link . $this->title . $this->author . $this->content . $this->tags(true)); + $this->hash = md5($this->link . $this->title . $this->authors(true) . $this->content . $this->tags(true)); } return $this->hash; } @@ -124,11 +127,18 @@ class FreshRSS_Entry extends Minz_Model { } public function _title($value) { $this->hash = null; - $this->title = mb_strcut($value, 0, 255, 'UTF-8'); + $this->title = $value; } - public function _author($value) { + public function _authors($value) { $this->hash = null; - $this->author = mb_strcut($value, 0, 255, 'UTF-8'); + if (!is_array($value)) { + if (strpos($value, ';') !== false) { + $value = preg_split('/\s*[;]\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); + } else { + $value = preg_split('/\s*[,]\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); + } + } + $this->authors = $value; } public function _content($value) { $this->hash = null; @@ -280,7 +290,7 @@ class FreshRSS_Entry extends Minz_Model { 'id' => $this->id(), 'guid' => $this->guid(), 'title' => $this->title(), - 'author' => $this->author(), + 'author' => $this->authors(true), 'content' => $this->content(), 'link' => $this->link(), 'date' => $this->date(true), diff --git a/app/Models/Feed.php b/app/Models/Feed.php index cc96cde44..d09577e6e 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -420,7 +420,7 @@ class FreshRSS_Feed extends Minz_Model { $author_names = ''; if (is_array($authors)) { foreach ($authors as $author) { - $author_names .= html_only_entity_decode(strip_tags($author->name == '' ? $author->email : $author->name)) . ', '; + $author_names .= html_only_entity_decode(strip_tags($author->name == '' ? $author->email : $author->name)) . '; '; } } $author_names = substr($author_names, 0, -2); diff --git a/app/Models/Search.php b/app/Models/Search.php index c338d63a1..c52e391fa 100644 --- a/app/Models/Search.php +++ b/app/Models/Search.php @@ -141,7 +141,7 @@ class FreshRSS_Search { $this->intitle = $matches['search']; $input = str_replace($matches[0], '', $input); } - if (preg_match_all('/\bintitle:(?P<search>[\w+]*)/', $input, $matches)) { + if (preg_match_all('/\bintitle:(?P<search>[^\s"]*)/', $input, $matches)) { $this->intitle = array_merge($this->intitle ? $this->intitle : array(), $matches['search']); $input = str_replace($matches[0], '', $input); } @@ -155,7 +155,7 @@ class FreshRSS_Search { $this->not_intitle = $matches['search']; $input = str_replace($matches[0], '', $input); } - if (preg_match_all('/[!-]intitle:(?P<search>[\w+]*)/', $input, $matches)) { + if (preg_match_all('/[!-]intitle:(?P<search>[^\s"]*)/', $input, $matches)) { $this->not_intitle = array_merge($this->not_intitle ? $this->not_intitle : array(), $matches['search']); $input = str_replace($matches[0], '', $input); } @@ -179,7 +179,7 @@ class FreshRSS_Search { $this->author = $matches['search']; $input = str_replace($matches[0], '', $input); } - if (preg_match_all('/\bauthor:(?P<search>[\w+]*)/', $input, $matches)) { + if (preg_match_all('/\bauthor:(?P<search>[^\s"]*)/', $input, $matches)) { $this->author = array_merge($this->author ? $this->author : array(), $matches['search']); $input = str_replace($matches[0], '', $input); } @@ -193,7 +193,7 @@ class FreshRSS_Search { $this->not_author = $matches['search']; $input = str_replace($matches[0], '', $input); } - if (preg_match_all('/[!-]author:(?P<search>[\w+]*)/', $input, $matches)) { + if (preg_match_all('/[!-]author:(?P<search>[^\s"]*)/', $input, $matches)) { $this->not_author = array_merge($this->not_author ? $this->not_author : array(), $matches['search']); $input = str_replace($matches[0], '', $input); } diff --git a/app/i18n/cz/gen.php b/app/i18n/cz/gen.php index 66c011da3..b9a65f210 100644 --- a/app/i18n/cz/gen.php +++ b/app/i18n/cz/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'Upozornění!', 'blank_to_disable' => 'Zakázat - ponechte prázdné', - 'by_author' => 'Od <em>%s</em>', + 'by_author' => 'Od:', 'by_default' => 'Výchozí', 'damn' => 'Sakra!', 'default_category' => 'Nezařazeno', diff --git a/app/i18n/de/gen.php b/app/i18n/de/gen.php index eb1e74ed6..26d109328 100644 --- a/app/i18n/de/gen.php +++ b/app/i18n/de/gen.php @@ -180,7 +180,7 @@ return array( 'short' => array( 'attention' => 'Achtung!', 'blank_to_disable' => 'Zum Deaktivieren frei lassen', - 'by_author' => 'Von <em>%s</em>', + 'by_author' => 'Von:', 'by_default' => 'standardmäßig', 'damn' => 'Verdammt!', 'default_category' => 'Unkategorisiert', diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 34e81af2e..9f7da55a5 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'Warning!', 'blank_to_disable' => 'Leave blank to disable', - 'by_author' => 'By <em>%s</em>', + 'by_author' => 'By:', 'by_default' => 'By default', 'damn' => 'Blast!', 'default_category' => 'Uncategorized', diff --git a/app/i18n/es/gen.php b/app/i18n/es/gen.php index 4dc1145b2..fe3d62e2d 100755 --- a/app/i18n/es/gen.php +++ b/app/i18n/es/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => '¡Aviso!', 'blank_to_disable' => 'Deja en blanco para desactivar', - 'by_author' => 'Por <em>%s</em>', + 'by_author' => 'Por:', 'by_default' => 'Por defecto', 'damn' => '¡Córcholis!', 'default_category' => 'Sin categorizar', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index 13e19283f..1e1cef590 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'Attention !', 'blank_to_disable' => 'Laissez vide pour désactiver', - 'by_author' => 'Par <em>%s</em>', + 'by_author' => 'Par :', 'by_default' => 'Par défaut', 'damn' => 'Arf !', 'default_category' => 'Sans catégorie', diff --git a/app/i18n/he/gen.php b/app/i18n/he/gen.php index a59f6b178..26b8f99e6 100644 --- a/app/i18n/he/gen.php +++ b/app/i18n/he/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'זהירות!', 'blank_to_disable' => 'יש להשאיר ריק על מנת לנטרל', - 'by_author' => 'מאת <em>%s</em>', + 'by_author' => 'מאת :', 'by_default' => 'ברירת מחדל', 'damn' => 'הו לא!', 'default_category' => 'ללא קטגוריה', diff --git a/app/i18n/it/gen.php b/app/i18n/it/gen.php index 2a90693f9..ab17441e7 100644 --- a/app/i18n/it/gen.php +++ b/app/i18n/it/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'Attenzione!', 'blank_to_disable' => 'Lascia vuoto per disabilitare', - 'by_author' => 'di <em>%s</em>', + 'by_author' => 'di:', 'by_default' => 'predefinito', 'damn' => 'Ops!', 'default_category' => 'Senza categoria', diff --git a/app/i18n/kr/gen.php b/app/i18n/kr/gen.php index e664eaa42..6a461bdac 100644 --- a/app/i18n/kr/gen.php +++ b/app/i18n/kr/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => '경고!', 'blank_to_disable' => '빈 칸으로 두면 비활성화', - 'by_author' => 'By <em>%s</em>', + 'by_author' => 'By:', 'by_default' => '기본값', 'damn' => '이런!', 'default_category' => '분류 없음', diff --git a/app/i18n/nl/gen.php b/app/i18n/nl/gen.php index ccbd86579..fdc4338c3 100644 --- a/app/i18n/nl/gen.php +++ b/app/i18n/nl/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'Attentie!', 'blank_to_disable' => 'Laat leeg om uit te zetten', - 'by_author' => 'Door <em>%s</em>', + 'by_author' => 'Door:', 'by_default' => 'Door standaard', 'damn' => 'Potverdorie!', 'default_category' => 'Niet ingedeeld', diff --git a/app/i18n/pt-br/gen.php b/app/i18n/pt-br/gen.php index 558482f07..59218597b 100644 --- a/app/i18n/pt-br/gen.php +++ b/app/i18n/pt-br/gen.php @@ -180,7 +180,7 @@ return array( 'short' => array( 'attention' => 'Atencão!', 'blank_to_disable' => 'Deixe em branco para desativar', - 'by_author' => 'Por <em>%s</em>', + 'by_author' => 'Por:', 'by_default' => 'Por padrão', 'damn' => 'Buumm!', 'default_category' => 'Sem categoria', diff --git a/app/i18n/ru/gen.php b/app/i18n/ru/gen.php index 911410a1c..6c8dd2adf 100644 --- a/app/i18n/ru/gen.php +++ b/app/i18n/ru/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'Warning!', 'blank_to_disable' => 'Leave blank to disable', - 'by_author' => 'By <em>%s</em>', + 'by_author' => 'By:', 'by_default' => 'By default', 'damn' => 'Damn!', 'default_category' => 'Uncategorized', diff --git a/app/i18n/tr/gen.php b/app/i18n/tr/gen.php index 2e1761517..b8dc18c01 100644 --- a/app/i18n/tr/gen.php +++ b/app/i18n/tr/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => 'Tehlike!', 'blank_to_disable' => 'Devredışı bırakmak için boş bırakın', - 'by_author' => '<em>%s</em> tarafından', + 'by_author' => 'Tarafından:', 'by_default' => 'Öntanımlı', 'damn' => 'Hay aksi!', 'default_category' => 'Kategorisiz', diff --git a/app/i18n/zh-cn/gen.php b/app/i18n/zh-cn/gen.php index 4ea2d73ab..078e1d378 100644 --- a/app/i18n/zh-cn/gen.php +++ b/app/i18n/zh-cn/gen.php @@ -181,7 +181,7 @@ return array( 'short' => array( 'attention' => '警告!', 'blank_to_disable' => '留空以禁用', - 'by_author' => '作者 <em>%s</em>', + 'by_author' => '作者', 'by_default' => '默认', 'damn' => '错误!', 'default_category' => '未分类', diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 414fd2cd6..132b9536c 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -39,7 +39,7 @@ <?php } ?> </div> <div class="properties"> - <div><?php echo sprintf('%s — %s', $theme['name'], _t('gen.short.by_author', $theme['author'])); ?></div> + <div><?php echo sprintf('%s — %s %s', $theme['name'], _t('gen.short.by_author'), $theme['author']); ?></div> <div><?php echo $theme['description'] ?></div> <div class="page-number"><?php echo sprintf('%d/%d', $i, $slides) ?></div> </div> diff --git a/app/views/helpers/export/articles.phtml b/app/views/helpers/export/articles.phtml index 75651483a..b8958f527 100644 --- a/app/views/helpers/export/articles.phtml +++ b/app/views/helpers/export/articles.phtml @@ -34,7 +34,7 @@ foreach ($this->entriesRaw as $entryRaw) { 'id' => $entry->guid(), 'categories' => array_values($entry->tags()), 'title' => $entry->title(), - 'author' => $entry->author(), + 'author' => $entry->authors(true), //TODO: Make an array like tags? 'published' => $entry->date(true), 'updated' => $entry->date(true), 'alternate' => array(array( diff --git a/app/views/helpers/extension/configure.phtml b/app/views/helpers/extension/configure.phtml index 95d968aba..cde872aa0 100644 --- a/app/views/helpers/extension/configure.phtml +++ b/app/views/helpers/extension/configure.phtml @@ -5,7 +5,7 @@ : _t('admin.extensions.disabled'); ?> </h1> - <p class="alert alert-warn"><?php echo $this->extension->getDescription(); ?> — <?php echo _t('gen.short.by_author', $this->extension->getAuthor()); ?></p> + <p class="alert alert-warn"><?php echo $this->extension->getDescription(); ?> — <?php echo _t('gen.short.by_author'), ' ', $this->extension->getAuthor(); ?></p> <h2><?php echo _t('gen.action.manage'); ?></h2> <?php diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index c7cab2d3f..e659509f9 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -67,10 +67,19 @@ if (!empty($this->entries)) { ?><div class="flux_content"> <div class="content <?php echo $content_width; ?>"> <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?php echo $this->entry->link(); ?>"><?php echo $this->entry->title(); ?></a></h1> - <?php - $author = $this->entry->author(); - echo $author != '' ? '<div class="author">' . _t('gen.short.by_author', $author) . '</div>' : '', - $lazyload && $hidePosts ? lazyimg($this->entry->content()) : $this->entry->content(); + <div class="author"><?php + $authors = $this->entry->authors(); + if (is_array($authors)): + $first = true; + foreach ($authors as $author): + echo $first ? _t('gen.short.by_author') . ' ' : '· '; + $first = false; + ?> +<em><a href="<?php echo _url('index', 'index', 'search', 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))); ?>"><?php echo $author; ?></a></em> + <?php endforeach; ?> + </div><?php + endif; + echo $lazyload && $hidePosts ? lazyimg($this->entry->content()) : $this->entry->content(); ?> </div><?php diff --git a/app/views/index/reader.phtml b/app/views/index/reader.phtml index eb6613b28..a92767f1c 100644 --- a/app/views/index/reader.phtml +++ b/app/views/index/reader.phtml @@ -39,9 +39,19 @@ if (!empty($this->entries)) { <h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?php echo $item->link(); ?>"><?php echo $item->title(); ?></a></h1> <div class="author"><?php - $author = $item->author(); - echo $author != '' ? _t('gen.short.by_author', $author) . ' — ' : '', - $item->date(); + $authors = $item->authors(); + if (is_array($authors)): + $first = true; + foreach ($authors as $author): + echo $first ? _t('gen.short.by_author') . ' ' : '· '; + $first = false; + ?> +<em><a href="<?php echo _url('index', 'index', 'search', 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))); ?>"><?php echo $author; ?></a></em> + <?php + endforeach; + echo ' — '; + endif; + echo $item->date(); ?></div> <?php echo $item->content(); ?> diff --git a/app/views/index/rss.phtml b/app/views/index/rss.phtml index 86074517c..104e03d15 100755 --- a/app/views/index/rss.phtml +++ b/app/views/index/rss.phtml @@ -13,10 +13,20 @@ foreach ($this->entries as $item) { <item> <title><?php echo $item->title(); ?></title> <link><?php echo $item->link(); ?></link> - <?php $author = $item->author(); ?> - <?php if ($author != '') { ?> - <dc:creator><?php echo $author; ?></dc:creator> - <?php } ?> + <?php + $authors = $item->authors(); + if (is_array($authors)) { + foreach ($authors as $author) { + echo "\t\t\t" , '<author>', $author, '</author>', "\n"; + } + } + $categories = $item->tags(); + if (is_array($categories)) { + foreach ($categories as $category) { + echo "\t\t\t" , '<category>', $category, '</category>', "\n"; + } + } + ?> <description><![CDATA[<?php echo $item->content(); ?>]]></description> |
