mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 08:07:30 +00:00
git subrepo clone /home/cloud/Code/pinski-plugins/templates src/site/html/static/js/templates
subrepo: subdir: "src/site/html/static/js/templates" merged: "a768add" upstream: origin: "/home/cloud/Code/pinski-plugins/templates" branch: "master" commit: "a768add" git-subrepo: version: "0.4.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "5d6aba9"
This commit is contained in:
parent
e684a04b03
commit
eb818bf63d
12
src/site/html/static/js/templates/.gitrepo
Normal file
12
src/site/html/static/js/templates/.gitrepo
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
; DO NOT EDIT (unless you know what you are doing)
|
||||||
|
;
|
||||||
|
; This subdirectory is a git "subrepo", and this file is maintained by the
|
||||||
|
; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme
|
||||||
|
;
|
||||||
|
[subrepo]
|
||||||
|
remote = /home/cloud/Code/pinski-plugins/templates
|
||||||
|
branch = master
|
||||||
|
commit = a768add65e7eb7cfd608ef5672342940b2232b4c
|
||||||
|
parent = e684a04b0313ed5a511a9e3cc50269ebc2b64691
|
||||||
|
method = merge
|
||||||
|
cmdver = 0.4.0
|
18
src/site/html/static/js/templates/api/templates.js
Normal file
18
src/site/html/static/js/templates/api/templates.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
const passthrough = require("../../../../../passthrough")
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
route: "/api/templates", methods: ["GET"], code: async () => {
|
||||||
|
const result = {}
|
||||||
|
const entries = passthrough.instance.pugCache.entries()
|
||||||
|
for (const [file, value] of entries) {
|
||||||
|
const match = file.match(/client\/.*?([^/]+)\.pug$/)
|
||||||
|
if (match) {
|
||||||
|
const name = match[1]
|
||||||
|
result[name] = value.client.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [200, result]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
14
src/site/html/static/js/templates/templates.js
Normal file
14
src/site/html/static/js/templates/templates.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import {AsyncValueCache} from "../avc/avc.js"
|
||||||
|
|
||||||
|
const tc = new AsyncValueCache(true, () => {
|
||||||
|
return fetch("/api/templates").then(res => res.json()).then(data => {
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
let fn = Function(data[key] + "; return template")()
|
||||||
|
data[key] = fn
|
||||||
|
})
|
||||||
|
console.log(`Loaded ${Object.keys(data).length} templates`)
|
||||||
|
return data
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
export {tc}
|
Loading…
Reference in New Issue
Block a user