← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~mbp/launchpad/798412-plusone into lp:launchpad

 

Martin Pool has proposed merging lp:~mbp/launchpad/798412-plusone into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~mbp/launchpad/798412-plusone/+merge/83449

This adds some Google Plus +1 buttons on various interesting objects in Launchpad: archive, product, distro, mp, bug, bug comment, answer, specs.

This could be very usefully extended to comments on bmps and answers, but the object needs to have a URL of its own and those don't yet.

We shouldn't add them to every single page, but mostly to things people are likely to express approval of or interest in.  I added them on things I already see people sharing, and on things I feel like sharing myself.

There is a feature flag to turn this off.  It defaults to on.  We might eventually want a per-user opt-out, but people who feel strongly about not having this probably have a browser configuration to get that already.

There are no specific tests for it (yet).  I think the most interesting test is really whether it works with the external systems.

I would like to also add this on bmp comments and answer comments, but the object has to have its own url and I think those don't yet.

I don't show the button on private objects, to prevent people accidentally sharing them, and (questionable) to prevent Google seeing the URL exists.  This would be cleaner if there was a consistent .private on eg LaunchpadView.  I might add one.

Possibly the button should be moved to a TAL macro.
-- 
https://code.launchpad.net/~mbp/launchpad/798412-plusone/+merge/83449
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/launchpad/798412-plusone into lp:launchpad.
=== modified file 'lib/lp/answers/templates/question-index.pt'
--- lib/lp/answers/templates/question-index.pt	2011-08-20 14:14:26 +0000
+++ lib/lp/answers/templates/question-index.pt	2011-11-25 21:55:39 +0000
@@ -60,6 +60,9 @@
       <tal:description
         define="global description context/description/fmt:obfuscate-email/fmt:text-to-html" />
 
+	<div style="float: right">
+	  <g:plusone tal:attributes="href context/fmt:url" align="right"></g:plusone>
+	</div>
       <div class="report"
         tal:content="structure description"/>
 

=== modified file 'lib/lp/app/templates/base-layout.pt'
--- lib/lp/app/templates/base-layout.pt	2011-11-25 02:19:28 +0000
+++ lib/lp/app/templates/base-layout.pt	2011-11-25 21:55:39 +0000
@@ -172,6 +172,21 @@
 
     <metal:lp-client-cache
       use-macro="context/@@+base-layout-macros/lp-client-cache" />
+
+    <tal:comment tal:replace="nothing">
+      When plusone is disabled, the div tags can still be emitted in to the page by
+      other templates, but they will have no effect because the script is inactive.
+    </tal:comment>
+    <script 
+      tal:condition="not:request/features/plusone.buttons.disabled"
+      type="text/javascript">
+      (function() {
+        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
+        po.src = 'https://apis.google.com/js/plusone.js';
+        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
+      })();
+    </script>
+
   </body>
 
 <tal:template>

=== modified file 'lib/lp/bugs/browser/bugcomment.py'
--- lib/lp/bugs/browser/bugcomment.py	2011-11-16 23:46:01 +0000
+++ lib/lp/bugs/browser/bugcomment.py	2011-11-25 21:55:39 +0000
@@ -341,6 +341,10 @@
             self.comment.index, self.context.bug.id)
 
     @property
+    def page_description(self):
+        return self.comment.text_contents
+
+    @property
     def privacy_notice_classes(self):
         if not self.context.bug.private:
             return 'hidden'

=== modified file 'lib/lp/bugs/templates/bugcomment-box.pt'
--- lib/lp/bugs/templates/bugcomment-box.pt	2011-11-24 00:37:40 +0000
+++ lib/lp/bugs/templates/bugcomment-box.pt	2011-11-25 21:55:39 +0000
@@ -36,13 +36,17 @@
           <td tal:condition="comment/bugwatch">
             <img width="14" height="14" src="/@@/bug-remote" alt=""/>
             In
-            <a tal:attributes="href comment/bugwatch/url"
-               tal:content="comment/bugwatch/title" />,
+            <a itemprop="url"
+              tal:attributes="href comment/bugwatch/url"
+              tal:content="comment/bugwatch/title" />,
             <tal:comment_owner
                 replace="structure comment/owner/fmt:link-display-name-id" />
             wrote
-            <span tal:attributes="title comment/datecreated/fmt:datetime"
-                  tal:content="comment/datecreated/fmt:displaydate">
+            <span 
+              itemprop="commentTime"
+              tal:attributes="title comment/datecreated/fmt:datetime
+                datetime comment/datecreated/fmt:isodate"
+              tal:content="comment/datecreated/fmt:displaydate">
               7 minutes ago
               </span>:
               <a tal:attributes="href comment/fmt:url">
@@ -50,9 +54,18 @@
                         tal:content="comment/title" />
               </a>
           </td>
+
+          <td>
+              <g:plusone
+                size="small"
+                tal:attributes="href comment/fmt:url"
+                align="right">
+              </g:plusone>
+          </td>
+
           <td class="bug-comment-index">
