diff --git a/assets/bingo/apple-touch-icon.png b/assets/bingo/apple-touch-icon.png new file mode 100644 index 0000000..4edcee5 Binary files /dev/null and b/assets/bingo/apple-touch-icon.png differ diff --git a/assets/bingo/favicon.ico b/assets/bingo/favicon.ico new file mode 100644 index 0000000..a2e3a14 Binary files /dev/null and b/assets/bingo/favicon.ico differ diff --git a/assets/bingo/favicon.svg b/assets/bingo/favicon.svg new file mode 100644 index 0000000..39a06b1 --- /dev/null +++ b/assets/bingo/favicon.svg @@ -0,0 +1 @@ + diff --git a/bingo_web.rb b/bingo_web.rb index 96ca286..dd0f020 100644 --- a/bingo_web.rb +++ b/bingo_web.rb @@ -111,6 +111,16 @@ class BingoWeb < Sinatra::Base erb :index end + # Icons from assets/bingo/ (public/ is asxp.io's). Search engines want + # a crawlable favicon URL; a data: URI doesn't count. + ICONS = { 'favicon.svg' => 'image/svg+xml', 'favicon.ico' => 'image/x-icon', + 'apple-touch-icon.png' => 'image/png' }.freeze + + get %r{/(favicon\.svg|favicon\.ico|apple-touch-icon\.png)} do |name| + cache_control :public, max_age: 86_400 + send_file File.join(settings.root, 'assets', 'bingo', name), type: ICONS[name] + end + # Photos are immutable per key (a new upload gets a new key). get '/p/:file' do bytes, type = Bingo::Photo.read(params[:file]) diff --git a/test/bingo_test.rb b/test/bingo_test.rb index ef13ea2..893b62b 100644 --- a/test/bingo_test.rb +++ b/test/bingo_test.rb @@ -190,6 +190,17 @@ class BingoTest < Minitest::Test assert_equal 'http://example.org/en?view=operational', last_response.location end + def test_icons + { '/favicon.svg' => 'image/svg+xml', '/favicon.ico' => 'image/x-icon', + '/apple-touch-icon.png' => 'image/png' }.each do |path, type| + get path + assert last_response.ok?, path + assert_equal type, last_response.content_type + end + get '/en' + assert_includes last_response.body, '' + end + def test_root_varies_on_language get '/' assert_equal 'Accept-Language', last_response.headers['Vary'] diff --git a/views/bingo/layout.erb b/views/bingo/layout.erb index 845342e..1e2af6a 100644 --- a/views/bingo/layout.erb +++ b/views/bingo/layout.erb @@ -34,7 +34,9 @@ - + + +