2021-03-05 12:08:28 +01:00
|
|
|
|
2022-07-25 12:19:05 +02:00
|
|
|
const { mastodon, goodreads, webmention, youtube } = require('jam-my-stack');
|
2021-03-05 12:08:28 +01:00
|
|
|
const fsp = require('fs').promises;
|
2022-04-29 14:16:57 +02:00
|
|
|
const wmconfig = require('./_conf.js');
|
2021-03-05 12:08:28 +01:00
|
|
|
|
2022-04-26 13:35:09 +02:00
|
|
|
const rootdir = `${__dirname}/../`;
|
|
|
|
|
2021-03-05 12:08:28 +01:00
|
|
|
(async function() {
|
|
|
|
// 1. parse Mastodon RSS feed
|
2021-06-21 14:10:15 +02:00
|
|
|
// currently disabling notes, as after 3 months, I find these do not bring anything relevant to the table.
|
|
|
|
/*
|
2021-03-05 12:08:28 +01:00
|
|
|
console.log("1. parsing Mastodon RSS feed...")
|
|
|
|
await mastodon.parseFeed({
|
|
|
|
notesdir: `${__dirname}/content/notes`,
|
2021-03-05 16:58:09 +01:00
|
|
|
url: "https://chat.brainbaking.com/users/wouter/feed",
|
2021-03-13 13:50:01 +01:00
|
|
|
utcOffset: 60,
|
2021-03-20 13:21:41 +01:00
|
|
|
titleCount: 50,
|
|
|
|
ignoreReplies: true
|
2021-03-05 12:08:28 +01:00
|
|
|
})
|
2021-06-21 14:10:15 +02:00
|
|
|
*/
|
2021-03-05 12:08:28 +01:00
|
|
|
|
|
|
|
// 2. update goodreads JS widget
|
|
|
|
console.log("2. Updating Goodreads Widget...")
|
|
|
|
const widget = await goodreads.createWidget("https://www.goodreads.com/review/grid_widget/5451893.Wouter's%20bookshelf:%20read?cover_size=medium&hide_link=&hide_title=&num_books=12&order=d&shelf=read&sort=date_added&widget_id=1496758344")
|
2022-04-26 13:35:09 +02:00
|
|
|
await fsp.writeFile(`${rootdir}/static/js/goodreads.js`, widget.replace(/src=/g, "loading=\"lazy\" src="), 'utf-8')
|
2021-03-05 12:08:28 +01:00
|
|
|
|
2022-07-25 12:19:05 +02:00
|
|
|
// 3. get webmentions
|
2021-03-19 20:51:56 +01:00
|
|
|
console.log("4. Fetching webmentions...")
|
2022-04-25 10:24:58 +02:00
|
|
|
const mentions = await webmention.getWebmentions("brainbaking.com", wmconfig)
|
2021-03-16 16:32:49 +01:00
|
|
|
const json = JSON.stringify(mentions, null, 4)
|
2022-04-26 13:35:09 +02:00
|
|
|
await fsp.writeFile(`${rootdir}/data/webmentions.json`, json, 'utf-8')
|
2021-06-15 13:31:36 +02:00
|
|
|
|
2022-07-25 12:19:05 +02:00
|
|
|
// 4. generate youtube thumbnails
|
2022-04-26 13:35:09 +02:00
|
|
|
console.log("5. Generating YouTube thumbnails...")
|
2021-06-15 13:31:36 +02:00
|
|
|
await youtube.thumbify({
|
2022-04-26 13:35:09 +02:00
|
|
|
postDir: `${rootdir}/content/post`,
|
|
|
|
downloadDir: `${rootdir}/static/img/yt`,
|
|
|
|
overlayImg: `${rootdir}/play.png`
|
2021-06-15 13:31:36 +02:00
|
|
|
})
|
2021-03-19 20:51:56 +01:00
|
|
|
|
2021-03-05 12:08:28 +01:00
|
|
|
console.log("-- all done!")
|
|
|
|
})()
|