-	  <a itemprop="url"
-	     tal:attributes="href comment/fmt:url"
+          <a itemprop="url"
+             tal:attributes="href comment/fmt:url"
              tal:content="string: #${comment/index}" />
           </td>
         </tr>
@@ -94,6 +107,7 @@
       <a tal:attributes="href comment/fmt:url">Read more...</a>
     </p>
   </div>
+
   <div class="boardCommentFooter" tal:condition="comment/show_footer">
     <a tal:attributes="id string:mark-spam-${context/index};"
        tal:condition="view/show_spam_controls"

=== modified file 'lib/lp/bugs/templates/bugtask-index.pt'
--- lib/lp/bugs/templates/bugtask-index.pt	2011-11-24 05:14:44 +0000
+++ lib/lp/bugs/templates/bugtask-index.pt	2011-11-25 21:55:39 +0000
@@ -81,7 +81,14 @@
     </tal:registering>
 
     <metal:heading fill-slot="heading" tal:define="context_menu context/menu:context">
-      <h1 tal:replace="structure view/bug_title_edit_widget">
+      <div style="float:right" tal:condition="not:context/bug/private" >
+        <g:plusone 
+          tal:attributes="href view/recommended_canonical_url"
+          align="right"></g:plusone>
+      </div>
+      <h1 
+        itemprop="name"
+        tal:replace="structure view/bug_title_edit_widget">
         Bug title
       </h1>
     </metal:heading>

=== modified file 'lib/lp/registry/templates/distribution-index.pt'
--- lib/lp/registry/templates/distribution-index.pt	2011-06-16 13:50:58 +0000
+++ lib/lp/registry/templates/distribution-index.pt	2011-11-25 21:55:39 +0000
@@ -24,7 +24,12 @@
 
   <body>
     <tal:heading metal:fill-slot="heading">
-      <h1 tal:content="context/title">project title</h1>
+      <div style="float:right">
+        <g:plusone
+          tal:attributes="href context/fmt:url" 
+          align="right"></g:plusone>
+      </div>
+      <h1 itemprop="name" tal:content="context/title">project title</h1>
     </tal:heading>
 
     <tal:registering metal:fill-slot="registering">
@@ -57,7 +62,7 @@
       </div>
 
       <div class="yui-g">
-        <div class="yui-u first">
+        <div itemprop="description" class="yui-u first">
            <tal:distro-information content="structure context/@@+details" />
         </div>
 

=== modified file 'lib/lp/registry/templates/product-index.pt'
--- lib/lp/registry/templates/product-index.pt	2011-11-20 13:16:14 +0000
+++ lib/lp/registry/templates/product-index.pt	2011-11-25 21:55:39 +0000
@@ -48,6 +48,9 @@
   <body>
     <tal:main metal:fill-slot="main"
       define="overview_menu context/menu:overview">
+      <div style="float:right">
+        <g:plusone align="right"></g:plusone>
+      </div>
       <div class="top-portlet">
         <p id="project-inactive" class="warning message"
           tal:condition="not: context/active">
@@ -55,8 +58,8 @@
           <a tal:replace="structure overview_menu/review_license/fmt:icon"/>
         </p>
 
-	<div class="summary" 
-	  tal:content="structure context/summary/fmt:markdown">
+        <div class="summary" 
+          tal:content="structure context/summary/fmt:markdown">
           $Product.summary goes here. This should be quite short,
           just a single paragraph of text really, giving the project
           highlights.

=== modified file 'lib/lp/services/features/flags.py'
--- lib/lp/services/features/flags.py	2011-11-25 12:34:41 +0000
+++ lib/lp/services/features/flags.py	2011-11-25 21:55:39 +0000
@@ -125,6 +125,12 @@
      'enabled',
      '',
      ''),
+    ('plusone.buttons.disabled',
+     'boolean',
+     'Disable Google plusone buttons.',
+     'enabled',
+     '',
+     ''),
     ('profiling.enabled',
      'boolean',
      'Overrides config.profiling.profiling_allowed to permit profiling.',

=== modified file 'lib/lp/soyuz/templates/archive-index.pt'
--- lib/lp/soyuz/templates/archive-index.pt	2011-07-18 09:23:10 +0000
+++ lib/lp/soyuz/templates/archive-index.pt	2011-11-25 21:55:39 +0000
@@ -8,11 +8,21 @@
   >
 <body>
   <tal:heading metal:fill-slot="heading">
-    <h1 tal:condition="context/enabled"
+    <div style="float:right"
+      tal:condition="not:context/private" >
+        <g:plusone 
+          tal:attributes="href context/fmt:url"
+          align="right"></g:plusone>
+    </div>
+    <meta itemprop="name"
+      tal:attributes="content context/displayname">
+    <h1
+        tal:condition="context/enabled"
         tal:replace="structure view/displayname_edit_widget">
       PPA for user
     </h1>
-    <h1 tal:condition="not: context/enabled"
+    <h1 itemprop="name"
+        tal:condition="not: context/enabled"
         tal:content="context/displayname"
         class="disabled">
       PPA for user


Follow ups