diff --git a/package-lock.json b/package-lock.json index c180f35..3b08453 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "fs": "^0.0.1-security", "hbs": "^4.2.0", "japanese-date-converter": "^2.0.0", + "rss": "^1.2.2", "serve-index": "^1.9.1" }, "devDependencies": { @@ -1001,6 +1002,37 @@ "node": ">= 0.8" } }, + "node_modules/rss": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/rss/-/rss-1.2.2.tgz", + "integrity": "sha512-xUhRTgslHeCBeHAqaWSbOYTydN2f0tAzNXvzh3stjz7QDhQMzdgHf3pfgNIngeytQflrFPfy6axHilTETr6gDg==", + "license": "MIT", + "dependencies": { + "mime-types": "2.1.13", + "xml": "1.0.1" + } + }, + "node_modules/rss/node_modules/mime-db": { + "version": "1.25.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.25.0.tgz", + "integrity": "sha512-5k547tI4Cy+Lddr/hdjNbBEWBwSl8EBc5aSdKvedav8DReADgWJzcYiktaRIw3GtGC1jjwldXtTzvqJZmtvC7w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/rss/node_modules/mime-types": { + "version": "2.1.13", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.13.tgz", + "integrity": "sha512-ryBDp1Z/6X90UvjUK3RksH0IBPM137T7cmg4OgD5wQBojlAiUwuok0QeELkim/72EtcYuNlmbkrcGuxj3Kl0YQ==", + "license": "MIT", + "dependencies": { + "mime-db": "~1.25.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1527,6 +1559,12 @@ "engines": { "node": ">=8" } + }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "license": "MIT" } } } diff --git a/package.json b/package.json index 9a464e3..7a37fd5 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "fs": "^0.0.1-security", "hbs": "^4.2.0", "japanese-date-converter": "^2.0.0", + "rss": "^1.2.2", "serve-index": "^1.9.1" }, "devDependencies": { diff --git a/src/router/common_path_logic/update_log.js b/src/router/common_path_logic/update_log.js new file mode 100644 index 0000000..946d188 --- /dev/null +++ b/src/router/common_path_logic/update_log.js @@ -0,0 +1,36 @@ +const { dirname } = require("path"); +const { readCsv } = require("../../utils/csv") +const thisDirectory = dirname(require.main.filename); + +async function getUpdates(){ + const csvData = await readCsv(thisDirectory + '/public/dynamic/sync/updates.csv') + + const updates = [] + let currentYear = "" + for (let i = csvData.length-1; i > -1; i--){ + const {date, description, link} = csvData[i] + const codeDate = new Date(date) + const updateYear = codeDate.getFullYear() + const updateDayMonth = codeDate.getDay() + '/' + (codeDate.getMonth()+1) + + if (updateYear !== currentYear){ + currentYear = updateYear + updates.push({ + year: currentYear, + updates: [] + }) + } + updates[updates.length-1].updates.push({ + date, + description, + link, + updateDayMonth + }) + } + + return { + updates + } +} + +module.exports = getUpdates \ No newline at end of file diff --git a/src/router/indexRouter.js b/src/router/indexRouter.js index 147186c..8963bdd 100644 --- a/src/router/indexRouter.js +++ b/src/router/indexRouter.js @@ -4,7 +4,8 @@ const router = express.Router(); const { readCsv } = require('../utils/csv'); const { dirname } = require('path'); const thisDirectory = dirname(require.main.filename); -const fs = require('fs') +const fs = require('fs'); +const makeRss = require('../utils/rss'); function addPaths(path, renderParams = {}){ let currentDefaultParams = {...renderParams} @@ -72,6 +73,22 @@ router.post('/comment', (req, res) => { res.redirect('/home#visitor_table') }) +router.get('/update_log/rss', async (_req, res) => { + const csvData = await readCsv(thisDirectory + '/public/dynamic/sync/updates.csv') + const rssMappedUpdates = csvData.map((u, i) => { + return { + title: "Update #" + i, + description: u.description, + author: "Gor Down", + pubDate: u.date, + } + }).reverse() + const rss = makeRss(rssMappedUpdates, 'https://lyricaltokarev.com/update_log/rss', "Update Log") + + res.send(rss) + + return rss +}) setInterval(() => { recent_posters.forEach(poster => { diff --git a/src/utils/rss.js b/src/utils/rss.js new file mode 100644 index 0000000..3796b77 --- /dev/null +++ b/src/utils/rss.js @@ -0,0 +1,13 @@ +const RSS = require("rss") + +function makeRss(items, feed_link, name, description, link){ + return new RSS({ + title: `Lyrical Tokarev${name ? ` ~ ${name}` : ""}`, + site_url: link ? link : "https://lyricaltokarev.com/home", + feed_url: feed_link, + description: description ? description : "Anime site.", + managingEditor: "gor@lyricaltokarev.com (Gor Down)" + }, items) +} + +module.exports = makeRss \ No newline at end of file diff --git a/views/home.hbs b/views/home.hbs index c99ed98..7fdc53a 100644 --- a/views/home.hbs +++ b/views/home.hbs @@ -24,7 +24,8 @@
  • Creator
  • Opinion
  • Art
  • -
  • Motivation
  • +
  • Technologies
  • +
  • Motivation
  • ç
  • Community
  • Toxic
  • Views
  • @@ -34,6 +35,7 @@
  • Develop
  • Saturated
  • Right
  • +
  • Left
  • Life
  • Tweet
  • Obscure
  • @@ -50,6 +52,7 @@
  • Yikes
  • Project
  • Idea
  • +
  • Pibes/Pibas
  • Identity
  • Global
  • Emotional
  • diff --git a/views/lists/anime.hbs b/views/lists/anime.hbs index e02ed33..7ed9fd0 100644 --- a/views/lists/anime.hbs +++ b/views/lists/anime.hbs @@ -11,7 +11,7 @@ {{/if}} {{#if rating}} {{#ifEquals rating "FAV"}} - + {{else}} {{rating}} {{/ifEquals}} @@ -20,6 +20,7 @@ {{/each}} +

    Total: {{animeList.length}}


    VN and vidya

    +

    Total: {{vnList.length}}


    {{>lyrics lyrics="常識という眼鏡で
    僕たちの世界は のぞけやしないのさ
    diff --git a/views/update_log.hbs b/views/update_log.hbs index 2b427ae..2ac02ce 100644 --- a/views/update_log.hbs +++ b/views/update_log.hbs @@ -1,6 +1,6 @@
    -

    2024

    + {{!--

    2024

    --}} + + RSS Feed + + {{#each updates}} +

    {{year}}

    + + {{/each}} +

    2022