Use canonical-rails gem to generate canonical URLs
This commit is contained in:
parent
ce209c8c4f
commit
24271b75bd
4 changed files with 46 additions and 19 deletions
3
Gemfile
3
Gemfile
|
@ -95,6 +95,9 @@ gem "kgio"
|
|||
# Load secure_headers for Content-Security-Policy support
|
||||
gem "secure_headers"
|
||||
|
||||
# Load canonical-rails to generate canonical URLs
|
||||
gem "canonical-rails"
|
||||
|
||||
# Used to generate logstash friendly log files
|
||||
gem "logstasher"
|
||||
|
||||
|
|
38
Gemfile.lock
38
Gemfile.lock
|
@ -42,11 +42,13 @@ GEM
|
|||
public_suffix (~> 2.0, >= 2.0.2)
|
||||
arel (6.0.4)
|
||||
ast (2.3.0)
|
||||
autoprefixer-rails (6.7.5)
|
||||
autoprefixer-rails (6.7.7.1)
|
||||
execjs
|
||||
bigdecimal (1.1.0)
|
||||
builder (3.2.3)
|
||||
capybara (2.12.1)
|
||||
canonical-rails (0.1.2)
|
||||
rails (>= 4.1, < 5.1)
|
||||
capybara (2.13.0)
|
||||
addressable
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
|
@ -67,7 +69,7 @@ GEM
|
|||
colorize (0.8.1)
|
||||
composite_primary_keys (8.1.4)
|
||||
activerecord (~> 4.2.0)
|
||||
concurrent-ruby (1.0.4)
|
||||
concurrent-ruby (1.0.5)
|
||||
coveralls (0.8.19)
|
||||
json (>= 1.8, < 3)
|
||||
simplecov (~> 0.12.0)
|
||||
|
@ -89,9 +91,9 @@ GEM
|
|||
factory_girl_rails (4.8.0)
|
||||
factory_girl (~> 4.8.0)
|
||||
railties (>= 3.0.0)
|
||||
faraday (0.10.1)
|
||||
faraday (0.11.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
fspath (3.0.3)
|
||||
fspath (3.1.0)
|
||||
geoip (1.6.3)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
|
@ -100,7 +102,7 @@ GEM
|
|||
htmlentities (4.3.4)
|
||||
http_accept_language (2.0.5)
|
||||
i18n (0.8.1)
|
||||
i18n-js (3.0.0.rc15)
|
||||
i18n-js (3.0.0.rc16)
|
||||
i18n (~> 0.6, >= 0.6.6)
|
||||
image_optim (0.24.2)
|
||||
exifr (~> 1.2, >= 1.2.2)
|
||||
|
@ -108,13 +110,13 @@ GEM
|
|||
image_size (~> 1.5)
|
||||
in_threads (~> 1.3)
|
||||
progress (~> 3.0, >= 3.0.1)
|
||||
image_optim_rails (0.2.0)
|
||||
image_optim_rails (0.3.0)
|
||||
image_optim (~> 0.24.0)
|
||||
rails
|
||||
sprockets
|
||||
image_size (1.5.0)
|
||||
in_threads (1.3.1)
|
||||
jquery-rails (4.2.2)
|
||||
in_threads (1.4.0)
|
||||
jquery-rails (4.3.1)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
|
@ -138,11 +140,10 @@ GEM
|
|||
sprockets (>= 2, < 4)
|
||||
sprockets-rails (>= 2, < 4)
|
||||
tilt
|
||||
libv8 (3.16.14.17)
|
||||
libv8 (3.16.14.19)
|
||||
libxml-ruby (3.0.0)
|
||||
logstash-event (1.2.02)
|
||||
logstasher (1.1.1)
|
||||
activerecord (>= 4.0)
|
||||
logstasher (1.2.1)
|
||||
activesupport (>= 4.0)
|
||||
logstash-event (~> 1.2.0)
|
||||
request_store
|
||||
|
@ -159,7 +160,7 @@ GEM
|
|||
multi_json (1.12.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.7.0.1)
|
||||
nokogiri (1.7.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
nokogumbo (1.4.9)
|
||||
nokogiri
|
||||
|
@ -211,8 +212,8 @@ GEM
|
|||
mimemagic (= 0.3.0)
|
||||
parser (2.4.0.0)
|
||||
ast (~> 2.2)
|
||||
pg (0.19.0)
|
||||
poltergeist (1.13.0)
|
||||
pg (0.20.0)
|
||||
poltergeist (1.14.0)
|
||||
capybara (~> 2.1)
|
||||
cliver (~> 0.3.1)
|
||||
websocket-driver (>= 0.2.0)
|
||||
|
@ -283,7 +284,7 @@ GEM
|
|||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
secure_headers (3.6.1)
|
||||
secure_headers (3.6.2)
|
||||
useragent
|
||||
simplecov (0.12.0)
|
||||
docile (~> 1.1.0)
|
||||
|
@ -304,12 +305,12 @@ GEM
|
|||
ref
|
||||
thor (0.19.4)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.6)
|
||||
tilt (2.0.7)
|
||||
timecop (0.8.1)
|
||||
tins (1.13.2)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (3.0.4)
|
||||
uglifier (3.1.9)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode-display_width (1.1.3)
|
||||
useragent (0.16.8)
|
||||
|
@ -334,6 +335,7 @@ DEPENDENCIES
|
|||
actionpack-page_caching
|
||||
autoprefixer-rails
|
||||
bigdecimal (~> 1.1.0)
|
||||
canonical-rails
|
||||
coffee-rails (~> 4.1.0)
|
||||
composite_primary_keys (~> 8.1.0)
|
||||
coveralls
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<%= tag("meta", { :name => "msapplication-TileColor", :content => "#00a300" }) %>
|
||||
<%= tag("meta", { :name => "msapplication-TileImage", :content => image_path("mstile-144x144.png") }) %>
|
||||
<%= tag("meta", { :name => "theme-color", :content => "#ffffff" }) %>
|
||||
<%= tag("link", { :rel => "canonical", :href => root_url(:host => SERVER_URL) }) %>
|
||||
<%= canonical_tag %>
|
||||
<%= tag("link", { :rel => "publisher", :href => "https://plus.google.com/111953119785824514010" }) %>
|
||||
<%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => asset_path("osm.xml") }) %>
|
||||
<%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %>
|
||||
|
|
22
config/initializers/canonical_rails.rb
Normal file
22
config/initializers/canonical_rails.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
CanonicalRails.setup do |config|
|
||||
# Force the protocol. If you do not specify, the protocol will be based on the incoming request's protocol.
|
||||
|
||||
# config.protocol#= 'https://'
|
||||
|
||||
# This is the main host, not just the TLD, omit slashes and protocol. If you have more than one, pick the one you want to rank in search results.
|
||||
|
||||
config.host = SERVER_URL
|
||||
|
||||
# http://en.wikipedia.org/wiki/URL_normalization
|
||||
# Trailing slash represents semantics of a directory, ie a collection view - implying an :index get route;
|
||||
# otherwise we have to assume semantics of an instance of a resource type, a member view - implying a :show get route
|
||||
#
|
||||
# Acts as a whitelist for routes to have trailing slashes
|
||||
|
||||
config.collection_actions = [:index]
|
||||
|
||||
# Parameter spamming can cause index dilution by creating seemingly different URLs with identical or near-identical content.
|
||||
# Unless whitelisted, these parameters will be omitted
|
||||
|
||||
config.whitelisted_parameters = []
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue