From 4d86ad0a8feb683fcc07f0a1ea969e5f06016fa4 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Tue, 4 Dec 2012 03:24:45 -0800 Subject: [PATCH] Add small front page gold advertisement. --- r2/example.ini | 4 +++ r2/r2/lib/app_globals.py | 3 ++ r2/r2/lib/configparse.py | 6 ++++ r2/r2/lib/pages/pages.py | 19 ++++++++---- r2/r2/public/static/css/reddit.css | 45 ++++++++++++++++++++++++++-- r2/r2/templates/goldvertisement.html | 37 +++++++++++++++++++++++ 6 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 r2/r2/templates/goldvertisement.html diff --git a/r2/example.ini b/r2/example.ini index 2c8c4d9dc..e7701fbc9 100644 --- a/r2/example.ini +++ b/r2/example.ini @@ -557,3 +557,7 @@ spotlight_interest_nosub_p = .1 # map of comment tree version to how frequently it should be chosen relative to # the others comment_tree_version_weights = 1:1, 2:0 +# message blurbs for the front page sidebar gold ad. +# use a '|' character to separate the title line from the smaller aside. +# in the title line, '%(reddit_gold)s' will be replaced by a link. +goldvertisement_blurbs = "Make reddit better. Try %(reddit_gold)." "This year, give the gift of %(reddit_gold)s.|(and you should probably also give some other, better gifts)" diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py index c617ebd09..aabef8c28 100755 --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -221,6 +221,9 @@ class Globals(object): ConfigValue.dict(ConfigValue.int, ConfigValue.float): [ 'comment_tree_version_weights', ], + ConfigValue.messages: [ + 'goldvertisement_blurbs', + ], } def __init__(self, global_conf, app_conf, paths, **extra): diff --git a/r2/r2/lib/configparse.py b/r2/r2/lib/configparse.py index 3b0173a10..64692e1dd 100644 --- a/r2/r2/lib/configparse.py +++ b/r2/r2/lib/configparse.py @@ -21,6 +21,7 @@ ############################################################################### import datetime +import re class ConfigValue(object): @@ -69,6 +70,11 @@ class ConfigValue(object): def days(v, key=None, data=None): return datetime.timedelta(int(v)) + messages_re = re.compile(r'"([^"]+)"') + @staticmethod + def messages(v, key=None, data=None): + return ConfigValue.messages_re.findall(v) + class ConfigValueParser(dict): def __init__(self, raw_data): diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index a1d0ddf1d..ed6cac384 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -304,6 +304,7 @@ class Reddit(Templated): ps.append(SponsorshipBox()) no_ads_yet = True + show_adbox = (c.user.pref_show_adbox or not c.user.gold) and not g.disable_ads if isinstance(c.site, (MultiReddit, ModSR)) and c.user_is_loggedin: srs = Subreddit._byID(c.site.sr_ids, data=True, return_dict=False) @@ -326,7 +327,7 @@ class Reddit(Templated): ps.append(self.wiki_actions_menu(moderator=moderator)) if moderator: ps.append(self.sr_admin_menu()) - if (c.user.pref_show_adbox or not c.user.gold) and not g.disable_ads: + if show_adbox: ps.append(Ads()) no_ads_yet = False elif c.show_wiki_actions: @@ -374,10 +375,10 @@ class Reddit(Templated): more_href = mod_href, more_text = more_text)) - - if no_ads_yet and not g.disable_ads: - if c.user.pref_show_adbox or not c.user.gold: - ps.append(Ads()) + if no_ads_yet and show_adbox: + ps.append(Ads()) + if g.live_config["goldvertisement_blurbs"]: + ps.append(Goldvertisement()) if c.user.pref_clickgadget and c.recent_clicks: ps.append(SideContentBox(_("Recently viewed links"), @@ -3702,3 +3703,11 @@ class GoldInfoPage(BoringPage): "gold_year_price": g.gold_year_price, } BoringPage.__init__(self, *args, **kwargs) + + +class Goldvertisement(Templated): + def __init__(self): + Templated.__init__(self) + blurbs = g.live_config["goldvertisement_blurbs"] + blurb = random.choice(blurbs) + self.blurb_title, sep, self.blurb_aside = blurb.partition("|") diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index 495b57eac..68623b46d 100755 --- a/r2/r2/public/static/css/reddit.css +++ b/r2/r2/public/static/css/reddit.css @@ -5450,12 +5450,15 @@ tr.gold-accent + tr > td { text-shadow: none; } +.gold-dropdown, .goldvertisement { + font-family: "Bitstream Charter", "Hoefler Text", "Palatino Linotype", + "Book Antiqua", Palatino, georgia, garamond, FreeSerif, serif; +} + .gold-dropdown { color: #482800; background-color: #fff088; font-size: 16px; - font-family: "Bitstream Charter", "Hoefler Text", "Palatino Linotype", - "Book Antiqua", Palatino, georgia, garamond, FreeSerif, serif; } .comment-visits-box .title { @@ -6323,3 +6326,41 @@ body.post-under-6h-old .gilded-comment-icon { .buttons li.comment-unsave-button { display: inline; } body.gold .buttons li.comment-save-button { display: inline; } + +.goldvertisement { + height: 50px; + border: 1px solid #c4b487; + text-align: center; + line-height: 1.3em; + box-shadow: 0 0 10px #dad0b3 inset; + color: #333; +} + +.goldvertisement .inner { + margin: 1px; + border: 1px solid #dbd1b5; + height: 46px; + line-height: 44px; +} + +.goldvertisement p { + display: inline-block; + vertical-align: middle; + margin: 0 4px; + line-height: 14px; +} + +.goldvertisement strong { + font-size: 15px; +} + +.goldvertisement a { + color: #9a7d2e; + font-weight: bold; + text-decoration: underline; +} + +.goldvertisement i { + font-size: 11px; + font-variant: italic; +} diff --git a/r2/r2/templates/goldvertisement.html b/r2/r2/templates/goldvertisement.html new file mode 100644 index 000000000..757f89f29 --- /dev/null +++ b/r2/r2/templates/goldvertisement.html @@ -0,0 +1,37 @@ +## 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-2012 +## reddit Inc. All Rights Reserved. +############################################################################### + +<%namespace file="utils.html" import="tags, text_with_links"/> + +
+
+

+ + ${text_with_links(thing.blurb_title, + reddit_gold=dict(link_text="reddit gold", path="/gold/about"))} + + % if thing.blurb_aside: +
${thing.blurb_aside} + % endif +

+
+