Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add support for a live-config sidebar info message.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromakode committed May 15, 2013
1 parent bf8750f commit 79ccaca
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
2 changes: 2 additions & 0 deletions r2/example.ini
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions r2/r2/lib/app_globals.py
Expand Up @@ -228,6 +228,7 @@ class Globals(object):
'goldvertisement_blurbs',
'goldvertisement_has_gold_blurbs',
'welcomebar_messages',
'sidebar_message',
],
}

Expand Down
9 changes: 9 additions & 0 deletions r2/r2/lib/pages/pages.py
Expand Up @@ -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())

Expand Down Expand Up @@ -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,
Expand Down
36 changes: 34 additions & 2 deletions r2/r2/public/static/css/reddit.less
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
29 changes: 29 additions & 0 deletions 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
%>

<div class="side-message">
${unsafe(safemarkdown(thing.message))}
</div>

0 comments on commit 79ccaca

Please sign in to comment.