Merge lp:~mbp/launchpad/888353-microformats into lp:launchpad

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 14377
Proposed branch: lp:~mbp/launchpad/888353-microformats
Merge into: lp:launchpad
Diff against target: 173 lines (+50/-12)
7 files modified
lib/lp/app/doc/hierarchical-menu.txt (+1/-1)
lib/lp/app/templates/base-layout.pt (+2/-0)
lib/lp/app/templates/launchpad-hierarchy.pt (+1/-0)
lib/lp/bugs/browser/tests/test_bugcomment.py (+29/-0)
lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt (+3/-3)
lib/lp/bugs/templates/bugcomment-box.pt (+13/-7)
lib/lp/bugs/templates/bugtask-index.pt (+1/-1)
To merge this branch: bzr merge lp:~mbp/launchpad/888353-microformats
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+82767@code.launchpad.net

Commit message

[r=rvb][bug=888353] add schema.org microformats for bugs and breadcrumbs

Description of the change

This adds a small amount of schemas.org to the main bug page and to the generic breadcrumbs, with a goal of getting search engines to give better summaries snippets of bug pages that turn up in search results.

To see whether it actually does work or not we'll need to deploy this and wait for it to be indexed. We could do a lot more but this is an experiment to see if it has a noticeable effect.

There are not any (intentional) changes is normal page content or behaviour.

You can see Google's test parser on it at <http://www.google.com/webmasters/tools/richsnippets?url=http%3A%2F%2Fsourcefrog.net%2Ftmp%2F1w%2Fbug1.html&view=cse>.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Hi Martin, this looks like a very good idea but I've got a few remarks. I'm no microformat expert so please bear with me ;).

= Real questions/remarks =

[0]

8 + itemscope itemtype="http://schema.org/WebPage"

You only include the breadcrumbs here, don't you think it would be useful (for the test to be complete), to also include a name (http://schema.org/Thing) and a URL (http://schema.org/Thing) [and maybe a description (http://schema.org/Thing)]? Obviously the parser can take the url as an identifier but maybe it's better if we explicitly provide one.

[1]

38 + itemprop="commentTime"

I'm not sure "on XXX" is correctly parsed as a date, and I'm pretty sure "a moment ago" won't be. Maybe it would be worth to add the date properly formatted in the tag with an attribute such as """ datetime="2007-10-20" """.

[2]

I cannot help but notice that there is no test for this. I understand this is a test so it's probably ok… Maybe you could include an empty (or almost empty) test for this with a reference to this bug just so that we don't forget to add tests should we develop this further.

= Details =

[0]

37 <span tal:attributes="title comment/datecreated/fmt:datetime"
38 + itemprop="commentTime"
39 tal:content="comment/datecreated/fmt:displaydate">

Weird formatting here.

[1]

45 <td class="bug-comment-index">
46 - <a tal:attributes="href comment/fmt:url"
47 - tal:content="string: #${comment/index}" />
48 + <a itemprop="url"
49 + tal:attributes="href comment/fmt:url"
50 + tal:content="string: #${comment/index}" />

And here.

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

2011/11/21 Raphaël Badin <email address hidden>:
> Review: Approve
>
> Hi Martin, this looks like a very good idea but I've got a few remarks.  I'm no microformat expert so please bear with me ;).

Thanks for being willing to review it anyhow.

>
> = Real questions/remarks =
>
> [0]
>
> 8       +    itemscope itemtype="http://schema.org/WebPage"
>
> You only include the breadcrumbs here, don't you think it would be useful (for the test to be complete), to also include a name (http://schema.org/Thing) and a URL (http://schema.org/Thing) [and maybe a description (http://schema.org/Thing)]? Obviously the parser can take the url as an identifier but maybe it's better if we explicitly provide one.

Putting in the description, probably using the same thing for the meta
description, might be useful. (Though, also kind of redundant
perhaps.)

Putting the URL for the page itself seems a bit redundant too, but
that could go off the canoncial_url_recommended.

A place where I can imagine the url being useful is in eg comments on
a bug, which each have a scope and a url of their own.

To some extent we're guessing how the black box of search engines will
behave - in the first cut I'm trying to do something large enough we
may see some difference without spending too much time or making too
intrusive changes.

>
> [1]
>
> 38      +                 itemprop="commentTime"
>
> I'm not sure "on XXX" is correctly parsed as a date, and I'm pretty sure "a moment ago" won't be.  Maybe it would be worth to add the date properly formatted in the tag with an attribute such as """ datetime="2007-10-20" """.

Good point.

