diff --git a/r2/example.ini b/r2/example.ini index ff166844dd..10276f99fb 100644 --- a/r2/example.ini +++ b/r2/example.ini @@ -574,6 +574,8 @@ frontpage_dart = false fastlane_links = # a message placed in the infobar announcement_message = +# an info message placed in the sidebar +sidebar_message = # spotlight links for subreddit discovery sr_discovery_links = # probability of the subreddit suggester showing up in the spotlight box diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py index e772b85a8f..9ff6ce6d45 100755 --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -228,6 +228,7 @@ class Globals(object): 'goldvertisement_blurbs', 'goldvertisement_has_gold_blurbs', 'welcomebar_messages', + 'sidebar_message', ], } diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 9c175353e9..47688ea4ce 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -328,6 +328,10 @@ def rightbox(self): if self.searchbox: ps.append(SearchForm()) + sidebar_message = g.live_config.get("sidebar_message") + if sidebar_message and isinstance(c.site, DefaultSR): + ps.append(SidebarMessage(sidebar_message[0])) + if not c.user_is_loggedin and self.loginbox and not g.read_only_mode: ps.append(LoginFormWide()) @@ -1624,6 +1628,11 @@ def __init__(self, client, *args, **kwargs): InfoBar.__init__(self, *args, **kwargs) self.client = client +class SidebarMessage(Templated): + """An info message box on the sidebar.""" + def __init__(self, message): + Templated.__init__(self, message=message) + class RedditError(BoringPage): site_tracking = False def __init__(self, title, message, image=None, sr_description=None, diff --git a/r2/r2/public/static/css/reddit.less b/r2/r2/public/static/css/reddit.less index 1a3be95dae..08c9ef1362 100755 --- a/r2/r2/public/static/css/reddit.less +++ b/r2/r2/public/static/css/reddit.less @@ -400,6 +400,36 @@ ul.flat-vert {text-align: left;} margin: 7px 0 12px 0; } +.side .side-message { + background: lighten(@info-bg, 10%) no-repeat 10px 10px; + border: 1px solid darken(@info-bg, 20%); + border-radius: 2px; + padding: 10px; + line-height: 1.75em; + + &:before { + content: ''; + display: inline-block; + float: left; + background-image: url(../icon-info.png); /* SPRITE */ + width: 16px; + height: 16px; + margin-right: 7px; + } + + p { + font-size: .9em; + margin: 0; + + strong { + display: block; + font-weight: normal; + font-size: 1.25em; + margin-bottom: .25em; + } + } +} + .morelink { display:block; text-align: center; @@ -1176,11 +1206,13 @@ a.author { margin-right: 0.5em; } overflow: auto; } +@info-bg: #f6e69f; +@info-border: orange; .infobar { - background-color: #f6e69f; + background-color: @info-bg; padding: 5px 10px; margin: 5px 305px 5px 0px; - border: 1px solid orange; + border: 1px solid @info-border; font-size: small; } diff --git a/r2/r2/templates/sidebarmessage.html b/r2/r2/templates/sidebarmessage.html new file mode 100644 index 0000000000..76d9680a2e --- /dev/null +++ b/r2/r2/templates/sidebarmessage.html @@ -0,0 +1,29 @@ +## 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. +############################################################################### + +<%! + from r2.lib.filters import safemarkdown +%> + +
+ ${unsafe(safemarkdown(thing.message))} +