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

1=== modified file 'lib/canonical/launchpad/doc/launchpadview.txt'
2--- lib/canonical/launchpad/doc/launchpadview.txt 2009-09-15 17:16:17 +0000
3+++ lib/canonical/launchpad/doc/launchpadview.txt 2009-09-16 08:00:49 +0000
4@@ -111,9 +111,3 @@
5 >>> view.isRedirectInhibited()
6 True
7
8-Every Launchpad view knows whether redirection is possible.
9-
10- >>> view.canRedirect()
11- False
12-
13-
14
15=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
16--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-15 13:55:00 +0000
17+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-16 07:59:36 +0000
18@@ -101,6 +101,69 @@
19 0
20
21
22+== Launchpad Edge ==
23+
24+Additionally, when a server is running as an edge server, the site-message
25+is appended with a link to disable edge redirects.
26+
27+In addition to this prominent display on the root page, each page will
28+also include the disable-redirect link in the site_message - if the
29+user is a member of the beta group and has not already disabled
30+the redirects.
31+
32+ # Now setup an edge site-message config and re-check.
33+ >>> edge_config_data = """
34+ ... [launchpad]
35+ ... site_message: This is a beta site.
36+ ... is_edge: True
37+ ... """
38+ >>> config.push('edge_config_data', edge_config_data)
39+ >>> beta_browser = setupBrowser(
40+ ... auth='Basic beta-admin@launchpad.net:test')
41+ >>> beta_browser.open('http://launchpad.dev/ubuntu')
42+ >>> site_message = find_tags_by_class(
43+ ... beta_browser.contents, 'sitemessage')[0]
44+ >>> print extract_text(site_message)
45+ This is a beta site. Disable edge redirect.
46+ >>> print extract_text(site_message.find(
47+ ... 'a', onclick="setBetaRedirect(false)"))
48+ Disable edge redirect.
49+
50+The disable-redirect link will not appear in the site_message when
51+browsed by non-beta users.
52+
53+ >>> browser.open('http://launchpad.dev/ubuntu')
54+ >>> print extract_text(find_tags_by_class(
55+ ... browser.contents, 'sitemessage')[0])
56+ This is a beta site.
57+
58+Similarly, once the redirection has been inhibited, the link will no longer
59+appear in the footer of edge pages.
60+
61+ # Workaround bug in mechanize where you cannot use the Cookie
62+ # header with the CookieJar
63+ >>> from mechanize._clientcookie import Cookie
64+ >>> cookiejar = (
65+ ... beta_browser.mech_browser._ua_handlers['_cookies'].cookiejar)
66+ >>> cookiejar.set_cookie(
67+ ... Cookie(
68+ ... version=0, name='inhibit_beta_redirect', value='1', port=None,
69+ ... port_specified=False, domain='.launchpad.dev',
70+ ... domain_specified=True, domain_initial_dot=True, path='/',
71+ ... path_specified=True, secure=False, expires=None,
72+ ... discard=None, comment=None, comment_url=None, rest={}))
73+ >>> beta_browser.open('http://launchpad.dev/ubuntu')
74+ >>> site_message = find_tags_by_class(
75+ ... beta_browser.contents, 'sitemessage')[0]
76+ >>> print extract_text(site_message)
77+ This is a beta site.
78+ >>> print site_message.find('a')
79+ None
80+
81+ # Remove the specific site-message config data before continuing.
82+ >>> dummy = config.pop('edge_config_data')
83+
84+
85 == Launchpad.net ==
86
87 On every instance except launchpad.net, Launchpad's version and
88
89=== modified file 'lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt'
90--- lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-09-15 17:16:17 +0000
91+++ lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-09-16 07:44:23 +0000
92@@ -126,40 +126,6 @@
93 for 2 hours</button></p>
94 </div>
95
96-In addition to this prominent display on the root page, each page will
97-also include the disable-redirect link in the site_message.
98-
99- # First ensure it's not there when there is no site-message to display.
100- >>> check(beta_browser.open, 'http://launchpad.dev')
101- >>> len(find_tags_by_class(beta_browser.contents, 'sitemessage'))
102- 0
103-
104- # Now setup a site-message config and re-check.
105- >>> site_msg_data = """
106- ... [launchpad]
107- ... site_message: This is a beta site.
108- ... """
109- >>> config.push('site_msg_data', site_msg_data)
110- >>> check(beta_browser.open, 'http://launchpad.dev')
111- >>> site_message = find_tags_by_class(
112- ... beta_browser.contents, 'sitemessage')[0]
113- >>> print extract_text(site_message)
114- This is a beta site. Disable edge redirect.
115- >>> print extract_text(site_message.find(
116- ... 'a', onclick="setBetaRedirect(false)"))
117- Disable edge redirect.
118-
119-The disable-redirect link will not appear in the site_message when
120-browsed by non-beta users.
121-
122- >>> check(user_browser.open, 'http://launchpad.dev')
123- >>> print extract_text(find_tags_by_class(
124- ... user_browser.contents, 'sitemessage')[0])
125- This is a beta site.
126-
127- # Remove the specific site-message config data before continuing.
128- >>> dummy = config.pop('site_msg_data')
129-
130 This is so that the user can make use of some client side JS on that
131 page that sets a cookie to inhibit the redirection. When the
132 redirection is inhibited, the info message changes to one that lets
133@@ -191,20 +157,6 @@
134 redirection</button></p>
135 </div>
136
137-Similarly, once the redirection has been inhibited, the link will no longer
138-appear in the footer of edge pages.
139-
140- >>> config.push('site_msg_data', site_msg_data)
141- >>> check(beta_browser.open, 'http://launchpad.dev')
142- >>> site_message = find_tags_by_class(
143- ... beta_browser.contents, 'sitemessage')[0]
144- >>> print extract_text(site_message)
145- This is a beta site.
146- >>> print site_message.find('a')
147- None
148-
149- >>> dummy = config.pop('site_msg_data')
150-
151
152 Now when they go to a page on the site, it loads as normal:
153
154
155=== modified file 'lib/canonical/launchpad/webapp/publisher.py'
156--- lib/canonical/launchpad/webapp/publisher.py 2009-09-15 17:16:17 +0000
157+++ lib/canonical/launchpad/webapp/publisher.py 2009-09-16 08:01:04 +0000
158@@ -277,12 +277,6 @@
159 """Returns True if redirection has been inhibited."""
160 return self.request.cookies.get('inhibit_beta_redirect', '0') == '1'
161
162- def canRedirect(self):
163- """Return True if the beta server is available to the user."""
164- return bool(
165- config.launchpad.beta_testers_redirection_host is not None and
166- self.isBetaUser)
167-
168 def __call__(self):
169 self.initialize()
170 if self._isRedirected():
171
172=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
173--- lib/lp/app/templates/base-layout-macros.pt 2009-09-15 17:30:59 +0000
174+++ lib/lp/app/templates/base-layout-macros.pt 2009-09-16 07:58:24 +0000
175@@ -376,12 +376,14 @@
176 <tal:site_message tal:content="structure site_message">
177 This site is running pre-release code.
178 </tal:site_message>
179- <tal:redirect_only condition="view/canRedirect">
180- <a href="#" class="js-action" onclick="setBetaRedirect(false)"
181- tal:condition="not:view/isRedirectInhibited">
182- Disable edge redirect.
183- </a>
184- </tal:redirect_only>
185+ <tal:edge_only condition="is_edge">
186+ <tal:beta_user condition="view/isBetaUser">
187+ <a href="#" class="js-action" onclick="setBetaRedirect(false)"
188+ tal:condition="not:view/isRedirectInhibited">
189+ Disable edge redirect.
190+ </a>
191+ </tal:beta_user>
192+ </tal:edge_only>
193 </div>
194 </metal:site-message>
195
196
197=== modified file 'lib/lp/registry/browser/root.py'
198--- lib/lp/registry/browser/root.py 2009-09-15 17:16:17 +0000
199+++ lib/lp/registry/browser/root.py 2009-09-16 08:01:30 +0000
200@@ -98,6 +98,12 @@
201 """The total blueprint count in all of Launchpad."""
202 return getUtility(ILaunchpadStatisticSet).value('question_count')
203
204+ def canRedirect(self):
205+ """Return True if the beta server is available to the user."""
206+ return bool(
207+ config.launchpad.beta_testers_redirection_host is not None and
208+ self.isBetaUser)
209+
210
211 class LaunchpadSearchFormView(LaunchpadView):
212 """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

1=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
2--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-16 17:13:23 +0000
3+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-17 15:24:12 +0000
4@@ -146,8 +146,8 @@
5 ... browser.contents, 'sitemessage')[0])
6 This is a beta site.
7
8-Similarly, once the redirection has been inhibited, the link will no longer
9-appear in the footer of edge pages.
10+Similarly, once the redirection has been inhibited, the link changes to
11+enable redirects..
12
13 # Workaround bug in mechanize where you cannot use the Cookie
14 # header with the CookieJar
15@@ -165,9 +165,11 @@
16 >>> site_message = find_tags_by_class(
17 ... beta_browser.contents, 'sitemessage')[0]
18 >>> print extract_text(site_message)
19- This is a beta site.
20- >>> print site_message.find('a')
21- None
22+ This is a beta site. Enable edge redirect.
23+ >>> print extract_text(site_message.find(
24+ ... 'a', onclick="setBetaRedirect(true)"))
25+ Enable edge redirect.
26+
27
28 # Remove the specific site-message config data before continuing.
29 >>> dummy = config.pop('edge_config_data')
30
31=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
32--- lib/lp/app/templates/base-layout-macros.pt 2009-09-16 10:03:52 +0000
33+++ lib/lp/app/templates/base-layout-macros.pt 2009-09-17 15:24:12 +0000
34@@ -392,6 +392,10 @@
35 tal:condition="not:view/isRedirectInhibited">
36 Disable edge redirect.
37 </a>
38+ <a href="#" class="js-action" onclick="setBetaRedirect(true)"
39+ tal:condition="view/isRedirectInhibited">
40+ Enable edge redirect.
41+ </a>
42 </tal:beta_user>
43 </tal:normal_lp_view>
44 </tal:edge_only>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/doc/launchpadview.txt'
2--- lib/canonical/launchpad/doc/launchpadview.txt 2009-04-17 10:32:16 +0000
3+++ lib/canonical/launchpad/doc/launchpadview.txt 2009-09-15 17:16:17 +0000
4@@ -101,3 +101,19 @@
5 >>> view.error_message = structured('Information overload.')
6 >>> view.error_message.escapedtext
7 u'Information overload.'
8+
9+Every Launchpad view also knows whether edge redirection has been inhibited.
10+
11+ >>> view.isRedirectInhibited()
12+ False
13+ >>> new_request = TestRequest(HTTP_COOKIE="inhibit_beta_redirect=1")
14+ >>> view = MyView(context, new_request)
15+ >>> view.isRedirectInhibited()
16+ True
17+
18+Every Launchpad view knows whether redirection is possible.
19+
20+ >>> view.canRedirect()
21+ False
22+
23+
24
25=== modified file 'lib/canonical/launchpad/icing/style.css'
26--- lib/canonical/launchpad/icing/style.css 2009-09-14 09:40:39 +0000
27+++ lib/canonical/launchpad/icing/style.css 2009-09-15 11:14:08 +0000
28@@ -674,30 +674,19 @@
29
30 /* === Universal page layout === */
31
32-/* All pages begin with a global header or a topline. */
33-#globalheader {
34- clear: both;
35- position: relative;
36- width: 100%;
37- height: 21px;
38- overflow: hidden;
39- margin: 0 0 1em 0;
40- padding: 0;
41- background-color: #EEE;
42- background-image: url(globalheader_bg.gif);
43- background-repeat: repeat-x;
44- background-position: top center;
45-}
46-#globalheader .sitemessage a {
47- color: #FFF;
48- text-decoration: underline;
49-}
50-/* Site-specific message. */
51-#globalheader .sitemessage {
52- text-align: center;
53- color: #FFF;
54- font-size: 13px;
55- padding-top: 2px;
56+/* All pages include the sitemessage in the footer if one is defined
57+ in the config. */
58+.sitemessage {
59+ clear: both;
60+ position: relative;
61+ width: 100%;
62+ height: 21px;
63+ overflow: hidden;
64+ margin: 1em 0;
65+ background: url(/@@/footer-background.png) top left repeat-x;
66+ text-align: center;
67+ font-size: 13px;
68+ padding-top: 0.5em;
69 }
70
71 /* === Login control === */
72
73=== modified file 'lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt'
74--- lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-08-30 13:31:02 +0000
75+++ lib/canonical/launchpad/pagetests/basics/demo-and-lpnet.txt 2009-09-15 13:55:00 +0000
76@@ -53,7 +53,8 @@
77 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
78 &bull;...Launchpad...) devmode demo site
79
80- >>> print extract_text(find_tag_by_id(browser.contents, 'globalheader'))
81+ >>> print extract_text(find_tags_by_class(
82+ ... browser.contents, 'sitemessage')[0])
83 This is a demo site mmk. File a bug.
84 >>> print browser.getLink(url="http://example.com").text
85 File a bug
86@@ -68,7 +69,8 @@
87 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
88 |...Launchpad...) devmode demo site
89
90- >>> print extract_text(find_tag_by_id(browser.contents, 'globalheader'))
91+ >>> print extract_text(find_tags_by_class(
92+ ... browser.contents, 'sitemessage')[0])
93 This is a demo site mmk. File a bug.
94 >>> print browser.getLink(url="http://example.com").text
95 File a bug
96@@ -86,16 +88,17 @@
97 >>> browser.open('http://launchpad.dev/ubuntu')
98 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
99 &bull;...Launchpad...) devmode
100- >>> print find_tag_by_id(browser.contents, 'globalheader')
101- None
102+ >>> len(find_tags_by_class(browser.contents, 'sitemessage'))
103+ 0
104+
105
106 And for a non-3-0 page:
107
108 >>> browser.open('http://launchpad.dev/')
109 >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version'))
110 |...Launchpad...) devmode
111- >>> print find_tag_by_id(browser.contents, 'globalheader')
112- None
113+ >>> len(find_tags_by_class(browser.contents, 'sitemessage'))
114+ 0
115
116
117 == Launchpad.net ==
118
119=== modified file 'lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt'
120--- lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-08-06 11:35:34 +0000
121+++ lib/canonical/launchpad/pagetests/standalone/xx-beta-testers-redirection.txt 2009-09-15 17:16:17 +0000
122@@ -126,6 +126,40 @@
123 for 2 hours</button></p>
124 </div>
125
126+In addition to this prominent display on the root page, each page will
127+also include the disable-redirect link in the site_message.
128+
129+ # First ensure it's not there when there is no site-message to display.
130+ >>> check(beta_browser.open, 'http://launchpad.dev')
131+ >>> len(find_tags_by_class(beta_browser.contents, 'sitemessage'))
132+ 0
133+
134+ # Now setup a site-message config and re-check.
135+ >>> site_msg_data = """
136+ ... [launchpad]
137+ ... site_message: This is a beta site.
138+ ... """
139+ >>> config.push('site_msg_data', site_msg_data)
140+ >>> check(beta_browser.open, 'http://launchpad.dev')
141+ >>> site_message = find_tags_by_class(
142+ ... beta_browser.contents, 'sitemessage')[0]
143+ >>> print extract_text(site_message)
144+ This is a beta site. Disable edge redirect.
145+ >>> print extract_text(site_message.find(
146+ ... 'a', onclick="setBetaRedirect(false)"))
147+ Disable edge redirect.
148+
149+The disable-redirect link will not appear in the site_message when
150+browsed by non-beta users.
151+
152+ >>> check(user_browser.open, 'http://launchpad.dev')
153+ >>> print extract_text(find_tags_by_class(
154+ ... user_browser.contents, 'sitemessage')[0])
155+ This is a beta site.
156+
157+ # Remove the specific site-message config data before continuing.
158+ >>> dummy = config.pop('site_msg_data')
159+
160 This is so that the user can make use of some client side JS on that
161 page that sets a cookie to inhibit the redirection. When the
162 redirection is inhibited, the info message changes to one that lets
163@@ -157,6 +191,21 @@
164 redirection</button></p>
165 </div>
166
167+Similarly, once the redirection has been inhibited, the link will no longer
168+appear in the footer of edge pages.
169+
170+ >>> config.push('site_msg_data', site_msg_data)
171+ >>> check(beta_browser.open, 'http://launchpad.dev')
172+ >>> site_message = find_tags_by_class(
173+ ... beta_browser.contents, 'sitemessage')[0]
174+ >>> print extract_text(site_message)
175+ This is a beta site.
176+ >>> print site_message.find('a')
177+ None
178+
179+ >>> dummy = config.pop('site_msg_data')
180+
181+
182 Now when they go to a page on the site, it loads as normal:
183
184 >>> check(beta_browser.open, 'http://launchpad.dev/ubuntu')
185
186=== modified file 'lib/canonical/launchpad/templates/main-template.pt'
187--- lib/canonical/launchpad/templates/main-template.pt 2009-08-30 13:31:02 +0000
188+++ lib/canonical/launchpad/templates/main-template.pt 2009-09-15 17:30:59 +0000
189@@ -98,12 +98,6 @@
190 <input type="search" id="search-text" name="field.text" />
191 </form>
192 <tal:hierarchy replace="structure context/@@+hierarchy" />
193- <div id="globalheader" xml:lang="en" lang="en" dir="ltr"
194- tal:condition="site_message">
195- <div class="sitemessage" tal:content="structure site_message">
196- This site is running pre-release code.
197- </div>
198- </div>
199 <div
200 tal:condition="view/macro:pagehas/applicationtabs"
201 tal:define="facetmenu view/menu:facet"
202@@ -239,6 +233,10 @@
203 <a tal:condition="request/lp:person" href="/feedback"
204 >Contact us</a> | <a href="https://help.launchpad.net/">Get help with Launchpad</a>
205 </div>
206+
207+ <metal:site-message
208+ use-macro="context/@@+base-layout-macros/site-message"/>
209+
210 <div id="lp-arcana">
211 &copy;&nbsp;2004-2009&nbsp;<a
212 href="http://canonical.com/">Canonical&nbsp;Ltd.</a>
213
214=== modified file 'lib/canonical/launchpad/webapp/publisher.py'
215--- lib/canonical/launchpad/webapp/publisher.py 2009-08-20 07:15:35 +0000
216+++ lib/canonical/launchpad/webapp/publisher.py 2009-09-15 17:16:17 +0000
217@@ -39,6 +39,7 @@
218 from zope.traversing.browser.interfaces import IAbsoluteURL
219
220 from canonical.cachedproperty import cachedproperty
221+from canonical.config import config
222 from canonical.launchpad.layers import setFirstLayer, WebServiceLayer
223 from canonical.launchpad.webapp.vhosts import allvhosts
224 from canonical.launchpad.webapp.interfaces import (
225@@ -272,6 +273,16 @@
226 """
227 return self.request.response.getStatus() in [301, 302, 303, 307]
228
229+ def isRedirectInhibited(self):
230+ """Returns True if redirection has been inhibited."""
231+ return self.request.cookies.get('inhibit_beta_redirect', '0') == '1'
232+
233+ def canRedirect(self):
234+ """Return True if the beta server is available to the user."""
235+ return bool(
236+ config.launchpad.beta_testers_redirection_host is not None and
237+ self.isBetaUser)
238+
239 def __call__(self):
240 self.initialize()
241 if self._isRedirected():
242
243=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
244--- lib/lp/app/templates/base-layout-macros.pt 2009-08-19 15:13:39 +0000
245+++ lib/lp/app/templates/base-layout-macros.pt 2009-09-15 17:30:59 +0000
246@@ -348,6 +348,9 @@
247 </form>
248 </div>
249
250+ <metal:site-message
251+ use-macro="context/@@+base-layout-macros/site-message"/>
252+
253 <div class="colophon">
254 &copy; 2004-2009
255 <a href="http://canonical.com/">Canonical&nbsp;Ltd.</a>
256@@ -367,4 +370,19 @@
257 </div>
258 </div>
259 </metal:footer>
260+
261+<metal:site-message define-macro="site-message">
262+ <div class="sitemessage" tal:condition="site_message">
263+ <tal:site_message tal:content="structure site_message">
264+ This site is running pre-release code.
265+ </tal:site_message>
266+ <tal:redirect_only condition="view/canRedirect">
267+ <a href="#" class="js-action" onclick="setBetaRedirect(false)"
268+ tal:condition="not:view/isRedirectInhibited">
269+ Disable edge redirect.
270+ </a>
271+ </tal:redirect_only>
272+ </div>
273+</metal:site-message>
274+
275 </macros>
276
277=== modified file 'lib/lp/app/templates/base-layout.pt'
278--- lib/lp/app/templates/base-layout.pt 2009-09-08 22:42:42 +0000
279+++ lib/lp/app/templates/base-layout.pt 2009-09-15 11:14:08 +0000
280@@ -79,12 +79,6 @@
281 ${view/context/fmt:public-private-css}
282 yui-skin-sam">
283 <div class="yui-d0">
284- <div id="globalheader" xml:lang="en" lang="en" dir="ltr"
285- tal:condition="site_message">
286- <div class="sitemessage" tal:content="structure site_message">
287- This site is running pre-release code.
288- </div>
289- </div>
290 <div id="locationbar">
291 <tal:login replace="structure context/@@login_status" />
292 </div><!--id="locationbar"-->
293
294=== modified file 'lib/lp/registry/browser/root.py'
295--- lib/lp/registry/browser/root.py 2009-06-25 04:06:00 +0000
296+++ lib/lp/registry/browser/root.py 2009-09-15 17:16:17 +0000
297@@ -18,7 +18,6 @@
298 from zope.schema.interfaces import TooLong
299 from zope.schema.vocabulary import getVocabularyRegistry
300
301-from canonical.config import config
302 from canonical.cachedproperty import cachedproperty
303 from lp.registry.browser.announcement import HasAnnouncementsView
304 from canonical.launchpad.interfaces.launchpadstatistic import (
305@@ -54,16 +53,6 @@
306 # determines the number of projects we display in each column.
307 FEATURED_PROJECT_ROWS = 10
308
309- def isRedirectInhibited(self):
310- """Returns True if redirection has been inhibited."""
311- return self.request.cookies.get('inhibit_beta_redirect', '0') == '1'
312-
313- def canRedirect(self):
314- """Return True if the beta server is available to the user."""
315- return bool(
316- config.launchpad.beta_testers_redirection_host is not None and
317- self.isBetaUser)
318-
319 @cachedproperty
320 def featured_projects(self):
321 """Return a list of featured projects."""