From 7e8d66eacd0f0572c779c177df97f08ce464d560 Mon Sep 17 00:00:00 2001 From: sgqy Date: Wed, 31 Oct 2018 11:02:01 +0800 Subject: [PATCH] rss category support (#1015) also do a bit fix of [solidot] feed --- routes/solidot/main.js | 21 ++++++++------------- views/atom.art | 4 +--- views/rss.art | 1 + 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/routes/solidot/main.js b/routes/solidot/main.js index 4a7be0cef..298c89035 100644 --- a/routes/solidot/main.js +++ b/routes/solidot/main.js @@ -46,19 +46,14 @@ module.exports = async (ctx) => { const cat_img = $(a[i]) .find('div.icon_float > a') .html(); - const date_raw = $(a[i]).find('div.talk_time'); - $(date_raw) - .find('div.icon_float') - .remove(); - $(date_raw) - .find('span.user') - .remove(); - $(date_raw) - .find('b') - .remove(); - const date_str_zh = $(date_raw) - .text() - .replace(/^[^`]*发表于(.*分)[^`]*$/g, '$1'); // use [^`] to match \n + const date_raw = $(a[i]) + .find('div.talk_time') + .clone() + .children() + .remove() + .end() + .text(); + const date_str_zh = date_raw.replace(/^[^`]*发表于(.*分)[^`]*$/g, '$1'); // use [^`] to match \n const date_str = date_str_zh .replace(/[年月]/g, '-') .replace(/时/g, ':') diff --git a/views/atom.art b/views/atom.art index 9ff6dca97..fa879eeb6 100644 --- a/views/atom.art +++ b/views/atom.art @@ -59,9 +59,7 @@ {{ /if }} {{ if $e.category }} - {{ each $e.category $c }} - - {{ /each }} + {{ /if }} diff --git a/views/rss.art b/views/rss.art index e8002091c..6546490a2 100644 --- a/views/rss.art +++ b/views/rss.art @@ -33,6 +33,7 @@ {{ if $value.enclosure_url }}{{ /if }} {{ if $value.itunes_duration }}{{ $value.itunes_duration }} {{ /if }} {{ if $value.author }}{{ /if }} + {{ if $value.category }}{{ $value.category }}{{ /if }} {{ /each }}