Merge lp://staging/~jcsackett/loggerhead/add-privacy-ribbon into lp://staging/loggerhead

Proposed by j.c.sackett
Status: Merged
Approved by: John A Meinel
Approved revision: 465
Merged at revision: 459
Proposed branch: lp://staging/~jcsackett/loggerhead/add-privacy-ribbon
Merge into: lp://staging/loggerhead
Diff against target: 236 lines (+165/-5)
5 files modified
loggerhead/apps/branch.py (+8/-1)
loggerhead/static/css/global.css (+61/-0)
loggerhead/static/javascript/custom.js (+87/-1)
loggerhead/templates/macros.pt (+1/-1)
loggerhead/tests/test_simple.py (+8/-2)
To merge this branch: bzr merge lp://staging/~jcsackett/loggerhead/add-privacy-ribbon
Reviewer Review Type Date Requested Status
John A Meinel Approve
Ian Booth (community) code Approve
Review via email: mp+80477@code.staging.launchpad.net

Commit message

Adds a privacy ribbon display to private branches in loggerhead.

Description of the change

Summary
=======
This branch adds an option privacy ribbon to be displayed when a branch's contents are private. It does so by adding javascript, css, and template changes to emulate the launchpad privacy ribbon.

Preimp
======
Spoke with Curtis Hovey

Implementation
==============
* Privacy functions from launchpad were added to custom.js; they have been modified to work with the YUI modules already existing in loggerhead.
* The global notification CSS has been added to the global.css for loggerhead.
* BranchWSGIApp has been updated to accept a private param, defaulting to False. It also has a method to provide the public or private class for the body element on the base layout.
* The base template for loggerhead sets the body class to "private" or "public" based on the above parameter.

QA
==
* Open a private branch on loggerhead; you should see the privacy ribbon.
* Open a public branch on loggerhead; you should not see the ribbon.

To post a comment you must log in.
Revision history for this message
Ian Booth (wallyworld) wrote :

Hi Jon

This looks nice (the answer to my question below notwithstanding). I have a small request and a question.

1. The Request

The method BranchWSGIApp.public_or_private() should be called public_private_css() to (i) be consistent with how Launchpad does it, and (ii) better reflect the semantics of what the method is used for.

2. The Question

I assume you needed to run up loggerhead locally to test? I'm confused how it works since I can't see how 'private' is ever set. The new 'private' parameter was added to BranchWSGIApp, but I can't see in the loggerhead code base anywhere this parameter is passed in. There are 2 places I can see where a BranchWSGIApp instance is instantiated with the bzr branch, but none of those call sites pass in the lp branch privacy parameter. So how does 'private' ever get set to anything other than the default = False.

3. Tests

There aren't any. Ah, I see there are no js tests in the loggerhead code base :-/
Should there be a test for the public_private_css() method. Seems trivial I know, so your call whether to add one.

Thanks.

review: Needs Fixing
Revision history for this message
j.c.sackett (jcsackett) wrote :

1) You got it.

2) We actually spin up loggerhead code in the launchpad code base, using lib/launchpad_loggerhead/app.py, which calls the BranchWSGIApp and passes in private. You can look at lp:~jcsackett/launchpad/private-loggerhead-notifications to see this.

3) I'll add the public_private test; I too am bummed by the lack of JS tests, but I don't have the bandwidth to add js test infrastructure on loggerhead as part of this work. :-/

462. By j.c.sackett

public_or_private renamed public_private_css and tests added.

463. By j.c.sackett

Fixed test.

Revision history for this message
Ian Booth (wallyworld) wrote :

Thanks for the changes and explanation. I wasn't expecting any js tests, just making an observation on the existing lack of them :-/

NB - the loggerhead/templates/macros.pt template still has the old public_or_private() method (according to the diff). Don't forget to change this prior to landing.

review: Approve (code)
Revision history for this message
John A Meinel (jameinel) wrote :

My CSS and Javascript isn't particularly strong, however:
  display_privacy_notification()
calls
  setup_privacy_notification()

however this code:
189 +Y.on('domready', function() {
190 + var body = Y.get('body');
191 + if (body.hasClass('private')) {
192 + setup_privacy_notification();
193 + display_privacy_notification();
194 + }

Calls both directly, seems a bit odd.

Further, I did this change:
=== modified file 'loggerhead/apps/transport.py'
--- loggerhead/apps/transport.py 2011-03-16 14:43:36 +0000
+++ loggerhead/apps/transport.py 2011-11-03 13:22:01 +0000
@@ -63,7 +63,7 @@
             self.root.graph_cache,
             is_root=is_root,
             use_cdn=self._config.get_option('use_cdn'),
- )
+ private=True)
         return branch_app.app

     def app_for_non_branch(self, environ):

And tested locally with "bzr serve --http". I can see that the private attribute is set to True, but the pages themselves are *not* rendering a privacy bar.

Am I missing how you're supposed to be poking a branch to be considered "private"?

review: Needs Fixing
464. By j.c.sackett

Fixed template to use the updated public/private thing.

465. By j.c.sackett

Updated from trunk.

Revision history for this message
j.c.sackett (jcsackett) wrote :

> My CSS and Javascript isn't particularly strong, however:
> display_privacy_notification()
> calls
> setup_privacy_notification()
>
> however this code:
> 189 +Y.on('domready', function() {
> 190 + var body = Y.get('body');
> 191 + if (body.hasClass('private')) {
> 192 + setup_privacy_notification();
> 193 + display_privacy_notification();
> 194 + }
>
> Calls both directly, seems a bit odd.

It's an artifact of how this code is/was used in Launchpad. I can remove the redundancy before landing. Good catch.
>
> Further, I did this change:
> === modified file 'loggerhead/apps/transport.py'
> --- loggerhead/apps/transport.py 2011-03-16 14:43:36 +0000
> +++ loggerhead/apps/transport.py 2011-11-03 13:22:01 +0000
> @@ -63,7 +63,7 @@
> self.root.graph_cache,
> is_root=is_root,
> use_cdn=self._config.get_option('use_cdn'),
> - )
> + private=True)
> return branch_app.app
>
> def app_for_non_branch(self, environ):
>
>
> And tested locally with "bzr serve --http". I can see that the private
> attribute is set to True, but the pages themselves are *not* rendering a
> privacy bar.

This was because, as Ian noted, I failed to update the macros.pt template when I renamed the method, so it wasn't setting. This worked with the change I just pushed on my machine. Sorry for missing this, and thanks for taking the time to look this over.

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

...

>>
>>
>> And tested locally with "bzr serve --http". I can see that the
>> private attribute is set to True, but the pages themselves are
>> *not* rendering a privacy bar.
>
> This was because, as Ian noted, I failed to update the macros.pt
> template when I renamed the method, so it wasn't setting. This
> worked with the change I just pushed on my machine. Sorry for
> missing this, and thanks for taking the time to look this over.

I can confirm that your current code seems to do the expected thing,
and show the privacy bar.

 merge: approve

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk60R5MACgkQJdeBCYSNAANHkQCg2EeJArOugGqCDohtsLdn3UH/
2ZsAn0+OodrskiPML4BYdkZT4a9jgBvE
=hVrs
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches