Allow mods to set custom labels for submit buttons

This commit is contained in:
Chad Birch
2013-02-26 20:31:02 -07:00
parent 83100a9827
commit fe1ce21109
8 changed files with 41 additions and 7 deletions

View File

@@ -1675,6 +1675,8 @@ class ApiController(RedditController, OAuth2ResourceController):
show_cname_sidebar = VBoolean('show_cname_sidebar'),
type = VOneOf('type', ('public', 'private', 'restricted', 'archived')),
link_type = VOneOf('link_type', ('any', 'link', 'self')),
submit_link_label=VLength('submit_link_label', max_length=60),
submit_text_label=VLength('submit_text_label', max_length=60),
wikimode = VOneOf('wikimode', ('disabled', 'modonly', 'anyone')),
wiki_edit_karma = VInt("wiki_edit_karma", coerce=False, num_default=0, min=0),
wiki_edit_age = VInt("wiki_edit_age", coerce=False, num_default=0, min=0),
@@ -1715,11 +1717,11 @@ class ApiController(RedditController, OAuth2ResourceController):
redir = False
kw = dict((k, v) for k, v in kw.iteritems()
if k in ('name', 'title', 'domain', 'description',
'show_media', 'show_cname_sidebar', 'type', 'link_type', 'lang',
'css_on_cname', 'header_title', 'over_18',
'exclude_banned_modqueue',
'wikimode', 'wiki_edit_karma', 'wiki_edit_age',
'allow_top', 'public_description'))
'show_media', 'show_cname_sidebar', 'type',
'link_type', 'submit_link_label',
'submit_text_label', 'lang', 'css_on_cname',
'header_title', 'over_18', 'wikimode', 'wiki_edit_karma',
'wiki_edit_age', 'allow_top', 'public_description'))
public_description = kw.pop('public_description')
description = kw.pop('description')

View File

@@ -718,6 +718,8 @@ class SubredditSettingsTemplate(ThingJsonTemplate):
prev_public_description_id = 'site.prev_public_description_id',
language = 'site.lang',
subreddit_type = 'site.type',
submit_link_label = 'site.submit_link_label',
submit_text_label = 'site.submit_text_label',
content_options = 'site.link_type',
over_18 = 'site.over_18',
default_set = 'site.allow_top',

View File

@@ -346,13 +346,15 @@ class Reddit(Templated):
else:
fake_sub = isinstance(c.site, FakeSubreddit)
if c.site.link_type != 'self':
ps.append(SideBox(title=_("Submit a new link"),
ps.append(SideBox(title=c.site.submit_link_label or
strings.submit_link_label,
css_class="submit submit-link",
link="/submit",
sr_path=not fake_sub,
show_cover=True))
if c.site.link_type != 'link':
ps.append(SideBox(title=_("Submit a new text post"),
ps.append(SideBox(title=c.site.submit_text_label or
strings.submit_text_label,
css_class="submit submit-text",
link="/submit?selftext=true",
sr_path=not fake_sub,

View File

@@ -121,6 +121,8 @@ string_dict = dict(
submit_link = _("""You are submitting a link. The key to a successful submission is interesting content and a descriptive title."""),
submit_text = _("""You are submitting a text-based post. Speak your mind. A title is required, but expanding further in the text field is not. Beginning your title with "vote up if" is violation of intergalactic law."""),
submit_link_label = _("Submit a new link"),
submit_text_label = _("Submit a new text post"),
compact_suggest = _("Looks like you're browsing on a small screen. Would you like to try [reddit's mobile interface](%(url)s)?"),
verify_email = _("we're going to need to verify your email address for you to proceed."),
verify_email_submit = _("you'll be able to submit more frequently once you verify your email address"),

View File

@@ -128,6 +128,8 @@ class ModAction(tdb_cassandra.UuidThing, Printable):
'lang': _('language'),
'type': _('type'),
'link_type': _('link type'),
'submit_link_label': _('submit link button label'),
'submit_text_label': _('submit text post button label'),
'over_18': _('toggle viewers must be over 18'),
'allow_top': _('toggle allow in default set'),
'show_media': _('toggle show thumbnail images of content'),

View File

@@ -89,6 +89,8 @@ class Subreddit(Thing, Printable):
mod_actions = 0,
# do we allow self-posts, links only, or any?
link_type = 'any', # one of ('link', 'self', 'any')
submit_link_label = '',
submit_text_label = '',
flair_enabled = True,
flair_position = 'right', # one of ('left', 'right')
link_flair_position = '', # one of ('', 'left', 'right')

View File

@@ -426,6 +426,9 @@ ul.flat-vert {text-align: left;}
.morelink a {
display: block;
width: 100%;
height: 100%;
overflow: hidden;
text-overflow: ellipsis;
color:#369;
}

View File

@@ -23,6 +23,7 @@
<%!
from r2.lib.filters import keep_space
from r2.lib.pages import UserText
from r2.lib.strings import strings
%>
<%namespace file="utils.html" import="error_field, language_tool, plain_link"/>
<%namespace file="utils.html" import="image_upload"/>
@@ -152,6 +153,24 @@
</table>
${error_field("INVALID_OPTION", "link_type")}
</div>
<div class="usertext-edit">
<div class="delete-field">
<label for="submit_link_label">${_('Custom label for submit link button (blank for default):')}</label>
<input id="submit_link_label" type="text" name="submit_link_label" maxlength="60" placeholder="${strings.submit_link_label}"
%if thing.site:
value="${thing.site.submit_link_label}"
%endif
>
</div>
<div class="delete-field">
<label for="submit_text_label">${_('Custom label for submit text post button (blank for default):')}</label>
<input id="submit_text_label" type="text" name="submit_text_label" maxlength="60" placeholder="${strings.submit_text_label}"
%if thing.site:
value="${thing.site.submit_text_label}"
%endif
>
</div>
</div>
</%utils:line_field>
<%utils:line_field title="${_('wiki')}">
<div class="delete-field">