Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Mark text of edited self-posts with an asterisk

Self-text submissions which have been edited now get an edited asterisk.
Edited asterisks get title text with 'last edited time'.
  • Loading branch information...
commit e0aaa3e0fb2038a859de17ed2a403053878ffbf3 1 parent c209cc2
@DEADB33F DEADB33F authored kemitche committed
View
2  r2/r2/controllers/api.py 100644 → 100755
@@ -914,7 +914,7 @@ def POST_editusertext(self, form, jquery, item, text):
if (item._date < timeago('3 minutes')
or (item._ups + item._downs > 2)):
- item.editted = True
+ item.editted = c.start_time
item._commit()
View
8 r2/r2/lib/jsontemplates.py 100644 → 100755
@@ -292,6 +292,7 @@ class LinkJsonTemplate(ThingJsonTemplate):
subreddit_id = "subreddit_id",
is_self = "is_self",
permalink = "permalink",
+ edited = "editted"
)
def thing_attr(self, thing, attr):
@@ -306,6 +307,9 @@ def thing_attr(self, thing, attr):
height = media_embed.height,
content = media_embed.content)
return dict()
+ elif attr == "editted" and not isinstance(thing.editted, bool):
+ return (time.mktime(thing.editted.astimezone(pytz.UTC).timetuple())
+ - time.timezone)
elif attr == 'subreddit':
return thing.subreddit.name
elif attr == 'subreddit_id':
@@ -351,12 +355,16 @@ class CommentJsonTemplate(ThingJsonTemplate):
banned_by = "banned_by",
approved_by = "approved_by",
parent_id = "parent_id",
+ edited = "editted"
)
def thing_attr(self, thing, attr):
from r2.models import Comment, Link, Subreddit
if attr == 'link_id':
return make_fullname(Link, thing.link_id)
+ elif attr == "editted" and not isinstance(thing.editted, bool):
+ return (time.mktime(thing.editted.astimezone(pytz.UTC).timetuple())
+ - time.timezone)
elif attr == 'subreddit':
return thing.subreddit.name
elif attr == 'subreddit_id':
View
4 r2/r2/lib/template_helpers.py 100644 → 100755
@@ -263,6 +263,10 @@ def _replace_render(style = None, display = True):
replacements['time_period'] = calc_time_period(item._date)
+ # compute the last edited time here so we don't end up caching it
+ if hasattr(item, "editted") and not isinstance(item.editted, bool):
+ replacements['lastedited'] = timesince(item.editted)
+
# Set in front.py:GET_comments()
replacements['previous_visits_hex'] = c.previous_visits_hex
View
6 r2/r2/models/link.py 100644 → 100755
@@ -497,6 +497,7 @@ def add_props(cls, user, wrapped):
item.commentcls = CachedVariable("commentcls")
item.midcolmargin = CachedVariable("midcolmargin")
item.comment_label = CachedVariable("numcomments")
+ item.lastedited = CachedVariable("lastedited")
item.as_deleted = False
if item.deleted and not c.user_is_admin:
@@ -533,6 +534,8 @@ def add_props(cls, user, wrapped):
if item.is_self:
item.expunged = Link._should_expunge_selftext(item)
+ item.editted = getattr(item, "editted", False)
+
if user_is_loggedin:
incr_counts(wrapped)
@@ -832,6 +835,9 @@ def add_props(cls, user, wrapped):
nofollow = item.nofollow,
target = item.target,
extra_css = extra_css)
+
+ item.lastedited = CachedVariable("lastedited")
+
# Run this last
Printable.add_props(user, wrapped)
View
0  r2/r2/models/printable.py 100644 → 100755
File mode changed
View
1  r2/r2/public/static/css/reddit.css 100644 → 100755
@@ -665,6 +665,7 @@ ul.flat-vert {text-align: left;}
.tagline .alum { color: #BE1337; }
.tagline a.author.admin { font-weight: bold }
.tagline a:hover { text-decoration: underline }
+.tagline .edited-timestamp{ cursor: default }
a.author { margin-right: 0.5em; }
View
6 r2/r2/templates/comment.html 100644 → 100755
@@ -26,7 +26,7 @@
from r2.lib.pages import WrappedUser
%>
-<%namespace file="utils.html" import="plain_link, thing_timestamp" />
+<%namespace file="utils.html" import="plain_link, thing_timestamp, edited" />
<%inherit file="comment_skeleton.html"/>
#####################
@@ -109,9 +109,7 @@
${unsafe(self.score(thing, likes = thing.likes))}&#32;
%endif
${thing_timestamp(thing, thing.timesince)}&#32;${_("ago")}
- %if thing.editted:
- <em>*</em>&nbsp;
- %endif
+ ${edited(thing, thing.lastedited)}
%endif
%if collapse:
&nbsp;<a href="#" class="expand"
View
12 r2/r2/templates/link.html 100644 → 100755
@@ -30,7 +30,7 @@
%>
<%inherit file="printable.html"/>
-<%namespace file="utils.html" import="plain_link, thing_timestamp" />
+<%namespace file="utils.html" import="plain_link, thing_timestamp, edited" />
<%namespace file="printablebuttons.html" import="toggle_button" />
<%def name="numcol()">
@@ -223,22 +223,24 @@
<%def name="tagline()">
<%
if thing.score_fmt == Score.points:
- taglinetext = "<span>" + _("%(score)s submitted %(when)s ago") + "</span>"
+ taglinetext = "<span>" + _("%(score)s submitted %(when)s ago%(lastedited)s") + "</span>"
if thing.different_sr:
taglinetext += " <span>" + _("by %(author)s to %(reddit)s") + "</span>"
else:
taglinetext += " <span>" + _("by %(author)s") + "</span>"
elif thing.different_sr:
- taglinetext = _("submitted %(when)s ago by %(author)s to %(reddit)s")
+ taglinetext = _("submitted %(when)s ago%(lastedited)s by %(author)s to %(reddit)s")
else:
- taglinetext = _("submitted %(when)s ago by %(author)s")
+ taglinetext = _("submitted %(when)s ago%(lastedited)s by %(author)s")
taglinetext = taglinetext.replace(" ", "&#32;")
%>
${unsafe(taglinetext % dict(reddit = self.subreddit(),
score = capture(self.score, thing, thing.likes, tag='span'),
when = capture(thing_timestamp, thing, thing.timesince),
- author = WrappedUser(thing.author, thing.attribs, thing).render()))}
+ author = WrappedUser(thing.author, thing.attribs, thing).render(),
+ lastedited = capture(edited, thing, thing.lastedited)
+ ))}
</%def>
<%def name="child()">
View
9 r2/r2/templates/utils.html 100644 → 100755
@@ -27,6 +27,7 @@
from r2.lib.template_helpers import add_sr, js_config, static
from r2.lib.utils import cols, long_datetime, timesince
from r2.lib.tracking import UserInfo
+ from datetime import datetime
%>
<%def name="tags(**kw)">
%for k, v in kw.iteritems():
@@ -553,3 +554,11 @@
${label}
</a>
</%def>
+
+<%def name="edited(thing, lastedited=None)">
+ %if isinstance(thing.editted, datetime):
+ <time class="edited-timestamp" title="${_('last edited')} ${unsafe(lastedited or timesince(thing.editted))} ${_('ago')}" datetime="${thing.editted.isoformat()}">*</time>
+ %elif thing.editted:
+ <em>*</em>
+ %endif
+</%def>
Please sign in to comment.
Something went wrong with that request. Please try again.