From 82adb01307e108e8a2b4eeb900552160d730d0b7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 14:10:46 +0300 Subject: render enclosures on the client --- js/Article.js | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'js/Article.js') diff --git a/js/Article.js b/js/Article.js index f8b0415b9..efe33bc99 100644 --- a/js/Article.js +++ b/js/Article.js @@ -140,6 +140,62 @@ const Article = { Headlines.toggleUnread(id, 0); }, + renderEnclosures: function (enclosures) { + + // enclosure list was handled by backend (HOOK_FORMAT_ENCLOSURES) + if (enclosures.formatted) + return enclosures.formatted; + + return ` + ${enclosures.can_inline ? + `
+ ${enclosures.entries.map((enc) => { + if (!enclosures.inline_text_only) { + if (enc.content_type && enc.content_type.indexOf("image/") != -1) { + return `

+ +

` + } else if (enc.content_type && enc.content_type.indexOf("audio/") != -1 && App.audioCanPlay(enc.content_type)) { + return `

+ +

+ `; + } else { + return `

+ ${App.escapeHtml(enc.content_url)} +

` + } + } else { + return `

+ ${App.escapeHtml(enc.content_url)} +

` + } + }).join("")} +
` : ''} + ${enclosures.entries.length > 0 ? + `
+ ${__('Attachments')} +
+ ${enclosures.entries.map((enc) => ` +
+ ${enc.title ? enc.title : enc.filename} +
+ `).join("")} +
+
` : ''} + ` + }, render: function (article) { App.cleanupMemory("content-insert"); @@ -241,7 +297,7 @@ const Article = {
${hl.note}
${hl.content} - ${hl.enclosures} + ${Article.renderEnclosures(hl.enclosures)}
`; -- cgit v1.2.3