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

@ -53,6 +53,24 @@ a:hover {
text-decoration: underline; text-decoration: underline;
} }
button {
background-color: #121212;
color: #f8f8f2;
border: 1px solid #ff6c6091;
padding: 3px 6px;
font-size: 14px;
cursor: pointer;
float: right;
}
button:hover {
border-color: #ff6c60;
}
button:active {
border-color: #ff9f97;
}
.status-el { .status-el {
overflow-wrap: break-word; overflow-wrap: break-word;
border-left-width: 0; border-left-width: 0;
@ -297,13 +315,12 @@ video, .video-container img {
top: 0; top: 0;
left: 0; left: 0;
z-index: 1; z-index: 1;
background-color: #0000008d; background-color: #0000009d;
} }
.video-overlay p { .video-overlay p {
position: relative; position: relative;
z-index: 0; z-index: 0;
color: #dcdcdc;
text-align: center; text-align: center;
top: calc(50% - 20px); top: calc(50% - 20px);
font-size: 20px; font-size: 20px;
@ -320,6 +337,14 @@ video, .video-container img {
height: 40px; height: 40px;
} }
.video-overlay form {
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
display: flex;
}
.still-image { .still-image {
max-height: 379.5px; max-height: 379.5px;
max-width: 533px; max-width: 533px;
@ -375,6 +400,7 @@ video, .video-container img {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
margin-bottom: -3px;
} }
.tweet-stat { .tweet-stat {
@ -1136,6 +1162,10 @@ video, .video-container img {
border-color: #ff6c60; border-color: #ff6c60;
} }
.preferences button {
margin-top: 6px;
}
fieldset { fieldset {
margin: .35em 0 .75em; margin: .35em 0 .75em;
border: 0; border: 0;
@ -1156,25 +1186,6 @@ legend {
margin-bottom: 6px; margin-bottom: 6px;
} }
.pref-submit, .pref-reset button {
background-color: #121212;
color: #f8f8f2;
border: 1px solid #ff6c6091;
padding: 3px 6px;
margin-top: 6px;
font-size: 14px;
cursor: pointer;
float: right;
}
.pref-submit:hover, .pref-reset button:hover {
border-color: #ff6c60;
}
.pref-submit:active, .pref-reset button:active {
border-color: #ff9f97;
}
.pref-reset { .pref-reset {
float: left; float: left;
} }

View File

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

View File

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

View File

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

View File

@ -58,7 +58,9 @@ proc renderVideoDisabled(video: Video): VNode =
of mp4: of mp4:
p: text "mp4 playback disabled in preferences" p: text "mp4 playback disabled in preferences"
of m3u8, vmap: 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 = proc renderVideoUnavailable(video: Video): VNode =
buildHtml(tdiv): buildHtml(tdiv):