From 86a7b0e1a5438f4875a0c6bde58b1bb815cc2f8f Mon Sep 17 00:00:00 2001 From: James Lamine Date: Sun, 17 Jul 2016 21:28:28 -0500 Subject: [PATCH 1/4] Add the ability to submit links. Fixes #548 --- r2/r2/controllers/api.py | 81 +++++++++---- r2/r2/controllers/front.py | 12 +- r2/r2/lib/menus.py | 9 +- r2/r2/lib/pages/pages.py | 65 +++++++++- r2/r2/models/link.py | 116 +++++++++++------- r2/r2/public/static/main.css | 60 +++++++++ r2/r2/public/static/utils.js | 26 +++- r2/r2/templates/featuredarticles.html | 6 +- r2/r2/templates/inlinearticle.html | 16 +-- r2/r2/templates/inlinearticle.xml | 13 +- r2/r2/templates/link.html | 56 ++++----- r2/r2/templates/link.xml | 17 ++- r2/r2/templates/newlink.html | 127 +++++++++++++++----- r2/r2/templates/recentpromotedarticles.html | 4 +- r2/r2/templates/tabs.html | 18 +++ 15 files changed, 457 insertions(+), 169 deletions(-) create mode 100644 r2/r2/templates/tabs.html diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index c0a888a2..1adbec04 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -89,6 +89,22 @@ def link_listing_by_url(url, count = None): listing = LinkListing(builder).listing() return listing +def strip_link_prefix(title): + """Remove the prefix '[Link]' from the begining of a title. + + LessWrong adds the prefix when rendering links, so there's no need to put + it in the title. + """ + if title is None: + return + + title = title.strip() + if title.startswith('['): + for prefix in ['[Link]', '[ Link ]', '[link]', '[ link ]']: + if title.startswith(prefix): + return title[len(prefix):].strip() + return title + class ApiController(RedditController): def response_func(self, **kw): @@ -289,6 +305,8 @@ def POST_unbless(self, res, link): VCaptcha(), VRatelimit(rate_user = True, rate_ip = True, prefix='rate_submit_'), VModhash(), + ValidDomain('url'), + url = VUrl(['url']), ip = ValidIP(), sr = VSubmitSR('sr'), title = VTitle('title'), @@ -298,10 +316,17 @@ def POST_unbless(self, res, link): continue_editing = VBoolean('keep_editing'), notify_on_comment = VBoolean('notify_on_comment'), cc_licensed = VBoolean('cc_licensed'), - tags = VTags('tags')) - def POST_submit(self, res, l, new_content, title, save, continue_editing, sr, ip, tags, notify_on_comment, cc_licensed): + tags = VTags('tags'), + kind = VOneOf('kind', ['link', 'self'])) + def POST_submit(self, res, l, new_content, title, url, save, + continue_editing, sr, ip, tags, notify_on_comment, + cc_licensed, kind): res._update('status', innerHTML = '') + # If an article_id is present, then we are editing an existing article/link + # Otherwise, we are creating a new article/link. + edit_mode = not not l + if res._chk_error(errors.SUBREDDIT_FORBIDDEN): # although new posts to main are disabled, editing of previous posts is permitted if sr == Subreddit._by_name(g.default_sr) and l.can_submit(c.user): @@ -309,19 +334,26 @@ def POST_submit(self, res, l, new_content, title, save, continue_editing, sr, ip else: sr = None + # remove the ratelimit error if the user's karma is high should_ratelimit = sr.should_ratelimit(c.user, 'link') if sr else True - - #remove the ratelimit error if the user's karma is high if not should_ratelimit: c.errors.remove(errors.RATELIMIT) - - #ratelimiter - if res._chk_error(errors.RATELIMIT): - pass - # check for title, otherwise look it up and return it - elif res._chk_error(errors.NO_TITLE): - # clear out this error - res._chk_error(errors.TITLE_TOO_LONG) + else: + res._chk_error(errors.RATELIMIT) + + if kind == 'link': + if not edit_mode: + # validate url on link submissions + if res._chk_errors((errors.NO_URL, errors.BAD_URL)): + res._focus('url') + elif res._chk_error(errors.ALREADY_SUB): + link = url[0] + res._redirect(link.already_submitted_link) + # TODO: Validate article content, enforce max-length. + + # check for title + if res._chk_error(errors.NO_TITLE): + res._chk_error(errors.TITLE_TOO_LONG) # clear out this error res._focus('title') elif res._chk_error(errors.TITLE_TOO_LONG): res._focus('title') @@ -330,8 +362,9 @@ def POST_submit(self, res, l, new_content, title, save, continue_editing, sr, ip elif res._chk_error(errors.SUBREDDIT_FORBIDDEN): pass - - if res.error or not title: return + post_title = strip_link_prefix(request.post.title) + if res.error or not title or not post_title: + return # check whether this is spam: spam = (c.user._spam or @@ -342,17 +375,19 @@ def POST_submit(self, res, l, new_content, title, save, continue_editing, sr, ip new_content = '' # well, nothing left to do but submit it - # TODO: include article body in arguments to Link model - # print "\n".join(request.post.va) - if not l: - l = Link._submit(request.post.title, new_content, c.user, sr, ip, tags, spam, - notify_on_comment=notify_on_comment, cc_licensed=cc_licensed) + if not edit_mode: + l = Link._submit(post_title, new_content, + url if kind == 'link' else 'self', + c.user, sr, ip, tags, spam, + notify_on_comment=notify_on_comment, + cc_licensed=cc_licensed + ) if save == 'on': r = l._save(c.user) if g.write_query_queue: queries.new_savehide(r) - #set the ratelimiter + # set the ratelimiter if should_ratelimit: VRatelimit.ratelimit(rate_user=True, rate_ip = True, prefix='rate_submit_') @@ -364,8 +399,9 @@ def POST_submit(self, res, l, new_content, title, save, continue_editing, sr, ip if c.user._id != l.author_id: edit = Edit._new(l,c.user,new_content) old_url = l.url - l.title = request.post.title - l.set_article(new_content) + l.title = post_title + if kind == 'self': + l.set_article(new_content) l.notify_on_comment = notify_on_comment l.cc_licensed = cc_licensed l.change_subreddit(sr._id) @@ -1841,6 +1877,7 @@ def POST_edit_promo(self, res, ip, res._redirect('/promote/edit_promo/%s' % to36(l._id)) else: + # TODO: This appears to be dead code. Investigate whether it can be removed l = Link._submit(title, url, c.user, sr, ip, False) if expire == 'expirein' and timelimitlength and timelimittype: diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index 5308a4b5..c4b6a060 100644 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -544,11 +544,16 @@ def GET_submit(self, can_submit, url, title, tags): except NotFound: sr = None + tab = 'article' + if 'link' in request.get: + tab = 'link' + return FormPage(_("Submit Article"), content=NewLink(title=title or '', subreddits = srs, tags=tags, sr_id = sr._id if sr else None, + tab=tab, captcha=captcha)).render() @validate(VUser(), @@ -568,7 +573,12 @@ def GET_editarticle(self, article): captcha = Captcha(tabular=False) if c.user.needs_captcha() else None return FormPage(_("Edit article"), - content=EditLink(article, subreddits=subreddits, tags=article.tag_names(), captcha=captcha)).render() + content=EditLink(article, + subreddits=subreddits, + tags=article.tag_names(), + captcha=captcha + ) + ).render() def _render_opt_in_out(self, msg_hash, leave): """Generates the form for an optin/optout page""" diff --git a/r2/r2/lib/menus.py b/r2/r2/lib/menus.py index 446bb6e6..072eb853 100644 --- a/r2/r2/lib/menus.py +++ b/r2/r2/lib/menus.py @@ -97,6 +97,7 @@ def __getattr__(self, attr): prefs = _("Preferences"), stats = _("Stats"), submit = _("Create new article"), + submitlink = _("Submit a new link"), meetupsnew = _("Add new meetup"), help = _("Help"), blog = _("Blog"), @@ -263,12 +264,13 @@ class NavButton(Styled): passed to a NavMenu instance upon its construction.""" def __init__(self, title, dest, sr_path = True, nocname=False, opt = '', aliases = [], - target = "", style = "plain", **kw): + target = "", style = "plain", dest_params = {}, **kw): # keep original dest to check against c.location when rendering self.aliases = set(a.rstrip('/') for a in aliases) self.aliases.add(dest.rstrip('/')) self.dest = dest + self.dest_params = dest_params Styled.__init__(self, style = style, sr_path = sr_path, nocname = nocname, target = target, @@ -289,6 +291,7 @@ def build(self, base_path = ''): else: p = {} base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/') + p.update(self.dest_params) self.bare_path = _force_unicode(base_path.replace('//', '/')).lower() self.bare_path = self.bare_path.rstrip('/') @@ -362,7 +365,7 @@ def selected_title(self): return NavButton.selected_title(self) class ExpandableButton(NamedButton): - def __init__(self, name, sr_path = True, nocname=False, dest = None, + def __init__(self, name, sr_path = True, nocname=False, dest = None, sub_reddit = "/", sub_menus=[], **kw): self.sub = sub_menus self.sub_reddit = sub_reddit @@ -613,5 +616,3 @@ class AdminTimeMenu(TimeMenu): get_param = 't' default = 'day' options = ('hour', 'day', 'week') - - diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index e4138bdf..acd02a84 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -215,6 +215,10 @@ def corner_buttons(self): buttons += [NamedButton('submit', sr_path = not c.default_sr, nocname=not c.authorized_cname)] + buttons += [NamedButton('submitlink', dest = 'submit', + dest_params = { 'link': True }, + sr_path = not c.default_sr, + nocname=not c.authorized_cname)] if c.user.safe_karma >= g.discussion_karma_to_post: buttons += [NamedButton('meetups/new', False, nocname=not c.authorized_cname)] @@ -1163,10 +1167,20 @@ def __init__(self, link = None, **kw): Wrapped.__init__(self, link = link, *kw) - class NewLink(Wrapped): """Render the link submission form""" - def __init__(self, captcha = None, article = '', title= '', subreddits = (), tags = (), sr_id = None): + def __init__(self, captcha = None, + article = '', + title= '', + subreddits = (), + tags = (), + sr_id = None, + tab = 'article'): + self.tabs = Tabs() + self.tabs.add_tab('Text Article', 'article-field-pane', tab == 'article') + self.tabs.add_tab('Link', 'link-field-pane', tab == 'link') + self.editing = False + Wrapped.__init__(self, captcha = captcha, article = article, title = title, subreddits = subreddits, tags = tags, sr_id = sr_id, notify_on_comment = True, @@ -1174,7 +1188,16 @@ def __init__(self, captcha = None, article = '', title= '', subreddits = (), tag class EditLink(Wrapped): """Render the edit link form""" - pass + def __init__(self, article, subreddits, tags, captcha): + self.editing = True + self.tabs = Tabs() + if article.is_self: + self.tabs.add_tab('Text Article', 'article-field-pane') + else: + self.tabs.add_tab('Link', 'link-field-pane') + + Wrapped.__init__(self, article, captcha = captcha, + subreddits = subreddits, tags = tags) class ShareLink(Wrapped): def __init__(self, link_name = "", emails = None): @@ -1659,3 +1682,39 @@ def __init__(self, name, page, skiplayout, **context): title = self.pagename, space_compress=False, **context) + +class TabModel(object): + def __init__(self, title, pane_id, is_selected): + self.title = title + self.pane_id = pane_id + self.is_selected = is_selected + +class Tabs(Wrapped): + """Renders a list of tabs which can be clicked on. + """ + def __init__(self): + self.tabs = [] + + def add_tab(self, title, pane_id, is_selected = False): + # The first tab is always selected + if len(self.tabs) == 0: + is_selected = True + # Ensure at most one tab is selected + if is_selected: + for tab in self.tabs: + tab.is_selected = False + + self.tabs.append(TabModel(title, pane_id, is_selected)) + + def _get_tab(self, pane_id): + for tab in self.tabs: + if tab.pane_id == pane_id: + return tab + + def has_tab(self, pane_id): + tab = self._get_tab(pane_id) + return tab is not None + + def is_selected(self, pane_id): + tab = self._get_tab(pane_id) + return tab is not None and tab.is_selected diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index 1071a85f..201dcf28 100644 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -6,16 +6,16 @@ # software over a computer network and provide for limited attribution for the # Original Developer. In addition, Exhibit A has been modified to be consistent # with Exhibit B. -# +# # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for # the specific language governing rights and limitations under the License. -# +# # The Original Code is Reddit. -# +# # The Original Developer is the Initial Developer. The Initial Developer of the # Original Code is CondeNet, Inc. -# +# # All portions of the code written by CondeNet are Copyright (c) 2006-2008 # CondeNet, Inc. All Rights Reserved. ################################################################################ @@ -88,7 +88,7 @@ def _by_url(cls, url, sr): from subreddit import Default if sr == Default: sr = None - + url = cls.by_url_key(url) link_ids = g.permacache.get(url) if link_ids: @@ -152,29 +152,35 @@ def resubmit_link(self, sr_url = False): return submit_url @classmethod - def _submit(cls, title, article, author, sr, ip, tags, spam = False, date = None, **kwargs): + def _submit(cls, title, article, url, author, sr, ip, tags, spam = False, date = None, **kwargs): # Create the Post and commit to db. l = cls(title = title, - url = 'self', + url = url, + is_self = url == 'self', + permalink = None, _spam = spam, author_id = author._id, - sr_id = sr._id, + sr_id = sr._id, lang = sr.lang, ip = ip, - article = article, + article = None, date = date, **kwargs ) l._commit() # Now that the post id is known update the Post with the correct permalink. - l.url = l.make_permalink_slow() - l.is_self = True + if l.url == 'self': + l.is_self = True + l.url = l.make_permalink_slow() + l.permalink = l.url + # Parse and create polls in the article + l.set_article(article) + else: + l.permalink = l.make_permalink_slow() + l.is_self = False l._commit() - # Parse and create polls in the article - l.set_article(article) - l.set_url_cache() # Add tags @@ -182,21 +188,39 @@ def _submit(cls, title, article, author, sr, ip, tags, spam = False, date = None l.add_tag(tag) return l - + def set_article(self, article): self.article = article self._commit() - + @property + def permalink(self): + # Older articles don't have a permalink, so use url instead + # This works because for articles, the url links to the article. + if self.is_self: + return self.url + # For link posts, the url links to an external site, while the + # permalink links to the comments. + return self._permalink + + @permalink.setter + def permalink_setter(self, value): + self._permalink = permalink + + @property + def display_title(self): + if not self.is_self: + return '[Link] {}'.format(self.title) + return self.title def _summary(self): if hasattr(self, 'article'): return self.article.split(self._more_marker)[0] - + def _has_more(self): if hasattr(self, 'article'): return self.article.find(self._more_marker) >= 0 - + def _more(self): if hasattr(self, 'article'): return self.article.split(self._more_marker)[1] @@ -315,21 +339,21 @@ def keep_item(self, wrapped): if self._spam and (not user or (user and self.author_id != user._id)): return False - + #author_karma = wrapped.author.link_karma #if author_karma <= 0 and random.randint(author_karma, 0) != 0: #return False if wrapped.hidden: return False - + if not user and wrapped._score < g.default_min_link_score: return False if user: if user.pref_hide_ups and wrapped.likes == True: return False - + if user.pref_hide_downs and wrapped.likes == False: return False @@ -355,7 +379,7 @@ def cache_key(wrapped): c.user.pref_compress, c.user.pref_media, request.host, - c.cname, + c.cname, wrapped.author == c.user, wrapped.likes, wrapped.saved, @@ -396,7 +420,7 @@ def make_permalink(self, sr, force_domain = False, sr_path = False): def make_permalink_slow(self): return self.make_permalink(self.subreddit_slow) - + @property def canonical_url(self): from r2.lib.template_helpers import get_domain @@ -431,7 +455,7 @@ def add_props(cls, user, wrapped): item.thumbnail = thumbnail_url(item) else: item.thumbnail = g.default_thumb - + item.domain = (domain(item.url) if not item.is_self else 'self.' + item.subreddit.name) if not hasattr(item,'top_link'): @@ -569,13 +593,13 @@ def set_tags(self, tags): updated_tags = set(tags) removed_tags = current_tags.difference(updated_tags) new_tags = updated_tags.difference(current_tags) - + for tag in new_tags: self.add_tag(tag) - + for tag in removed_tags: self.remove_tag(tag) - + def tag_names(self): """Returns just the names of the tags of this article""" return [tag.name for tag in self.get_tags()] @@ -894,7 +918,7 @@ class LinkTag(Relation(Link, Tag)): class Comment(Thing, Printable): _data_int_props = Thing._data_int_props + ('reported',) - _defaults = dict(reported = 0, + _defaults = dict(reported = 0, moderator_banned = False, banned_before_moderator = False, is_html = False, @@ -908,7 +932,7 @@ def _markdown(self): def _delete(self): link = Link._byID(self.link_id, data = True) link._incr('num_comments', -1) - + @classmethod def _new(cls, author, link, parent, body, ip, spam = False, date = None): comment = Comment(body = body, @@ -917,7 +941,7 @@ def _new(cls, author, link, parent, body, ip, spam = False, date = None): author_id = author._id, ip = ip, date = date) - + comment._spam = spam #these props aren't relations @@ -1066,10 +1090,10 @@ def subreddit_slow(self): def collapse_in_link_threads(self): if c.user_is_admin: return False - + if c.user_is_loggedin and self._score < c.user.pref_min_comment_score: return True - + return self._score < g.default_min_comment_score @property @@ -1115,7 +1139,7 @@ def cache_key(wrapped): bool(c.user_is_loggedin), c.focal_comment == wrapped._id36, request.host, - c.cname, + c.cname, wrapped.author == c.user, wrapped.likes, wrapped.friend, @@ -1155,18 +1179,18 @@ def make_permalink_title(self, link): author = Account._byID(self.author_id, data=True).name params = {'author' : _force_unicode(author), 'title' : _force_unicode(link.title), 'site' : c.site.title} return strings.permalink_title % params - + @classmethod def add_props(cls, user, wrapped): #fetch parent links links = Link._byID(set(l.link_id for l in wrapped), True) - + #get srs for comments that don't have them (old comments) for cm in wrapped: if not hasattr(cm, 'sr_id'): cm.sr_id = links[cm.link_id].sr_id - + subreddits = Subreddit._byID(set(cm.sr_id for cm in wrapped), data=True,return_dict=False) can_reply_srs = set(s._id for s in subreddits if s.can_comment(user)) @@ -1200,10 +1224,10 @@ def add_props(cls, user, wrapped): # Don't allow users to vote on their own comments # Also require user karma to be >= global threshold as anti-sockpuppet measure item.votable = bool(c.user_is_loggedin - and c.user != item.author + and c.user != item.author and not item.retracted and c.user.safe_karma >= g.karma_to_vote) - + if item.votable and c.profilepage: # Can only vote on profile page under certain conditions item.votable = bool((c.user.safe_karma > g.karma_to_vote_in_overview) and (g.karma_percentage_to_be_voted > item.author.percent_up())) @@ -1221,7 +1245,7 @@ def add_props(cls, user, wrapped): not (c.profilepage or item.deleted or c.user_is_admin)) - + if not hasattr(item,'editted'): item.editted = False #will get updated in builder @@ -1272,12 +1296,12 @@ class MoreComments(object): @staticmethod def cache_key(item): return False - + def __init__(self, link, depth, parent=None): if parent: self.parent_id = parent._id self.parent_name = parent._fullname - self.parent_permalink = parent.make_permalink(link, + self.parent_permalink = parent.make_permalink(link, link.subreddit_slow) self.link_name = link._fullname self.link_id = link._id @@ -1299,7 +1323,7 @@ class MoreRecursion(MoreComments): class MoreChildren(MoreComments): pass - + class Message(Thing, Printable): _defaults = dict(reported = 0,) _data_int_props = Thing._data_int_props + ('reported', ) @@ -1329,7 +1353,7 @@ def add_props(cls, user, wrapped): #TODO global-ish functions that shouldn't be here? #reset msgtime after this request msgtime = c.have_messages - + #load the "to" field if required to_ids = set(w.to_id for w in wrapped) tos = Account._byID(to_ids, True) if to_ids else {} @@ -1342,7 +1366,7 @@ def add_props(cls, user, wrapped): item.new = False item.score_fmt = Score.none - + @staticmethod def cache_key(wrapped): #warning: inbox/sent messages @@ -1369,10 +1393,10 @@ def _add(cls, to, obj, *a, **kw): if not to._loaded: to._load() - + #if there is not msgtime, or it's false, set it if not hasattr(to, 'msgtime') or not to.msgtime: to.msgtime = obj._date to._commit() - + return i diff --git a/r2/r2/public/static/main.css b/r2/r2/public/static/main.css index 76c17c9b..967c0594 100644 --- a/r2/r2/public/static/main.css +++ b/r2/r2/public/static/main.css @@ -130,6 +130,66 @@ input, select, textarea, button { } +/* Tabs on link submision page +-------------------------------------------------------------------------------------- */ +.tabs { + margin-left: 0; + list-style-type: none; + white-space: nowrap; + display: block; + vertical-align: bottom; + padding-left: 10px; + margin-top: 5px; + border-bottom: 3px solid #538d4d; +} + +.tabs ul { + list-style: none; + margin: 0; + padding: 0; +} + +.tabs li { + font-size: 15px; + line-height: 1; + margin: 0; + padding: 0; + display: inline; +} + +.tabs li a { + font-weight: normal; + outline: none; + padding: 5px 12px 3px 12px; + vertical-align: bottom; + border: 1px solid #999; + border-bottom: none; + text-decoration: none; + background-color: #f7f7f8; + position: relative; + bottom: 4px; + } + +.tabs li.selected a { + color: #fff; + font-size: 130%; + background-color: #538d4d; + border: none; + z-index: 100; +} + +.tabs a { + +} + +.tabs .selected a { + font-weight: bold; +} + +.tab-pane:not(.active) { + display: none; +} + /* Header -------------------------------------------------------------------------------------- */ #header { diff --git a/r2/r2/public/static/utils.js b/r2/r2/public/static/utils.js index 5ab197b8..3f6429f8 100644 --- a/r2/r2/public/static/utils.js +++ b/r2/r2/public/static/utils.js @@ -481,7 +481,7 @@ function handleResponse(action, options) { if (cleanup_func) cleanup_func(res_obj); - + var r = res_obj.response; if(!r) return; @@ -576,7 +576,7 @@ function re_id_node(node, id) { // Return the value of an input element, unless that input element is in a "placeholder text"-like state function field(form_field) { - if (form_field == null || form_field.value == null || + if (form_field == null || form_field.value == null || form_field.disabled || ((form_field.type == 'text' || form_field.type == 'textarea') && form_field.style.color == "gray") || (form_field.type == 'radio' && ! form_field.checked)) { @@ -621,6 +621,28 @@ function change_state_by_class(link, type, className) { return false; } +// Used for the tabs in the article submission form +function select_form_tab(elem, to_show, ids_to_hide) { + // change which tab is active + var link_parent = jQuery(elem).parent(); + link_parent + .addClass('selected') + .siblings().removeClass('selected'); + + // show/hide tab contents and enable/disable form inputs + jQuery(to_show) + .addClass("active") + .find(":input") + .removeAttr("disabled") + .end(); + + jQuery(ids_to_hide.join(',')) + .removeClass("active") + .find(":input") + .attr("disabled", true) + .end(); +} + function post_form(form, where, statusfunc, nametransformfunc, block, api_loc, options) { options = options || {}; var cleanup_func = options.cleanup_func; diff --git a/r2/r2/templates/featuredarticles.html b/r2/r2/templates/featuredarticles.html index ec96a6f0..be99d2b2 100644 --- a/r2/r2/templates/featuredarticles.html +++ b/r2/r2/templates/featuredarticles.html @@ -1,12 +1,12 @@ <%namespace file="utils.html" import="plain_link"/> -<% +<% article_generator = thing.things %> %for a in article_generator: diff --git a/r2/r2/templates/inlinearticle.html b/r2/r2/templates/inlinearticle.html index 08ac9765..47617180 100644 --- a/r2/r2/templates/inlinearticle.html +++ b/r2/r2/templates/inlinearticle.html @@ -6,16 +6,16 @@ ## software over a computer network and provide for limited attribution for the ## Original Developer. In addition, Exhibit A has been modified to be consistent ## with Exhibit B. -## +## ## Software distributed under the License is distributed on an "AS IS" basis, ## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for ## the specific language governing rights and limitations under the License. -## +## ## The Original Code is Reddit. -## +## ## The Original Developer is the Initial Developer. The Initial Developer of ## the Original Code is CondeNet, Inc. -## +## ## All portions of the code written by CondeNet are Copyright (c) 2006-2008 ## CondeNet, Inc. All Rights Reserved. ################################################################################ @@ -28,7 +28,7 @@ <%inherit file="printable.htmllite" /> <%def name="entry()"> -<% +<% if thing.num_comments: # generates "XX comments" as a noun com_label = "%d %s" % \ @@ -36,15 +36,15 @@ ungettext("comment", "comments", thing.num_comments)) else: # generates "comment" the imperative verb - com_label = _("Comment") + com_label = _("Comment") domain = get_domain(subreddit=False) permalink = "http://%s%s" % (domain, thing.permalink) %>

