mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-28 17:07:53 +01:00
Add dark theme
This commit is contained in:
parent
6bbbfcb919
commit
4bf0e538e4
26
assets/css/darktheme.css
Normal file
26
assets/css/darktheme.css
Normal file
@ -0,0 +1,26 @@
|
||||
a:hover,
|
||||
a:active {
|
||||
color: #46aaf6;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #f0f0f0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #101010;
|
||||
color: #f0f0f0;
|
||||
}
|
||||
|
||||
.pure-form legend {
|
||||
color: #f0f0f0;
|
||||
}
|
||||
|
||||
.pure-menu-heading {
|
||||
color: #f0f0f0;
|
||||
}
|
||||
|
||||
.pure-form > fieldset > input {
|
||||
color: #101010;
|
||||
}
|
@ -1,13 +1,3 @@
|
||||
a {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover,
|
||||
a:active {
|
||||
color: #167ac6;
|
||||
}
|
||||
|
||||
.h-box {
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
9
assets/css/lighttheme.css
Normal file
9
assets/css/lighttheme.css
Normal file
@ -0,0 +1,9 @@
|
||||
a:hover,
|
||||
a:active {
|
||||
color: #167ac6;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #303030;
|
||||
text-decoration: none;
|
||||
}
|
@ -208,6 +208,10 @@ before_all do |env|
|
||||
notifications ||= 0
|
||||
env.set "notifications", notifications
|
||||
end
|
||||
|
||||
if env.request.cookies.has_key?("darktheme") && env.request.cookies["darktheme"].value == "true"
|
||||
env.set "darktheme", true
|
||||
end
|
||||
end
|
||||
|
||||
get "/" do |env|
|
||||
@ -514,8 +518,10 @@ get "/signout" do |env|
|
||||
referer ||= "/"
|
||||
|
||||
env.request.cookies.each do |cookie|
|
||||
if cookie.name != "darktheme"
|
||||
cookie.expires = Time.new(1990, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
env.request.cookies.add_response_headers(env.response.headers)
|
||||
env.redirect referer
|
||||
@ -770,6 +776,20 @@ get "/subscription_ajax" do |env|
|
||||
env.redirect referer
|
||||
end
|
||||
|
||||
get "/modify_theme" do |env|
|
||||
referer = env.request.headers["referer"]?
|
||||
referer ||= "/"
|
||||
|
||||
if env.params.query["dark"]?
|
||||
env.response.cookies["darktheme"] = "true"
|
||||
elsif env.params.query["light"]?
|
||||
env.request.cookies["darktheme"].expires = Time.new(1990, 1, 1)
|
||||
env.request.cookies.add_response_headers(env.response.headers)
|
||||
end
|
||||
|
||||
env.redirect referer
|
||||
end
|
||||
|
||||
error 404 do |env|
|
||||
error_message = "404 Page not found"
|
||||
templated "error"
|
||||
|
@ -7,7 +7,12 @@
|
||||
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css">
|
||||
<link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/grids-responsive-min.css">
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.6/css/all.css">
|
||||
<link rel="stylesheet" href="/css/custom.css">
|
||||
<link rel="stylesheet" href="/css/default.css">
|
||||
<% if env.get? "darktheme" %>
|
||||
<link rel="stylesheet" href="/css/darktheme.css">
|
||||
<% else %>
|
||||
<link rel="stylesheet" href="/css/lighttheme.css">
|
||||
<% end %>
|
||||
<%= yield_content "header" %>
|
||||
</head>
|
||||
|
||||
@ -21,7 +26,9 @@
|
||||
</div>
|
||||
<div class="pure-u-1 pure-u-md-3-5">
|
||||
<form class="pure-form" action="/search" method="get">
|
||||
<fieldset>
|
||||
<input type="search" style="width:100%;" name="q" placeholder="search" value="<%= env.params.query["q"]? %>">
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<div class="pure-u-1 pure-u-md-1-5">
|
||||
@ -47,6 +54,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<%= content %>
|
||||
<center class="h-box">
|
||||
<% if env.get? "darktheme" %>
|
||||
<a href="/modify_theme?light">Light theme</a>
|
||||
<% else %>
|
||||
<a href="/modify_theme?dark">Dark theme</a>
|
||||
<% end %>
|
||||
</center>
|
||||
<center class="h-box">
|
||||
Released under AGPLv3 by <a href="https://github.com/omarroth">Omar Roth</a> -
|
||||
source available <a href="https://github.com/omarroth/invidious">here</a>
|
||||
|
Loading…
Reference in New Issue
Block a user