Add button to enable hls playback when disabled

This commit is contained in:
Zed
2019-08-22 23:44:22 +02:00
parent 1c43dd66a7
commit ac6f4e7d61
5 changed files with 53 additions and 33 deletions

View File

@@ -86,6 +86,15 @@ routes:
resp Http404, showError("Please enter a username.", cfg.title)
redirect("/" & @"query")
get "/settings":
let refUri = request.headers.getOrDefault("Referer").parseUri()
var path =
if refUri.path.len > 0 and "/settings" notin refUri.path: refUri.path
else: "/"
if refUri.query.len > 0: path &= &"?{refUri.query}"
let prefs = cookiePrefs()
resp renderMain(renderPreferences(prefs, path), prefs, cfg.title, "Preferences")
post "/saveprefs":
var prefs = cookiePrefs()
genUpdatePrefs()
@@ -98,14 +107,12 @@ routes:
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=cfg.useHttps)
redirect("/settings")
get "/settings":
let refUri = request.headers.getOrDefault("Referer").parseUri()
var path =
if refUri.path.len > 0 and "/settings" notin refUri.path: refUri.path
else: "/"
if refUri.query.len > 0: path &= &"?{refUri.query}"
let prefs = cookiePrefs()
resp renderMain(renderPreferences(prefs, path), prefs, cfg.title, "Preferences")
post "/enablehls":
var prefs = cookiePrefs()
prefs.hlsPlayback = true
cache(prefs)
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=cfg.useHttps)
redirect(request.headers.getOrDefault("referer"))
get "/@name/?":
cond '.' notin @"name"

View File

@@ -57,7 +57,7 @@ proc renderMain*(body: VNode; prefs: Prefs; title="Nitter"; titleText=""; desc="
proc renderSearch*(): VNode =
buildHtml(tdiv(class="panel")):
tdiv(class="search-panel"):
form(`method`="post", action="search"):
form(`method`="post", action="/search"):
input(`type`="text", name="query", autofocus="", placeholder="Enter usernames...")
button(`type`="submit"): icon "search"

View File

@@ -54,7 +54,7 @@ macro renderPrefs*(): untyped =
proc renderPreferences*(prefs: Prefs; path: string): VNode =
buildHtml(tdiv(class="preferences-container")):
fieldset(class="preferences"):
form(`method`="post", action="saveprefs"):
form(`method`="post", action="/saveprefs"):
verbatim "<input name=\"referer\" style=\"display: none\" value=\"$1\"/>" % path
renderPrefs()
@@ -62,6 +62,6 @@ proc renderPreferences*(prefs: Prefs; path: string): VNode =
button(`type`="submit", class="pref-submit"):
text "Save preferences"
form(`method`="post", action="resetprefs", class="pref-reset"):
form(`method`="post", action="/resetprefs", class="pref-reset"):
button(`type`="submit"):
text "Reset preferences"

View File

@@ -58,7 +58,9 @@ proc renderVideoDisabled(video: Video): VNode =
of mp4:
p: text "mp4 playback disabled in preferences"
of m3u8, vmap:
p: text "hls playback disabled in preferences"
form(`method`="post", action=("/enablehls")):
button(`type`="submit"):
text "Enable hls playback"
proc renderVideoUnavailable(video: Video): VNode =
buildHtml(tdiv):