diff --git a/docs/en/journal.md b/docs/en/journal.md index bfbdd6d3bb..547cc266b7 100644 --- a/docs/en/journal.md +++ b/docs/en/journal.md @@ -124,6 +124,10 @@ New items may always at the end of the list, when the number of paper entries is +## INFORMS + + + ## JASA ### Latest Research diff --git a/docs/en/new-media.md b/docs/en/new-media.md index 6d55f5a5c1..41589daf8a 100644 --- a/docs/en/new-media.md +++ b/docs/en/new-media.md @@ -626,7 +626,7 @@ Language | ------- | ------- | ---- | -------- | ------- | ------- | --------- | | en | ar | zh | fr | ru | es | pt | - + ### Newsroom @@ -642,4 +642,4 @@ Language | ------- | ------- | ---- | -------- | ------- | ------- | --------- | | en | ar | zh | fr | ru | es | pt | - + diff --git a/docs/journal.md b/docs/journal.md index 5b1810353d..8895132193 100644 --- a/docs/journal.md +++ b/docs/journal.md @@ -120,6 +120,10 @@ pageClass: routes +## INFORMS + + + ## JASA ### 最新文章 diff --git a/lib/v2/informs/index.js b/lib/v2/informs/index.js new file mode 100644 index 0000000000..73a0cf4903 --- /dev/null +++ b/lib/v2/informs/index.js @@ -0,0 +1,74 @@ +const config = require('@/config').value; +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { art } = require('@/utils/render'); +const path = require('path'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'https://pubsonline.informs.org'; + +module.exports = async (ctx) => { + const category = ctx.params.category ?? 'orsc'; + const cateUrl = `${rootUrl}/toc/${category}/0/0`; + + const getCookie = () => + ctx.cache.tryGet(cateUrl, async () => { + const setCookiesUrl = `${cateUrl}?cookieSet=1`; + + const response = await got.extend({ followRedirect: false }).get(setCookiesUrl, { + headers: { + Referer: cateUrl, + }, + }); + const cookie = response.headers['set-cookie'] + .slice(1) + .map((item) => item.split(';')[0]) + .join('; '); + + return cookie; + }); + + const response = await got.get(cateUrl, { + headers: { + referer: cateUrl, + 'User-Agent': config.ua, + cookie: await getCookie(), + }, + }); + const $ = cheerio.load(response.data); + const list = $('div.issue-item') + .slice(0, 10) + .map((_, item) => ({ + title: $(item).find('h5.issue-item__title').text(), + link: `${rootUrl}${$(item).find('h5.issue-item__title > a').attr('href')}`, + pubDate: parseDate($(item).find('div.rlist--inline.separator.toc-item__detail > p').remove('span').text()), + })) + .get(); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got.get(item.link, { + headers: { + referer: cateUrl, + 'User-Agent': config.ua, + cookie: await getCookie(), + }, + }); + const detail = cheerio.load(detailResponse.data); + item.description = art(path.join(__dirname, 'templates/content.art'), { + author: detail('div.accordion-tabbed.loa-accordion').text(), + content: detail('div.hlFld-Abstract').find('h2').replaceWith($('

Abstract

')).end().html(), + }); + + return item; + }) + ) + ); + + ctx.state.data = { + title: `INFORMS - ${category}`, + link: cateUrl, + item: items, + }; +}; diff --git a/lib/v2/informs/maintainer.js b/lib/v2/informs/maintainer.js new file mode 100644 index 0000000000..406522b47b --- /dev/null +++ b/lib/v2/informs/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:category?': ['Fatpandac'], +}; diff --git a/lib/v2/informs/radar.js b/lib/v2/informs/radar.js new file mode 100644 index 0000000000..75b573aead --- /dev/null +++ b/lib/v2/informs/radar.js @@ -0,0 +1,109 @@ +module.exports = { + 'informs.org': { + _name: 'INFORMS', + pubsonline: [ + { + title: 'Decision Analysis', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/deca', '/toc/deca/0/0'], + target: `/informs/deca`, + }, + { + title: 'Marketing Science', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/mksc', '/toc/mksc/0/0'], + target: `/informs/mksc`, + }, + { + title: 'Information Systems Research', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/isrc', '/toc/isrc/0/0'], + target: `/informs/isrc`, + }, + { + title: 'Mathematics of Operations Research', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/moor', '/toc/moor/0/0'], + target: `/informs/moor`, + }, + { + title: 'INFORMS Journal on Applied Analytics', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/inte', '/toc/inte/0/0'], + target: `/informs/inte`, + }, + { + title: 'Operations Research', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/opre', '/toc/opre/0/0'], + target: `/informs/opre`, + }, + { + title: 'INFORMS Journal on Computing', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/ijoc', '/toc/ijoc/0/0'], + target: `/informs/ijoc`, + }, + { + title: 'Organization Science', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/orsc', '/toc/orsc/0/0'], + target: `/informs/orsc`, + }, + { + title: 'INFORMS Journal on Data Science', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/ijds', '/toc/ijds/0/0'], + target: `/informs/ijds`, + }, + { + title: 'Service Science', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/serv', '/toc/serv/0/0'], + target: `/informs/serv`, + }, + { + title: 'INFORMS Journal on Optimization', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/ijoo', '/toc/ijoo/0/0'], + target: `/informs/ijoo`, + }, + { + title: 'Stochastic Systems', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/stsy', '/toc/stsy/0/0'], + target: `/informs/stsy`, + }, + { + title: 'INFORMS Transactions on Education', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/ited', '/toc/ited/0/0'], + target: `/informs/ited`, + }, + { + title: 'Strategy Science', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/stsc', '/toc/stsc/0/0'], + target: `/informs/stsc`, + }, + { + title: 'Management Science', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/mnsc', '/toc/mnsc/0/0'], + target: `/informs/mnsc`, + }, + { + title: 'Transportation Science', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/trsc', '/toc/trsc/0/0'], + target: `/informs/trsc`, + }, + { + title: 'Manufacturing & Service Operations Management', + docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + source: ['/journal/msom', '/toc/msom/0/0'], + target: `/informs/msom`, + }, + ], + }, +}; diff --git a/lib/v2/informs/router.js b/lib/v2/informs/router.js new file mode 100644 index 0000000000..cf781366fd --- /dev/null +++ b/lib/v2/informs/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:category?', require('./index')); +}; diff --git a/lib/v2/informs/templates/content.art b/lib/v2/informs/templates/content.art new file mode 100644 index 0000000000..a8349d2219 --- /dev/null +++ b/lib/v2/informs/templates/content.art @@ -0,0 +1,3 @@ + {{ author }} +
+{{ content }}