Refactor tag grid downloader locals
This commit is contained in:
parent
5cda6a1687
commit
df59c6b65c
2 changed files with 9 additions and 5 deletions
|
@ -70,9 +70,7 @@ function render(event, filename, locals) {
|
||||||
pugCache.set(path, async (event, locals) => {
|
pugCache.set(path, async (event, locals) => {
|
||||||
const localAnd = params => and(event, params)
|
const localAnd = params => and(event, params)
|
||||||
// automatically generate locals required by included templates
|
// automatically generate locals required by included templates
|
||||||
console.log([...beforeIncludes.keys()])
|
|
||||||
for (const dep of dependencies) {
|
for (const dep of dependencies) {
|
||||||
console.log(dep)
|
|
||||||
const fn = beforeIncludes.get(dep)
|
const fn = beforeIncludes.get(dep)
|
||||||
if (fn) Object.assign(locals, await fn(path, event, locals))
|
if (fn) Object.assign(locals, await fn(path, event, locals))
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
const {z} = require("zod")
|
const {z} = require("zod")
|
||||||
const {defineEventHandler, getQuery, getValidatedQuery, sendRedirect, createError, getValidatedRouterParams, getCookie} = require("h3")
|
const {defineEventHandler, getQuery, getValidatedQuery, sendRedirect, createError, getValidatedRouterParams, getCookie} = require("h3")
|
||||||
const {router, db, sync, select, from} = require("../passthrough")
|
const {router, db, sync, select, from} = require("../passthrough")
|
||||||
|
|
||||||
|
/** @type {import("../pug-sync")} */
|
||||||
const pugSync = sync.require("../pug-sync")
|
const pugSync = sync.require("../pug-sync")
|
||||||
|
|
||||||
/** @type {import("./load-tags")} */
|
/** @type {import("./load-tags")} */
|
||||||
|
@ -146,12 +148,16 @@ router.get("/:account/", defineEventHandler({
|
||||||
loadPreviews(locals, "band_name", 4, whereClause, account, filter_field, filter, filter_fuzzy)
|
loadPreviews(locals, "band_name", 4, whereClause, account, filter_field, filter, filter_fuzzy)
|
||||||
} else if (mode === "label_grid") {
|
} else if (mode === "label_grid") {
|
||||||
loadPreviews(locals, "band_url", 6, whereClause, account, filter_field, filter, filter_fuzzy)
|
loadPreviews(locals, "band_url", 6, whereClause, account, filter_field, filter, filter_fuzzy)
|
||||||
} else if (arrange === "tag") {
|
|
||||||
locals.downloadManager = loadTags.downloadManager
|
|
||||||
locals.downloader = loadTags.downloadManager.check(account)
|
|
||||||
}
|
}
|
||||||
// if there are any untagged items then we don't have full track data
|
// if there are any untagged items then we don't have full track data
|
||||||
locals.hasFullTrackData = !db.prepare("SELECT * FROM item LEFT JOIN item_tag USING (account, item_id) WHERE account = ? AND item_id = NULL").get(account)
|
locals.hasFullTrackData = !db.prepare("SELECT * FROM item LEFT JOIN item_tag USING (account, item_id) WHERE account = ? AND item_id = NULL").get(account)
|
||||||
return pugSync.render(event, `${arrange}_${shape}.pug`, locals)
|
return pugSync.render(event, `${arrange}_${shape}.pug`, locals)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
pugSync.beforeInclude("tag_grid.pug", async (from, event, {account}) => {
|
||||||
|
return {
|
||||||
|
downloadManager: loadTags.downloadManager,
|
||||||
|
downloader: loadTags.downloadManager.check(account)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue