From 72f40fbd75aaa007126335810c2781361895e76f Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Sat, 12 Nov 2016 22:04:42 +0100 Subject: [PATCH 1/2] [formats] Allow multiple enclosures All formats now support multiple enclosures. RSS will show a warning if more than one enclosure is used since many feed reader don't support multiple enclosures with RSS (also not clearly specified in the specification) --- formats/AtomFormat.php | 13 +++++++++---- formats/HtmlFormat.php | 22 ++++++++++++++++------ formats/MrssFormat.php | 24 +++++++++++++++++++----- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index 1944905f..bb9abb5b 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -27,9 +27,14 @@ class AtomFormat extends FormatAbstract{ $entryTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_ATOM, $item['timestamp'])) : ''; $entryContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : ''; - $entryEnclosure = ''; - if(isset($item['enclosure'])){ - $entryEnclosure = ''; + $entryEnclosures = ''; + if(isset($item['enclosures'])){ + foreach($item['enclosures'] as $enclosure){ + $entryEnclosures .= '' + . PHP_EOL; + } } $entries .= <<{$entryUri} {$entryTimestamp} {$entryContent} - {$entryEnclosure} + {$entryEnclosures} EOD; diff --git a/formats/HtmlFormat.php b/formats/HtmlFormat.php index 8f96466b..3e5e59de 100644 --- a/formats/HtmlFormat.php +++ b/formats/HtmlFormat.php @@ -30,11 +30,21 @@ class HtmlFormat extends FormatAbstract { . ''; } - $entryEnclosure = ''; - if(isset($item['enclosure'])){ - $entryEnclosure = '
enclosure
'; + $entryEnclosures = ''; + if(isset($item['enclosures'])){ + $entryEnclosures = '

Attachments:

'; + + foreach($item['enclosures'] as $enclosure){ + $url = $this->sanitizeHtml($enclosure); + + $entryEnclosures .= '
  • ' + . substr($url, strrpos($url, '/') + 1) + . '
  • '; + } + + $entryEnclosures .= '
    '; } $entries .= << EOD; diff --git a/formats/MrssFormat.php b/formats/MrssFormat.php index 19c703ea..a7573f56 100644 --- a/formats/MrssFormat.php +++ b/formats/MrssFormat.php @@ -31,9 +31,23 @@ class MrssFormat extends FormatAbstract { $itemTimestamp = isset($item['timestamp']) ? $this->xml_encode(date(DATE_RFC2822, $item['timestamp'])) : ''; $itemContent = isset($item['content']) ? $this->xml_encode($this->sanitizeHtml($item['content'])) : ''; - $entryEnclosure = ''; - if(isset($item['enclosure'])){ - $entryEnclosure = ''; + $entryEnclosuresWarning = ''; + $entryEnclosures = ''; + if(isset($item['enclosures'])){ + $entryEnclosures .= ''; + + if(count($item['enclosures']) > 1){ + $entryEnclosures .= PHP_EOL; + $entryEnclosuresWarning = '<br>Warning: +Some media files might not be shown to you. Consider using the ATOM format instead!'; + foreach($item['enclosures'] as $enclosure){ + $entryEnclosures .= '' + . PHP_EOL; + } + } } $items .= <<{$itemUri} {$itemUri} {$itemTimestamp} - {$itemContent} + {$itemContent}{$entryEnclosuresWarning} {$itemAuthor} - {$entryEnclosure} + {$entryEnclosures} EOD; From 8d417185537a8f88c000e512d33fb9b6113667e7 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 16 Nov 2016 16:27:17 +0100 Subject: [PATCH 2/2] [HtmlFormat] Update stylesheet for attachments --- css/HtmlFormat.css | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/css/HtmlFormat.css b/css/HtmlFormat.css index cee20207..b7e0d0eb 100644 --- a/css/HtmlFormat.css +++ b/css/HtmlFormat.css @@ -70,12 +70,19 @@ a.backlink, a.backlink:link, a.backlink:visited, a.itemtitle, a.itemtitle:link, } -section > div.content { +section > div.content, section > div.attachments { padding: 10px; } +section > div.attachments > li.enclosure { + + list-style-type: circle; + list-style-position: inside; + +} + section > time, section > p.author { color: #888;