1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-21 23:57:30 +00:00

Cache some semi-static data

This commit is contained in:
Cadence Ember 2020-05-04 23:50:54 +12:00
parent 8c2a4454f2
commit 12c02fd8af
No known key found for this signature in database
GPG Key ID: 128B99B1B74A6412
7 changed files with 12 additions and 8 deletions

View File

@ -1,6 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "esnext", "target": "esnext",
"module": "esnext",
"checkJs": true, "checkJs": true,
"moduleResolution": "node", "moduleResolution": "node",
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true

View File

@ -2,7 +2,7 @@ const constants = require("../../lib/constants")
const {Feed} = require("feed") const {Feed} = require("feed")
const {getFeedSetup} = require("../../lib/utils/feed") const {getFeedSetup} = require("../../lib/utils/feed")
const {fetchUser, userRequestCache} = require("../../lib/collectors") const {fetchUser, userRequestCache} = require("../../lib/collectors")
const {render} = require("pinski/plugins") const {render, getStaticURL} = require("pinski/plugins")
const {pugCache} = require("../passthrough") const {pugCache} = require("../passthrough")
const {compile} = require("pug") const {compile} = require("pug")
@ -80,7 +80,8 @@ module.exports = [
"Retry-After": userRequestCache.getTtl("user/"+fill[0], 1000) "Retry-After": userRequestCache.getTtl("user/"+fill[0], 1000)
}, },
content: pugCache.get("pug/blocked.pug").web({ content: pugCache.get("pug/blocked.pug").web({
expiresMinutes: userRequestCache.getTtl("user/"+fill[0], 1000*60) expiresMinutes: userRequestCache.getTtl("user/"+fill[0], 1000*60),
getStaticURL
}) })
} }
} else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) { } else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) {

View File

@ -1,7 +1,7 @@
const constants = require("../../lib/constants") const constants = require("../../lib/constants")
const switcher = require("../../lib/utils/torswitcher") const switcher = require("../../lib/utils/torswitcher")
const {fetchUser, getOrFetchShortcode, userRequestCache, history} = require("../../lib/collectors") const {fetchUser, getOrFetchShortcode, userRequestCache, history} = require("../../lib/collectors")
const {render, redirect} = require("pinski/plugins") const {render, redirect, getStaticURL} = require("pinski/plugins")
const {pugCache} = require("../passthrough") const {pugCache} = require("../passthrough")
/** @param {import("../../lib/structures/TimelineEntry")} post */ /** @param {import("../../lib/structures/TimelineEntry")} post */
@ -86,7 +86,8 @@ module.exports = [
"Retry-After": userRequestCache.getTtl("user/"+fill[0], 1000) "Retry-After": userRequestCache.getTtl("user/"+fill[0], 1000)
}, },
content: pugCache.get("pug/blocked.pug").web({ content: pugCache.get("pug/blocked.pug").web({
expiresMinutes: userRequestCache.getTtl("user/"+fill[0], 1000*60) expiresMinutes: userRequestCache.getTtl("user/"+fill[0], 1000*60),
getStaticURL
}) })
} }
} else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) { } else if (error === constants.symbols.extractor_results.AGE_RESTRICTED) {

View File

@ -1,5 +1,5 @@
meta(charset="utf-8") meta(charset="utf-8")
link(rel="stylesheet" type="text/css" href="/static/css/main.css") link(rel="stylesheet" type="text/css" href=getStaticURL("sass", "main.sass"))
meta(name="viewport" content="width=device-width, initial-scale=1") meta(name="viewport" content="width=device-width, initial-scale=1")
link(rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png") link(rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png")
link(rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png") link(rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png")

View File

@ -7,7 +7,7 @@ html
head head
title= title title= title
include includes/head include includes/head
script(type="module" src="/static/js/post_overlay.js") script(type="module" src=getStaticURL("html", "/static/js/post_overlay.js"))
meta(property="og:url" content=`${website_origin}/p/${post.data.shortcode}`) meta(property="og:url" content=`${website_origin}/p/${post.data.shortcode}`)
meta(property="og:type" content="article") meta(property="og:type" content="article")
- let firstEntry = post.children[0] - let firstEntry = post.children[0]

View File

@ -15,8 +15,8 @@ html
else else
title= `@${user.data.username} | Bibliogram` title= `@${user.data.username} | Bibliogram`
include includes/head include includes/head
script(src="/static/js/pagination.js" type="module") script(src=getStaticURL("html", "/static/js/pagination.js") type="module")
script(src="/static/js/post_overlay.js" type="module") script(src=getStaticURL("html", "/static/js/post_overlay.js") type="module")
meta(property="og:url" content=`${constants.website_origin}/u/${user.data.username}`) meta(property="og:url" content=`${constants.website_origin}/u/${user.data.username}`)
meta(property="og:type" content="profile") meta(property="og:type" content="profile")
meta(property="og:title" content=(user.data.full_name || user.data.username)) meta(property="og:title" content=(user.data.full_name || user.data.username))

View File

@ -24,6 +24,7 @@ subdirs("pug", async (err, dirs) => {
pinski.addRoute("/static/css/main.css", "sass/main.sass", "sass") pinski.addRoute("/static/css/main.css", "sass/main.sass", "sass")
pinski.addPugDir("pug", dirs) pinski.addPugDir("pug", dirs)
pinski.addSassDir("sass") pinski.addSassDir("sass")
pinski.addStaticHashTableDir("html/static/js")
pinski.muteLogsStartingWith("/imageproxy") pinski.muteLogsStartingWith("/imageproxy")
pinski.muteLogsStartingWith("/videoproxy") pinski.muteLogsStartingWith("/videoproxy")
pinski.muteLogsStartingWith("/static") pinski.muteLogsStartingWith("/static")