1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-14 04:17:29 +00:00

Autofocus search if user-agent not a mobile device

This commit is contained in:
Cadence Ember 2021-04-10 01:04:00 +12:00
parent 54ae21685f
commit 848651757a
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17
3 changed files with 13 additions and 3 deletions

11
api/pages.js Normal file
View File

@ -0,0 +1,11 @@
const {render} = require("pinski/plugins")
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})
}
}
]

View File

@ -11,9 +11,9 @@ block content
p You're in control. Watch things your way. p You're in control. Watch things your way.
p Go on. What do you want to watch? p Go on. What do you want to watch?
form(method="get" action="/search").encouraging-search-form form(method="get" action="/search").encouraging-search-form
input(type="text" name="q" placeholder="I'd like to watch..." autocomplete="off").search.base-border-look input(type="text" name="q" placeholder="I'd like to watch..." autocomplete="off" autofocus=!mobile).search.base-border-look
p: a(href="/cant-think") ...can't think of anything? p: a(href="/cant-think") ...can't think of anything?
.encouraging-message .encouraging-message
p CloudTube gets better with your help. I can't deal with issues that I don't know about. p CloudTube gets better with your help. I can't deal with issues that I don't know about.
p: a(href="https://todo.sr.ht/~cadence/tube") Report a problem or missing feature p: a(href="https://todo.sr.ht/~cadence/tube") Report a problem or missing feature

View File

@ -16,7 +16,6 @@ const {setInstance} = require("pinski/plugins")
server.addRoute("/static/css/main.css", "sass/main.sass", "sass") server.addRoute("/static/css/main.css", "sass/main.sass", "sass")
server.addPugDir("pug", ["pug/includes"]) server.addPugDir("pug", ["pug/includes"])
server.addRoute("/", "pug/home.pug", "pug")
server.addRoute("/cant-think", "pug/cant-think.pug", "pug") server.addRoute("/cant-think", "pug/cant-think.pug", "pug")
server.addStaticHashTableDir("html/static/js") server.addStaticHashTableDir("html/static/js")