From fe1ce211090f77ab9e7a75bc8f16fae3ac3337b9 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Tue, 26 Feb 2013 20:31:02 -0700 Subject: [PATCH] Allow mods to set custom labels for submit buttons --- r2/r2/controllers/api.py | 12 +++++++----- r2/r2/lib/jsontemplates.py | 2 ++ r2/r2/lib/pages/pages.py | 6 ++++-- r2/r2/lib/strings.py | 2 ++ r2/r2/models/modaction.py | 2 ++ r2/r2/models/subreddit.py | 2 ++ r2/r2/public/static/css/reddit.less | 3 +++ r2/r2/templates/createsubreddit.html | 19 +++++++++++++++++++ 8 files changed, 41 insertions(+), 7 deletions(-) diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index fbd2215e8..03358330b 100755 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -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') diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index cee71b334..6b9be0991 100755 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -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', diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 7c4327b9a..954d66742 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -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, diff --git a/r2/r2/lib/strings.py b/r2/r2/lib/strings.py index ac87411f2..e60fe0a65 100644 --- a/r2/r2/lib/strings.py +++ b/r2/r2/lib/strings.py @@ -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"), diff --git a/r2/r2/models/modaction.py b/r2/r2/models/modaction.py index 26decd1a8..6d7e2da64 100644 --- a/r2/r2/models/modaction.py +++ b/r2/r2/models/modaction.py @@ -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'), diff --git a/r2/r2/models/subreddit.py b/r2/r2/models/subreddit.py index 49155feba..c7bd88122 100644 --- a/r2/r2/models/subreddit.py +++ b/r2/r2/models/subreddit.py @@ -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') diff --git a/r2/r2/public/static/css/reddit.less b/r2/r2/public/static/css/reddit.less index a307fc235..9b20d0c89 100755 --- a/r2/r2/public/static/css/reddit.less +++ b/r2/r2/public/static/css/reddit.less @@ -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; } diff --git a/r2/r2/templates/createsubreddit.html b/r2/r2/templates/createsubreddit.html index 20a2a359a..1db57e274 100644 --- a/r2/r2/templates/createsubreddit.html +++ b/r2/r2/templates/createsubreddit.html @@ -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 @@ ${error_field("INVALID_OPTION", "link_type")} +
+
+ + +
+
+ + +
+
<%utils:line_field title="${_('wiki')}">