Commit 6ab984b1 authored by fred's avatar fred

replace history URI by canonical URI

We have various redirects done on the webserver, but the xmlHttpRequest follows
them silently and the new page is thus displayed with the "wrong" URI. To fix
that we add a <link> element with the canonical URI and use that value to fix
the history.
parent 774108b7
......@@ -53,13 +53,22 @@ $(function() {
if (textStatus == "error") {
doLog('Sorry! And error occur when loading page content','error');
}
new_content = $($.parseHTML(html)).find('#Changing>*');
new_html = $.parseHTML(html);
new_content = $(new_html).find('#Changing>*');
$main.hide().empty().append(new_content).show();
/* calling onpopstate here is necessary to get urlParams to be
* updated */
window.onpopstate();
canonical_href_node = $.grep($(new_html), function(elem, idx) {
return (elem.nodeName === "LINK" && elem.attributes['rel'].value == "canonical");
})[0];
if (canonical_href_node) {
canonical_href = canonical_href_node.attributes['href'].value;
history.replaceState({}, '', canonical_href);
}
new_menu = $($.parseHTML(html)).find('#metaNav>*');
$metaNav.empty().append(new_menu);
......
......@@ -7,6 +7,7 @@
<link rel="icon" href="{{ STATIC_URL }}img/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="{{ STATIC_URL}}img/touch-icon.png">
<link rel="apple-touch-icon-precomposed" href="{{ STATIC_URL}}img/touch-icon.png">
<link rel="canonical" href="{{ request.build_absolute_uri }}" />
<meta name="og:site_name" content="Radio Panik"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment