From 79ddb15072dbb22c63f455a26d654579683ef210 Mon Sep 17 00:00:00 2001 From: Andre D Date: Fri, 6 Dec 2013 15:57:22 -0500 Subject: [PATCH] oauth: Add an authorize.compact support. --- r2/r2/lib/pages/pages.py | 8 +- .../compact/border-button-red-active.png | Bin 0 -> 1175 bytes .../static/compact/border-button-red.png | Bin 0 -> 842 bytes r2/r2/public/static/css/compact.css | 100 ++++++++++++++++++ r2/r2/templates/clientinfobar.compact | 23 ++++ r2/r2/templates/oauth2authorization.compact | 23 ++++ r2/r2/templates/oauth2authorization.html | 12 ++- r2/r2/templates/redditheader.compact | 1 + 8 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 r2/r2/public/static/compact/border-button-red-active.png create mode 100644 r2/r2/public/static/compact/border-button-red.png create mode 100644 r2/r2/templates/clientinfobar.compact create mode 100644 r2/r2/templates/oauth2authorization.compact diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 8098c6443..da787be22 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -174,10 +174,11 @@ class Reddit(Templated): def __init__(self, space_compress=None, nav_menus=None, loginbox=True, infotext='', content=None, short_description='', title='', robots=None, show_sidebar=True, show_chooser=False, - footer=True, srbar=True, page_classes=None, + footer=True, srbar=True, page_classes=None, short_title=None, show_wiki_actions=False, extra_js_config=None, **context): Templated.__init__(self, **context) self.title = title + self.short_title = short_title self.short_description = short_description self.robots = robots self.infotext = infotext @@ -1020,7 +1021,7 @@ class LoginPage(BoringPage): if self.dest: u = UrlParser(self.dest) # Display a preview message for OAuth2 client authorizations - if u.path == '/api/v1/authorize': + if u.path in ['/api/v1/authorize', '/api/v1/authorize.compact']: client_id = u.query_dict.get("client_id") self.client = client_id and OAuth2Client.get_token(client_id) if self.client: @@ -1104,7 +1105,8 @@ class OAuth2AuthorizationPage(BoringPage): duration=duration, expiration=expiration) BoringPage.__init__(self, _("request for permission"), - show_sidebar=False, content=content) + show_sidebar=False, content=content, + short_title=_("permission")) class OAuth2Authorization(Templated): pass diff --git a/r2/r2/public/static/compact/border-button-red-active.png b/r2/r2/public/static/compact/border-button-red-active.png new file mode 100644 index 0000000000000000000000000000000000000000..8b135a37a405dd9d6b8dcc3b770b6eafc37a0af4 GIT binary patch literal 1175 zcmV;I1Zew-P)5CC3f|#MYJ1|Bt5rP?Q zRo2RqkYyyT)&=0@sk!;9+rSgEGpU&T*sk@Rtkn-NXn}eWsDyxs;LQG)+8~0N(Q=Me zQ5KvhTfI#s%YQYoC#UA-+gm~{B5$-S>B;_jox?@JV5{IhD@dZD7WWkDC`u89wTh>L z@%O+0E74B&wbtJPKD_&kU-JV448_1uSuhw{c)*zN;Ue5HYP&LIr3@^TI-Yl zf^{RzLs2+UOH=A0aG)$noWrXk&VlNl-K&x~$APk>9s;$#lqj5-9zT9?Q}F|XgAX@X zR;Zeh21ufi#K^sxVkD}h0jg$X>Zl*Qe+*di0R5Fpb;*Rpgv1PS4s(uPm;i|xi3wuD zfi$gcDo#XH#1JQVRqz6V-k1X)1#yCik%;KF0^&^YG2+Egv?p9|5g!F-(!Fwt6D&zE zHHgv^u&H6%QM@BKsv;tY7Xls=>j^lBAlfNH@s85>pW+B6jwl|S1M3YK5n>Qb9K;YJd=m^X zK6&bVl4lpME!^N*JFw6$X@)@4jAb*LA}qnK-V|Zkj76YX1{TYbYZkbEbAcq!E{;#0 zI=?NeSC1aM@cf&vfBO9=pD$m(^4BxVhlV)RU!xiYA3L2(!tQt5oM6Ey6>>9{*4D|I zO)A;#OV7P}=CjqK$1d#nu73BGMiqErY5M)gf4hA7MRRT}dXL!lw$>FM3>2g&kP!Yn z^3dpak4>JswD`!8FB^?Uwj=nC4Lk}wUH$2Y!L=LL_th?H4-SX?iKm*t&%nh-qY=9P pN$jwJI?%t*E1WeNjg@YL{{XMP<)@_Ix<&v1002ovPDHLkV1jkV95ny{ literal 0 HcmV?d00001 diff --git a/r2/r2/public/static/compact/border-button-red.png b/r2/r2/public/static/compact/border-button-red.png new file mode 100644 index 0000000000000000000000000000000000000000..35b1eea3b418b1460a4860609ea5f304ddda0b80 GIT binary patch literal 842 zcmV-Q1GW5#P)zrWr4+if~69kH!7|0GJOgGd|e*fb zL2!cAOE38l1VJ%+3cFzoTMoNW#gyV_#{{#+3BbNc(an{%SII*%S$}+-G zXZs?65dg#Ccp_66XN9c}Mk5{o4+HysCmK2qV~^7bn>5M-+W@Q!f%)la#6HbW0XQ3u zCl-sq!Dz%z#9oCCwsyB1XoXl^1qo4+{!CGz*4AQnZVr>lq*8wRja?*9^D=TPryV2$MbpyCw*pZxF^txOS-_sx=cGN{W4R4(b00y^! zgVD%d?r?NeD+;W#YDIyn**k_h+w1dFUFUN7GrA7IfR(0dyWnuvGy?dl0)Ru)92s2) z3~RvvP@`#8`HJlfHbw*pX(^Nu!Ok}2%`XsQ41&l~FfmrVxtJiZ3eW9dD;8w3GHn1e zbZZ5+neA#RE!P-Q7K4cxq;4&k$V6jev?U{JhKovk7XQOJE&|)61k(ft|67p#sUNV6Gc)}lpUWawdH0D!*KV!=m;?~xoQslw5+(`k22fpQr_-GCZ>5620et57 U2*8Nw=l}o!07*qoM6N<$g1Mq{k^lez literal 0 HcmV?d00001 diff --git a/r2/r2/public/static/css/compact.css b/r2/r2/public/static/css/compact.css index b68f7e4d1..d1bf08a7a 100644 --- a/r2/r2/public/static/css/compact.css +++ b/r2/r2/public/static/css/compact.css @@ -17,6 +17,22 @@ textarea { font-family: inherit; } .newbutton { -webkit-appearance: none; -moz-appearance: none; appearance: none; border: 8px solid transparent; -moz-border-image: url("../compact/border-button.png") 8; -webkit-border-image: url("../compact/border-button.png") 8; -webkit-border-image: url("../compact/border-button.png") 8; -o-border-image: url("../compact/border-button.png") 8; border-image: url("../compact/border-button.png") 8 fill; color: white; font-family: inherit; font-size: 12px; font-weight: bold; text-decoration: none; text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.1), 0px -1px 1px rgba(0, 0, 0, 0.4); background: none; } .newbutton:active, .newbutton:hover, .newbutton[selected], .newbutton.expanded, .newbutton.active { -moz-border-image: url("../compact/border-button-active.png") 8; -webkit-border-image: url("../compact/border-button-active.png") 8; -webkit-border-image: url("../compact/border-button-active.png") 8; -o-border-image: url("../compact/border-button-active.png") 8; border-image: url("../compact/border-button-active.png") 8 fill; color: white; } +.newbutton.red { + -moz-border-image: url("../compact/border-button-red.png") 8; + -webkit-border-image: url("../compact/border-button-red.png") 8; + -o-border-image: url("../compact/border-button-red.png") 8; + border-image: url("../compact/border-button-red.png") 8 fill; +} + +.newbutton.red:active, .newbutton.red:hover, .newbutton.red[selected], .newbutton.red.expanded, .newbutton.red.active { + -moz-border-image: url("../compact/border-button-red-active.png") 8; + -webkit-border-image: url("../compact/border-button-red-active.png") 8; + -o-border-image: url("../compact/border-button-red-active.png") 8; + border-image: url("../compact/border-button-red-active.png") 8 fill; + color: white; +} + + .button, .button:visited { -webkit-border-radius: 6px; -moz-border-radius: 6px; -ms-border-radius: 6px; -o-border-radius: 6px; border-radius: 6px; background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #bfd0e0), color-stop(100%, #80a2c4)); background: -webkit-linear-gradient(top, #bfd0e0, #80a2c4); background: -moz-linear-gradient(top, #bfd0e0, #80a2c4); background: -o-linear-gradient(top, #bfd0e0, #80a2c4); background: linear-gradient(top, #bfd0e0, #80a2c4); background-color: #9fb9d2; height: 30px; line-height: 30px; color: white; font-family: inherit; font-size: 12px; font-weight: bold; margin: 0px; padding: 5px; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; width: auto; text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.1), 0px -1px 1px rgba(0, 0, 0, 0.4); border: 1px solid #517191; -webkit-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.75), 0px 1px 1px rgba(255, 255, 255, 0.6), 0px -1px 1px rgba(0, 0, 0, 0.1); -moz-box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.75), 0px 1px 1px rgba(255, 255, 255, 0.6), 0px -1px 1px rgba(0, 0, 0, 0.1); box-shadow: inset 0px 1px 0px rgba(255, 255, 255, 0.75), 0px 1px 1px rgba(255, 255, 255, 0.6), 0px -1px 1px rgba(0, 0, 0, 0.1); } .button:active, .button[selected], .button.active, .button.upmod, .button.downmod { background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #7e8994), color-stop(100%, #80a2c4)); background: -webkit-linear-gradient(top, #7e8994, #80a2c4); background: -moz-linear-gradient(top, #7e8994, #80a2c4); background: -o-linear-gradient(top, #7e8994, #80a2c4); background: linear-gradient(top, #7e8994, #80a2c4); background-color: #7f95ac; } @@ -580,3 +596,87 @@ a.author { margin-right: 0.5em; } display: block; margin-top: 2px; } + +.infobar { + background-color: #f6e69f; + padding: 5px 10px; + margin-bottom: -10px; + text-align: center; +} + +.infobar.client-info { + height: 48px; +} + +.infobar.client-info .icon img { + position: absolute; + left: 10px; + width: 48px; + height: 48px; +} + +.infobar.client-info div { + height: 48px; + display: table-cell; + vertical-align: middle; + text-align: left; + padding-left: 56px; +} + +.oauth2-authorize { + background-color: white; + max-width: 350px; + margin: 10px auto; + border-radius: 5px; + -webkit-border-radius: 5px; + padding: 10px; +} + +.oauth2-authorize .icon { + text-align: center; +} + +.oauth2-authorize h1 { + font-size: 18px; + padding: 5px; +} + +.oauth2-authorize form .allow { + margin-right: 10px; +} + +.oauth2-authorize form { + text-align: center; +} + +.oauth2-authorize .access-permissions { + border: 1px solid #CCC; + padding: 5px; + background-color: #EEE; + border-radius: 5px; + -webkit-border-radius: 5px; + margin-bottom: 15px; +} + +.oauth2-authorize h2 { + margin: 0; + font-size: 15px; +} + +.oauth2-authorize ul { + margin: 5px 0; + padding-left: 25px; + font-size: 15px; +} + +.oauth2-authorize a { + text-decoration: none; +} + +.oauth2-authorize .notice { + color: #333; + font-size: 15px; + margin: 10px 0; + padding-left: 5px; + font-weight: bold; +} diff --git a/r2/r2/templates/clientinfobar.compact b/r2/r2/templates/clientinfobar.compact new file mode 100644 index 000000000..fed8b4958 --- /dev/null +++ b/r2/r2/templates/clientinfobar.compact @@ -0,0 +1,23 @@ +## The contents of this file are subject to the Common Public Attribution +## License Version 1.0. (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License at +## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public +## License Version 1.1, but Sections 14 and 15 have been added to cover use of +## software over a computer network and provide for limited attribution for the +## Original Developer. In addition, Exhibit A has been modified to be +## consistent with Exhibit B. +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for +## the specific language governing rights and limitations under the License. +## +## The Original Code is reddit. +## +## The Original Developer is the Initial Developer. The Initial Developer of +## the Original Code is reddit Inc. +## +## All portions of the code written by reddit are Copyright (c) 2006-2013 +## reddit Inc. All Rights Reserved. +############################################################################### + +<%inherit file="clientinfobar.html" /> diff --git a/r2/r2/templates/oauth2authorization.compact b/r2/r2/templates/oauth2authorization.compact new file mode 100644 index 000000000..1084dd5b3 --- /dev/null +++ b/r2/r2/templates/oauth2authorization.compact @@ -0,0 +1,23 @@ +## The contents of this file are subject to the Common Public Attribution +## License Version 1.0. (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License at +## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public +## License Version 1.1, but Sections 14 and 15 have been added to cover use of +## software over a computer network and provide for limited attribution for the +## Original Developer. In addition, Exhibit A has been modified to be +## consistent with Exhibit B. +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for +## the specific language governing rights and limitations under the License. +## +## The Original Code is reddit. +## +## The Original Developer is the Initial Developer. The Initial Developer of +## the Original Code is reddit Inc. +## +## All portions of the code written by reddit are Copyright (c) 2006-2013 +## reddit Inc. All Rights Reserved. +############################################################################### + +<%inherit file="oauth2authorization.html"/> diff --git a/r2/r2/templates/oauth2authorization.html b/r2/r2/templates/oauth2authorization.html index 03bb0dbdb..f87eaeb82 100644 --- a/r2/r2/templates/oauth2authorization.html +++ b/r2/r2/templates/oauth2authorization.html @@ -46,10 +46,12 @@ % dict(app=app_link(thing.client)))}
-

${unsafe(_("Allow %(app)s to:") % dict(app=app_name))}

- ${scope_details(thing.scope, expiration=thing.expiration)} +
+

${unsafe(_("Allow %(app)s to:") % dict(app=app_name))}

+ ${scope_details(thing.scope, expiration=thing.expiration)} +

- ${unsafe( + ${unsafe( _("%(app)s will not be able to access your reddit password.") % dict(app=app_name))}

@@ -61,9 +63,9 @@
- -
diff --git a/r2/r2/templates/redditheader.compact b/r2/r2/templates/redditheader.compact index 751f84e5d..f61e43885 100644 --- a/r2/r2/templates/redditheader.compact +++ b/r2/r2/templates/redditheader.compact @@ -35,6 +35,7 @@ if toolbars and isinstance(toolbars[0], PageNameNav): nav = toolbars[0] toolbars = toolbars[1:] + nav = thing.short_title or nav %>