Merge lp:~michael.nelson/launchpad/429353-site-message-to-footer into lp:launchpad

Proposed by Michael Nelson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~michael.nelson/launchpad/429353-site-message-to-footer
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~michael.nelson/launchpad/429353-site-message-to-footer
Reviewer Review Type Date Requested Status
Barry Warsaw (community) ui* Approve
Brad Crittenden (community) code Approve
Review via email: mp+11813@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

= Summary =

This branch addresses bug 429353 by moving the site_message into the
footer (for both pre-3.0 and 3-0 pages).

As requested on the bug, an extra link is included in the site message
for edge to disable redirection - iff (1) edge redirection is enabled,
(2) the user is a beta user, and (3) the user has not already got edge
redirection disabled. This enables users to disable edge redirection
without having to go back to the root page.

== Proposed fix ==

Initially we were simply going to include the link to disable
redirections in the site-message config option, but as I implemented it
I realised that this would mean it's always there, even when (1) the
user is not a beta user (or even logged in for that matter), or (2) when
the user has already disabled redirection.

== Pre-implementation notes ==

See https://bugs.launchpad.net/launchpad-foundations/+bug/429353

== Implementation details ==

I'm a bit uncertain about moving isRedirectInhibited() and canRedirect
from LaunchpadRootIndexView to LaunchpadView - but I can't see any other
way to enable this on every LP page.

== Tests ==

bin/test -vv -t launchpadview.txt -t demo-and-lpnet.txt -t
xx-beta-testers-redirection.txt

== Demo and Q/A ==

Because the local dev environment can't be run with redirects enabled,
getting the actual re-direct link to display is a pain, but it's
straight-forward enough to see what the site-message looks like in the
footer:

1. After merging, patch with http://pastebin.ubuntu.com/271505/ (note,
this patch will cause the above tests to fail, so revert it before testing).
2. Visit https://launchpad.dev/ubuntu and check the footer.

Q/A
1. Visit https://edge.launchpad.net/ubuntu and verify the site-message
has the option to disable redirects.
2. Click the link to disable the redirect, and verify that it's worked.
3. Re-visit https://edge.launchpad.net/ubuntu and verify that the
site-message does not include the link to redirect.
4. Re-enable redirections via the launchpad.net homepage.
5. Re-affirm that the site-message now includes the link to disable again.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/icing/style.css
  lib/lp/registry/browser/root.py
  lib/canonical/launchpad/webapp/publisher.py
  lib/canonical/launchpad/templates/main-template.pt
  lib/lp/app/templates/base-layout.pt
  lib/lp/app/templates/base-layout-macros.pt
  lib/canonical/launchpad/doc/launchpadview.txt
  lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt

lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt

== Pylint notices ==

lib/lp/registry/browser/root.py
    40: [F0401] Unable to import 'lazr.batchnavigator.z3batching' (No
module named batchnavigator)
    473: [E1002, WindowedListBatch.__iter__] Use super on an old style class

--
Michael

Revision history for this message
Michael Nelson (michael.nelson) wrote :
Revision history for this message
Martin Albisetti (beuno) wrote :

How about adding the message on the same block as the rest of the footer, right aligned?

I think this double row looks a but funky. Looking forward to having a clean header :)

Revision history for this message
Michael Nelson (michael.nelson) wrote :

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

Martin Albisetti wrote:
> How about adding the message on the same block as the rest of the footer, right aligned?
>

Hmm... it probably won't normally fit (remember there is also the
'Disable edge redirect'). If it does fit it'll look nice, but otherwise
it will wrap when the window is too small - but perhaps that's not so
bad. I'll update it first thing tomorrow.

Thanks Martin!

- --
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqv2yUACgkQGSan/irvan1w+ACeKGRL2LWlik9u4DykW9g/L+Kn
3VgAn3T9CSeLteKI0HXpe66HNakrAX4Q
=mDCb
-----END PGP SIGNATURE-----

Revision history for this message
Brad Crittenden (bac) wrote :

This change looks very good Michael, thanks for doing it. Having the message up top was very prominent but did interfere with the page flow. I hope it won't be too discreet way down there.

I don't see any problem moving those methods to LaunchpadView.

