Unified · Split
| @@ -128,11 +128,11 @@ class App < Sinatra::Application · 127 unmodified lines | |||
| 128 | end | 128 | end |
| 129 | 129 | ||
| 130 | def main_stylesheet_path | 130 | def main_stylesheet_path |
| 131 | stylesheet_paths[cookies[:dark].nil? ? :default : :dark] | 131 | stylesheet_paths[dark_theme? ? :dark : :default] |
| 132 | end | 132 | end |
| 133 | 133 | ||
| 134 | def alternate_stylesheet_path | 134 | def alternate_stylesheet_path |
| 135 | stylesheet_paths[cookies[:dark].nil? ? :dark : :default] | 135 | stylesheet_paths[dark_theme? ? :default : :dark] |
| 136 | end | 136 | end |
| 137 | 137 | ||
| 138 | def stylesheet_paths | 138 | def stylesheet_paths |
| @@ -142,8 +142,16 @@ class App < Sinatra::Application · 3 unmodified lines | |||
| 142 | } | 142 | } |
| 143 | end | 143 | end |
| 144 | 144 | ||
| 145 | def size | 145 | def app_size |
| 146 | @size ||= cookies[:size].nil? ? '18rem' : "#{cookies[:size]}px" | 146 | @app_size ||= cookies[:size].nil? ? '18rem' : "#{cookies[:size]}px" |
| 147 | end | ||
| 148 | |||
| 149 | def app_theme | ||
| 150 | @app_theme ||= cookies[:dark].nil? ? 'default' : 'dark' | ||
| 151 | end | ||
| 152 | |||
| 153 | def dark_theme? | ||
| 154 | app_theme == 'dark' | ||
| 147 | end | 155 | end |
| 148 | end | 156 | end |
| 149 | 157 | ||
| @@ -69,17 +69,17 @@ class AppTest < MiniTest::Spec · 68 unmodified lines | |||
| 69 | assert_includes last_response.body, '/html/index.json' | 69 | assert_includes last_response.body, '/html/index.json' |
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | it "includes has the word 'light' by default" do | 72 | it "has the word 'default' when no 'dark' cookie is set" do |
| 73 | get '/manifest.appcache' | 73 | get '/manifest.appcache' |
| 74 | assert_includes last_response.body, '# light' | 74 | assert_includes last_response.body, '# default' |
| 75 | refute_includes last_response.body, '# dark' | 75 | refute_includes last_response.body, '# dark' |
| 76 | end | 76 | end |
| 77 | 77 | ||
| 78 | it "includes has the word 'dark' when the cookie is set" do | 78 | it "has the word 'dark' when the cookie is set" do |
| 79 | set_cookie('dark=1') | 79 | set_cookie('dark=1') |
| 80 | get '/manifest.appcache' | 80 | get '/manifest.appcache' |
| 81 | assert_includes last_response.body, '# dark' | 81 | assert_includes last_response.body, '# dark' |
| 82 | refute_includes last_response.body, '# light' | 82 | refute_includes last_response.body, '# default' |
| 83 | end | 83 | end |
| 84 | 84 | ||
| 85 | it "sets default size" do | 85 | it "sets default size" do |
| @@ -44,9 +44,9 @@ · 43 unmodified lines | |||
| 44 | a.src="//secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0]; | 44 | a.src="//secure.gaug.es/track.js";var b=document.getElementsByTagName("script")[0]; |
| 45 | b.parentNode.insertBefore(a,b)}(); | 45 | b.parentNode.insertBefore(a,b)}(); |
| 46 | </script><% end %> | 46 | </script><% end %> |
| 47 | <style data-size="<%= size %>" data-resizer> | 47 | <style data-size="<%= app_size %>" data-resizer> |
| 48 | ._container { margin-left: <%= size %>; } | 48 | ._container { margin-left: <%= app_size %>; } |
| 49 | ._search, ._list, ._sidebar-footer { width: <%= size %>; } | 49 | ._search, ._list, ._sidebar-footer { width: <%= app_size %>; } |
| 50 | ._list-hover.clone { min-width: <%= size %>; } | 50 | ._list-hover.clone { min-width: <%= app_size %>; } |
| 51 | ._notice, ._path, ._resizer { left: <%= size %>; } | 51 | ._notice, ._path, ._resizer { left: <%= app_size %>; } |
| 52 | </style> | 52 | </style> |
| @@ -1,5 +1,5 @@ | |||
| 1 | CACHE MANIFEST | 1 | CACHE MANIFEST |
| 2 | # <%= cookies[:dark].nil? ? 'light' : 'dark' %> <%= size %> | 2 | # <%= app_theme %> <%= app_size %> |
| 3 | 3 | ||
| 4 | CACHE: | 4 | CACHE: |
| 5 | / | 5 | / |