From c9a4c5e77cb765e4f89491f5add4f40514d8a1c4 Mon Sep 17 00:00:00 2001 From: str4d Date: Wed, 19 Dec 2012 04:51:36 +0000 Subject: [PATCH] Add canonical link to of each page --- i2p2www/__init__.py | 10 +++++++++- i2p2www/pages/global/layout.html | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/i2p2www/__init__.py b/i2p2www/__init__.py index e1a572c5..328917f5 100644 --- a/i2p2www/__init__.py +++ b/i2p2www/__init__.py @@ -18,6 +18,8 @@ from helpers import Pagination CURRENT_I2P_VERSION = '0.9.4' +CANONICAL_DOMAIN = 'www.i2p2.de' + TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'pages') STATIC_DIR = os.path.join(os.path.dirname(__file__), 'static') @@ -127,6 +129,11 @@ def restructuredtext(value): @app.context_processor def utility_processor(): + # Provide the canonical link to the current page + def get_canonical_link(): + protocol = request.url.split('//')[0] + return protocol + '//' + CANONICAL_DOMAIN + request.path + # Convert an I2P url to an equivalent clearnet one i2ptoclear = { 'www.i2p2.i2p': 'www.i2p2.de', @@ -163,7 +170,8 @@ def utility_processor(): return dict(i2pconv=convert_url_to_clearnet, url_for_other_page=url_for_other_page, - change_theme=change_theme) + change_theme=change_theme, + canonical=get_canonical_link) ################ diff --git a/i2p2www/pages/global/layout.html b/i2p2www/pages/global/layout.html index 1d71c19f..494d2566 100644 --- a/i2p2www/pages/global/layout.html +++ b/i2p2www/pages/global/layout.html @@ -4,6 +4,7 @@ {% block title_outer %}{% block title %}{% endblock %} - I2P{% endblock %} +