review: Approve (code)
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Brad Crittenden wrote:
> Review: Approve code
> This change looks very good Michael, thanks for doing it. Having the message up top was very prominent but did interfere with the page flow. I hope it won't be too discreet way down there.
>
> I don't see any problem moving those methods to LaunchpadView.
>

Thanks Brad!

Unfortunately, after sleeping on it I realised that it was not quite
right. As it was, the link to disable the redirections would never have
been displayed as it was conditional on a site-message being present in
the config and redirection being enabled on the *current* app server
(which is only ever production, afaiui).

So I've updated and tested the branch to ensure that the
disable-redirection link only appears when:

1. a site-message is defined (as it's displayed with the site-message),
2. the app server is an edge app server (ie. the *target* of redirections),
3. the page is *not* a locationless page (ie. one where the view may not
necessarily inherit from LPView - and therefore view/isBetaUser will error)
4. the user is a beta user (non-beta users can visit edge also), and
5. the user has not already inhibited the redirection link.

*phew*

Additionally, I've updated the way it displays after Martins comments.

Screenshots here:

http://people.canonical.com/~michaeln/tmp/site-msg-footer-on-3.0-wide.png
http://people.canonical.com/~michaeln/tmp/site-msg-footer-on-3.0-narrow.png
http://people.canonical.com/~michaeln/tmp/site-message-footer-old-template.png

Or to demo:
1. apply diff http://pastebin.ubuntu.com/271972/
2. as anonymous or any non-beta user, view the footer at both:
   https://launchpad.dev/ubuntu (a 3.0 page)
   https://launchpad.dev/ (a non-3.0 page)
   It should state only "This site is running... Please report all bugs."
3. Logout and in as beta-admin, refresh the above urls and note the extra
   link.
4. Click on the 'Disable edge redirect' link. Reload the page and verify
   the disable edge redirect link is no-longer there.

The incremental is attached - part of it is reverting some previous
changes/tests, so it might be easier to look at the full diff on the branch.

--
Michael

=== modified file 'lib/canonical/launchpad/doc/launchpadview.txt'
--- lib/canonical/launchpad/doc/launchpadview.txt 2009-09-15 17:16:17 +0000
+++ lib/canonical/launchpad/doc/launchpadview.txt 2009-09-16 08:00:49 +0000
@@ -111,9 +111,3 @@
111 >>> view.isRedirectInhibited()111 >>> view.isRedirectInhibited()
112 True112 True
113113
114Every Launchpad view knows whether redirection is possible.
115
116 >>> view.canRedirect()
117 False
118
119
120114
=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-15 13:55:00 +0000
+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-16 07:59:36 +0000
@@ -101,6 +101,69 @@
101 0101 0
102102
103103
104== Launchpad Edge ==
105
106Additionally, when a server is running as an edge server, the site-message
107is appended with a link to disable edge redirects.
108
109In addition to this prominent display on the root page, each page will
110also include the disable-redirect link in the site_message - if the
111user is a member of the beta group and has not already disabled
112the redirects.
113
114 # Now setup an edge site-message config and re-check.
115 >>> edge_config_data = """
116 ... [launchpad]
117 ... site_message: This is a beta site.
118 ... is_edge: True
119 ... """
120 >>> config.push('edge_config_data', edge_config_data)
121 >>> beta_browser = setupBrowser(
122 ... auth='Basic beta-admin@launchpad.net:test')
123 >>> beta_browser.open('http://launchpad.dev/ubuntu')
124 >>> site_message = find_tags_by_class(
125 ... beta_browser.contents, 'sitemessage')[0]
126 >>> print extract_text(site_message)
127 This is a beta site. Disable edge redirect.
128 >>> print extract_text(site_message.find(
129 ... 'a', onclick="setBetaRedirect(false)"))
130 Disable edge redirect.
131
132The disable-redirect link will not appear in the site_message when
133browsed by non-beta users.
134
135 >>> browser.open('http://launchpad.dev/ubuntu')
136 >>> print extract_text(find_tags_by_class(
137 ... browser.contents, 'sitemessage')[0])
138 This is a beta site.
139
140Similarly, once the redirection has been inhibited, the link will no longer
141appear in the footer of edge pages.
142
143 # Workaround bug in mechanize where you cannot use the Cookie
144 # header with the CookieJar
145 >>> from mechanize._clientcookie import Cookie
146 >>> cookiejar = (
147 ... beta_browser.mech_browser._ua_handlers['_cookies'].cookiejar)
148 >>> cookiejar.set_cookie(
149 ... Cookie(
150 ... version=0, name='inhibit_beta_redirect', value='1', port=None,
151 ... port_specified=False, domain='.launchpad.dev',
152 ... domain_specified=True, domain_initial_dot=True, path='/',
153 ... path_specified=True, secure=False, expires=None,
154 ... discard=None, comment=None, comment_url=None, rest={}))
155 >>> beta_browser.open('http://launchpad.dev/ubuntu')
156 >>> site_message = find_tags_by_class(
157 ... beta_browser.contents, 'sitemessage')[0]
158 >>> print extract_text(site_message)
159 This is a beta site.
160 >>> print site_message.find('a')
161 None
162
163 # Remove the specific site-message config data before continuing.
164 >>> dummy = config.pop('edge_config_data')
165
166
104== Launchpad.net ==167== Launchpad.net ==
105168
106On every instance except launchpad.net, Launchpad's version and169On every instance except launchpad.net, Launchpad's version and
107170
=== modified file 'lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt'
--- lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-09-15 17:16:17 +0000
+++ lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-09-16 07:44:23 +0000
@@ -126,40 +126,6 @@
126 for 2 hours</button></p>126 for 2 hours</button></p>
127 </div>127 </div>
128128
129In addition to this prominent display on the root page, each page will
130also include the disable-redirect link in the site_message.
131
132 # First ensure it's not there when there is no site-message to display.
133 >>> check(beta_browser.open, 'http://launchpad.dev')
134 >>> len(find_tags_by_class(beta_browser.contents, 'sitemessage'))
135 0
136
137 # Now setup a site-message config and re-check.
138 >>> site_msg_data = """
139 ... [launchpad]
140 ... site_message: This is a beta site.
141 ... """
142 >>> config.push('site_msg_data', site_msg_data)
143 >>> check(beta_browser.open, 'http://launchpad.dev')
144 >>> site_message = find_tags_by_class(
145 ... beta_browser.contents, 'sitemessage')[0]
146 >>> print extract_text(site_message)
147 This is a beta site. Disable edge redirect.
148 >>> print extract_text(site_message.find(
149 ... 'a', onclick="setBetaRedirect(false)"))
150 Disable edge redirect.
151
152The disable-redirect link will not appear in the site_message when
153browsed by non-beta users.
154
155 >>> check(user_browser.open, 'http://launchpad.dev')
156 >>> print extract_text(find_tags_by_class(
157 ... user_browser.contents, 'sitemessage')[0])
158 This is a beta site.
159
160 # Remove the specific site-message config data before continuing.
161 >>> dummy = config.pop('site_msg_data')
162
163This is so that the user can make use of some client side JS on that129This is so that the user can make use of some client side JS on that
164page that sets a cookie to inhibit the redirection. When the130page that sets a cookie to inhibit the redirection. When the
165redirection is inhibited, the info message changes to one that lets131redirection is inhibited, the info message changes to one that lets
@@ -191,20 +157,6 @@
191 redirection</button></p>157 redirection</button></p>
192 </div>158 </div>
193159
194Similarly, once the redirection has been inhibited, the link will no longer
195appear in the footer of edge pages.
196
197 >>> config.push('site_msg_data', site_msg_data)
198 >>> check(beta_browser.open, 'http://launchpad.dev')
199 >>> site_message = find_tags_by_class(
200 ... beta_browser.contents, 'sitemessage')[0]
201 >>> print extract_text(site_message)
202 This is a beta site.
203 >>> print site_message.find('a')
204 None
205
206 >>> dummy = config.pop('site_msg_data')
207
208160
209Now when they go to a page on the site, it loads as normal:161Now when they go to a page on the site, it loads as normal:
210162
211163
=== modified file 'lib/canonical/launchpad/webapp/publisher.py'
--- lib/canonical/launchpad/webapp/publisher.py 2009-09-15 17:16:17 +0000
+++ lib/canonical/launchpad/webapp/publisher.py 2009-09-16 08:01:04 +0000
@@ -277,12 +277,6 @@
277 """Returns True if redirection has been inhibited."""277 """Returns True if redirection has been inhibited."""
278 return self.request.cookies.get('inhibit_beta_redirect', '0') == '1'278 return self.request.cookies.get('inhibit_beta_redirect', '0') == '1'
279279
280 def canRedirect(self):
281 """Return True if the beta server is available to the user."""
282 return bool(
283 config.launchpad.beta_testers_redirection_host is not None and
284 self.isBetaUser)
285
286 def __call__(self):280 def __call__(self):
287 self.initialize()281 self.initialize()
288 if self._isRedirected():282 if self._isRedirected():
289283
=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
--- lib/lp/app/templates/base-layout-macros.pt 2009-09-15 17:30:59 +0000
+++ lib/lp/app/templates/base-layout-macros.pt 2009-09-16 07:58:24 +0000
@@ -376,12 +376,14 @@
376 <tal:site_message tal:content="structure site_message">376 <tal:site_message tal:content="structure site_message">
377 This site is running pre-release code.377 This site is running pre-release code.
378 </tal:site_message>378 </tal:site_message>
379 <tal:redirect_only condition="view/canRedirect">379 <tal:edge_only condition="is_edge">
380 <a href="#" class="js-action" onclick="setBetaRedirect(false)"380 <tal:beta_user condition="view/isBetaUser">
381 tal:condition="not:view/isRedirectInhibited">381 <a href="#" class="js-action" onclick="setBetaRedirect(false)"
382 Disable edge redirect.382 tal:condition="not:view/isRedirectInhibited">
383 </a>383 Disable edge redirect.
384 </tal:redirect_only>384 </a>
385 </tal:beta_user>
386 </tal:edge_only>
385 </div>387 </div>
386</metal:site-message>388</metal:site-message>
387389
388390
=== modified file 'lib/lp/registry/browser/root.py'
--- lib/lp/registry/browser/root.py 2009-09-15 17:16:17 +0000
+++ lib/lp/registry/browser/root.py 2009-09-16 08:01:30 +0000
@@ -98,6 +98,12 @@
98 """The total blueprint count in all of Launchpad."""98 """The total blueprint count in all of Launchpad."""
99 return getUtility(ILaunchpadStatisticSet).value('question_count')99 return getUtility(ILaunchpadStatisticSet).value('question_count')
100100
101 def canRedirect(self):
102 """Return True if the beta server is available to the user."""
103 return bool(
104 config.launchpad.beta_testers_redirection_host is not None and
105 self.isBetaUser)
106
101107
102class LaunchpadSearchFormView(LaunchpadView):108class LaunchpadSearchFormView(LaunchpadView):
103 """A view to display the global search form in any page."""109 """A view to display the global search form in any page."""
Revision history for this message
Brad Crittenden (bac) wrote :

Michael,

The new changes you made look good with the addition of the small change we discussed on IRC:

=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-08-30 13:31:02 +0000
+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-16 15:38:49 +0000
@@ -53,7 +53,8 @@

+In addition to this prominent display on the root page, each page will
+also include the disable-redirect link in the site_message - if the
+user is a member of the beta group and has not already disabled
+the redirects.

s/each page will/most pages will/

review: Approve (code)
Revision history for this message
Barry Warsaw (barry) :
review: Approve (ui*)
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Barry Warsaw wrote:
> Review: Approve ui*
>

Thanks Barry, I've attached the diff for the enable link.

--
Michael

=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-16 17:13:23 +0000
+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-17 15:24:12 +0000
@@ -146,8 +146,8 @@
146 ... browser.contents, 'sitemessage')[0])146 ... browser.contents, 'sitemessage')[0])
147 This is a beta site.147 This is a beta site.
148148
149Similarly, once the redirection has been inhibited, the link will no longer149Similarly, once the redirection has been inhibited, the link changes to
150appear in the footer of edge pages.150enable redirects..
151151
152 # Workaround bug in mechanize where you cannot use the Cookie152 # Workaround bug in mechanize where you cannot use the Cookie
153 # header with the CookieJar153 # header with the CookieJar
@@ -165,9 +165,11 @@
165 >>> site_message = find_tags_by_class(165 >>> site_message = find_tags_by_class(
166 ... beta_browser.contents, 'sitemessage')[0]166 ... beta_browser.contents, 'sitemessage')[0]
167 >>> print extract_text(site_message)167 >>> print extract_text(site_message)
168 This is a beta site.168 This is a beta site. Enable edge redirect.
169 >>> print site_message.find('a')169 >>> print extract_text(site_message.find(
170 None170 ... 'a', onclick="setBetaRedirect(true)"))
171 Enable edge redirect.
172
171173
172 # Remove the specific site-message config data before continuing.174 # Remove the specific site-message config data before continuing.
173 >>> dummy = config.pop('edge_config_data')175 >>> dummy = config.pop('edge_config_data')
174176
=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
--- lib/lp/app/templates/base-layout-macros.pt 2009-09-16 10:03:52 +0000
+++ lib/lp/app/templates/base-layout-macros.pt 2009-09-17 15:24:12 +0000
@@ -392,6 +392,10 @@
392 tal:condition="not:view/isRedirectInhibited">392 tal:condition="not:view/isRedirectInhibited">
393 Disable edge redirect.393 Disable edge redirect.
394 </a>394 </a>
395 <a href="#" class="js-action" onclick="setBetaRedirect(true)"
396 tal:condition="view/isRedirectInhibited">
397 Enable edge redirect.
398 </a>
395 </tal:beta_user>399 </tal:beta_user>
396 </tal:normal_lp_view>400 </tal:normal_lp_view>
397 </tal:edge_only>401 </tal:edge_only>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/doc/launchpadview.txt'
--- lib/canonical/launchpad/doc/launchpadview.txt 2009-04-17 10:32:16 +0000
+++ lib/canonical/launchpad/doc/launchpadview.txt 2009-09-15 17:16:17 +0000
@@ -101,3 +101,19 @@
101 >>> view.error_message = structured('Information overload.')101 >>> view.error_message = structured('Information overload.')
102 >>> view.error_message.escapedtext102 >>> view.error_message.escapedtext
103 u'Information overload.'103 u'Information overload.'
104
105Every Launchpad view also knows whether edge redirection has been inhibited.
106
107 >>> view.isRedirectInhibited()
108 False
109 >>> new_request = TestRequest(HTTP_COOKIE="inhibit_beta_redirect=1")
110 >>> view = MyView(context, new_request)
111 >>> view.isRedirectInhibited()
112 True
113
114Every Launchpad view knows whether redirection is possible.
115
116 >>> view.canRedirect()
117 False
118
119
104120
=== modified file 'lib/canonical/launchpad/icing/style.css'
--- lib/canonical/launchpad/icing/style.css 2009-09-14 09:40:39 +0000
+++ lib/canonical/launchpad/icing/style.css 2009-09-15 11:14:08 +0000
@@ -674,30 +674,19 @@
674674
675/* === Universal page layout === */675/* === Universal page layout === */
676676
677/* All pages begin with a global header or a topline. */677/* All pages include the sitemessage in the footer if one is defined
678#globalheader {678 in the config. */
679 clear: both;679.sitemessage {
680 position: relative;680 clear: both;
681 width: 100%;681 position: relative;
682 height: 21px;682 width: 100%;
683 overflow: hidden;683 height: 21px;
684 margin: 0 0 1em 0;684 overflow: hidden;
685 padding: 0;685 margin: 1em 0;
686 background-color: #EEE;686 background: url(/@@/footer-background.png) top left repeat-x;
687 background-image: url(globalheader_bg.gif);687 text-align: center;
688 background-repeat: repeat-x;688 font-size: 13px;
689 background-position: top center;689 padding-top: 0.5em;
690}
691#globalheader .sitemessage a {
692 color: #FFF;
693 text-decoration: underline;
694}
695/* Site-specific message. */
696#globalheader .sitemessage {
697 text-align: center;
698 color: #FFF;
699 font-size: 13px;
700 padding-top: 2px;
701}690}
702691
703/* === Login control === */692/* === Login control === */
704693
=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-08-30 13:31:02 +0000
+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-15 13:55:00 +0000
@@ -53,7 +53,8 @@
53 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))53 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
54 &bull;...Launchpad...) devmode demo site54 &bull;...Launchpad...) devmode demo site
5555
56 >>> print extract_text(find_tag_by_id(browser.contents, 'globalheader'))56 >>> print extract_text(find_tags_by_class(
57 ... browser.contents, 'sitemessage')[0])
57 This is a demo site mmk. File a bug.58 This is a demo site mmk. File a bug.
58 >>> print browser.getLink(url="http://example.com").text59 >>> print browser.getLink(url="http://example.com").text
59 File a bug60 File a bug
@@ -68,7 +69,8 @@
68 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))69 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
69 |...Launchpad...) devmode demo site70 |...Launchpad...) devmode demo site
7071
71 >>> print extract_text(find_tag_by_id(browser.contents, 'globalheader'))72 >>> print extract_text(find_tags_by_class(
73 ... browser.contents, 'sitemessage')[0])
72 This is a demo site mmk. File a bug.74 This is a demo site mmk. File a bug.
73 >>> print browser.getLink(url="http://example.com").text75 >>> print browser.getLink(url="http://example.com").text
74 File a bug76 File a bug
@@ -86,16 +88,17 @@
86 >>> browser.open('http://launchpad.dev/ubuntu')88 >>> browser.open('http://launchpad.dev/ubuntu')
87 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))89 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
88 &bull;...Launchpad...) devmode90 &bull;...Launchpad...) devmode
89 >>> print find_tag_by_id(browser.contents, 'globalheader')91 >>> len(find_tags_by_class(browser.contents, 'sitemessage'))
90 None92 0
93
9194
92And for a non-3-0 page:95And for a non-3-0 page:
9396
94 >>> browser.open('http://launchpad.dev/')97 >>> browser.open('http://launchpad.dev/')
95 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))98 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
96 |...Launchpad...) devmode99 |...Launchpad...) devmode
97 >>> print find_tag_by_id(browser.contents, 'globalheader')100 >>> len(find_tags_by_class(browser.contents, 'sitemessage'))
98 None101 0
99102
100103
101== Launchpad.net ==104== Launchpad.net ==
102105
=== modified file 'lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt'
--- lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-08-06 11:35:34 +0000
+++ lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-09-15 17:16:17 +0000
@@ -126,6 +126,40 @@
126 for 2 hours</button></p>126 for 2 hours</button></p>
127 </div>127 </div>
128128
129In addition to this prominent display on the root page, each page will
130also include the disable-redirect link in the site_message.
131
132 # First ensure it's not there when there is no site-message to display.
133 >>> check(beta_browser.open, 'http://launchpad.dev')
134 >>> len(find_tags_by_class(beta_browser.contents, 'sitemessage'))
135 0
136
137 # Now setup a site-message config and re-check.
138 >>> site_msg_data = """
139 ... [launchpad]
140 ... site_message: This is a beta site.
141 ... """
142 >>> config.push('site_msg_data', site_msg_data)
143 >>> check(beta_browser.open, 'http://launchpad.dev')
144 >>> site_message = find_tags_by_class(
145 ... beta_browser.contents, 'sitemessage')[0]
146 >>> print extract_text(site_message)
147 This is a beta site. Disable edge redirect.
148 >>> print extract_text(site_message.find(
149 ... 'a', onclick="setBetaRedirect(false)"))
150 Disable edge redirect.
151
152The disable-redirect link will not appear in the site_message when
153browsed by non-beta users.
154
155 >>> check(user_browser.open, 'http://launchpad.dev')
156 >>> print extract_text(find_tags_by_class(
157 ... user_browser.contents, 'sitemessage')[0])
158 This is a beta site.
159
160 # Remove the specific site-message config data before continuing.
161 >>> dummy = config.pop('site_msg_data')
162
129This is so that the user can make use of some client side JS on that163This is so that the user can make use of some client side JS on that
130page that sets a cookie to inhibit the redirection. When the164page that sets a cookie to inhibit the redirection. When the
131redirection is inhibited, the info message changes to one that lets165redirection is inhibited, the info message changes to one that lets
@@ -157,6 +191,21 @@
157 redirection</button></p>191 redirection</button></p>
158 </div>192 </div>
159193
194Similarly, once the redirection has been inhibited, the link will no longer
195appear in the footer of edge pages.
196
197 >>> config.push('site_msg_data', site_msg_data)
198 >>> check(beta_browser.open, 'http://launchpad.dev')
199 >>> site_message = find_tags_by_class(
200 ... beta_browser.contents, 'sitemessage')[0]
201 >>> print extract_text(site_message)
202 This is a beta site.
203 >>> print site_message.find('a')
204 None
205
206 >>> dummy = config.pop('site_msg_data')
207
208
160Now when they go to a page on the site, it loads as normal:209Now when they go to a page on the site, it loads as normal:
161210
162 >>> check(beta_browser.open, 'http://launchpad.dev/ubuntu')211 >>> check(beta_browser.open, 'http://launchpad.dev/ubuntu')
163212
=== modified file 'lib/canonical/launchpad/templates/main-template.pt'
--- lib/canonical/launchpad/templates/main-template.pt 2009-08-30 13:31:02 +0000
+++ lib/canonical/launchpad/templates/main-template.pt 2009-09-15 17:30:59 +0000
@@ -98,12 +98,6 @@
98 <input type="search" id="search-text" name="field.text" />98 <input type="search" id="search-text" name="field.text" />
99 </form>99 </form>
100 <tal:hierarchy replace="structure context/@@+hierarchy" />100 <tal:hierarchy replace="structure context/@@+hierarchy" />
101 <div id="globalheader" xml:lang="en" lang="en" dir="ltr"
102 tal:condition="site_message">
103 <div class="sitemessage" tal:content="structure site_message">
104 This site is running pre-release code.
105 </div>
106 </div>
107 <div101 <div
108 tal:condition="view/macro:pagehas/applicationtabs"102 tal:condition="view/macro:pagehas/applicationtabs"
109 tal:define="facetmenu view/menu:facet"103 tal:define="facetmenu view/menu:facet"
@@ -239,6 +233,10 @@
239 <a tal:condition="request/lp:person" href="/feedback"233 <a tal:condition="request/lp:person" href="/feedback"
240 >Contact us</a> | <a href="https://help.launchpad.net/">Get help with Launchpad</a>234 >Contact us</a> | <a href="https://help.launchpad.net/">Get help with Launchpad</a>
241 </div>235 </div>
236
237 <metal:site-message
238 use-macro="context/@@+base-layout-macros/site-message"/>
239
242 <div id="lp-arcana">240 <div id="lp-arcana">
243 &copy;&nbsp;2004-2009&nbsp;<a241 &copy;&nbsp;2004-2009&nbsp;<a
244 href="http://canonical.com/">Canonical&nbsp;Ltd.</a>242 href="http://canonical.com/">Canonical&nbsp;Ltd.</a>
245243
=== modified file 'lib/canonical/launchpad/webapp/publisher.py'
--- lib/canonical/launchpad/webapp/publisher.py 2009-08-20 07:15:35 +0000
+++ lib/canonical/launchpad/webapp/publisher.py 2009-09-15 17:16:17 +0000
@@ -39,6 +39,7 @@
39from zope.traversing.browser.interfaces import IAbsoluteURL39from zope.traversing.browser.interfaces import IAbsoluteURL
4040
41from canonical.cachedproperty import cachedproperty41from canonical.cachedproperty import cachedproperty
42from canonical.config import config
42from canonical.launchpad.layers import setFirstLayer, WebServiceLayer43from canonical.launchpad.layers import setFirstLayer, WebServiceLayer
43from canonical.launchpad.webapp.vhosts import allvhosts44from canonical.launchpad.webapp.vhosts import allvhosts
44from canonical.launchpad.webapp.interfaces import (45from canonical.launchpad.webapp.interfaces import (
@@ -272,6 +273,16 @@
272 """273 """
273 return self.request.response.getStatus() in [301, 302, 303, 307]274 return self.request.response.getStatus() in [301, 302, 303, 307]
274275
276 def isRedirectInhibited(self):
277 """Returns True if redirection has been inhibited."""
278 return self.request.cookies.get('inhibit_beta_redirect', '0') == '1'
279
280 def canRedirect(self):
281 """Return True if the beta server is available to the user."""
282 return bool(
283 config.launchpad.beta_testers_redirection_host is not None and
284 self.isBetaUser)
285
275 def __call__(self):286 def __call__(self):
276 self.initialize()287 self.initialize()
277 if self._isRedirected():288 if self._isRedirected():
278289
=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
--- lib/lp/app/templates/base-layout-macros.pt 2009-08-19 15:13:39 +0000
+++ lib/lp/app/templates/base-layout-macros.pt 2009-09-15 17:30:59 +0000
@@ -348,6 +348,9 @@
348 </form>348 </form>
349 </div>349 </div>
350350
351 <metal:site-message
352 use-macro="context/@@+base-layout-macros/site-message"/>
353
351 <div class="colophon">354 <div class="colophon">
352 &copy; 2004-2009355 &copy; 2004-2009
353 <a href="http://canonical.com/">Canonical&nbsp;Ltd.</a>356 <a href="http://canonical.com/">Canonical&nbsp;Ltd.</a>
@@ -367,4 +370,19 @@
367 </div>370 </div>
368 </div>371 </div>
369</metal:footer>372</metal:footer>
373
374<metal:site-message define-macro="site-message">
375 <div class="sitemessage" tal:condition="site_message">
376 <tal:site_message tal:content="structure site_message">
377 This site is running pre-release code.
378 </tal:site_message>
379 <tal:redirect_only condition="view/canRedirect">
380 <a href="#" class="js-action" onclick="setBetaRedirect(false)"
381 tal:condition="not:view/isRedirectInhibited">
382 Disable edge redirect.
383 </a>
384 </tal:redirect_only>
385 </div>
386</metal:site-message>
387
370</macros>388</macros>
371389
=== modified file 'lib/lp/app/templates/base-layout.pt'
--- lib/lp/app/templates/base-layout.pt 2009-09-08 22:42:42 +0000
+++ lib/lp/app/templates/base-layout.pt 2009-09-15 11:14:08 +0000
@@ -79,12 +79,6 @@
79 ${view/context/fmt:public-private-css}79 ${view/context/fmt:public-private-css}
80 yui-skin-sam">80 yui-skin-sam">
81 <div class="yui-d0">81 <div class="yui-d0">
82 <div id="globalheader" xml:lang="en" lang="en" dir="ltr"
83 tal:condition="site_message">
84 <div class="sitemessage" tal:content="structure site_message">
85 This site is running pre-release code.
86 </div>
87 </div>
88 <div id="locationbar">82 <div id="locationbar">
89 <tal:login replace="structure context/@@login_status" />83 <tal:login replace="structure context/@@login_status" />
90 </div><!--id="locationbar"-->84 </div><!--id="locationbar"-->
9185
=== modified file 'lib/lp/registry/browser/root.py'
--- lib/lp/registry/browser/root.py 2009-06-25 04:06:00 +0000
+++ lib/lp/registry/browser/root.py 2009-09-15 17:16:17 +0000
@@ -18,7 +18,6 @@
18from zope.schema.interfaces import TooLong18from zope.schema.interfaces import TooLong
19from zope.schema.vocabulary import getVocabularyRegistry19from zope.schema.vocabulary import getVocabularyRegistry
2020
21from canonical.config import config
22from canonical.cachedproperty import cachedproperty21from canonical.cachedproperty import cachedproperty
23from lp.registry.browser.announcement import HasAnnouncementsView22from lp.registry.browser.announcement import HasAnnouncementsView
24from canonical.launchpad.interfaces.launchpadstatistic import (23from canonical.launchpad.interfaces.launchpadstatistic import (
@@ -54,16 +53,6 @@
54 # determines the number of projects we display in each column.53 # determines the number of projects we display in each column.
55 FEATURED_PROJECT_ROWS = 1054 FEATURED_PROJECT_ROWS = 10
5655
57 def isRedirectInhibited(self):
58 """Returns True if redirection has been inhibited."""
59 return self.request.cookies.get('inhibit_beta_redirect', '0') == '1'
60
61 def canRedirect(self):
62 """Return True if the beta server is available to the user."""
63 return bool(
64 config.launchpad.beta_testers_redirection_host is not None and
65 self.isBetaUser)
66
67 @cachedproperty56 @cachedproperty
68 def featured_projects(self):57 def featured_projects(self):
69 """Return a list of featured projects."""58 """Return a list of featured projects."""