Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ability to specify self text via the submit url paramaters. eg …

…/submit?text=Example%20sefltext
  • Loading branch information...
commit 9605865b5dafc58f1be71be31268df7db58f66e1 1 parent 3380be6
@DEADB33F DEADB33F authored Logan Hanks committed
View
4 r2/r2/controllers/front.py 100644 → 100755
@@ -780,8 +780,9 @@ def GET_comment_by_id(self, comment):
@validate(url = VRequired('url', None),
title = VRequired('title', None),
+ text = VRequired('text', None),
then = VOneOf('then', ('tb','comments'), default = 'comments'))
- def GET_submit(self, url, title, then):
+ def GET_submit(self, url, title, text, then):
"""Submit form."""
resubmit = request.get.get('resubmit')
if url and not resubmit:
@@ -812,6 +813,7 @@ def GET_submit(self, url, title, then):
page_classes=['submit-page'],
content=NewLink(url=url or '',
title=title or '',
+ text=text or '',
subreddits = sr_names,
captcha=captcha,
resubmit=resubmit,
View
13 r2/r2/lib/pages/pages.py 100644 → 100755
@@ -1817,8 +1817,8 @@ def add_props(cls, user, wrapped):
class NewLink(Templated):
"""Render the link submission form"""
- def __init__(self, captcha = None, url = '', title= '', subreddits = (),
- then = 'comments', resubmit=False):
+ def __init__(self, captcha = None, url = '', title= '', text = '',
+ subreddits = (), then = 'comments', resubmit=False):
self.show_link = self.show_self = False
@@ -1833,7 +1833,12 @@ def __init__(self, captcha = None, url = '', title= '', subreddits = (),
if self.show_self and self.show_link:
all_fields = set(chain(*(parts for (tab, parts) in tabs)))
buttons = []
- self.default_tab = tabs[0][0]
+
+ if text != '':
+ self.default_tab = tabs[1][0]
+ else:
+ self.default_tab = tabs[0][0]
+
for tab_name, parts in tabs:
to_show = ','.join('#' + p for p in parts)
to_hide = ','.join('#' + p for p in all_fields if p not in parts)
@@ -1856,7 +1861,7 @@ def __init__(self, captcha = None, url = '', title= '', subreddits = (),
self.default_sr = c.site
Templated.__init__(self, captcha = captcha, url = url,
- title = title, subreddits = subreddits,
+ title = title, text = text, subreddits = subreddits,
then = then)
class ShareLink(CachedTemplate):
View
2  r2/r2/templates/newlink.html 100644 → 100755
@@ -89,7 +89,7 @@
<%utils:round_field title="${_('text')}", description="${_('(optional)')}" id="text-field">
<input name="kind" value="self" type="hidden"/>
- ${UserText(None, have_form = False, creating = True)}
+ ${UserText(None, text = thing.text, have_form = False, creating = True)}
${error_field("NO_SELFS", "sr")}
</%utils:round_field>
Please sign in to comment.
Something went wrong with that request. Please try again.