Skip to content
This repository
Browse code

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 authored kemitche committed
2  r2/r2/controllers/api.py 100644 → 100755
@@ -914,7 +914,7 @@ def POST_editusertext(self, form, jquery, item, text):
914 914
 
915 915
             if (item._date < timeago('3 minutes')
916 916
                 or (item._ups + item._downs > 2)):
917  
-                item.editted = True
  917
+                item.editted = c.start_time
918 918
 
919 919
             item._commit()
920 920
 
8  r2/r2/lib/jsontemplates.py 100644 → 100755
@@ -292,6 +292,7 @@ class LinkJsonTemplate(ThingJsonTemplate):
292 292
                                                 subreddit_id = "subreddit_id",
293 293
                                                 is_self      = "is_self", 
294 294
                                                 permalink    = "permalink",
  295
+                                                edited       = "editted"
295 296
                                                 )
296 297
 
297 298
     def thing_attr(self, thing, attr):
@@ -306,6 +307,9 @@ def thing_attr(self, thing, attr):
306 307
                                height = media_embed.height,
307 308
                                content = media_embed.content)
308 309
            return dict()
  310
+        elif attr == "editted" and not isinstance(thing.editted, bool):
  311
+            return (time.mktime(thing.editted.astimezone(pytz.UTC).timetuple())
  312
+                    - time.timezone)
309 313
         elif attr == 'subreddit':
310 314
             return thing.subreddit.name
311 315
         elif attr == 'subreddit_id':
@@ -351,12 +355,16 @@ class CommentJsonTemplate(ThingJsonTemplate):
351 355
                                                 banned_by    = "banned_by",
352 356
                                                 approved_by  = "approved_by",
353 357
                                                 parent_id    = "parent_id",
  358
+                                                edited       = "editted"
354 359
                                                 )
355 360
 
356 361
     def thing_attr(self, thing, attr):
357 362
         from r2.models import Comment, Link, Subreddit
358 363
         if attr == 'link_id':
359 364
             return make_fullname(Link, thing.link_id)
  365
+        elif attr == "editted" and not isinstance(thing.editted, bool):
  366
+            return (time.mktime(thing.editted.astimezone(pytz.UTC).timetuple())
  367
+                    - time.timezone)
360 368
         elif attr == 'subreddit':
361 369
             return thing.subreddit.name
362 370
         elif attr == 'subreddit_id':
4  r2/r2/lib/template_helpers.py 100644 → 100755
@@ -263,6 +263,10 @@ def _replace_render(style = None, display = True):
263 263
 
264 264
             replacements['time_period'] = calc_time_period(item._date)
265 265
 
  266
+        # compute the last edited time here so we don't end up caching it
  267
+        if hasattr(item, "editted") and not isinstance(item.editted, bool):
  268
+            replacements['lastedited'] = timesince(item.editted)
  269
+
266 270
         # Set in front.py:GET_comments()
267 271
         replacements['previous_visits_hex'] = c.previous_visits_hex
268 272
 
6  r2/r2/models/link.py 100644 → 100755
@@ -497,6 +497,7 @@ def add_props(cls, user, wrapped):
@@ -533,6 +534,8 @@ def add_props(cls, user, wrapped):
@@ -832,6 +835,9 @@ def add_props(cls, user, wrapped):
0  r2/r2/models/printable.py 100644 → 100755
File mode changed
1  r2/r2/public/static/css/reddit.css 100644 → 100755
@@ -665,6 +665,7 @@ ul.flat-vert {text-align: left;}
665 665
 .tagline .alum { color: #BE1337; }
666 666
 .tagline a.author.admin { font-weight: bold }
667 667
 .tagline a:hover { text-decoration: underline }
  668
+.tagline .edited-timestamp{ cursor: default }
668 669
 
669 670
 a.author { margin-right: 0.5em; }
670 671
 
6  r2/r2/templates/comment.html 100644 → 100755
@@ -26,7 +26,7 @@
26 26
    from r2.lib.pages import WrappedUser
27 27
 %>
28 28
 
29  
-<%namespace file="utils.html" import="plain_link, thing_timestamp" />
  29
+<%namespace file="utils.html" import="plain_link, thing_timestamp, edited" />
30 30
 <%inherit file="comment_skeleton.html"/>
31 31
 
32 32
 #####################
@@ -109,9 +109,7 @@
109 109
        ${unsafe(self.score(thing, likes = thing.likes))}&#32;
110 110
     %endif
111 111
     ${thing_timestamp(thing, thing.timesince)}&#32;${_("ago")}
112  
-    %if thing.editted:
113  
-      <em>*</em>&nbsp;
114  
-    %endif
  112
+    ${edited(thing, thing.lastedited)}
115 113
   %endif
116 114
   %if collapse:
117 115
     &nbsp;<a href="#" class="expand"
12  r2/r2/templates/link.html 100644 → 100755
@@ -30,7 +30,7 @@
@@ -223,22 +223,24 @@
9  r2/r2/templates/utils.html 100644 → 100755
@@ -27,6 +27,7 @@
27 27
    from r2.lib.template_helpers import add_sr, js_config, static
28 28
    from r2.lib.utils import cols, long_datetime, timesince
29 29
    from r2.lib.tracking import UserInfo
  30
+   from datetime import datetime
30 31
 %>
31 32
 <%def name="tags(**kw)">
32 33
 %for k, v in kw.iteritems():
@@ -553,3 +554,11 @@
553 554
        ${label}
554 555
   </a>
555 556
 </%def>
  557
+
  558
+<%def name="edited(thing, lastedited=None)">
  559
+  %if isinstance(thing.editted, datetime):
  560
+    <time class="edited-timestamp" title="${_('last edited')} ${unsafe(lastedited or timesince(thing.editted))} ${_('ago')}" datetime="${thing.editted.isoformat()}">*</time>
  561
+  %elif thing.editted:
  562
+    <em>*</em>
  563
+  %endif
  564
+</%def>

0 notes on commit e0aaa3e

Please sign in to comment.
Something went wrong with that request. Please try again.