>
> [2]
>
> I cannot help but notice that there is no test for this.  I understand this is a test so it's probably ok…  Maybe you could include an empty (or almost empty) test for this with a reference to this bug just so that we don't forget to add tests should we develop this further.

Good idea too.

--
Martin

Revision history for this message
Raphaël Badin (rvb) wrote :

> A place where I can imagine the url being useful is in eg comments on
> a bug, which each have a scope and a url of their own.

Right.

> To some extent we're guessing how the black box of search engines will
> behave - in the first cut I'm trying to do something large enough we
> may see some difference without spending too much time or making too
> intrusive changes.

True… I'm really looking forward to see how this impacts Goo^Wsearch engines. I'm subscribed to the related bug… would you be kind enough to post a small summary of your findings in the bug comments when you'll have assessed the impact of this change?

Revision history for this message
Martin Pool (mbp) wrote :

ok, this update
 * changes to a <time datetime=> tag
 * uses a machine readable date
 * adds a test for that tag

Is there a better way to write this test?

thanks.

Revision history for this message
Raphaël Badin (rvb) wrote :

> ok, this update
> * changes to a <time datetime=> tag
> * uses a machine readable date
> * adds a test for that tag
>
> Is there a better way to write this test?
>
> thanks.

It's a little bit verbose, I'll give you that… but fairly readable still I think.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/doc/hierarchical-menu.txt'
2--- lib/lp/app/doc/hierarchical-menu.txt 2011-05-27 18:27:59 +0000
3+++ lib/lp/app/doc/hierarchical-menu.txt 2011-11-24 01:04:28 +0000
4@@ -248,7 +248,7 @@
5 represents the current location.
6
7 >>> print markup
8- <ol class="breadcrumbs">
9+ <ol itemprop="breadcrumb" class="breadcrumbs">
10 <li>
11 <a href="http://launchpad.dev/joy-of-cooking">Joy of cooking</a>
12 </li>
13
14=== modified file 'lib/lp/app/templates/base-layout.pt'
15--- lib/lp/app/templates/base-layout.pt 2011-11-20 06:38:50 +0000
16+++ lib/lp/app/templates/base-layout.pt 2011-11-24 01:04:28 +0000
17@@ -62,6 +62,8 @@
18 </head>
19
20 <body id="document"
21+ itemscope=""
22+ itemtype="http://schema.org/WebPage"
23 tal:attributes="class string:tab-${view/menu:selectedfacetname}
24 ${view/macro:pagetype}
25 ${view/context/fmt:public-private-css}
26
27=== modified file 'lib/lp/app/templates/launchpad-hierarchy.pt'
28--- lib/lp/app/templates/launchpad-hierarchy.pt 2010-07-21 18:03:44 +0000
29+++ lib/lp/app/templates/launchpad-hierarchy.pt 2011-11-24 01:04:28 +0000
30@@ -1,4 +1,5 @@
31 <ol
32+ itemprop="breadcrumb"
33 class="breadcrumbs"
34 xmlns:tal="http://xml.zope.org/namespaces/tal"
35 xmlns:metal="http://xml.zope.org/namespaces/metal"
36
37=== modified file 'lib/lp/bugs/browser/tests/test_bugcomment.py'
38--- lib/lp/bugs/browser/tests/test_bugcomment.py 2011-11-16 23:46:01 +0000
39+++ lib/lp/bugs/browser/tests/test_bugcomment.py 2011-11-24 01:04:28 +0000
40@@ -15,6 +15,14 @@
41 from zope.component import getUtility
42 from zope.security.proxy import removeSecurityProxy
43
44+from soupmatchers import (
45+ HTMLContains,
46+ Tag,
47+ )
48+
49+from canonical.launchpad.ftests import (
50+ login_person,
51+ )
52 from canonical.launchpad.testing.pages import find_tag_by_id
53 from canonical.testing.layers import DatabaseFunctionalLayer
54 from lp.app.interfaces.launchpad import ILaunchpadCelebrities
55@@ -287,3 +295,24 @@
56 naked_bugtask = removeSecurityProxy(context.default_bugtask)
57 removeSecurityProxy(naked_bugtask.pillar).security_contact = person
58 self._test_hide_link_visible(context, person)
59+
60+
61+class TestBugCommentMicroformats(BrowserTestCase):
62+
63+ layer = DatabaseFunctionalLayer
64+
65+ def test_bug_comment_metadata(self):
66+ owner = self.factory.makePerson()
67+ login_person(owner)
68+ bug_comment = self.factory.makeBugComment()
69+ browser = self.getViewBrowser(bug_comment)
70+ iso_date = bug_comment.datecreated.isoformat()
71+ self.assertThat(
72+ browser.contents,
73+ HTMLContains(Tag(
74+ 'comment time tag',
75+ 'time',
76+ attrs=dict(
77+ itemprop='commentTime',
78+ title=True,
79+ datetime=iso_date))))
80
81=== modified file 'lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt'
82--- lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt 2010-03-22 22:56:44 +0000
83+++ lib/lp/bugs/stories/bugs/xx-bug-comments-truncated.txt 2011-11-24 01:04:28 +0000
84@@ -30,14 +30,14 @@
85 ... print div_tag
86 >>> print_comments(browser.contents) #doctest: -ELLIPSIS
87 <div class="boardCommentBody">
88- <div class="bug-comment"><p>This
89+ <div class="bug-comment" itemprop="commentText"><p>This
90 would be a real killer feature. If there...</p></div>
91 <p>
92 <a href="/tomcat/+bug/2/comments/1">Read more...</a>
93 </p>
94 </div>
95 <div class="boardCommentBody">
96- <div class="bug-comment"><p>Oddly
97+ <div class="bug-comment" itemprop="commentText"><p>Oddly
98 enough the bug system seems only capabl...</p></div>
99 <p>
100 <a href="/tomcat/+bug/2/comments/2">Read more...</a>
101@@ -57,7 +57,7 @@
102
103 >>> print_comments(browser.contents) #doctest: -ELLIPSIS
104 <div class="boardCommentBody">
105- <div class="bug-comment"><p>This
106+ <div class="bug-comment" itemprop="commentText"><p>This
107 would be a real killer feature. If there is already code
108 to make it possible, why aren't there tons of press announcements
109 about the secuirty possibilities. Imagine - no more embarrassing
110
111=== modified file 'lib/lp/bugs/templates/bugcomment-box.pt'
112--- lib/lp/bugs/templates/bugcomment-box.pt 2011-09-01 10:54:38 +0000
113+++ lib/lp/bugs/templates/bugcomment-box.pt 2011-11-24 01:04:28 +0000
114@@ -2,6 +2,8 @@
115 xmlns="http://www.w3.org/1999/xhtml"
116 xmlns:tal="http://xml.zope.org/namespaces/tal"
117 xmlns:metal="http://xml.zope.org/namespaces/metal"
118+ itemscope=""
119+ itemtype="http://schema.org/UserComments"
120 tal:define="comment context;
121 remote_bug_comment_class
122 python: comment.bugwatch and 'remoteBugComment' or '';
123@@ -19,10 +21,13 @@
124 <tal:comment_owner
125 replace="structure comment/owner/fmt:link-display-name-id" />
126 wrote
127- <span tal:attributes="title comment/datecreated/fmt:datetime"
128- tal:content="comment/datecreated/fmt:displaydate">
129- 7 minutes ago
130- </span>:
131+ <time
132+ itemprop="commentTime"
133+ tal:attributes="title comment/datecreated/fmt:datetime;
134+ datetime comment/datecreated/fmt:isodate"
135+ tal:content="comment/datecreated/fmt:displaydate">
136+ 7 minutes ago
137+ </time>:
138 <a tal:attributes="href comment/fmt:url"
139 tal:condition="comment/display_title">
140 <strong tal:content="comment/title" />
141@@ -46,8 +51,9 @@
142 </a>
143 </td>
144 <td class="bug-comment-index">
145- <a tal:attributes="href comment/fmt:url"
146- tal:content="string: #${comment/index}" />
147+ <a itemprop="url"
148+ tal:attributes="href comment/fmt:url"
149+ tal:content="string: #${comment/index}" />
150 </td>
151 </tr>
152 </tbody>
153@@ -79,7 +85,7 @@
154 </li>
155 </ul>
156
157- <div class="bug-comment"
158+ <div class="bug-comment" itemprop="commentText"
159 tal:content="structure
160 comment/text_for_display/fmt:obfuscate-email/fmt:email-to-html">
161 Comment text.
162
163=== modified file 'lib/lp/bugs/templates/bugtask-index.pt'
164--- lib/lp/bugs/templates/bugtask-index.pt 2011-11-14 04:07:15 +0000
165+++ lib/lp/bugs/templates/bugtask-index.pt 2011-11-24 01:04:28 +0000
166@@ -129,7 +129,7 @@
167 <div><!-- id="nonportlets"> -->
168 <div class="top-portlet">
169
170- <div class="report">
171+ <div itemprop="mainContentOfPage" class="report">
172 <tal:description
173 define="global description context/bug/description/fmt:obfuscate-email/fmt:text-to-html" />
174