Provides enahncement fguillot/miniflux #162 "Provide original link to any audio/video enclosures".

Essentially, if an enclosure tag exists in the item, then the item menu will contain
a link 'multimedia [speaker symbol]' to the media url. Otherwise, if there is no
enclosure tag, there is no menu item shown.

This feature required adding an enclosure column to the items table (models/schema.php)
and bumping the DB version to 21 (models/config.php). I also added enclosure tag logic
to the Rss20 parser, the model/item.php and template/item.php files.
This commit is contained in:
Philip Walden 2014-02-17 10:41:22 -08:00
parent cead0305ca
commit 2874d16a5d
5 changed files with 24 additions and 2 deletions

View File

@ -16,7 +16,7 @@ use SimpleValidator\Validator;
use SimpleValidator\Validators; use SimpleValidator\Validators;
use PicoDb\Database; use PicoDb\Database;
const DB_VERSION = 20; const DB_VERSION = 21;
const HTTP_USERAGENT = 'Miniflux - http://miniflux.net'; const HTTP_USERAGENT = 'Miniflux - http://miniflux.net';
const HTTP_FAKE_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36'; const HTTP_FAKE_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36';

View File

@ -18,6 +18,7 @@ function get_everything()
'items.title', 'items.title',
'items.updated', 'items.updated',
'items.url', 'items.url',
'items.enclosure',
'items.bookmark', 'items.bookmark',
'items.feed_id', 'items.feed_id',
'items.status', 'items.status',
@ -41,6 +42,7 @@ function get_everything_since($timestamp)
'items.title', 'items.title',
'items.updated', 'items.updated',
'items.url', 'items.url',
'items.enclosure',
'items.bookmark', 'items.bookmark',
'items.feed_id', 'items.feed_id',
'items.status', 'items.status',
@ -75,6 +77,7 @@ function get_all($status, $offset = null, $limit = null, $order_column = 'update
'items.title', 'items.title',
'items.updated', 'items.updated',
'items.url', 'items.url',
'items.enclosure',
'items.bookmark', 'items.bookmark',
'items.feed_id', 'items.feed_id',
'items.status', 'items.status',
@ -119,6 +122,7 @@ function get_bookmarks($offset = null, $limit = null)
'items.title', 'items.title',
'items.updated', 'items.updated',
'items.url', 'items.url',
'items.enclosure',
'items.bookmark', 'items.bookmark',
'items.status', 'items.status',
'items.content', 'items.content',
@ -155,6 +159,7 @@ function get_all_by_feed($feed_id, $offset = null, $limit = null, $order_column
'items.title', 'items.title',
'items.updated', 'items.updated',
'items.url', 'items.url',
'items.enclosure',
'items.feed_id', 'items.feed_id',
'items.status', 'items.status',
'items.content', 'items.content',
@ -420,7 +425,8 @@ function update_all($feed_id, array $items, $grabber = false)
'author' => $item->author, 'author' => $item->author,
'content' => $nocontent ? '' : $item->content, 'content' => $nocontent ? '' : $item->content,
'status' => 'unread', 'status' => 'unread',
'feed_id' => $feed_id 'feed_id' => $feed_id,
'enclosure' => isset($item->enclosure) ? $item->enclosure : NULL
)); ));
} }
else { else {

View File

@ -3,6 +3,11 @@
namespace Schema; namespace Schema;
function version_21($pdo)
{
$pdo->exec('ALTER TABLE items ADD COLUMN enclosure TEXT');
}
function version_20($pdo) function version_20($pdo)
{ {
$pdo->exec('ALTER TABLE config ADD COLUMN redirect_nothing_to_read TEXT DEFAULT "feeds"'); $pdo->exec('ALTER TABLE config ADD COLUMN redirect_nothing_to_read TEXT DEFAULT "feeds"');

View File

@ -35,6 +35,11 @@
<li class="hide-mobile"> <li class="hide-mobile">
<a href="<?= $item['url'] ?>" id="original-<?= $item['id'] ?>" rel="noreferrer" target="_blank" data-item-id="<?= $item['id'] ?>"><?= t('original link') ?></a> <a href="<?= $item['url'] ?>" id="original-<?= $item['id'] ?>" rel="noreferrer" target="_blank" data-item-id="<?= $item['id'] ?>"><?= t('original link') ?></a>
</li> </li>
<?php if (isset($item['enclosure']) && ! is_null($item['enclosure'])): ?>
<li class="hide-mobile">
<a href="<?= $item['enclosure'] ?>" rel="noreferrer" target="_blank">multimedia 🔉</a>
</li>
<?php endif ?>
<?= \PicoTools\Template\load('bookmark_links', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'source' => '')) ?> <?= \PicoTools\Template\load('bookmark_links', array('item' => $item, 'menu' => $menu, 'offset' => $offset, 'source' => '')) ?>
<?= \PicoTools\Template\load('status_links', array('item' => $item, 'redirect' => $menu, 'offset' => $offset)) ?> <?= \PicoTools\Template\load('status_links', array('item' => $item, 'redirect' => $menu, 'offset' => $offset)) ?>
</ul> </ul>

View File

@ -110,6 +110,12 @@ class Rss20 extends \PicoFeed\Parser
if (empty($item->title)) $item->title = $item->url; if (empty($item->title)) $item->title = $item->url;
// if optional enclosure tag with multimedia provided, capture here
if (isset($entry->enclosure)) {
$item->enclosure = (string) $entry->enclosure['url'];
// \PicoFeed\Logging::log(\get_called_class().': recorded enclosure ('.(string) $item->enclosure.')');
}
$item->content = $this->filterHtml($item->content, $item->url); $item->content = $this->filterHtml($item->content, $item->url);
$this->items[] = $item; $this->items[] = $item;
} }