From 8d4dbb9a8034deda27a3ff6b704077352a6bb5be Mon Sep 17 00:00:00 2001 From: Derek Date: Sat, 19 Aug 2023 20:44:11 +0800 Subject: [PATCH] fix(route): update v2/scitation to v2/aip (#12955) * fix(route): scitation/journal * fix(docs): scitation/journal * fix(docs): (en) scitation/journal * chores * fix(radar): scitation/journal * fix(radar): scitation/journal * fix(radar): scitation/journal * style: auto format * fix(route): mv scitation to aip * fix(route): v2/AIP chores * fix(docs): v2/aip docs * fix(docs): chores: jounus/advanced/advanced-feed * fix(docs): update en docs * fix(docs): not right close the * fix(docs): correct some mistake * Update lib/v2/aip/radar.js --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .../journal.js => aip/journal-pupp.js} | 4 +- lib/v2/aip/journal.js | 55 ++++++++++++++ lib/v2/{scitation => aip}/maintainer.js | 1 - lib/v2/aip/radar.js | 13 ++++ lib/v2/aip/router.js | 4 + .../templates/description.art | 0 lib/v2/{scitation => aip}/utils.js | 0 lib/v2/scitation/radar.js | 19 ----- lib/v2/scitation/router.js | 4 - lib/v2/scitation/section.js | 76 ------------------- website/docs/joinus/advanced/advanced-feed.md | 2 +- website/docs/routes/journal.md | 26 ++++--- .../current/routes/journal.md | 26 ++++--- 13 files changed, 107 insertions(+), 123 deletions(-) rename lib/v2/{scitation/journal.js => aip/journal-pupp.js} (94%) create mode 100644 lib/v2/aip/journal.js rename lib/v2/{scitation => aip}/maintainer.js (56%) create mode 100644 lib/v2/aip/radar.js create mode 100644 lib/v2/aip/router.js rename lib/v2/{scitation => aip}/templates/description.art (100%) rename lib/v2/{scitation => aip}/utils.js (100%) delete mode 100644 lib/v2/scitation/radar.js delete mode 100644 lib/v2/scitation/router.js delete mode 100644 lib/v2/scitation/section.js diff --git a/lib/v2/scitation/journal.js b/lib/v2/aip/journal-pupp.js similarity index 94% rename from lib/v2/scitation/journal.js rename to lib/v2/aip/journal-pupp.js index 3c437e4ec7..e11d146f6e 100644 --- a/lib/v2/scitation/journal.js +++ b/lib/v2/aip/journal-pupp.js @@ -6,8 +6,8 @@ const { isValidHost } = require('@/utils/valid-host'); module.exports = async (ctx) => { const pub = ctx.params.pub; const jrn = ctx.params.jrn; - const host = `https://${pub}.scitation.org`; - const jrnlUrl = `${host}/toc/${jrn}/current?size=all`; + const host = `https://pubs.aip.org`; + const jrnlUrl = `${host}/${pub}/${jrn}/issue`; if (!isValidHost(pub)) { throw Error('Invalid pub'); } diff --git a/lib/v2/aip/journal.js b/lib/v2/aip/journal.js new file mode 100644 index 0000000000..9c32f52cd7 --- /dev/null +++ b/lib/v2/aip/journal.js @@ -0,0 +1,55 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { renderDesc } = require('./utils'); + +module.exports = async (ctx) => { + const pub = ctx.params.pub; + const jrn = ctx.params.jrn; + const host = `https://pubs.aip.org`; + const jrnlUrl = `${host}/${pub}/${jrn}/issue`; + + const { data: response } = await got.get(jrnlUrl); + const $ = cheerio.load(response); + const jrnlName = $('meta[property="og:title"]') + .attr('content') + .match(/(?:[^=]*=)?\s*([^>]+)\s*/)[1]; + const publication = $('.al-article-item-wrap.al-normal'); + + const list = publication + .map((_, item) => { + const title = $(item).find('.item-title a:first').text(); + const link = $(item).find('.item-title a:first').attr('href'); + const doilink = $(item).find('.citation-label a').attr('href'); + const doi = doilink && doilink.match(/10\.\d+\/\S+/)[0]; + const id = $(item).find('h5[data-resource-id-access]').data('resource-id-access'); + const authors = $(item) + .find('.al-authors-list') + .find('a') + .map(function () { + return $(this).text(); + }) + .get() + .join('; '); + const imgUrl = $(item).find('.issue-featured-image a img').attr('src'); + const img = imgUrl ? imgUrl.replace(/\?.+$/, '') : ''; + const description = renderDesc(title, authors, doi, img); + return { + title, + link, + doilink, + id, + authors, + img, + doi, + description, + }; + }) + .get(); + + ctx.state.data = { + title: jrnlName, + link: jrnlUrl, + item: list, + allowEmpty: true, + }; +}; diff --git a/lib/v2/scitation/maintainer.js b/lib/v2/aip/maintainer.js similarity index 56% rename from lib/v2/scitation/maintainer.js rename to lib/v2/aip/maintainer.js index 574573dd9c..10beeda6c5 100644 --- a/lib/v2/scitation/maintainer.js +++ b/lib/v2/aip/maintainer.js @@ -1,4 +1,3 @@ module.exports = { '/:pub/:jrn': ['Derekmini', 'auto-bot-ty'], - '/:pub/:jrn/:sec': ['Derekmini', 'auto-bot-ty'], }; diff --git a/lib/v2/aip/radar.js b/lib/v2/aip/radar.js new file mode 100644 index 0000000000..358de94184 --- /dev/null +++ b/lib/v2/aip/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'aip.org': { + _name: 'American Institute of Physics', + pubs: [ + { + title: 'Journal', + docs: 'https://docs.rsshub.app/routes/journal#american-institute-of-physics', + source: '/:pub/:jrn', + target: '/aip/:pub/:jrn', + }, + ], + }, +}; diff --git a/lib/v2/aip/router.js b/lib/v2/aip/router.js new file mode 100644 index 0000000000..2164ed7a99 --- /dev/null +++ b/lib/v2/aip/router.js @@ -0,0 +1,4 @@ +module.exports = function (router) { + router.get('/:pub/:jrn', require('./journal')); + // router.get('/:pub/:jrn', require('./journal-pupp')); // Switch to this route if the official website blocks the "got" method. +}; diff --git a/lib/v2/scitation/templates/description.art b/lib/v2/aip/templates/description.art similarity index 100% rename from lib/v2/scitation/templates/description.art rename to lib/v2/aip/templates/description.art diff --git a/lib/v2/scitation/utils.js b/lib/v2/aip/utils.js similarity index 100% rename from lib/v2/scitation/utils.js rename to lib/v2/aip/utils.js diff --git a/lib/v2/scitation/radar.js b/lib/v2/scitation/radar.js deleted file mode 100644 index f3804079bd..0000000000 --- a/lib/v2/scitation/radar.js +++ /dev/null @@ -1,19 +0,0 @@ -module.exports = { - 'scitation.org': { - _name: 'scitation', - '.': [ - { - title: 'journal', - docs: 'https://docs.rsshub.app/routes/journal#scitation', - source: ':pub.scitation.org/toc/:jrn', - target: '/scitation/:pub/:jrn', - }, - { - title: 'section', - docs: 'https://docs.rsshub.app/routes/journal#scitation', - source: ':pub.scitation.org/toc/:jrn', - target: (params, url) => `/scitation/:pub/:jrn/${new URL(url).searchParams.get('tocSection')}`, - }, - ], - }, -}; diff --git a/lib/v2/scitation/router.js b/lib/v2/scitation/router.js deleted file mode 100644 index 4090a5fdc3..0000000000 --- a/lib/v2/scitation/router.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = function (router) { - router.get('/:pub/:jrn', require('./journal')); - router.get('/:pub/:jrn/:sec', require('./section')); -}; diff --git a/lib/v2/scitation/section.js b/lib/v2/scitation/section.js deleted file mode 100644 index ae307f61cf..0000000000 --- a/lib/v2/scitation/section.js +++ /dev/null @@ -1,76 +0,0 @@ -const cheerio = require('cheerio'); -const { puppeteerGet, renderDesc } = require('./utils'); -const config = require('@/config').value; -const { isValidHost } = require('@/utils/valid-host'); - -module.exports = async (ctx) => { - const pub = ctx.params.pub; - const jrn = ctx.params.jrn; - const sec = ctx.params.sec.split('+').join(' '); - const host = `https://${pub}.scitation.org`; - const jrnlUrl = `${host}/toc/${jrn}/current?size=all`; - if (!isValidHost(pub)) { - throw Error('Invalid pub'); - } - - // use Puppeteer due to the obstacle by cloudflare challenge - const browser = await require('@/utils/puppeteer')(); - - const response = await puppeteerGet(jrnlUrl, browser); - const $ = cheerio.load(response); - const jrnlName = $('.header-journal-title').text(); - const issueUrl = $('.row.js_issue.highlighted').find('a').attr('href'); - const section = $('.subject-heading') - .toArray() - .map((item) => ({ - name: $(item).text(), - })); - - let ifContainSection = false; - for (let i = 0, l = section.length; i < l; i++) { - if (section[i].name === sec) { - ifContainSection = true; - } - } - - let list; - if (ifContainSection === true) { - const secUrl = `${issueUrl}?tocSection=${sec}`; - list = await ctx.cache.tryGet( - secUrl, - async () => { - const response2 = await puppeteerGet(secUrl, browser); - const $2 = cheerio.load(response2); - list = $2('.card') - .toArray() - .map((item) => { - $2(item).find('.access-text').remove(); - const title = $2(item).find('.hlFld-Title').text(); - const authors = $2(item).find('.entryAuthor.all').text(); - const img = $2(item).find('img').attr('src'); - const link = $2(item).find('.ref.nowrap').attr('href'); - const doi = link.replace('/doi/full/', ''); - const description = renderDesc(title, authors, doi, img); - return { - title, - link, - doi, - description, - }; - }); - return list; - }, - config.cache.routeExpire, - false - ); - } - - browser.close(); - - ctx.state.data = { - title: jrnlName.concat(' - ', sec), - link: jrnlUrl, - item: list, - allowEmpty: true, - }; -}; diff --git a/website/docs/joinus/advanced/advanced-feed.md b/website/docs/joinus/advanced/advanced-feed.md index 2163481e30..945a74f622 100644 --- a/website/docs/joinus/advanced/advanced-feed.md +++ b/website/docs/joinus/advanced/advanced-feed.md @@ -113,7 +113,7 @@ ctx.state.data = { ### 更新文档 -要显示您制作的期刊订阅源支持 Sui-hub 功能,您需要将 `Route` 组件的 `supportScihub` 属性设置为 `"1"`。以下是一个示例: +要显示您制作的期刊订阅源支持 Sci-hub 功能,您需要将 `Route` 组件的 `supportScihub` 属性设置为 `"1"`。以下是一个示例: ```vue diff --git a/website/docs/routes/journal.md b/website/docs/routes/journal.md index f1ae84f80e..2e02582974 100644 --- a/website/docs/routes/journal.md +++ b/website/docs/routes/journal.md @@ -61,6 +61,22 @@ import Route from '@site/src/components/Route'; +## American Institute of Physics {#american-institute-of-physics} + +### Journal {#american-institute-of-physics-journal} + + + +参考 URL 格式 `pubs.aip.org/:pub/:jrn` + +:::tip 提示 + +更多期刊可在 [AIP Publications](https://publishing.aip.org/publications/find-the-right-journal) 中找到。 + +::: + + + ## Annual Reviews {#annual-reviews} ### Journal {#annual-reviews-journal} @@ -398,16 +414,6 @@ You can get all short name of a journal from -## Scitation {#scitation} - -### 期刊 {#scitation-qi-kan} - - - -### 专栏 {#scitation-zhuan-lan} - - - ## Springer {#springer} ### 期刊 {#springer-qi-kan} diff --git a/website/i18n/en/docusaurus-plugin-content-docs/current/routes/journal.md b/website/i18n/en/docusaurus-plugin-content-docs/current/routes/journal.md index 1bebeab655..ef6cbdee1a 100644 --- a/website/i18n/en/docusaurus-plugin-content-docs/current/routes/journal.md +++ b/website/i18n/en/docusaurus-plugin-content-docs/current/routes/journal.md @@ -61,6 +61,22 @@ More jounals can be found in [AEA Journals](https://www.aeaweb.org/journals). +## American Institute of Physics + +### Journal + + + +Refer to the URL format `pubs.aip.org/:pub/:jrn` + +:::tip Tip + +More jounals can be found in [AIP Publications](https://publishing.aip.org/publications/find-the-right-journal). + +::: + + + ## Annual Reviews ### Journal @@ -427,16 +443,6 @@ To subscribe to [IN THE PIPELINE by Derek Lowe’s](https://science.org/blogs/pi -## Scitation - -### Journal - - - -### Section - - - ## Springer ### Journal