mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 02:31:35 +00:00
Add theme support, light theme, and edgeless light
This commit is contained in:
parent
4e1f2b3607
commit
0d23d66700
45 changed files with 433 additions and 212 deletions
|
|
@ -24,7 +24,7 @@ module.exports = [
|
|||
video.watched = watchedVideos.includes(video.videoId)
|
||||
})
|
||||
}
|
||||
return render(200, "pug/channel.pug", {url, data, subscribed, instanceOrigin})
|
||||
return render(200, "pug/channel.pug", {settings, url, data, subscribed, instanceOrigin})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ const {Matcher, PatternCompileError} = require("../utils/matcher")
|
|||
const filterMaxLength = 160
|
||||
const regexpEnabledText = constants.server_setup.allow_regexp_filters ? "" : "not"
|
||||
|
||||
function getCategories(req) {
|
||||
const user = getUser(req)
|
||||
function getCategories(user) {
|
||||
const filters = user.getFilters()
|
||||
|
||||
// Sort filters into categories for display. Titles are already sorted.
|
||||
|
|
@ -39,7 +38,9 @@ function getCategories(req) {
|
|||
module.exports = [
|
||||
{
|
||||
route: "/filters", methods: ["GET"], code: async ({req, url}) => {
|
||||
const categories = getCategories(req)
|
||||
const user = getUser(req)
|
||||
const categories = getCategories(user)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
let referrer = url.searchParams.get("referrer") || null
|
||||
|
||||
let type = null
|
||||
|
|
@ -54,7 +55,7 @@ module.exports = [
|
|||
label = url.searchParams.get("label")
|
||||
}
|
||||
|
||||
return render(200, "pug/filters.pug", {categories, type, contents, label, referrer, filterMaxLength, regexpEnabledText})
|
||||
return render(200, "pug/filters.pug", {settings, categories, type, contents, label, referrer, filterMaxLength, regexpEnabledText})
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -100,8 +101,10 @@ module.exports = [
|
|||
return true
|
||||
}, state => {
|
||||
const {type, contents, label, compileError} = state
|
||||
const categories = getCategories(req)
|
||||
return render(400, "pug/filters.pug", {categories, type, contents, label, compileError, filterMaxLength, regexpEnabledText})
|
||||
const user = getUser(req)
|
||||
const categories = getCategories(user)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
return render(400, "pug/filters.pug", {settings, categories, type, contents, label, compileError, filterMaxLength, regexpEnabledText})
|
||||
})
|
||||
.last(state => {
|
||||
const {type, contents, label} = state
|
||||
|
|
|
|||
25
api/pages.js
25
api/pages.js
|
|
@ -1,16 +1,35 @@
|
|||
const {render} = require("pinski/plugins")
|
||||
const {getUser} = require("../utils/getuser")
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
route: "/", methods: ["GET"], code: async ({req}) => {
|
||||
const userAgent = req.headers["user-agent"] || ""
|
||||
const mobile = userAgent.toLowerCase().includes("mobile")
|
||||
return render(200, "pug/home.pug", {mobile})
|
||||
const user = getUser(req)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
return render(200, "pug/home.pug", {settings, mobile})
|
||||
}
|
||||
},
|
||||
{
|
||||
route: "/js-licenses", methods: ["GET"], code: async () => {
|
||||
return render(200, "pug/js-licenses.pug")
|
||||
route: "/(?:js-)?licenses", methods: ["GET"], code: async ({req}) => {
|
||||
const user = getUser(req)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
return render(200, "pug/licenses.pug", {settings})
|
||||
}
|
||||
},
|
||||
{
|
||||
route: "/cant-think", methods: ["GET"], code: async ({req}) => {
|
||||
const user = getUser(req)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
return render(200, "pug/cant-think.pug", {settings})
|
||||
}
|
||||
},
|
||||
{
|
||||
route: "/privacy", methods: ["GET"], code: async ({req}) => {
|
||||
const user = getUser(req)
|
||||
const settings = user.getSettingsOrDefaults()
|
||||
return render(200, "pug/privacy.pug", {settings})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module.exports = [
|
|||
const filters = user.getFilters()
|
||||
results = converters.applyVideoFilters(results, filters).videos
|
||||
|
||||
return render(200, "pug/search.pug", {url, query, results, instanceOrigin})
|
||||
return render(200, "pug/search.pug", {settings, url, query, results, instanceOrigin})
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ module.exports = [
|
|||
// Check if playback is allowed
|
||||
const videoTakedownInfo = db.prepare("SELECT id, org, url FROM TakedownVideos WHERE id = ?").get(id)
|
||||
if (videoTakedownInfo) {
|
||||
return render(451, "pug/takedown-video.pug", videoTakedownInfo)
|
||||
return render(451, "pug/takedown-video.pug", Object.assign({settings}, videoTakedownInfo))
|
||||
}
|
||||
|
||||
// Media fragment
|
||||
|
|
@ -129,7 +129,7 @@ module.exports = [
|
|||
// Work out how to fetch the video
|
||||
if (req.method === "GET") {
|
||||
if (settings.local) { // skip to the local fetching page, which will then POST video data in a moment
|
||||
return render(200, "pug/local-video.pug", {id})
|
||||
return render(200, "pug/local-video.pug", {settings, id})
|
||||
}
|
||||
var instanceOrigin = settings.instance
|
||||
var outURL = `${instanceOrigin}/api/v1/videos/${id}`
|
||||
|
|
@ -153,7 +153,7 @@ module.exports = [
|
|||
// automatically add the entry to the videos list, so it won't be fetched again
|
||||
const args = {id, ...channelTakedownInfo}
|
||||
db.prepare("INSERT INTO TakedownVideos (id, org, url) VALUES (@id, @org, @url)").run(args)
|
||||
return render(451, "pug/takedown-video.pug", channelTakedownInfo)
|
||||
return render(451, "pug/takedown-video.pug", Object.assign({settings}, channelTakedownInfo))
|
||||
}
|
||||
|
||||
// process stream list ordering
|
||||
|
|
@ -225,7 +225,7 @@ module.exports = [
|
|||
// Create appropriate formatted message
|
||||
const message = render(0, `pug/errors/${errorType}.pug`, locals).content
|
||||
|
||||
return render(500, "pug/video.pug", {video: {videoId: id}, error: true, message})
|
||||
return render(500, "pug/video.pug", {video: {videoId: id}, error: true, message, settings})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue