bibliogram/src/lib/structures/TimelineChild.js

33 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-07-10 10:34:06 +00:00
const constants = require("../constants")
2020-01-18 15:38:14 +00:00
const collectors = require("../collectors")
const TimelineBaseMethods = require("./TimelineBaseMethods")
2020-07-10 10:34:06 +00:00
const {compile} = require("pug")
2020-01-18 15:38:14 +00:00
require("../testimports")(collectors)
2020-07-10 10:34:06 +00:00
const rssImageTemplate = compile(`
img(src=constants.website_origin+entry.getDisplayUrlP() alt=entry.getAlt() width=entry.data.dimensions && entry.data.dimensions.width height=entry.data.dimensions && entry.data.dimensions.height)
2020-07-10 10:34:06 +00:00
`)
const rssVideoTemplate = compile(`
video(src=constants.website_origin+entry.getVideoUrlP() controls preload="auto" width=entry.data.dimensions && entry.data.dimensions.width height=entry.data.dimensions && entry.data.dimensions.height)
2020-07-10 10:34:06 +00:00
`)
class TimelineChild extends TimelineBaseMethods {
2020-01-18 15:38:14 +00:00
/**
* @param {import("../types").GraphChildAll} data
2020-01-18 15:38:14 +00:00
*/
constructor(data) {
super()
2020-01-18 15:38:14 +00:00
this.data = data
}
2020-07-10 10:34:06 +00:00
getFeedItem() {
if (this.data.video_url) {
return rssVideoTemplate({entry: this, constants})
} else {
return rssImageTemplate({entry: this, constants})
}
}
2020-01-18 15:38:14 +00:00
}
module.exports = TimelineChild