- - ${thing.title} + + ${thing.display_title}

by diff --git a/r2/r2/templates/inlinearticle.xml b/r2/r2/templates/inlinearticle.xml index 7f5e0c3a..20c7ac3c 100644 --- a/r2/r2/templates/inlinearticle.xml +++ b/r2/r2/templates/inlinearticle.xml @@ -6,16 +6,16 @@ ## software over a computer network and provide for limited attribution for the ## Original Developer. In addition, Exhibit A has been modified to be consistent ## with Exhibit B. -## +## ## Software distributed under the License is distributed on an "AS IS" basis, ## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for ## the specific language governing rights and limitations under the License. -## +## ## The Original Code is Reddit. -## +## ## The Original Developer is the Initial Developer. The Initial Developer of ## the Original Code is CondeNet, Inc. -## +## ## All portions of the code written by CondeNet are Copyright (c) 2006-2008 ## CondeNet, Inc. All Rights Reserved. ################################################################################ @@ -26,13 +26,13 @@ from r2.models import FakeSubreddit from r2.lib.utils import rfc822format %> -<% +<% com_label = ungettext("comment", "comments", thing.num_comments) url = add_sr(thing.permalink, force_hostname = True) use_thumbs = thing.thumbnail and not request.GET.has_key("nothumbs") %> - ${thing.title} + ${thing.display_title} ${url} ${url} ${rfc822format(thing._date)} @@ -46,4 +46,3 @@ %endif - diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html index 6eb71d96..5714319d 100644 --- a/r2/r2/templates/link.html +++ b/r2/r2/templates/link.html @@ -62,35 +62,31 @@ label = unsafe('Post author:') if full_article else ''))} ${prettytime(thing._date)}
-##{_RL - -##}_RL -
-## The div below is a hack to get the space compressor to leave whitespace in articles alone - + %if full_article: + + %endif + %else: +
%endif
${parent.midcol(thing.votable)} @@ -102,7 +98,7 @@

${_('Comments (%d)') % (num_comments)} + ${_('Comments (%d)') % (num_comments)} %endif