Improve enclosure support
This commit is contained in:
parent
2874d16a5d
commit
74d8d361ee
@ -63,6 +63,7 @@ People who sent a pull-request, report a bug, make a new theme or share a super
|
|||||||
- MonsieurPaulLeBoulanger: https://github.com/MonsieurPaulLeBoulanger
|
- MonsieurPaulLeBoulanger: https://github.com/MonsieurPaulLeBoulanger
|
||||||
- Necku: https://github.com/Necku
|
- Necku: https://github.com/Necku
|
||||||
- Nicolas Dewaele: http://adminrezo.fr/
|
- Nicolas Dewaele: http://adminrezo.fr/
|
||||||
|
- Pcwalden: https://github.com/pcwalden
|
||||||
- Silvus: https://github.com/Silvus
|
- Silvus: https://github.com/Silvus
|
||||||
- Skasi7: https://github.com/skasi7
|
- Skasi7: https://github.com/skasi7
|
||||||
- Thiriot Christophe: https://github.com/doubleface
|
- Thiriot Christophe: https://github.com/doubleface
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
'attachment' => 'pièce jointe',
|
||||||
'When there is nothing to read, redirect me to this page' => 'Quand il n\'y a rien à lire, redirigez moi vers cette page',
|
'When there is nothing to read, redirect me to this page' => 'Quand il n\'y a rien à lire, redirigez moi vers cette page',
|
||||||
'Subscription page' => 'Page des abonnements',
|
'Subscription page' => 'Page des abonnements',
|
||||||
'History page' => 'Historique de lecture',
|
'History page' => 'Historique de lecture',
|
||||||
|
@ -19,6 +19,7 @@ function get_everything()
|
|||||||
'items.updated',
|
'items.updated',
|
||||||
'items.url',
|
'items.url',
|
||||||
'items.enclosure',
|
'items.enclosure',
|
||||||
|
'items.enclosure_type',
|
||||||
'items.bookmark',
|
'items.bookmark',
|
||||||
'items.feed_id',
|
'items.feed_id',
|
||||||
'items.status',
|
'items.status',
|
||||||
@ -43,6 +44,7 @@ function get_everything_since($timestamp)
|
|||||||
'items.updated',
|
'items.updated',
|
||||||
'items.url',
|
'items.url',
|
||||||
'items.enclosure',
|
'items.enclosure',
|
||||||
|
'items.enclosure_type',
|
||||||
'items.bookmark',
|
'items.bookmark',
|
||||||
'items.feed_id',
|
'items.feed_id',
|
||||||
'items.status',
|
'items.status',
|
||||||
@ -78,6 +80,7 @@ function get_all($status, $offset = null, $limit = null, $order_column = 'update
|
|||||||
'items.updated',
|
'items.updated',
|
||||||
'items.url',
|
'items.url',
|
||||||
'items.enclosure',
|
'items.enclosure',
|
||||||
|
'items.enclosure_type',
|
||||||
'items.bookmark',
|
'items.bookmark',
|
||||||
'items.feed_id',
|
'items.feed_id',
|
||||||
'items.status',
|
'items.status',
|
||||||
@ -123,6 +126,7 @@ function get_bookmarks($offset = null, $limit = null)
|
|||||||
'items.updated',
|
'items.updated',
|
||||||
'items.url',
|
'items.url',
|
||||||
'items.enclosure',
|
'items.enclosure',
|
||||||
|
'items.enclosure_type',
|
||||||
'items.bookmark',
|
'items.bookmark',
|
||||||
'items.status',
|
'items.status',
|
||||||
'items.content',
|
'items.content',
|
||||||
@ -160,6 +164,7 @@ function get_all_by_feed($feed_id, $offset = null, $limit = null, $order_column
|
|||||||
'items.updated',
|
'items.updated',
|
||||||
'items.url',
|
'items.url',
|
||||||
'items.enclosure',
|
'items.enclosure',
|
||||||
|
'items.enclosure_type',
|
||||||
'items.feed_id',
|
'items.feed_id',
|
||||||
'items.status',
|
'items.status',
|
||||||
'items.content',
|
'items.content',
|
||||||
@ -426,7 +431,8 @@ function update_all($feed_id, array $items, $grabber = false)
|
|||||||
'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
|
'enclosure' => isset($item->enclosure) ? $item->enclosure : null,
|
||||||
|
'enclosure_type' => isset($item->enclosure_type) ? $item->enclosure_type : null,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -6,8 +6,10 @@ namespace Schema;
|
|||||||
function version_21($pdo)
|
function version_21($pdo)
|
||||||
{
|
{
|
||||||
$pdo->exec('ALTER TABLE items ADD COLUMN enclosure TEXT');
|
$pdo->exec('ALTER TABLE items ADD COLUMN enclosure TEXT');
|
||||||
|
$pdo->exec('ALTER TABLE items ADD COLUMN enclosure_type 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"');
|
||||||
|
@ -63,14 +63,20 @@
|
|||||||
<a href="?action=enable-grabber-feed&feed_id=<?= $feed['id'] ?>"><?= t('enable full content') ?></a>
|
<a href="?action=enable-grabber-feed&feed_id=<?= $feed['id'] ?>"><?= t('enable full content') ?></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</li>
|
</li>
|
||||||
<li class="hide-mobile">
|
|
||||||
<?php if ($feed['enabled']): ?>
|
<?php if ($feed['enabled']): ?>
|
||||||
|
<li class="hide-mobile">
|
||||||
<a href="?action=confirm-disable-feed&feed_id=<?= $feed['id'] ?>"><?= t('disable') ?></a>
|
<a href="?action=confirm-disable-feed&feed_id=<?= $feed['id'] ?>"><?= t('disable') ?></a>
|
||||||
<a href="?action=refresh-feed&feed_id=<?= $feed['id'] ?>" data-feed-id="<?= $feed['id'] ?>" data-action="refresh-feed"><?= t('refresh') ?></a>
|
|
||||||
<?php else: ?>
|
|
||||||
<a href="?action=enable-feed&feed_id=<?= $feed['id'] ?>"><?= t('enable') ?></a>
|
|
||||||
<?php endif ?>
|
|
||||||
</li>
|
</li>
|
||||||
|
<li class="hide-mobile">
|
||||||
|
<a href="?action=refresh-feed&feed_id=<?= $feed['id'] ?>" data-feed-id="<?= $feed['id'] ?>" data-action="refresh-feed"><?= t('refresh') ?></a>
|
||||||
|
</li>
|
||||||
|
<?php else: ?>
|
||||||
|
<li>
|
||||||
|
<a href="?action=enable-feed&feed_id=<?= $feed['id'] ?>"><?= t('enable') ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
<li class="hide-mobile">
|
<li class="hide-mobile">
|
||||||
<a href="?action=edit-feed&feed_id=<?= $feed['id'] ?>"><?= t('edit') ?></a>
|
<a href="?action=edit-feed&feed_id=<?= $feed['id'] ?>"><?= t('edit') ?></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
<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'])): ?>
|
<?php if ($item['enclosure']): ?>
|
||||||
<li class="hide-mobile">
|
<li>
|
||||||
<a href="<?= $item['enclosure'] ?>" rel="noreferrer" target="_blank">multimedia 🔉</a>
|
<a href="<?= $item['enclosure'] ?>" rel="noreferrer" target="_blank"><?= t('media') ?></a>
|
||||||
</li>
|
</li>
|
||||||
<?php endif ?>
|
<?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' => '')) ?>
|
||||||
|
@ -64,6 +64,11 @@
|
|||||||
<li class="hide-mobile">
|
<li class="hide-mobile">
|
||||||
<?= dt('%e %B %Y %k:%M', $item['updated']) ?>
|
<?= dt('%e %B %Y %k:%M', $item['updated']) ?>
|
||||||
</li>
|
</li>
|
||||||
|
<?php if ($item['enclosure']): ?>
|
||||||
|
<li>
|
||||||
|
<a href="<?= $item['enclosure'] ?>" rel="noreferrer" target="_blank"><?= t('attachment') ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endif ?>
|
||||||
<li class="hide-mobile">
|
<li class="hide-mobile">
|
||||||
<span id="download-item"
|
<span id="download-item"
|
||||||
data-item-id="<?= $item['id'] ?>"
|
data-item-id="<?= $item['id'] ?>"
|
||||||
@ -79,6 +84,18 @@
|
|||||||
|
|
||||||
<div id="item-content">
|
<div id="item-content">
|
||||||
<?= $item['content'] ?>
|
<?= $item['content'] ?>
|
||||||
|
|
||||||
|
<?php if ($item['enclosure']): ?>
|
||||||
|
<?php if (strpos($item['enclosure_type'], 'audio') !== false): ?>
|
||||||
|
<audio controls>
|
||||||
|
<source src="<?= $item['enclosure'] ?>" type="<?= $item['enclosure_type'] ?>">
|
||||||
|
</audio>
|
||||||
|
<?php elseif (strpos($item['enclosure_type'], 'video') !== false): ?>
|
||||||
|
<video controls>
|
||||||
|
<source src="<?= $item['enclosure'] ?>" type="<?= $item['enclosure_type'] ?>">
|
||||||
|
</video>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if (isset($item_nav)): ?>
|
<?php if (isset($item_nav)): ?>
|
||||||
|
4
vendor/PicoFeed/Filter.php
vendored
4
vendor/PicoFeed/Filter.php
vendored
@ -315,7 +315,7 @@ class Filter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getAbsoluteUrl($path, $url)
|
public static function getAbsoluteUrl($path, $url)
|
||||||
{
|
{
|
||||||
$components = parse_url($url);
|
$components = parse_url($url);
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ class Filter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function isRelativePath($value)
|
public static function isRelativePath($value)
|
||||||
{
|
{
|
||||||
if (strpos($value, 'data:') === 0) return false;
|
if (strpos($value, 'data:') === 0) return false;
|
||||||
return strpos($value, '://') === false && strpos($value, '//') !== 0;
|
return strpos($value, '://') === false && strpos($value, '//') !== 0;
|
||||||
|
18
vendor/PicoFeed/Parsers/Atom.php
vendored
18
vendor/PicoFeed/Parsers/Atom.php
vendored
@ -44,6 +44,19 @@ class Atom extends \PicoFeed\Parser
|
|||||||
|
|
||||||
if (empty($item->title)) $item->title = $item->url;
|
if (empty($item->title)) $item->title = $item->url;
|
||||||
|
|
||||||
|
// Try to find an enclosure
|
||||||
|
foreach ($entry->link as $link) {
|
||||||
|
if ((string) $link['rel'] === 'enclosure') {
|
||||||
|
$item->enclosure = (string) $link['href'];
|
||||||
|
$item->enclosure_type = (string) $link['type'];
|
||||||
|
|
||||||
|
if (\PicoFeed\Filter::isRelativePath($item->enclosure)) {
|
||||||
|
$item->enclosure = \PicoFeed\Filter::getAbsoluteUrl($item->enclosure, $this->url);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,16 +71,13 @@ class Atom extends \PicoFeed\Parser
|
|||||||
if (isset($entry->content) && ! empty($entry->content)) {
|
if (isset($entry->content) && ! empty($entry->content)) {
|
||||||
|
|
||||||
if (count($entry->content->children())) {
|
if (count($entry->content->children())) {
|
||||||
|
|
||||||
return (string) $entry->content->asXML();
|
return (string) $entry->content->asXML();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
return (string) $entry->content;
|
return (string) $entry->content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isset($entry->summary) && ! empty($entry->summary)) {
|
else if (isset($entry->summary) && ! empty($entry->summary)) {
|
||||||
|
|
||||||
return (string) $entry->summary;
|
return (string) $entry->summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +88,7 @@ class Atom extends \PicoFeed\Parser
|
|||||||
public function getUrl($xml)
|
public function getUrl($xml)
|
||||||
{
|
{
|
||||||
foreach ($xml->link as $link) {
|
foreach ($xml->link as $link) {
|
||||||
|
|
||||||
if ((string) $link['type'] === 'text/html' || (string) $link['type'] === 'application/xhtml+xml') {
|
if ((string) $link['type'] === 'text/html' || (string) $link['type'] === 'application/xhtml+xml') {
|
||||||
|
|
||||||
return (string) $link['href'];
|
return (string) $link['href'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
vendor/PicoFeed/Parsers/Rss20.php
vendored
19
vendor/PicoFeed/Parsers/Rss20.php
vendored
@ -58,16 +58,21 @@ class Rss20 extends \PicoFeed\Parser
|
|||||||
$item->author= '';
|
$item->author= '';
|
||||||
$item->updated = '';
|
$item->updated = '';
|
||||||
$item->content = '';
|
$item->content = '';
|
||||||
|
$item->enclosure = '';
|
||||||
|
$item->enclosure_type = '';
|
||||||
|
|
||||||
foreach ($namespaces as $name => $url) {
|
foreach ($namespaces as $name => $url) {
|
||||||
|
|
||||||
$namespace = $entry->children($namespaces[$name]);
|
$namespace = $entry->children($namespaces[$name]);
|
||||||
|
|
||||||
if (! $item->url && ! empty($namespace->origLink)) $item->url = (string) $namespace->origLink;
|
|
||||||
if (! $item->author && ! empty($namespace->creator)) $item->author = (string) $namespace->creator;
|
if (! $item->author && ! empty($namespace->creator)) $item->author = (string) $namespace->creator;
|
||||||
if (! $item->updated && ! empty($namespace->date)) $item->updated = $this->parseDate((string) $namespace->date);
|
if (! $item->updated && ! empty($namespace->date)) $item->updated = $this->parseDate((string) $namespace->date);
|
||||||
if (! $item->updated && ! empty($namespace->updated)) $item->updated = $this->parseDate((string) $namespace->updated);
|
if (! $item->updated && ! empty($namespace->updated)) $item->updated = $this->parseDate((string) $namespace->updated);
|
||||||
if (! $item->content && ! empty($namespace->encoded)) $item->content = (string) $namespace->encoded;
|
if (! $item->content && ! empty($namespace->encoded)) $item->content = (string) $namespace->encoded;
|
||||||
|
|
||||||
|
// Get FeedBurner original links
|
||||||
|
if (! $item->url && ! empty($namespace->origLink)) $item->url = (string) $namespace->origLink;
|
||||||
|
if (! $item->enclosure && ! empty($namespace->origEnclosureLink)) $item->enclosure = (string) $namespace->origEnclosureLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($item->url)) {
|
if (empty($item->url)) {
|
||||||
@ -112,8 +117,16 @@ class Rss20 extends \PicoFeed\Parser
|
|||||||
|
|
||||||
// if optional enclosure tag with multimedia provided, capture here
|
// if optional enclosure tag with multimedia provided, capture here
|
||||||
if (isset($entry->enclosure)) {
|
if (isset($entry->enclosure)) {
|
||||||
$item->enclosure = (string) $entry->enclosure['url'];
|
|
||||||
// \PicoFeed\Logging::log(\get_called_class().': recorded enclosure ('.(string) $item->enclosure.')');
|
if (! $item->enclosure) {
|
||||||
|
$item->enclosure = isset($entry->enclosure['url']) ? (string) $entry->enclosure['url'] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$item->enclosure_type = isset($entry->enclosure['type']) ? (string) $entry->enclosure['type'] : '';
|
||||||
|
|
||||||
|
if (\PicoFeed\Filter::isRelativePath($item->enclosure)) {
|
||||||
|
$item->enclosure = \PicoFeed\Filter::getAbsoluteUrl($item->enclosure, $this->url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$item->content = $this->filterHtml($item->content, $item->url);
|
$item->content = $this->filterHtml($item->content, $item->url);
|
||||||
|
Loading…
Reference in New Issue
Block a user