mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 15:58:06 -05:00
Replace goldvertisement with daily progress bar.
Many thanks to @chromakode for design and copy. The old goldvertisement live config is left in for now so that old code continues to function during rollout.
This commit is contained in:
@@ -608,6 +608,8 @@ frontend_logging = true
|
||||
# use **strong** markup for a larger font, and " \n" (<br>) to separate lines.
|
||||
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)"
|
||||
goldvertisement_has_gold_blurbs = "**“Exquisite!”** \nGrab a drink and join us in [the lounge](/r/lounge)."
|
||||
# daily gold revenue goal (in pennies) for progress bar thing
|
||||
gold_revenue_goal = 0
|
||||
# sample multireddits (displayed when a user has no multis)
|
||||
listing_chooser_sample_multis = /user/reddit/m/hello, /user/reddit/m/world
|
||||
# multi of subreddits to share with gold users
|
||||
|
||||
@@ -229,6 +229,7 @@ class Globals(object):
|
||||
ConfigValue.float: [
|
||||
'spotlight_interest_sub_p',
|
||||
'spotlight_interest_nosub_p',
|
||||
'gold_revenue_goal',
|
||||
],
|
||||
ConfigValue.tuple: [
|
||||
'sr_discovery_links',
|
||||
|
||||
@@ -31,7 +31,12 @@ from r2.models import Flair, FlairTemplate, FlairTemplateBySubredditIndex
|
||||
from r2.models import USER_FLAIR, LINK_FLAIR
|
||||
from r2.models import GoldPartnerDealCode
|
||||
from r2.models.bidding import Bid
|
||||
from r2.models.gold import gold_payments_by_user, gold_received_by_user, days_to_pennies
|
||||
from r2.models.gold import (
|
||||
gold_payments_by_user,
|
||||
gold_received_by_user,
|
||||
days_to_pennies,
|
||||
gold_revenue_on,
|
||||
)
|
||||
from r2.models.promo import NO_TRANSACTION, PromotionLog, PromotedLinkRoadblock
|
||||
from r2.models.token import OAuth2Client, OAuth2AccessToken
|
||||
from r2.models import traffic
|
||||
@@ -503,7 +508,7 @@ class Reddit(Templated):
|
||||
|
||||
if no_ads_yet and show_adbox:
|
||||
ps.append(Ads())
|
||||
if g.live_config["goldvertisement_blurbs"]:
|
||||
if g.live_config["gold_revenue_goal"]:
|
||||
ps.append(Goldvertisement())
|
||||
|
||||
if c.user.pref_clickgadget and c.recent_clicks:
|
||||
@@ -1733,6 +1738,14 @@ class ServerSecondsBar(Templated):
|
||||
# for simplicity all payment processor fees are $0.30 + 2.9%
|
||||
return pennies * (1 - 0.029) - 30
|
||||
|
||||
@classmethod
|
||||
def current_value_of_month(cls):
|
||||
price = g.gold_month_price.pennies
|
||||
after_fees = cls.subtract_fees(price)
|
||||
current_rate = cls.get_rate(datetime.datetime.now(g.display_tz))
|
||||
delta = datetime.timedelta(seconds=after_fees / current_rate)
|
||||
return precise_format_timedelta(delta, threshold=5, locale=c.locale)
|
||||
|
||||
def make_message(self, seconds, my_message, their_message):
|
||||
if not seconds:
|
||||
return ''
|
||||
@@ -4267,12 +4280,12 @@ class GoldPartnersPage(BoringPage):
|
||||
|
||||
class Goldvertisement(Templated):
|
||||
def __init__(self):
|
||||
today = datetime.datetime.now(g.display_tz).date()
|
||||
revenue_today = gold_revenue_on(today)
|
||||
revenue_goal = g.live_config["gold_revenue_goal"]
|
||||
self.percent_filled = int((revenue_today / revenue_goal) * 100)
|
||||
self.hours_paid = ServerSecondsBar.current_value_of_month()
|
||||
Templated.__init__(self)
|
||||
if not c.user.gold:
|
||||
blurbs = g.live_config["goldvertisement_blurbs"]
|
||||
else:
|
||||
blurbs = g.live_config["goldvertisement_has_gold_blurbs"]
|
||||
self.blurb = random.choice(blurbs)
|
||||
|
||||
class LinkCommentsSettings(Templated):
|
||||
def __init__(self, link):
|
||||
|
||||
@@ -33,6 +33,8 @@ from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
from sqlalchemy.schema import Column
|
||||
from sqlalchemy.sql import and_
|
||||
from sqlalchemy.sql.expression import select
|
||||
from sqlalchemy.sql.functions import sum as sa_sum
|
||||
from sqlalchemy.types import DateTime, Integer, String
|
||||
|
||||
from xml.dom.minidom import Document
|
||||
@@ -48,6 +50,7 @@ from BeautifulSoup import BeautifulStoneSoup
|
||||
from r2.lib.db.tdb_cassandra import NotFound
|
||||
from r2.models.subreddit import Frontpage
|
||||
from r2.models.wiki import WikiPage
|
||||
from r2.lib.memoize import memoize
|
||||
|
||||
gold_bonus_cutoff = datetime(2010,7,27,0,0,0,0,g.tz)
|
||||
|
||||
@@ -515,3 +518,13 @@ def append_random_bottlecap_phrase(message):
|
||||
if bottlecap:
|
||||
message += '\n\n> ' + bottlecap
|
||||
return message
|
||||
|
||||
|
||||
@memoize("gold-revenue", time=600)
|
||||
def gold_revenue_on(date):
|
||||
NON_REVENUE_STATUSES = ("declined", "chargeback", "fudge")
|
||||
query = (select([sa_sum(gold_table.c.pennies)])
|
||||
.where(~ gold_table.c.status.in_(NON_REVENUE_STATUSES))
|
||||
.where(func.date_trunc('day', gold_table.c.date) == date))
|
||||
rows = ENGINE.execute(query)
|
||||
return rows.fetchone()[0] or 0
|
||||
|
||||
@@ -7363,41 +7363,136 @@ body.post-under-6h-old .gilded-comment-icon {
|
||||
body.gold .buttons li.comment-save-button { display: inline; }
|
||||
|
||||
.goldvertisement {
|
||||
height: 50px;
|
||||
border: 1px solid #c4b487;
|
||||
@border-color: #c4b487;
|
||||
@background-shadow: #dad0b3;
|
||||
|
||||
border: 1px solid @border-color;
|
||||
text-align: center;
|
||||
line-height: 1.3em;
|
||||
box-shadow: 0 0 10px #dad0b3 inset;
|
||||
color: #333;
|
||||
box-shadow: 0 0 10px @background-shadow inset;
|
||||
color: darken(@border-color, 40%);
|
||||
|
||||
.inner {
|
||||
margin: 1px;
|
||||
border: 1px solid #dbd1b5;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
|
||||
li {
|
||||
display: inline-block;
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-weight: normal;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.progress {
|
||||
@bar-height: 17px;
|
||||
padding: 7px 0;
|
||||
|
||||
.bar {
|
||||
border: 1px solid #dad0b3;
|
||||
height: @bar-height;
|
||||
overflow: auto;
|
||||
|
||||
border-radius: 10px;
|
||||
|
||||
span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: linear-gradient(to bottom, #fff8ba 0%, #eccf90 100%);
|
||||
border-radius: (@bar-height/2);
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
float: right;
|
||||
font-weight: bold;
|
||||
font-size: 15px;
|
||||
color: #5a3f1a;
|
||||
line-height: @bar-height + 2; // +2 to match border on bar
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
background: lighten(@background-shadow, 20%);
|
||||
border: 1px solid lighten(@border-color, 10%);
|
||||
border-bottom-width: 2px;
|
||||
color: darken(@border-color, 40%);
|
||||
|
||||
&:hover {
|
||||
background: #fdf4c5;
|
||||
}
|
||||
|
||||
&:active {
|
||||
margin-top: 1px;
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.goldvertisement .inner {
|
||||
margin: 1px;
|
||||
border: 1px solid #dbd1b5;
|
||||
height: 46px;
|
||||
line-height: 44px;
|
||||
}
|
||||
.gold-bubble {
|
||||
width: 290px;
|
||||
border-radius: 4px;
|
||||
font-size: 125%;
|
||||
line-height: 1.13;
|
||||
font-family: "Hoefler Text","Palatino Linotype","Book Antiqua",
|
||||
Palatino,georgia,garamond,FreeSerif,serif;
|
||||
border-color: #907c47;
|
||||
padding: 4px;
|
||||
|
||||
.goldvertisement p {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
margin: 0 4px;
|
||||
line-height: 14px;
|
||||
}
|
||||
&.anchor-top-centered:before {
|
||||
border-bottom-color: #907c47;
|
||||
}
|
||||
|
||||
.goldvertisement strong {
|
||||
font-size: 15px;
|
||||
}
|
||||
p + p {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.goldvertisement a {
|
||||
color: #9a7d2e;
|
||||
font-weight: bold;
|
||||
text-decoration: underline;
|
||||
}
|
||||
span.gold-branding {
|
||||
display: inline-block;
|
||||
vertical-align: bottom;
|
||||
text-indent: -9999px;
|
||||
background: transparent url(../gold/goldvertisement-logo.png) top left no-repeat;
|
||||
width: 79px;
|
||||
height: 18px;
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
||||
.goldvertisement i {
|
||||
font-size: 11px;
|
||||
font-variant: italic;
|
||||
p.buy-gold {
|
||||
background: transparent url(../gold/goldvertisement-gold.png) top left no-repeat;
|
||||
margin-left: 13px;
|
||||
padding-left: 67px;
|
||||
min-height: 45px;
|
||||
|
||||
a {
|
||||
color: #825b25;
|
||||
}
|
||||
}
|
||||
|
||||
p.give-gold {
|
||||
background: transparent url(../gold/goldvertisement-gild.png) top left no-repeat;
|
||||
margin-left: 23px;
|
||||
padding-left: 57px;
|
||||
min-height: 39px;
|
||||
}
|
||||
|
||||
p.aside {
|
||||
color: #777;
|
||||
font-style: italic;
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#stripe-payment th {
|
||||
|
||||
@@ -20,10 +20,40 @@
|
||||
## reddit Inc. All Rights Reserved.
|
||||
###############################################################################
|
||||
|
||||
<%namespace file="utils.html" import="text_with_links, md"/>
|
||||
<%!
|
||||
from babel.numbers import format_percent
|
||||
%>
|
||||
|
||||
<div class="goldvertisement">
|
||||
<div class="inner">
|
||||
${md(thing.blurb)}
|
||||
<h2>${_("daily reddit gold goal")}</h2>
|
||||
|
||||
<div class="progress">
|
||||
<p>${format_percent(thing.percent_filled / 100.0, locale=c.locale)}</p>
|
||||
<div class="bar">
|
||||
<span style="width: ${min(100, thing.percent_filled)}%"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="/gold?goldtype=autorenew&source=progressbar" target="_blank">${_("help support reddit")}</a>
|
||||
|
||||
<div class="gold-bubble hover-bubble help-bubble anchor-top-centered">
|
||||
<p><span class="gold-branding">reddit gold</span> gives you extra features
|
||||
and helps keep our servers running. We believe the more reddit can be
|
||||
user-supported, the freer we will be to make reddit the best it can
|
||||
be.</p>
|
||||
|
||||
<p class="buy-gold">Buy gold for yourself to gain access to <a
|
||||
href="/gold/about" target="_blank">extra features</a> and <a
|
||||
href="/r/goldbenefits" target="_blank">special benefits</a>. A month of gold pays for
|
||||
 <b>${thing.hours_paid}</b> of reddit server time!</p>
|
||||
|
||||
<p class="give-gold">Give gold to thank exemplary people and encourage them to post
|
||||
more.</p>
|
||||
|
||||
<p class="aside">This daily goal updates every 10 minutes and is reset at
|
||||
midnight <a target="_blank"
|
||||
href="http://en.wikipedia.org/wiki/Mountain_Standard_Time">MST</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user