Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise logo #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified app/assets/images/logos/adopt-a-hydrant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/logos/favicons/favicon.ico
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions app/assets/images/logos/favicons/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,7 @@ img.lock {
opacity: 0.8;
filter: alpha(opacity=80); /* For IE8 and earlier */
}

#adopt-a-hydrant-logo {
width: 220px;
}
13 changes: 13 additions & 0 deletions app/assets/xml/browserconfig.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<% environment.context_class.instance_eval { include ApplicationHelper } %>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="<%= namespaced_png_favicon_path('mstile',70) %>"/>
<square150x150logo src="<%= namespaced_png_favicon_path('mstile',150) %>"/>
<square310x310logo src="<%= namespaced_png_favicon_path('mstile',310) %>"/>
<wide310x150logo src="<%= favicon_path('mstile-310x150.png') %>"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
24 changes: 24 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,28 @@ def us_states # rubocop:disable MethodLength
['Wyoming', 'WY'],
]
end

def dimensions(dimension)
"#{dimension}x#{dimension}"
end

def favicon_path(file)
image_path "logos/favicons/#{file}?v=#{Rails.application.config.assets.version}"
end

def favicon_attrs(rel, type = 'image/png')
{rel: rel, type: type}
end

def namespaced_png_favicon_path(namespace, dimension)
favicon_path("#{namespace}-#{dimensions(dimension)}.png")
end

def namespaced_png_favicon_link_tag(namespace, dimension, rel)
favicon_link_tag namespaced_png_favicon_path(namespace, dimension), favicon_attrs(rel).merge(sizes: dimensions(dimension))
end

def namespaced_png_favicon_link_tags(namespace, dimensions, rel = 'icon')
safe_join dimensions.map { |dimension| namespaced_png_favicon_link_tag(namespace, dimension, rel).html_safe }
end
end
41 changes: 25 additions & 16 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@
%title
= t("titles.main", :thing => t("defaults.thing").titleize)
= csrf_meta_tag
= namespaced_png_favicon_link_tags('apple-touch-icon', [57, 60, 72, 76, 114, 120, 144, 152, 180], 'apple-touch-icon')
= namespaced_png_favicon_link_tags('favicon', [16, 32, 96])
= namespaced_png_favicon_link_tags('android-chrome', [36, 48, 72])
= favicon_link_tag favicon_path('safari-pinned-tab.svg'), favicon_attrs('mask-icon', 'image/svg+xml')
= favicon_link_tag favicon_path('favicon.ico')
%meta{name: 'msapplication-TileColor', content: '#da532c'}
%meta{name: 'msapplication-TileImage', content: "#{namespaced_png_favicon_path('mstile', 144)}"}
%meta{name: 'msapplication-config', content: "#{asset_path('browserconfig.xml')}"}
%meta{name: 'theme-color', content: '#ffffff'}
%meta{:name => "viewport", :content => "width=800, user-scalable=no"}
/ HTML5 shim, for IE6-8 support of HTML5 elements
/[if lt IE 9]
= javascript_include_tag "//html5shim.googlecode.com/svn/trunk/html5.js"
= javascript_include_tag "//maps.google.com/maps/api/js?sensor=false&language=#{I18n.locale}"
= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"
= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
= javascript_include_tag "application"
- if Rails.env.production? && ENV['GOOGLE_ANALYTICS_ID'].present?
%script{:type => "text/javascript"}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '#{ENV['GOOGLE_ANALYTICS_ID']}', '#{ENV['GOOGLE_ANALYTICS_DOMAIN']}');
ga('send', 'pageview');
= stylesheet_link_tag "application"
%body
= yield
/ HTML5 shim, for IE6-8 support of HTML5 elements
/[if lt IE 9]
= javascript_include_tag "//html5shim.googlecode.com/svn/trunk/html5.js"
= javascript_include_tag "//maps.google.com/maps/api/js?sensor=false&language=#{I18n.locale}"
= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"
= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
= javascript_include_tag "application"
- if Rails.env.production? && ENV['GOOGLE_ANALYTICS_ID'].present?
%script{:type => "text/javascript"}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '#{ENV['GOOGLE_ANALYTICS_ID']}', '#{ENV['GOOGLE_ANALYTICS_DOMAIN']}');
ga('send', 'pageview');
2 changes: 1 addition & 1 deletion app/views/main/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.table-row
.table-cell.sidebar
%h1
= image_tag "logos/adopt-a-hydrant.png", :alt => t("titles.main", :thing => t("defaults.thing").titleize), :title => t("titles.main", :thing => t("defaults.thing").titleize)
= image_tag 'logos/adopt-a-hydrant.png', alt: t('titles.main', thing: t('defaults.thing').titleize), title: t('titles.main', thing: t('defaults.thing').titleize), id: 'adopt-a-hydrant-logo'
%p.alert-message.block-message#tagline
= t("defaults.tagline")
#content
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
45 changes: 45 additions & 0 deletions test/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'test_helper'

class ApplicationHelperTest < ActionView::TestCase
include ApplicationHelper

setup do
@namespace = 'android-chrome'
@dimension = 96
@assets_version = Rails.application.config.assets.version
@path = "/images/logos/favicons/#{@namespace}-#{dimensions(@dimension)}.png?v=" << @assets_version
@rel = 'icon'
end

test 'should return dimensions' do
assert_equal('96x96', dimensions(@dimension))
end

test "should return a favicon's path" do
file = 'test.png'
path = "/images/logos/favicons/#{file}?v=" << @assets_version

assert_equal(path, favicon_path(file))
end

test 'should return favicon attributes' do
assert_equal({rel: @rel, type: 'image/png'}, favicon_attrs(@rel))
end

test 'should return favicon attributes for a given type' do
rel = 'mask-icon'
type = 'image/svg+xml'

assert_equal({rel: rel, type: type}, favicon_attrs(rel, type))
end

test "should return a namespaced png favicon's path" do
assert_equal(@path, namespaced_png_favicon_path(@namespace, @dimension))
end

test "should return a namespaced png favicon's link tag" do
favicon_link_tag = "<link rel=\"#{@rel}\" type=\"image/png\" href=\"" << @path << "\" sizes=\"#{dimensions(@dimension)}\" />"

assert_equal(favicon_link_tag, namespaced_png_favicon_link_tag(@namespace, @dimension, @rel))
end
end