History

Allow search engines to crawl /offline &co

Thibaut Courouble committed 10 years ago

Commit 0cb57d51 parent 6f75f3c2 files · +7 −5Browse files

Showing the changes to assets/javascripts (1 of 2 files). Show all

Unified · Split

assets/javascripts/lib/page.coffee+6−0
@@ -41,6 +41,7 @@ page.show = (path, state) -> · 40 unmodified lines
41 currentState = context.state41 currentState = context.state
42 page.dispatch(context)42 page.dispatch(context)
43 context.pushState()43 context.pushState()
44 updateCanonicalLink()
44 track()45 track()
45 context46 context
46 47
@@ -50,6 +51,7 @@ page.replace = (path, state, skipDispatch, init) -> · 3 unmodified lines
50 currentState = context.state51 currentState = context.state
51 page.dispatch(context) unless skipDispatch52 page.dispatch(context) unless skipDispatch
52 context.replaceState()53 context.replaceState()
54 updateCanonicalLink()
53 track() unless init or skipDispatch55 track() unless init or skipDispatch
54 context56 context
55 57
@@ -177,6 +179,10 @@ onclick = (event) -> · 121 unmodified lines
177isSameOrigin = (url) ->179isSameOrigin = (url) ->
178 url.indexOf("#{location.protocol}//#{location.hostname}") is 0180 url.indexOf("#{location.protocol}//#{location.hostname}") is 0
179 181
182updateCanonicalLink = ->
183 @canonicalLink ||= document.head.querySelector('link[rel="canonical"]')
184 @canonicalLink.setAttribute('href', "http://#{location.host}#{location.pathname}")
185
180track = ->186track = ->
181 ga?('send', 'pageview', location.pathname + location.search + location.hash)187 ga?('send', 'pageview', location.pathname + location.search + location.hash)
182 _gauges?.push(['track'])188 _gauges?.push(['track'])