mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
add canonical links and descriptions to the meta tags
This commit is contained in:
@@ -95,6 +95,7 @@ class ListingController(RedditController):
|
||||
show_sidebar = self.show_sidebar,
|
||||
nav_menus = self.menus,
|
||||
title = self.title(),
|
||||
description = c.site.description,
|
||||
infotext = self.infotext,
|
||||
**self.render_params).render()
|
||||
return res
|
||||
|
||||
@@ -78,9 +78,12 @@ class Reddit(Wrapped):
|
||||
|
||||
def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
|
||||
infotext = '', content = None, title = '', robots = None,
|
||||
show_sidebar = True, **context):
|
||||
canonical = None, description = None, show_sidebar = True,
|
||||
**context):
|
||||
Wrapped.__init__(self, **context)
|
||||
self.title = title
|
||||
self.description = description
|
||||
self.canonical = canonical
|
||||
self.robots = robots
|
||||
self.infotext = infotext
|
||||
self.loginbox = True
|
||||
@@ -432,7 +435,9 @@ class LinkInfoPage(Reddit):
|
||||
self.link = self.link_listing.things[0]
|
||||
|
||||
link_title = ((self.link.title) if hasattr(self.link, 'title') else '')
|
||||
canonical = "%s%s" % (add_sr(self.link.permalink), "?sort=top")
|
||||
if comment:
|
||||
canonical = "%s%s" % (add_sr(comment.make_permalink_slow()), "?sort=top")
|
||||
if comment._deleted and not c.user_is_admin:
|
||||
author = _("[deleted]")
|
||||
else:
|
||||
@@ -443,7 +448,7 @@ class LinkInfoPage(Reddit):
|
||||
else:
|
||||
params = {'title':_force_unicode(link_title), 'site' : c.site.name}
|
||||
title = strings.link_info_title % params
|
||||
Reddit.__init__(self, title = title, *a, **kw)
|
||||
Reddit.__init__(self, title = title, canonical=canonical, *a, **kw)
|
||||
|
||||
def build_toolbars(self):
|
||||
base_path = "/%s/%s/" % (self.link._id36, title_to_url(self.link.title))
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
<meta name="keywords" content="${self.keywords()}" />
|
||||
<meta name="title" content="${self.Title()}" />
|
||||
${self.Description()}
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
${self.robots()}
|
||||
|
||||
@@ -73,6 +74,9 @@
|
||||
${title}
|
||||
</%def>
|
||||
|
||||
<%def name="Description()">
|
||||
</%def>
|
||||
|
||||
<%def name="keywords()">
|
||||
reddit, reddit.com, vote, comment, submit
|
||||
</%def>
|
||||
|
||||
@@ -36,6 +36,12 @@
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="Description()">
|
||||
%if thing.description:
|
||||
<meta name="description" content="${thing.description}" />
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="stylesheet()">
|
||||
<% from r2.lib.template_helpers import static, get_domain %>
|
||||
|
||||
@@ -73,6 +79,9 @@
|
||||
<link rel="alternate" type="application/rss+xml" title="RSS"
|
||||
href="${add_sr(join_urls(request.path,'.rss'))}" />
|
||||
%endif
|
||||
%if thing.canonical:
|
||||
<link rel="canonical" href="${thing.canonical}" />
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="javascript()">
|
||||
|
||||
Reference in New Issue
Block a user