Permalink
Browse files

bugfix for messages too long (now generates an error); fix of rss fee…

…d title and image; added thumbnail and media attributes on the API for links; added autohide get parameter to hide buttons when the user is not logged in.
  • Loading branch information...
1 parent 7822386 commit c3b894f263b21d6378975974a4b6b0c98ec33ad6 @KeyserSosa KeyserSosa committed May 22, 2009
Showing with 20 additions and 6 deletions.
  1. +2 −1 r2/r2/controllers/api.py
  2. +6 −3 r2/r2/controllers/buttons.py
  3. +2 −0 r2/r2/lib/jsontemplates.py
  4. +10 −2 r2/r2/templates/base.xml
View
3 r2/r2/controllers/api.py
@@ -143,7 +143,8 @@ def POST_compose(self, form, jquery, to, subject, body, ip):
if not (form.has_errors("to", errors.USER_DOESNT_EXIST,
errors.NO_USER) or
form.has_errors("subject", errors.NO_SUBJECT) or
- form.has_errors("message", errors.NO_MSG_BODY) or
+ form.has_errors("message", errors.NO_MSG_BODY,
+ errors.COMMENT_TOO_LONG) or
form.chk_captcha(errors.BAD_CAPTCHA)):
spam = (c.user._spam or
errors.BANNED_IP in c.errors or
View
9 r2/r2/controllers/buttons.py
@@ -125,14 +125,17 @@ def GET_button_content(self, url, title, css, vote, newwindow, width, link):
@validate(buttontype = VInt('t', 1, 5),
url = VSanitizedUrl("url"),
_height = VInt('height', 0, 300),
- _width = VInt('width', 0, 800))
- def GET_button_embed(self, buttontype, _height, _width, url):
+ _width = VInt('width', 0, 800),
+ autohide = VBoolean("autohide"))
+ def GET_button_embed(self, buttontype, _height, _width, url, autohide):
# no buttons on domain listings
if isinstance(c.site, DomainSR):
return self.abort404()
-
c.render_style = 'js'
c.response_content_type = 'text/javascript; charset=UTF-8'
+ if not c.user_is_loggedin and autohide:
+ c.response.content = "void(0);"
+ return c.response
buttontype = buttontype or 1
width, height = ((120, 22), (51, 69), (69, 52), (51, 52), (600, 52))[min(buttontype - 1, 4)]
View
2 r2/r2/lib/jsontemplates.py
@@ -197,6 +197,8 @@ class LinkJsonTemplate(ThingJsonTemplate):
title = "title",
url = "url",
author = "author",
+ thumbnail = "thumbnail",
+ media = "media_object",
num_comments = "num_comments",
subreddit = "subreddit",
subreddit_id = "subreddit_id")
View
12 r2/r2/templates/base.xml
@@ -36,8 +36,10 @@
header_img = DefaultSR.header
else:
header_img = c.site.header
+ if not header_img.startswith("http:"):
+ header_img = add_sr(header_img, sr_path=False, force_hostname=True)
%>
- <url>http://${get_domain(subreddit = False, cname = c.cname)}${header_img}</url>
+ <url>${header_img}</url>
<title>${self.Title()}</title>
<link>${add_sr("/", force_hostname = True)}</link>
</image>
@@ -46,6 +48,12 @@
</rss>
<%def name="Title()">
- ${c.site.name}: ${_("what's new online")}
+<%
+ try:
+ title = _(c.site.title)
+ except UnicodeDecodeError:
+ title = c.site.title
+ %>
+${title}
</%def>

0 comments on commit c3b894f

Please sign in to comment.