From 049ee52fb5e044628195425655338c379602435e Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Mon, 16 Jul 2018 15:32:24 +0500 Subject: [PATCH] Implemented feed item categories (#746) --- formats/AtomFormat.php | 11 +++++++++++ formats/HtmlFormat.php | 15 +++++++++++++++ formats/MrssFormat.php | 11 +++++++++++ static/HtmlFormat.css | 4 +++- 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/formats/AtomFormat.php b/formats/AtomFormat.php index 6ebdf771..9bd08bd1 100644 --- a/formats/AtomFormat.php +++ b/formats/AtomFormat.php @@ -40,6 +40,16 @@ class AtomFormat extends FormatAbstract{ } } + $entryCategories = ''; + if(isset($item['categories'])) { + foreach($item['categories'] as $category) { + $entryCategories .= '' + . PHP_EOL; + } + } + $entries .= << @@ -52,6 +62,7 @@ class AtomFormat extends FormatAbstract{ {$entryTimestamp} {$entryContent} {$entryEnclosures} + {$entryCategories} EOD; diff --git a/formats/HtmlFormat.php b/formats/HtmlFormat.php index fc4adcc0..c4c5012a 100644 --- a/formats/HtmlFormat.php +++ b/formats/HtmlFormat.php @@ -47,6 +47,20 @@ class HtmlFormat extends FormatAbstract { $entryEnclosures .= ''; } + $entryCategories = ''; + if(isset($item['categories'])) { + $entryCategories = '

Categories:

'; + + foreach($item['categories'] as $category) { + + $entryCategories .= '
  • ' + . $this->sanitizeHtml($category) + . '
  • '; + } + + $entryCategories .= '
    '; + } + $entries .= << @@ -55,6 +69,7 @@ class HtmlFormat extends FormatAbstract { {$entryAuthor} {$entryContent} {$entryEnclosures} + {$entryCategories} EOD; diff --git a/formats/MrssFormat.php b/formats/MrssFormat.php index 8f54ef0b..6d079288 100644 --- a/formats/MrssFormat.php +++ b/formats/MrssFormat.php @@ -51,6 +51,16 @@ Some media files might not be shown to you. Consider using the ATOM format inste } } + $entryCategories = ''; + if(isset($item['categories'])) { + + foreach($item['categories'] as $category) { + $entryCategories .= '' + . $category . '' + . PHP_EOL; + } + } + $items .= << @@ -61,6 +71,7 @@ Some media files might not be shown to you. Consider using the ATOM format inste {$itemContent}{$entryEnclosuresWarning} {$itemAuthor} {$entryEnclosures} + {$entryCategories} EOD; diff --git a/static/HtmlFormat.css b/static/HtmlFormat.css index 9e0ee13e..195a9b0d 100644 --- a/static/HtmlFormat.css +++ b/static/HtmlFormat.css @@ -69,12 +69,14 @@ a.backlink, a.backlink:link, a.backlink:visited, a.itemtitle, a.itemtitle:link, } +section > div.content, section > div.categories, section > div.content, section > div.attachments { padding: 10px; } +section > div.categories > li.category, section > div.attachments > li.enclosure { list-style-type: circle; @@ -114,4 +116,4 @@ img { max-width: 100%; -} \ No newline at end of file +}