Invidious is an alternative front-end to YouTube
Add dark theme
Omar Roth4bf0e538e4cb
diff --git a/assets/css/darktheme.css b/assets/css/darktheme.cssnew file mode 100644index 00000000..19cdfd45--- /dev/null+++ b/assets/css/darktheme.css@@ -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;+}diff --git a/assets/css/custom.css b/assets/css/default.csssimilarity index 55%rename from assets/css/custom.cssrename to assets/css/default.cssindex abd4e66e..850ebd47 100644--- a/assets/css/custom.css+++ b/assets/css/default.css@@ -1,13 +1,3 @@-a {- color: #333;- text-decoration: none;-}--a:hover,-a:active {- color: #167ac6;-}-.h-box {padding-left: 1em;padding-right: 1em;@@ -16,4 +6,4 @@ a:active {.v-box {padding-top: 1em;padding-bottom: 1em;-}\ No newline at end of file+}diff --git a/assets/css/lighttheme.css b/assets/css/lighttheme.cssnew file mode 100644index 00000000..34bb9fc1--- /dev/null+++ b/assets/css/lighttheme.css@@ -0,0 +1,9 @@+a:hover,+a:active {+ color: #167ac6;+}++a {+ color: #303030;+ text-decoration: none;+}diff --git a/src/invidious.cr b/src/invidious.crindex 78b13b1c..85645611 100644--- a/src/invidious.cr+++ b/src/invidious.cr@@ -208,6 +208,10 @@ before_all do |env|notifications ||= 0env.set "notifications", notificationsend++ if env.request.cookies.has_key?("darktheme") && env.request.cookies["darktheme"].value == "true"+ env.set "darktheme", true+ endendget "/" do |env|@@ -514,7 +518,9 @@ get "/signout" do |env|referer ||= "/"env.request.cookies.each do |cookie|- cookie.expires = Time.new(1990, 1, 1)+ if cookie.name != "darktheme"+ cookie.expires = Time.new(1990, 1, 1)+ endendenv.request.cookies.add_response_headers(env.response.headers)@@ -770,6 +776,20 @@ get "/subscription_ajax" do |env|env.redirect refererend+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"diff --git a/src/views/layout.ecr b/src/views/layout.ecrindex cf26da3f..22abd4c5 100644--- a/src/views/layout.ecr+++ b/src/views/layout.ecr@@ -7,7 +7,12 @@<link rel="stylesheet" href="https://unpkg.com/[email protected]/build/pure-min.css"><link rel="stylesheet" href="https://unpkg.com/[email protected]/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">- <input type="search" style="width:100%;" name="q" placeholder="search" value="<%= env.params.query["q"]? %>">+ <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>