From 8cc0dfa231fc4ec02c3d9930d3bfaa6ed27d806b Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Wed, 6 Jan 2021 15:49:58 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=E7=AE=80=E9=98=85(simpread)=20noti?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/program-update.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/simpread/notice.js | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 lib/routes/simpread/notice.js diff --git a/docs/program-update.md b/docs/program-update.md index 5cddf1086..a2dafca86 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -433,3 +433,9 @@ pageClass: routes | | -commentCount | -createdAt | createdAt | + +## simpread + +### 消息通知 + + diff --git a/lib/router.js b/lib/router.js index 5bb0f656c..e9f57e387 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3780,4 +3780,7 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog')); // Caixin Latest router.get('/caixin/latest', require('./routes/caixin/latest')); +// SimpRead +router.get('/simpread/notice', require('./routes/simpread/notice')); + module.exports = router; diff --git a/lib/routes/simpread/notice.js b/lib/routes/simpread/notice.js new file mode 100644 index 000000000..a6ef1a11d --- /dev/null +++ b/lib/routes/simpread/notice.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); +const md = require('markdown-it')(); + +module.exports = async (ctx) => { + const url = 'https://static.simp.red/notice'; + const response = await got.get(url); + const data = response.data.notice; + ctx.state.data = { + title: 'SimpRead 消息通知', + link: url, + description: 'SimpRead 消息通知', + item: data.map((item) => ({ + description: md.render(item.content), + link: url, + pubDate: item.date, + title: `${item.category.name}-${item.title}`, + author: 'SimpRead', + })), + }; +}; From da9be824ee48c647499cc8d12bdddacc3e948e85 Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Thu, 7 Jan 2021 17:57:33 +0800 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=E7=AE=80=E9=98=85(simpread)=20chan?= =?UTF-8?q?gelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/program-update.md | 3 ++ lib/router.js | 5 ++- lib/routes/simpread/changelog.js | 77 ++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 lib/routes/simpread/changelog.js diff --git a/docs/program-update.md b/docs/program-update.md index a2dafca86..706791de6 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -439,3 +439,6 @@ pageClass: routes ### 消息通知 + +### 更新日志 + diff --git a/lib/router.js b/lib/router.js index e9f57e387..2da405237 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3780,7 +3780,10 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog')); // Caixin Latest router.get('/caixin/latest', require('./routes/caixin/latest')); -// SimpRead +// SimpRead-消息通知 router.get('/simpread/notice', require('./routes/simpread/notice')); +// SimpRead-更新日志 +router.get('/simpread/changelog', require('./routes/simpread/changelog')); + module.exports = router; diff --git a/lib/routes/simpread/changelog.js b/lib/routes/simpread/changelog.js new file mode 100644 index 000000000..d7ad05d76 --- /dev/null +++ b/lib/routes/simpread/changelog.js @@ -0,0 +1,77 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://simpread.pro/changelog.html'; + const response = await got.get(url); + const data = response.data; + const $ = cheerio.load(data); + ctx.state.data = { + title: 'SimpRead 更新日志', + link: url, + description: $('body > div.container.changelog > div.desc').html(), + item: $('.version') + .map((index, item) => { + const year = $(item).find('.year').html(); + const month_day = $(item).find('.day').html(); + let version = ''; + let detail = ''; + + // 结构异化-收个version与后续version不同级 + if (index === 0) { + // 版本名称处理 + version = $($(item).find('.num > a')[0]).clone().children().remove().end().text(); + // detail处理 + detail = $($(item).find('.details')[0]); + } else { + // 版本名称处理 + version = $(item).find('.num > a').clone().children().remove().end().text(); + // detail处理 + detail = $(item).find('.details'); + } + if (version === '') { + version = $(item).find('.num').clone().children().remove().end().text(); + } + let version_type = $(item).find('.num > a > i').attr('class'); + // 部分结构不一致处理 + if (version_type === undefined) { + version_type = $(item).find('.num > i').attr('class'); + } + if (version_type.indexOf('chrome') !== -1) { + version_type = 'Chrome'; + } + if (version_type.indexOf('apple') !== -1) { + version_type = 'Safari'; + } + if (version_type.indexOf('code') !== -1) { + version_type = 'UserScript'; + } + if (version_type.indexOf('firefox') !== -1) { + version_type = 'Firefox'; + } + + $(detail) + .find('li') + .map((index, item) => { + const level = $(item).find('span').attr('class'); + if (level !== undefined) { + if (level.indexOf('empty') !== -1) { + $(item).wrap('
    '); + } else { + $(item).find('span').append('
    '); + } + } + return {}; + }); + + return { + description: $(detail).html(), + link: url, + pubDate: `${year}-${month_day.replace('.', '-')} 00:00:00 GMT`, + title: `${version_type}${version}`, + author: 'SimpRead', + }; + }) + .get(), + }; +}; From 2aca91a25e71b508cf74a9fb48bf57acc0bbd54c Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Fri, 8 Jan 2021 08:57:25 +0800 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20=E7=AE=80=E9=98=85(simpread)=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/program-update.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/program-update.md b/docs/program-update.md index 706791de6..b12003588 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -438,7 +438,7 @@ pageClass: routes ### 消息通知 - + ### 更新日志 - + From 7aec48e8d0f83c1fd640fef3583a235d07a5b08a Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Fri, 8 Jan 2021 12:41:47 +0800 Subject: [PATCH 4/8] =?UTF-8?q?fix:=20=E7=AE=80=E9=98=85(simpread)=20chang?= =?UTF-8?q?elog=E7=BB=93=E6=9E=84bug=E4=BF=AE=E5=A4=8D=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/simpread/changelog.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/routes/simpread/changelog.js b/lib/routes/simpread/changelog.js index d7ad05d76..5be450af7 100644 --- a/lib/routes/simpread/changelog.js +++ b/lib/routes/simpread/changelog.js @@ -16,19 +16,10 @@ module.exports = async (ctx) => { const month_day = $(item).find('.day').html(); let version = ''; let detail = ''; - - // 结构异化-收个version与后续version不同级 - if (index === 0) { - // 版本名称处理 - version = $($(item).find('.num > a')[0]).clone().children().remove().end().text(); - // detail处理 - detail = $($(item).find('.details')[0]); - } else { - // 版本名称处理 - version = $(item).find('.num > a').clone().children().remove().end().text(); - // detail处理 - detail = $(item).find('.details'); - } + // 版本名称处理 + version = $(item).find('.num > a').clone().children().remove().end().text(); + // detail处理 + detail = $(item).find('.details'); if (version === '') { version = $(item).find('.num').clone().children().remove().end().text(); } From 92ddaf6178c193ce799f82df00b4862332168cab Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Fri, 8 Jan 2021 13:20:07 +0800 Subject: [PATCH 5/8] =?UTF-8?q?fix:=20=E7=AE=80=E9=98=85(simpread)=20?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E5=AD=97=E7=AC=A6=E5=8E=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/simpread/changelog.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/routes/simpread/changelog.js b/lib/routes/simpread/changelog.js index 5be450af7..dfa3f8a14 100644 --- a/lib/routes/simpread/changelog.js +++ b/lib/routes/simpread/changelog.js @@ -45,11 +45,13 @@ module.exports = async (ctx) => { .find('li') .map((index, item) => { const level = $(item).find('span').attr('class'); + const text = $(item).find('span').html(); + $(item).find('span').remove(); if (level !== undefined) { if (level.indexOf('empty') !== -1) { $(item).wrap('
      '); } else { - $(item).find('span').append('
      '); + $(item).prepend(`${text}: `); } } return {}; From f17c4e92b8d199599b91379493b8970a3cbd5e21 Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Fri, 8 Jan 2021 14:31:28 +0800 Subject: [PATCH 6/8] =?UTF-8?q?fix:=20=E7=AE=80=E9=98=85(simpread)=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/simpread/changelog.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/routes/simpread/changelog.js b/lib/routes/simpread/changelog.js index dfa3f8a14..9665b4cb5 100644 --- a/lib/routes/simpread/changelog.js +++ b/lib/routes/simpread/changelog.js @@ -2,7 +2,7 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); module.exports = async (ctx) => { - const url = 'https://simpread.pro/changelog.html'; + const url = 'http://ksria.com/simpread/changelog.html'; const response = await got.get(url); const data = response.data; const $ = cheerio.load(data); @@ -41,17 +41,26 @@ module.exports = async (ctx) => { version_type = 'Firefox'; } + // detail + const text_color = { + important: '#9c27b0', + add: '#4caf50', + change: '#ffc107', + fix: '#f44336', + complete: '#03a9f4', + }; $(detail) .find('li') .map((index, item) => { - const level = $(item).find('span').attr('class'); + let span_class = $(item).find('span').attr('class'); const text = $(item).find('span').html(); $(item).find('span').remove(); - if (level !== undefined) { - if (level.indexOf('empty') !== -1) { + if (span_class !== undefined) { + span_class = span_class.split(' '); + if (span_class[1] === 'empty') { $(item).wrap('
        '); } else { - $(item).prepend(`${text}: `); + $(item).prepend(`${text}: `); } } return {}; From ce132be12e11a3b8565fa74503f8bbc34bdcf61e Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Fri, 8 Jan 2021 15:06:05 +0800 Subject: [PATCH 7/8] =?UTF-8?q?fix:=20=E7=AE=80=E9=98=85(simpread)=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/simpread/notice.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/simpread/notice.js b/lib/routes/simpread/notice.js index a6ef1a11d..8da1c99bc 100644 --- a/lib/routes/simpread/notice.js +++ b/lib/routes/simpread/notice.js @@ -7,11 +7,11 @@ module.exports = async (ctx) => { const data = response.data.notice; ctx.state.data = { title: 'SimpRead 消息通知', - link: url, + link: 'http://ksria.com/simpread/changelog.html', description: 'SimpRead 消息通知', item: data.map((item) => ({ description: md.render(item.content), - link: url, + link: 'http://ksria.com/simpread/changelog.html', pubDate: item.date, title: `${item.category.name}-${item.title}`, author: 'SimpRead', From 0747bfb9927475669b7e7f6602714d208509e6f2 Mon Sep 17 00:00:00 2001 From: zytomorrow Date: Fri, 8 Jan 2021 15:13:42 +0800 Subject: [PATCH 8/8] =?UTF-8?q?fix:=20=E7=AE=80=E9=98=85(simpread)=20?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=BE=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/simpread/changelog.js | 4 ++-- lib/routes/simpread/notice.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/routes/simpread/changelog.js b/lib/routes/simpread/changelog.js index 9665b4cb5..59ecaea8f 100644 --- a/lib/routes/simpread/changelog.js +++ b/lib/routes/simpread/changelog.js @@ -8,7 +8,7 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); ctx.state.data = { title: 'SimpRead 更新日志', - link: url, + link: 'https://simpread.pro/changelog.html', description: $('body > div.container.changelog > div.desc').html(), item: $('.version') .map((index, item) => { @@ -68,7 +68,7 @@ module.exports = async (ctx) => { return { description: $(detail).html(), - link: url, + link: 'https://simpread.pro/changelog.html', pubDate: `${year}-${month_day.replace('.', '-')} 00:00:00 GMT`, title: `${version_type}${version}`, author: 'SimpRead', diff --git a/lib/routes/simpread/notice.js b/lib/routes/simpread/notice.js index 8da1c99bc..79dd7950e 100644 --- a/lib/routes/simpread/notice.js +++ b/lib/routes/simpread/notice.js @@ -7,11 +7,11 @@ module.exports = async (ctx) => { const data = response.data.notice; ctx.state.data = { title: 'SimpRead 消息通知', - link: 'http://ksria.com/simpread/changelog.html', + link: 'https://simpread.pro/changelog.html', description: 'SimpRead 消息通知', item: data.map((item) => ({ description: md.render(item.content), - link: 'http://ksria.com/simpread/changelog.html', + link: 'https://simpread.pro/changelog.html', pubDate: item.date, title: `${item.category.name}-${item.title}`, author: 'SimpRead',