mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-25 23:08:22 -05:00
Added ability to specify self text via the submit url paramaters. eg /submit?text=Example%20sefltext
This commit is contained in:
4
r2/r2/controllers/front.py
Normal file → Executable file
4
r2/r2/controllers/front.py
Normal file → Executable file
@@ -780,8 +780,9 @@ class FrontController(RedditController):
|
||||
|
||||
@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 @@ class FrontController(RedditController):
|
||||
page_classes=['submit-page'],
|
||||
content=NewLink(url=url or '',
|
||||
title=title or '',
|
||||
text=text or '',
|
||||
subreddits = sr_names,
|
||||
captcha=captcha,
|
||||
resubmit=resubmit,
|
||||
|
||||
13
r2/r2/lib/pages/pages.py
Normal file → Executable file
13
r2/r2/lib/pages/pages.py
Normal file → Executable file
@@ -1817,8 +1817,8 @@ class FrameToolbar(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 @@ class NewLink(Templated):
|
||||
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 @@ class NewLink(Templated):
|
||||
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):
|
||||
|
||||
2
r2/r2/templates/newlink.html
Normal file → Executable file
2
r2/r2/templates/newlink.html
Normal file → Executable file
@@ -89,7 +89,7 @@ ${thing.formtabs_menu}
|
||||
<%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>
|
||||
|
||||
Reference in New Issue
Block a user