Add small front page gold advertisement.

This commit is contained in:
Max Goodman
2012-12-04 03:24:45 -08:00
committed by Neil Williams
parent 8bf881535f
commit 4d86ad0a8f
6 changed files with 107 additions and 7 deletions

View File

@@ -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)"

View File

@@ -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):

View File

@@ -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):

View File

@@ -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("|")

View File

@@ -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;
}

View File

@@ -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"/>
<div class="goldvertisement">
<div class="inner">
<p>
<strong>
${text_with_links(thing.blurb_title,
reddit_gold=dict(link_text="reddit gold", path="/gold/about"))}
</strong>
% if thing.blurb_aside:
<br><i>${thing.blurb_aside}</i>
% endif
</p>
</div>
</div>