Merge lp:~michael.nelson/launchpad/429353-site-message-to-footer into lp:launchpad
- 429353-site-message-to-footer
- Merge into devel
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Barry Warsaw (community) | ui* | Approve | |
Brad Crittenden (community) | code | Approve | |
Review via email: mp+11813@code.launchpad.net |
Commit message
Description of the change
Michael Nelson (michael.nelson) wrote : | # |
Michael Nelson (michael.nelson) wrote : | # |
Screenshots (without the disable-redirect link):
http://
http://
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 :)
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://
iEYEARECAAYFAkq
3VgAn3T9CSeLteK
=mDCb
-----END PGP SIGNATURE-----
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.
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://
http://
http://
Or to demo:
1. apply diff http://
2. as anonymous or any non-beta user, view the footer at both:
https:/
https:/
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 | 111 | >>> view.isRedirectInhibited() | 111 | >>> view.isRedirectInhibited() |
6 | 112 | True | 112 | True |
7 | 113 | 113 | ||
8 | 114 | Every Launchpad view knows whether redirection is possible. | ||
9 | 115 | |||
10 | 116 | >>> view.canRedirect() | ||
11 | 117 | False | ||
12 | 118 | |||
13 | 119 | |||
14 | 120 | 114 | ||
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 | 101 | 0 | 101 | 0 |
20 | 102 | 102 | ||
21 | 103 | 103 | ||
22 | 104 | == Launchpad Edge == | ||
23 | 105 | |||
24 | 106 | Additionally, when a server is running as an edge server, the site-message | ||
25 | 107 | is appended with a link to disable edge redirects. | ||
26 | 108 | |||
27 | 109 | In addition to this prominent display on the root page, each page will | ||
28 | 110 | also include the disable-redirect link in the site_message - if the | ||
29 | 111 | user is a member of the beta group and has not already disabled | ||
30 | 112 | the redirects. | ||
31 | 113 | |||
32 | 114 | # Now setup an edge site-message config and re-check. | ||
33 | 115 | >>> edge_config_data = """ | ||
34 | 116 | ... [launchpad] | ||
35 | 117 | ... site_message: This is a beta site. | ||
36 | 118 | ... is_edge: True | ||
37 | 119 | ... """ | ||
38 | 120 | >>> config.push('edge_config_data', edge_config_data) | ||
39 | 121 | >>> beta_browser = setupBrowser( | ||
40 | 122 | ... auth='Basic beta-admin@launchpad.net:test') | ||
41 | 123 | >>> beta_browser.open('http://launchpad.dev/ubuntu') | ||
42 | 124 | >>> site_message = find_tags_by_class( | ||
43 | 125 | ... beta_browser.contents, 'sitemessage')[0] | ||
44 | 126 | >>> print extract_text(site_message) | ||
45 | 127 | This is a beta site. Disable edge redirect. | ||
46 | 128 | >>> print extract_text(site_message.find( | ||
47 | 129 | ... 'a', onclick="setBetaRedirect(false)")) | ||
48 | 130 | Disable edge redirect. | ||
49 | 131 | |||
50 | 132 | The disable-redirect link will not appear in the site_message when | ||
51 | 133 | browsed by non-beta users. | ||
52 | 134 | |||
53 | 135 | >>> browser.open('http://launchpad.dev/ubuntu') | ||
54 | 136 | >>> print extract_text(find_tags_by_class( | ||
55 | 137 | ... browser.contents, 'sitemessage')[0]) | ||
56 | 138 | This is a beta site. | ||
57 | 139 | |||
58 | 140 | Similarly, once the redirection has been inhibited, the link will no longer | ||
59 | 141 | appear in the footer of edge pages. | ||
60 | 142 | |||
61 | 143 | # Workaround bug in mechanize where you cannot use the Cookie | ||
62 | 144 | # header with the CookieJar | ||
63 | 145 | >>> from mechanize._clientcookie import Cookie | ||
64 | 146 | >>> cookiejar = ( | ||
65 | 147 | ... beta_browser.mech_browser._ua_handlers['_cookies'].cookiejar) | ||
66 | 148 | >>> cookiejar.set_cookie( | ||
67 | 149 | ... Cookie( | ||
68 | 150 | ... version=0, name='inhibit_beta_redirect', value='1', port=None, | ||
69 | 151 | ... port_specified=False, domain='.launchpad.dev', | ||
70 | 152 | ... domain_specified=True, domain_initial_dot=True, path='/', | ||
71 | 153 | ... path_specified=True, secure=False, expires=None, | ||
72 | 154 | ... discard=None, comment=None, comment_url=None, rest={})) | ||
73 | 155 | >>> beta_browser.open('http://launchpad.dev/ubuntu') | ||
74 | 156 | >>> site_message = find_tags_by_class( | ||
75 | 157 | ... beta_browser.contents, 'sitemessage')[0] | ||
76 | 158 | >>> print extract_text(site_message) | ||
77 | 159 | This is a beta site. | ||
78 | 160 | >>> print site_message.find('a') | ||
79 | 161 | None | ||
80 | 162 | |||
81 | 163 | # Remove the specific site-message config data before continuing. | ||
82 | 164 | >>> dummy = config.pop('edge_config_data') | ||
83 | 165 | |||
84 | 166 | |||
85 | 104 | == Launchpad.net == | 167 | == Launchpad.net == |
86 | 105 | 168 | ||
87 | 106 | On every instance except launchpad.net, Launchpad's version and | 169 | On every instance except launchpad.net, Launchpad's version and |
88 | 107 | 170 | ||
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 | 126 | for 2 hours</button></p> | 126 | for 2 hours</button></p> |
94 | 127 | </div> | 127 | </div> |
95 | 128 | 128 | ||
96 | 129 | In addition to this prominent display on the root page, each page will | ||
97 | 130 | also include the disable-redirect link in the site_message. | ||
98 | 131 | |||
99 | 132 | # First ensure it's not there when there is no site-message to display. | ||
100 | 133 | >>> check(beta_browser.open, 'http://launchpad.dev') | ||
101 | 134 | >>> len(find_tags_by_class(beta_browser.contents, 'sitemessage')) | ||
102 | 135 | 0 | ||
103 | 136 | |||
104 | 137 | # Now setup a site-message config and re-check. | ||
105 | 138 | >>> site_msg_data = """ | ||
106 | 139 | ... [launchpad] | ||
107 | 140 | ... site_message: This is a beta site. | ||
108 | 141 | ... """ | ||
109 | 142 | >>> config.push('site_msg_data', site_msg_data) | ||
110 | 143 | >>> check(beta_browser.open, 'http://launchpad.dev') | ||
111 | 144 | >>> site_message = find_tags_by_class( | ||
112 | 145 | ... beta_browser.contents, 'sitemessage')[0] | ||
113 | 146 | >>> print extract_text(site_message) | ||
114 | 147 | This is a beta site. Disable edge redirect. | ||
115 | 148 | >>> print extract_text(site_message.find( | ||
116 | 149 | ... 'a', onclick="setBetaRedirect(false)")) | ||
117 | 150 | Disable edge redirect. | ||
118 | 151 | |||
119 | 152 | The disable-redirect link will not appear in the site_message when | ||
120 | 153 | browsed by non-beta users. | ||
121 | 154 | |||
122 | 155 | >>> check(user_browser.open, 'http://launchpad.dev') | ||
123 | 156 | >>> print extract_text(find_tags_by_class( | ||
124 | 157 | ... user_browser.contents, 'sitemessage')[0]) | ||
125 | 158 | This is a beta site. | ||
126 | 159 | |||
127 | 160 | # Remove the specific site-message config data before continuing. | ||
128 | 161 | >>> dummy = config.pop('site_msg_data') | ||
129 | 162 | |||
130 | 163 | This is so that the user can make use of some client side JS on that | 129 | This is so that the user can make use of some client side JS on that |
131 | 164 | page that sets a cookie to inhibit the redirection. When the | 130 | page that sets a cookie to inhibit the redirection. When the |
132 | 165 | redirection is inhibited, the info message changes to one that lets | 131 | redirection is inhibited, the info message changes to one that lets |
133 | @@ -191,20 +157,6 @@ | |||
134 | 191 | redirection</button></p> | 157 | redirection</button></p> |
135 | 192 | </div> | 158 | </div> |
136 | 193 | 159 | ||
137 | 194 | Similarly, once the redirection has been inhibited, the link will no longer | ||
138 | 195 | appear in the footer of edge pages. | ||
139 | 196 | |||
140 | 197 | >>> config.push('site_msg_data', site_msg_data) | ||
141 | 198 | >>> check(beta_browser.open, 'http://launchpad.dev') | ||
142 | 199 | >>> site_message = find_tags_by_class( | ||
143 | 200 | ... beta_browser.contents, 'sitemessage')[0] | ||
144 | 201 | >>> print extract_text(site_message) | ||
145 | 202 | This is a beta site. | ||
146 | 203 | >>> print site_message.find('a') | ||
147 | 204 | None | ||
148 | 205 | |||
149 | 206 | >>> dummy = config.pop('site_msg_data') | ||
150 | 207 | |||
151 | 208 | 160 | ||
152 | 209 | Now when they go to a page on the site, it loads as normal: | 161 | Now when they go to a page on the site, it loads as normal: |
153 | 210 | 162 | ||
154 | 211 | 163 | ||
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 | 277 | """Returns True if redirection has been inhibited.""" | 277 | """Returns True if redirection has been inhibited.""" |
160 | 278 | return self.request.cookies.get('inhibit_beta_redirect', '0') == '1' | 278 | return self.request.cookies.get('inhibit_beta_redirect', '0') == '1' |
161 | 279 | 279 | ||
162 | 280 | def canRedirect(self): | ||
163 | 281 | """Return True if the beta server is available to the user.""" | ||
164 | 282 | return bool( | ||
165 | 283 | config.launchpad.beta_testers_redirection_host is not None and | ||
166 | 284 | self.isBetaUser) | ||
167 | 285 | |||
168 | 286 | def __call__(self): | 280 | def __call__(self): |
169 | 287 | self.initialize() | 281 | self.initialize() |
170 | 288 | if self._isRedirected(): | 282 | if self._isRedirected(): |
171 | 289 | 283 | ||
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 | 376 | <tal:site_message tal:content="structure site_message"> | 376 | <tal:site_message tal:content="structure site_message"> |
177 | 377 | This site is running pre-release code. | 377 | This site is running pre-release code. |
178 | 378 | </tal:site_message> | 378 | </tal:site_message> |
185 | 379 | <tal:redirect_only condition="view/canRedirect"> | 379 | <tal:edge_only condition="is_edge"> |
186 | 380 | <a href="#" class="js-action" onclick="setBetaRedirect(false)" | 380 | <tal:beta_user condition="view/isBetaUser"> |
187 | 381 | tal:condition="not:view/isRedirectInhibited"> | 381 | <a href="#" class="js-action" onclick="setBetaRedirect(false)" |
188 | 382 | Disable edge redirect. | 382 | tal:condition="not:view/isRedirectInhibited"> |
189 | 383 | </a> | 383 | Disable edge redirect. |
190 | 384 | </tal:redirect_only> | 384 | </a> |
191 | 385 | </tal:beta_user> | ||
192 | 386 | </tal:edge_only> | ||
193 | 385 | </div> | 387 | </div> |
194 | 386 | </metal:site-message> | 388 | </metal:site-message> |
195 | 387 | 389 | ||
196 | 388 | 390 | ||
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 | 98 | """The total blueprint count in all of Launchpad.""" | 98 | """The total blueprint count in all of Launchpad.""" |
202 | 99 | return getUtility(ILaunchpadStatisticSet).value('question_count') | 99 | return getUtility(ILaunchpadStatisticSet).value('question_count') |
203 | 100 | 100 | ||
204 | 101 | def canRedirect(self): | ||
205 | 102 | """Return True if the beta server is available to the user.""" | ||
206 | 103 | return bool( | ||
207 | 104 | config.launchpad.beta_testers_redirection_host is not None and | ||
208 | 105 | self.isBetaUser) | ||
209 | 106 | |||
210 | 101 | 107 | ||
211 | 102 | class LaunchpadSearchFormView(LaunchpadView): | 108 | class LaunchpadSearchFormView(LaunchpadView): |
212 | 103 | """A view to display the global search form in any page.""" | 109 | """A view to display the global search form in any page.""" |
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/
--- lib/canonical/
+++ lib/canonical/
@@ -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/
Barry Warsaw (barry) : | # |
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 | 146 | ... browser.contents, 'sitemessage')[0]) | 146 | ... browser.contents, 'sitemessage')[0]) |
6 | 147 | This is a beta site. | 147 | This is a beta site. |
7 | 148 | 148 | ||
10 | 149 | Similarly, once the redirection has been inhibited, the link will no longer | 149 | Similarly, once the redirection has been inhibited, the link changes to |
11 | 150 | appear in the footer of edge pages. | 150 | enable redirects.. |
12 | 151 | 151 | ||
13 | 152 | # Workaround bug in mechanize where you cannot use the Cookie | 152 | # Workaround bug in mechanize where you cannot use the Cookie |
14 | 153 | # header with the CookieJar | 153 | # header with the CookieJar |
15 | @@ -165,9 +165,11 @@ | |||
16 | 165 | >>> site_message = find_tags_by_class( | 165 | >>> site_message = find_tags_by_class( |
17 | 166 | ... beta_browser.contents, 'sitemessage')[0] | 166 | ... beta_browser.contents, 'sitemessage')[0] |
18 | 167 | >>> print extract_text(site_message) | 167 | >>> print extract_text(site_message) |
22 | 168 | This is a beta site. | 168 | This is a beta site. Enable edge redirect. |
23 | 169 | >>> print site_message.find('a') | 169 | >>> print extract_text(site_message.find( |
24 | 170 | None | 170 | ... 'a', onclick="setBetaRedirect(true)")) |
25 | 171 | Enable edge redirect. | ||
26 | 172 | |||
27 | 171 | 173 | ||
28 | 172 | # Remove the specific site-message config data before continuing. | 174 | # Remove the specific site-message config data before continuing. |
29 | 173 | >>> dummy = config.pop('edge_config_data') | 175 | >>> dummy = config.pop('edge_config_data') |
30 | 174 | 176 | ||
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 | 392 | tal:condition="not:view/isRedirectInhibited"> | 392 | tal:condition="not:view/isRedirectInhibited"> |
36 | 393 | Disable edge redirect. | 393 | Disable edge redirect. |
37 | 394 | </a> | 394 | </a> |
38 | 395 | <a href="#" class="js-action" onclick="setBetaRedirect(true)" | ||
39 | 396 | tal:condition="view/isRedirectInhibited"> | ||
40 | 397 | Enable edge redirect. | ||
41 | 398 | </a> | ||
42 | 395 | </tal:beta_user> | 399 | </tal:beta_user> |
43 | 396 | </tal:normal_lp_view> | 400 | </tal:normal_lp_view> |
44 | 397 | </tal:edge_only> | 401 | </tal:edge_only> |
Preview Diff
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 | 101 | >>> view.error_message = structured('Information overload.') | 101 | >>> view.error_message = structured('Information overload.') |
6 | 102 | >>> view.error_message.escapedtext | 102 | >>> view.error_message.escapedtext |
7 | 103 | u'Information overload.' | 103 | u'Information overload.' |
8 | 104 | |||
9 | 105 | Every Launchpad view also knows whether edge redirection has been inhibited. | ||
10 | 106 | |||
11 | 107 | >>> view.isRedirectInhibited() | ||
12 | 108 | False | ||
13 | 109 | >>> new_request = TestRequest(HTTP_COOKIE="inhibit_beta_redirect=1") | ||
14 | 110 | >>> view = MyView(context, new_request) | ||
15 | 111 | >>> view.isRedirectInhibited() | ||
16 | 112 | True | ||
17 | 113 | |||
18 | 114 | Every Launchpad view knows whether redirection is possible. | ||
19 | 115 | |||
20 | 116 | >>> view.canRedirect() | ||
21 | 117 | False | ||
22 | 118 | |||
23 | 119 | |||
24 | 104 | 120 | ||
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 | 674 | 674 | ||
30 | 675 | /* === Universal page layout === */ | 675 | /* === Universal page layout === */ |
31 | 676 | 676 | ||
56 | 677 | /* All pages begin with a global header or a topline. */ | 677 | /* All pages include the sitemessage in the footer if one is defined |
57 | 678 | #globalheader { | 678 | in the config. */ |
58 | 679 | clear: both; | 679 | .sitemessage { |
59 | 680 | position: relative; | 680 | clear: both; |
60 | 681 | width: 100%; | 681 | position: relative; |
61 | 682 | height: 21px; | 682 | width: 100%; |
62 | 683 | overflow: hidden; | 683 | height: 21px; |
63 | 684 | margin: 0 0 1em 0; | 684 | overflow: hidden; |
64 | 685 | padding: 0; | 685 | margin: 1em 0; |
65 | 686 | background-color: #EEE; | 686 | background: url(/@@/footer-background.png) top left repeat-x; |
66 | 687 | background-image: url(globalheader_bg.gif); | 687 | text-align: center; |
67 | 688 | background-repeat: repeat-x; | 688 | font-size: 13px; |
68 | 689 | background-position: top center; | 689 | padding-top: 0.5em; |
45 | 690 | } | ||
46 | 691 | #globalheader .sitemessage a { | ||
47 | 692 | color: #FFF; | ||
48 | 693 | text-decoration: underline; | ||
49 | 694 | } | ||
50 | 695 | /* Site-specific message. */ | ||
51 | 696 | #globalheader .sitemessage { | ||
52 | 697 | text-align: center; | ||
53 | 698 | color: #FFF; | ||
54 | 699 | font-size: 13px; | ||
55 | 700 | padding-top: 2px; | ||
69 | 701 | } | 690 | } |
70 | 702 | 691 | ||
71 | 703 | /* === Login control === */ | 692 | /* === Login control === */ |
72 | 704 | 693 | ||
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 | 53 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) | 53 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) |
78 | 54 | •...Launchpad...) devmode demo site | 54 | •...Launchpad...) devmode demo site |
79 | 55 | 55 | ||
81 | 56 | >>> print extract_text(find_tag_by_id(browser.contents, 'globalheader')) | 56 | >>> print extract_text(find_tags_by_class( |
82 | 57 | ... browser.contents, 'sitemessage')[0]) | ||
83 | 57 | This is a demo site mmk. File a bug. | 58 | This is a demo site mmk. File a bug. |
84 | 58 | >>> print browser.getLink(url="http://example.com").text | 59 | >>> print browser.getLink(url="http://example.com").text |
85 | 59 | File a bug | 60 | File a bug |
86 | @@ -68,7 +69,8 @@ | |||
87 | 68 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) | 69 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) |
88 | 69 | |...Launchpad...) devmode demo site | 70 | |...Launchpad...) devmode demo site |
89 | 70 | 71 | ||
91 | 71 | >>> print extract_text(find_tag_by_id(browser.contents, 'globalheader')) | 72 | >>> print extract_text(find_tags_by_class( |
92 | 73 | ... browser.contents, 'sitemessage')[0]) | ||
93 | 72 | This is a demo site mmk. File a bug. | 74 | This is a demo site mmk. File a bug. |
94 | 73 | >>> print browser.getLink(url="http://example.com").text | 75 | >>> print browser.getLink(url="http://example.com").text |
95 | 74 | File a bug | 76 | File a bug |
96 | @@ -86,16 +88,17 @@ | |||
97 | 86 | >>> browser.open('http://launchpad.dev/ubuntu') | 88 | >>> browser.open('http://launchpad.dev/ubuntu') |
98 | 87 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) | 89 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) |
99 | 88 | •...Launchpad...) devmode | 90 | •...Launchpad...) devmode |
102 | 89 | >>> print find_tag_by_id(browser.contents, 'globalheader') | 91 | >>> len(find_tags_by_class(browser.contents, 'sitemessage')) |
103 | 90 | None | 92 | 0 |
104 | 93 | |||
105 | 91 | 94 | ||
106 | 92 | And for a non-3-0 page: | 95 | And for a non-3-0 page: |
107 | 93 | 96 | ||
108 | 94 | >>> browser.open('http://launchpad.dev/') | 97 | >>> browser.open('http://launchpad.dev/') |
109 | 95 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) | 98 | >>> print extract_text(find_tag_by_id(browser.contents, 'lp-version')) |
110 | 96 | |...Launchpad...) devmode | 99 | |...Launchpad...) devmode |
113 | 97 | >>> print find_tag_by_id(browser.contents, 'globalheader') | 100 | >>> len(find_tags_by_class(browser.contents, 'sitemessage')) |
114 | 98 | None | 101 | 0 |
115 | 99 | 102 | ||
116 | 100 | 103 | ||
117 | 101 | == Launchpad.net == | 104 | == Launchpad.net == |
118 | 102 | 105 | ||
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 | 126 | for 2 hours</button></p> | 126 | for 2 hours</button></p> |
124 | 127 | </div> | 127 | </div> |
125 | 128 | 128 | ||
126 | 129 | In addition to this prominent display on the root page, each page will | ||
127 | 130 | also include the disable-redirect link in the site_message. | ||
128 | 131 | |||
129 | 132 | # First ensure it's not there when there is no site-message to display. | ||
130 | 133 | >>> check(beta_browser.open, 'http://launchpad.dev') | ||
131 | 134 | >>> len(find_tags_by_class(beta_browser.contents, 'sitemessage')) | ||
132 | 135 | 0 | ||
133 | 136 | |||
134 | 137 | # Now setup a site-message config and re-check. | ||
135 | 138 | >>> site_msg_data = """ | ||
136 | 139 | ... [launchpad] | ||
137 | 140 | ... site_message: This is a beta site. | ||
138 | 141 | ... """ | ||
139 | 142 | >>> config.push('site_msg_data', site_msg_data) | ||
140 | 143 | >>> check(beta_browser.open, 'http://launchpad.dev') | ||
141 | 144 | >>> site_message = find_tags_by_class( | ||
142 | 145 | ... beta_browser.contents, 'sitemessage')[0] | ||
143 | 146 | >>> print extract_text(site_message) | ||
144 | 147 | This is a beta site. Disable edge redirect. | ||
145 | 148 | >>> print extract_text(site_message.find( | ||
146 | 149 | ... 'a', onclick="setBetaRedirect(false)")) | ||
147 | 150 | Disable edge redirect. | ||
148 | 151 | |||
149 | 152 | The disable-redirect link will not appear in the site_message when | ||
150 | 153 | browsed by non-beta users. | ||
151 | 154 | |||
152 | 155 | >>> check(user_browser.open, 'http://launchpad.dev') | ||
153 | 156 | >>> print extract_text(find_tags_by_class( | ||
154 | 157 | ... user_browser.contents, 'sitemessage')[0]) | ||
155 | 158 | This is a beta site. | ||
156 | 159 | |||
157 | 160 | # Remove the specific site-message config data before continuing. | ||
158 | 161 | >>> dummy = config.pop('site_msg_data') | ||
159 | 162 | |||
160 | 129 | This is so that the user can make use of some client side JS on that | 163 | This is so that the user can make use of some client side JS on that |
161 | 130 | page that sets a cookie to inhibit the redirection. When the | 164 | page that sets a cookie to inhibit the redirection. When the |
162 | 131 | redirection is inhibited, the info message changes to one that lets | 165 | redirection is inhibited, the info message changes to one that lets |
163 | @@ -157,6 +191,21 @@ | |||
164 | 157 | redirection</button></p> | 191 | redirection</button></p> |
165 | 158 | </div> | 192 | </div> |
166 | 159 | 193 | ||
167 | 194 | Similarly, once the redirection has been inhibited, the link will no longer | ||
168 | 195 | appear in the footer of edge pages. | ||
169 | 196 | |||
170 | 197 | >>> config.push('site_msg_data', site_msg_data) | ||
171 | 198 | >>> check(beta_browser.open, 'http://launchpad.dev') | ||
172 | 199 | >>> site_message = find_tags_by_class( | ||
173 | 200 | ... beta_browser.contents, 'sitemessage')[0] | ||
174 | 201 | >>> print extract_text(site_message) | ||
175 | 202 | This is a beta site. | ||
176 | 203 | >>> print site_message.find('a') | ||
177 | 204 | None | ||
178 | 205 | |||
179 | 206 | >>> dummy = config.pop('site_msg_data') | ||
180 | 207 | |||
181 | 208 | |||
182 | 160 | Now when they go to a page on the site, it loads as normal: | 209 | Now when they go to a page on the site, it loads as normal: |
183 | 161 | 210 | ||
184 | 162 | >>> check(beta_browser.open, 'http://launchpad.dev/ubuntu') | 211 | >>> check(beta_browser.open, 'http://launchpad.dev/ubuntu') |
185 | 163 | 212 | ||
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 | 98 | <input type="search" id="search-text" name="field.text" /> | 98 | <input type="search" id="search-text" name="field.text" /> |
191 | 99 | </form> | 99 | </form> |
192 | 100 | <tal:hierarchy replace="structure context/@@+hierarchy" /> | 100 | <tal:hierarchy replace="structure context/@@+hierarchy" /> |
193 | 101 | <div id="globalheader" xml:lang="en" lang="en" dir="ltr" | ||
194 | 102 | tal:condition="site_message"> | ||
195 | 103 | <div class="sitemessage" tal:content="structure site_message"> | ||
196 | 104 | This site is running pre-release code. | ||
197 | 105 | </div> | ||
198 | 106 | </div> | ||
199 | 107 | <div | 101 | <div |
200 | 108 | tal:condition="view/macro:pagehas/applicationtabs" | 102 | tal:condition="view/macro:pagehas/applicationtabs" |
201 | 109 | tal:define="facetmenu view/menu:facet" | 103 | tal:define="facetmenu view/menu:facet" |
202 | @@ -239,6 +233,10 @@ | |||
203 | 239 | <a tal:condition="request/lp:person" href="/feedback" | 233 | <a tal:condition="request/lp:person" href="/feedback" |
204 | 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> |
205 | 241 | </div> | 235 | </div> |
206 | 236 | |||
207 | 237 | <metal:site-message | ||
208 | 238 | use-macro="context/@@+base-layout-macros/site-message"/> | ||
209 | 239 | |||
210 | 242 | <div id="lp-arcana"> | 240 | <div id="lp-arcana"> |
211 | 243 | © 2004-2009 <a | 241 | © 2004-2009 <a |
212 | 244 | href="http://canonical.com/">Canonical Ltd.</a> | 242 | href="http://canonical.com/">Canonical Ltd.</a> |
213 | 245 | 243 | ||
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 | 39 | from zope.traversing.browser.interfaces import IAbsoluteURL | 39 | from zope.traversing.browser.interfaces import IAbsoluteURL |
219 | 40 | 40 | ||
220 | 41 | from canonical.cachedproperty import cachedproperty | 41 | from canonical.cachedproperty import cachedproperty |
221 | 42 | from canonical.config import config | ||
222 | 42 | from canonical.launchpad.layers import setFirstLayer, WebServiceLayer | 43 | from canonical.launchpad.layers import setFirstLayer, WebServiceLayer |
223 | 43 | from canonical.launchpad.webapp.vhosts import allvhosts | 44 | from canonical.launchpad.webapp.vhosts import allvhosts |
224 | 44 | from canonical.launchpad.webapp.interfaces import ( | 45 | from canonical.launchpad.webapp.interfaces import ( |
225 | @@ -272,6 +273,16 @@ | |||
226 | 272 | """ | 273 | """ |
227 | 273 | return self.request.response.getStatus() in [301, 302, 303, 307] | 274 | return self.request.response.getStatus() in [301, 302, 303, 307] |
228 | 274 | 275 | ||
229 | 276 | def isRedirectInhibited(self): | ||
230 | 277 | """Returns True if redirection has been inhibited.""" | ||
231 | 278 | return self.request.cookies.get('inhibit_beta_redirect', '0') == '1' | ||
232 | 279 | |||
233 | 280 | def canRedirect(self): | ||
234 | 281 | """Return True if the beta server is available to the user.""" | ||
235 | 282 | return bool( | ||
236 | 283 | config.launchpad.beta_testers_redirection_host is not None and | ||
237 | 284 | self.isBetaUser) | ||
238 | 285 | |||
239 | 275 | def __call__(self): | 286 | def __call__(self): |
240 | 276 | self.initialize() | 287 | self.initialize() |
241 | 277 | if self._isRedirected(): | 288 | if self._isRedirected(): |
242 | 278 | 289 | ||
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 | 348 | </form> | 348 | </form> |
248 | 349 | </div> | 349 | </div> |
249 | 350 | 350 | ||
250 | 351 | <metal:site-message | ||
251 | 352 | use-macro="context/@@+base-layout-macros/site-message"/> | ||
252 | 353 | |||
253 | 351 | <div class="colophon"> | 354 | <div class="colophon"> |
254 | 352 | © 2004-2009 | 355 | © 2004-2009 |
255 | 353 | <a href="http://canonical.com/">Canonical Ltd.</a> | 356 | <a href="http://canonical.com/">Canonical Ltd.</a> |
256 | @@ -367,4 +370,19 @@ | |||
257 | 367 | </div> | 370 | </div> |
258 | 368 | </div> | 371 | </div> |
259 | 369 | </metal:footer> | 372 | </metal:footer> |
260 | 373 | |||
261 | 374 | <metal:site-message define-macro="site-message"> | ||
262 | 375 | <div class="sitemessage" tal:condition="site_message"> | ||
263 | 376 | <tal:site_message tal:content="structure site_message"> | ||
264 | 377 | This site is running pre-release code. | ||
265 | 378 | </tal:site_message> | ||
266 | 379 | <tal:redirect_only condition="view/canRedirect"> | ||
267 | 380 | <a href="#" class="js-action" onclick="setBetaRedirect(false)" | ||
268 | 381 | tal:condition="not:view/isRedirectInhibited"> | ||
269 | 382 | Disable edge redirect. | ||
270 | 383 | </a> | ||
271 | 384 | </tal:redirect_only> | ||
272 | 385 | </div> | ||
273 | 386 | </metal:site-message> | ||
274 | 387 | |||
275 | 370 | </macros> | 388 | </macros> |
276 | 371 | 389 | ||
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 | 79 | ${view/context/fmt:public-private-css} | 79 | ${view/context/fmt:public-private-css} |
282 | 80 | yui-skin-sam"> | 80 | yui-skin-sam"> |
283 | 81 | <div class="yui-d0"> | 81 | <div class="yui-d0"> |
284 | 82 | <div id="globalheader" xml:lang="en" lang="en" dir="ltr" | ||
285 | 83 | tal:condition="site_message"> | ||
286 | 84 | <div class="sitemessage" tal:content="structure site_message"> | ||
287 | 85 | This site is running pre-release code. | ||
288 | 86 | </div> | ||
289 | 87 | </div> | ||
290 | 88 | <div id="locationbar"> | 82 | <div id="locationbar"> |
291 | 89 | <tal:login replace="structure context/@@login_status" /> | 83 | <tal:login replace="structure context/@@login_status" /> |
292 | 90 | </div><!--id="locationbar"--> | 84 | </div><!--id="locationbar"--> |
293 | 91 | 85 | ||
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 | 18 | from zope.schema.interfaces import TooLong | 18 | from zope.schema.interfaces import TooLong |
299 | 19 | from zope.schema.vocabulary import getVocabularyRegistry | 19 | from zope.schema.vocabulary import getVocabularyRegistry |
300 | 20 | 20 | ||
301 | 21 | from canonical.config import config | ||
302 | 22 | from canonical.cachedproperty import cachedproperty | 21 | from canonical.cachedproperty import cachedproperty |
303 | 23 | from lp.registry.browser.announcement import HasAnnouncementsView | 22 | from lp.registry.browser.announcement import HasAnnouncementsView |
304 | 24 | from canonical.launchpad.interfaces.launchpadstatistic import ( | 23 | from canonical.launchpad.interfaces.launchpadstatistic import ( |
305 | @@ -54,16 +53,6 @@ | |||
306 | 54 | # determines the number of projects we display in each column. | 53 | # determines the number of projects we display in each column. |
307 | 55 | FEATURED_PROJECT_ROWS = 10 | 54 | FEATURED_PROJECT_ROWS = 10 |
308 | 56 | 55 | ||
309 | 57 | def isRedirectInhibited(self): | ||
310 | 58 | """Returns True if redirection has been inhibited.""" | ||
311 | 59 | return self.request.cookies.get('inhibit_beta_redirect', '0') == '1' | ||
312 | 60 | |||
313 | 61 | def canRedirect(self): | ||
314 | 62 | """Return True if the beta server is available to the user.""" | ||
315 | 63 | return bool( | ||
316 | 64 | config.launchpad.beta_testers_redirection_host is not None and | ||
317 | 65 | self.isBetaUser) | ||
318 | 66 | |||
319 | 67 | @cachedproperty | 56 | @cachedproperty |
320 | 68 | def featured_projects(self): | 57 | def featured_projects(self): |
321 | 69 | """Return a list of featured projects.""" | 58 | """Return a list of featured projects.""" |
= 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 isRedirectInhib ited() and canRedirect dexView to LaunchpadView - but I can't see any other
from LaunchpadRootIn
way to enable this on every LP page.
== Tests ==
bin/test -vv -t launchpadview.txt -t demo-and-lpnet.txt -t testers- redirection. txt
xx-beta-
== 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, /launchpad. dev/ubuntu and check the footer.
this patch will cause the above tests to fail, so revert it before testing).
2. Visit https:/
Q/A /edge.launchpad .net/ubuntu and verify the site-message /edge.launchpad .net/ubuntu and verify that the
1. Visit https:/
has the option to disable redirects.
2. Click the link to disable the redirect, and verify that it's worked.
3. Re-visit https:/
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: /launchpad/ icing/style. css registry/ browser/ root.py /launchpad/ webapp/ publisher. py /launchpad/ templates/ main-template. pt app/templates/ base-layout. pt app/templates/ base-layout- macros. pt /launchpad/ doc/launchpadvi ew.txt /launchpad/ pagetests/ basics/ demo-and- lpnet.txt
lib/canonical
lib/lp/
lib/canonical
lib/canonical
lib/lp/
lib/lp/
lib/canonical
lib/canonical
lib/canonical/ launchpad/ pagetests/ standalone/ xx-beta- testers- redirection. txt
== Pylint notices ==
lib/lp/ registry/ browser/ root.py gator.z3batchin g' (No ch.__iter_ _] Use super on an old style class
40: [F0401] Unable to import 'lazr.batchnavi
module named batchnavigator)
473: [E1002, WindowedListBat
--
Michael