diff --git a/.rubocop.yml b/.rubocop.yml index 8f8ed4291..78feced66 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,7 +18,7 @@ Metrics/LineLength: Description: Limit lines to 80 characters. StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits Enabled: false - Max: 80 + Max: 100 AllowURI: true URISchemes: - http diff --git a/Gemfile b/Gemfile index 8c0eab393..4d407b214 100644 --- a/Gemfile +++ b/Gemfile @@ -49,6 +49,8 @@ gem 'figaro' # Handles logic behind Pagination UI component. gem 'kaminari' +gem 'sprockets', '~> 2.12' + group :production, :staging do # Enables serving assets in production and setting logger to standard out. gem 'rails_12factor' @@ -84,10 +86,10 @@ group :test do gem 'coveralls', require: false gem 'capybara', '~> 2.4' gem 'poltergeist' - gem 'vcr', git: 'https://github.com/vcr/vcr.git' + gem 'vcr' gem 'webmock', '~> 1.20' gem 'email_spec', '~> 1.6.0' - gem 'haml-lint' + gem 'haml_lint', git: 'https://github.com/brigade/haml-lint.git' # Ruby static code analyzer, based on the community Ruby style guide. gem 'rubocop' diff --git a/Gemfile.lock b/Gemfile.lock index f26abde02..571c95b87 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,44 +1,46 @@ GIT - remote: https://github.com/vcr/vcr.git - revision: cc57fc4c6da01c37ecb5700040a5eeda5633e12a + remote: https://github.com/brigade/haml-lint.git + revision: 0618339b32b7cc5da18f6b9415c4791af76f1136 specs: - vcr (3.0.0) + haml_lint (0.16.0) + haml (~> 4.0) + rake (~> 10.0) + rubocop (>= 0.36.0) + sysexits (~> 1.1) GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.5) - actionpack (= 4.2.5) - actionview (= 4.2.5) - activejob (= 4.2.5) + actionmailer (4.2.5.1) + actionpack (= 4.2.5.1) + actionview (= 4.2.5.1) + activejob (= 4.2.5.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.5) - actionview (= 4.2.5) - activesupport (= 4.2.5) + actionpack (4.2.5.1) + actionview (= 4.2.5.1) + activesupport (= 4.2.5.1) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5) - activesupport (= 4.2.5) + actionview (4.2.5.1) + activesupport (= 4.2.5.1) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.5) - activesupport (= 4.2.5) + activejob (4.2.5.1) + activesupport (= 4.2.5.1) globalid (>= 0.3.0) - activesupport (4.2.5) + activesupport (4.2.5.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) - ast (2.1.0) - astrolabe (1.3.1) - parser (~> 2.2) + ast (2.2.0) autoparse (0.3.3) addressable (>= 2.3.1) extlib (>= 0.9.15) @@ -51,7 +53,8 @@ GEM binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) - capybara (2.5.0) + capybara (2.6.2) + addressable mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) @@ -72,10 +75,10 @@ GEM sass (>= 3.3.0, < 3.5) compass-import-once (1.0.5) sass (>= 3.2, < 3.5) - compass-rails (2.0.5) + compass-rails (3.0.0) compass (~> 1.0.0) sass-rails (< 5.1) - sprockets (< 2.13) + sprockets (< 4.0) coveralls (0.8.10) json (~> 1.8) rest-client (>= 1.6.8, < 2) @@ -83,23 +86,23 @@ GEM term-ansicolor (~> 1.3) thor (~> 0.19.1) tins (~> 1.6.0) - crack (0.4.2) + crack (0.4.3) safe_yaml (~> 1.0.0) dalli (2.7.5) debug_inspector (0.0.2) derailed (0.1.0) derailed_benchmarks - derailed_benchmarks (1.1.3) + derailed_benchmarks (1.3.0) benchmark-ips (~> 2) get_process_mem (~> 0) heapy (~> 0) memory_profiler (~> 0) - rack (~> 1) + rack (>= 1) rake (~> 10) thor (~> 0.19) diff-lcs (1.2.5) docile (1.1.5) - domain_name (0.5.25) + domain_name (0.5.20160128) unf (>= 0.0.5, < 1.0.0) email_spec (1.6.0) launchy (~> 2.1) @@ -135,19 +138,16 @@ GEM multi_json (~> 1.10) retriable (~> 1.4) signet (~> 0.6) - googleauth (0.4.2) + googleauth (0.5.1) faraday (~> 0.9) jwt (~> 1.4) logging (~> 2.0) memoist (~> 0.12) multi_json (~> 1.11) - signet (~> 0.6) + os (~> 0.9) + signet (~> 0.7) haml (4.0.7) tilt - haml-lint (0.13.0) - haml (~> 4.0) - rubocop (>= 0.25.0) - sysexits (~> 1.1) haml-rails (0.9.0) actionpack (>= 4.0.1) activesupport (>= 4.0.1) @@ -192,31 +192,32 @@ GEM mail (2.6.3) mime-types (>= 1.16, < 3) memcachier (0.0.2) - memoist (0.13.0) + memoist (0.14.0) memory_profiler (0.9.6) mime-types (2.99) mini_portile2 (2.0.0) - minitest (5.8.3) + minitest (5.8.4) multi_json (1.11.2) multipart-post (2.0.0) netrc (0.11.0) - nokogiri (1.6.7.1) + nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) ohanakapa (1.1.2) sawyer (~> 0.5.3) - parser (2.2.3.0) - ast (>= 1.1, < 3.0) + os (0.9.6) + parser (2.3.0.2) + ast (~> 2.2) poltergeist (1.8.1) capybara (~> 2.1) cliver (~> 0.3.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) powerpack (0.1.1) - puma (2.15.3) + puma (2.16.0) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) rack (1.6.4) - rack-cache (1.5.1) + rack-cache (1.6.0) rack (>= 0.4) rack-mini-profiler (0.9.8) rack (>= 1.1.3) @@ -229,23 +230,23 @@ GEM activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) + rails-html-sanitizer (1.0.3) loofah (~> 2.0) rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.4) rails_stdout_logging (0.0.4) - railties (4.2.5) - actionpack (= 4.2.5) - activesupport (= 4.2.5) + railties (4.2.5.1) + actionpack (= 4.2.5.1) + activesupport (= 4.2.5.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.0.0) - rake (10.4.2) + rainbow (2.1.0) + rake (10.5.0) rake-compiler (0.9.5) rake - rb-fsevent (0.9.6) + rb-fsevent (0.9.7) rb-inotify (0.9.5) ffi (>= 0.5.0) ref (2.0.0) @@ -256,15 +257,15 @@ GEM mime-types (>= 1.16, < 3.0) netrc (~> 0.7) retriable (1.4.1) - rspec-core (3.4.1) + rspec-core (3.4.2) rspec-support (~> 3.4.0) rspec-expectations (3.4.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) - rspec-mocks (3.4.0) + rspec-mocks (3.4.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.4.0) - rspec-rails (3.4.0) + rspec-rails (3.4.1) actionpack (>= 3.0, < 4.3) activesupport (>= 3.0, < 4.3) railties (>= 3.0, < 4.3) @@ -273,18 +274,16 @@ GEM rspec-mocks (~> 3.4.0) rspec-support (~> 3.4.0) rspec-support (3.4.1) - rubocop (0.35.1) - astrolabe (~> 1.3) - parser (>= 2.2.3.0, < 3.0) + rubocop (0.36.0) + parser (>= 2.3.0.0, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) - tins (<= 1.6.0) ruby-progressbar (1.7.5) - ruby_parser (3.7.2) + ruby_parser (3.7.3) sexp_processor (~> 4.1) safe_yaml (1.0.4) - sass (3.4.19) + sass (3.4.21) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) sass (~> 3.1) @@ -294,10 +293,9 @@ GEM sawyer (0.5.5) addressable (~> 2.3.5) faraday (~> 0.8, < 0.10) - sexp_processor (4.6.0) - signet (0.6.1) + sexp_processor (4.6.1) + signet (0.7.2) addressable (~> 2.3) - extlib (~> 0.9) faraday (~> 0.9) jwt (~> 1.5) multi_json (~> 1.10) @@ -306,7 +304,7 @@ GEM json (~> 1.8) simplecov-html (~> 0.10.0) simplecov-html (0.10.0) - spring (1.6.1) + spring (1.6.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) spring-watcher-listen (2.0.0) @@ -339,7 +337,8 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.1) - webmock (1.22.3) + vcr (3.0.1) + webmock (1.22.6) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff @@ -368,8 +367,8 @@ DEPENDENCIES flamegraph font-awesome-rails google-api-client (~> 0.8.1) - haml-lint haml-rails + haml_lint! jshint kaminari kgio @@ -391,8 +390,9 @@ DEPENDENCIES spring spring-commands-rspec spring-watcher-listen + sprockets (~> 2.12) uglifier - vcr! + vcr webmock (~> 1.20) yard diff --git a/app/helpers/alert_helper.rb b/app/helpers/alert_helper.rb index 75ee4ead8..460a7fce6 100644 --- a/app/helpers/alert_helper.rb +++ b/app/helpers/alert_helper.rb @@ -1,7 +1,7 @@ module AlertHelper def alert_tag(message) content_tag(:div, class: 'alert alert-error') do - concat(content_tag :p, message, id: 'flash_error', class: 'alert-message') + concat(content_tag(:p, message, id: 'flash_error', class: 'alert-message')) concat(content_tag(:a, class: 'alert-close', data: { dismiss: 'alert' }) do content_tag :i, nil, class: 'fa fa-times-circle fa-2x' end) diff --git a/app/helpers/homepage_links_helper.rb b/app/helpers/homepage_links_helper.rb index 155d2b840..013a1a908 100644 --- a/app/helpers/homepage_links_helper.rb +++ b/app/helpers/homepage_links_helper.rb @@ -67,7 +67,7 @@ def link_to_keyword(keyword, link_text) locations_path(keyword: keyword), 'class' => 'links-to-track', 'data-ga-category' => 'Home_Categories', - 'data-ga-label' => "#{link_text}" + 'data-ga-label' => link_text ) end end diff --git a/app/helpers/info_box_helper.rb b/app/helpers/info_box_helper.rb index a4a60528a..a9fb222fb 100644 --- a/app/helpers/info_box_helper.rb +++ b/app/helpers/info_box_helper.rb @@ -47,8 +47,8 @@ def info_box_key_corresponding_to_keyword # description, and a "More info..." link to its URL if it has one defined. def render_html_for_generic_info_box(info_box) html = content_tag :dl do - concat(content_tag :dt, info_box['title']) - concat(content_tag :dd, info_box['description']) + concat(content_tag(:dt, info_box['title'])) + concat(content_tag(:dd, info_box['description'])) end return html if info_box['url'].blank? html.concat(content_tag(:p) do diff --git a/app/helpers/result_summary_helper.rb b/app/helpers/result_summary_helper.rb index de2028f58..95cd22868 100644 --- a/app/helpers/result_summary_helper.rb +++ b/app/helpers/result_summary_helper.rb @@ -14,13 +14,21 @@ def search_results_page_title def map_summary total_results = @search.locations.size total_map_markers = @search.map_data.size - if total_map_markers == total_results - summary = '' - else - summary = " "\ + summary = if total_map_markers == total_results + '' + else + " "\ "#{total_map_markers}/#{total_results} "\ 'located on map' - end + end summary.html_safe end + + def location_link_for(location) + if location.organization.name == location.name + location_path([location.slug], request.query_parameters) + else + location_path([location.organization.slug, location.slug], request.query_parameters) + end + end end diff --git a/app/views/component/detail/_service_keywords.html.haml b/app/views/component/detail/_service_keywords.html.haml index ba18b4f40..cc5ce1ab9 100644 --- a/app/views/component/detail/_service_keywords.html.haml +++ b/app/views/component/detail/_service_keywords.html.haml @@ -6,4 +6,4 @@ - @keywords.each do |keyword| %li %span - = link_to keyword, locations_path(request.query_parameters.merge(keyword: keyword)) \ No newline at end of file + = link_to keyword, locations_path(request.query_parameters.merge(keyword: keyword)) diff --git a/app/views/component/locations/detail/_body.html.haml b/app/views/component/locations/detail/_body.html.haml index 6ac22c19b..577669c3f 100644 --- a/app/views/component/locations/detail/_body.html.haml +++ b/app/views/component/locations/detail/_body.html.haml @@ -7,7 +7,7 @@ %h1.name = superscript_ordinals(full_name_content_for(@location)) - - if (@location.organization.name) && (@location.organization.name != @location.name) + - if @location.organization.name && @location.organization.name != @location.name %h2.agency = link_to(locations_path(org_name: @location.organization.name)) do %span diff --git a/app/views/component/locations/results/_list_view.html.haml b/app/views/component/locations/results/_list_view.html.haml index f1162212f..617a976de 100644 --- a/app/views/component/locations/results/_list_view.html.haml +++ b/app/views/component/locations/results/_list_view.html.haml @@ -3,16 +3,16 @@ - @search.locations.each do |location| %li - %a{ href: (location.organization.name == location.name) ? "#{location_path([location.slug], request.query_parameters)}" : "#{location_path([location.organization.slug, location.slug], request.query_parameters)}", title: "#{location.name}", name: "#{location.id}" } + %a{ href: location_link_for(location), title: location.name, name: location.id }   %section.results-entry{ itemscope: '', itemtype: 'http://schema.org/Organization' } %header %hgroup %h1.name - %a{ href: (location.organization.name == location.name) ? "#{location_path([location.slug], request.query_parameters)}" : "#{location_path([location.organization.slug, location.slug], request.query_parameters)}", name: "#{location.id}" } + %a{ href: location_link_for(location), name: location.id } = superscript_ordinals(full_name_content_for(location)) - - if (location.organization.name) && (location.organization.name != location.name) + - if location.organization.name && location.organization.name != location.name %h2.agency = link_to(locations_path(org_name: location.organization.name)) do %span diff --git a/app/views/locations/show.html.haml b/app/views/locations/show.html.haml index d1aa448c5..62cc5134e 100644 --- a/app/views/locations/show.html.haml +++ b/app/views/locations/show.html.haml @@ -2,4 +2,4 @@ - @location.name == @location.organization.name ? canonical("#{locations_url}/#{@location.slug}") : canonical("#{locations_url}/#{@location.organization.slug}/#{@location.slug}") = render 'component/search/aside' %section#results-container - = render 'component/locations/detail/body' \ No newline at end of file + = render 'component/locations/detail/body' diff --git a/app/views/shared/_header.html.haml b/app/views/shared/_header.html.haml index 770585a3d..6403b06a2 100644 --- a/app/views/shared/_header.html.haml +++ b/app/views/shared/_header.html.haml @@ -1,7 +1,7 @@ %header#content-header %h1#logo %a{ href: '/', target: '_self' } - %img{ src: "#{asset_path(SETTINGS[:site_logo])}", alt: "#{SETTINGS[:site_title]} Logo" } + %img{ src: asset_path(SETTINGS[:site_logo]), alt: "#{SETTINGS[:site_title]} Logo" } %h2= t('branding.header', location: t('branding.location')) %nav %ul