Use <time> element with a title attribute for comments and submissions.

Based on a commit by Zeno <zenomcdohl@gmail.com>.
This commit is contained in:
Max Goodman
2010-10-20 12:08:24 -07:00
parent 5fd545393a
commit 04be215974
6 changed files with 20 additions and 12 deletions

View File

@@ -319,6 +319,8 @@ def trunc_time(time, mins, hours=None):
second = 0,
microsecond = 0)
def long_datetime(datetime):
return datetime.ctime() + " GMT"
def median(l):
if l:

View File

@@ -26,6 +26,7 @@
from r2.lib.pages import WrappedUser
%>
<%namespace file="utils.html" import="timestamp" />
<%inherit file="comment_skeleton.html"/>
#####################
@@ -95,8 +96,7 @@ ${parent.collapsed()}
%if show:
${unsafe(self.score(thing, likes = thing.likes))}&#32;
%endif
## thing.timesince is a cache stub
${unsafe(_("%(timeago)s ago") % dict(timeago=thing.timesince))}
${timestamp(thing, thing.timesince)}&#32;${_("ago")}
%if thing.editted:
<em>*</em>&nbsp;
%endif

View File

@@ -29,7 +29,7 @@
%>
<%inherit file="printable.html"/>
<%namespace file="utils.html" import="plain_link" />
<%namespace file="utils.html" import="plain_link, timestamp" />
<%namespace file="printablebuttons.html" import="toggle_button" />
<%def name="numcol()">
@@ -214,8 +214,8 @@ ${parent.thing_css_class(what)} ${"over18" if thing.over_18 else ""}
${unsafe(taglinetext % dict(reddit = self.subreddit(),
score = capture(self.score, thing, thing.likes, tag='span'),
when = thing.timesince,
author= WrappedUser(thing.author, thing.attribs, thing).render()))}
when = capture(timestamp, thing, thing.timesince),
author = WrappedUser(thing.author, thing.attribs, thing).render()))}
</%def>

View File

@@ -24,9 +24,8 @@
import locale
from r2.lib.filters import edit_comment_filter, unsafe, safemarkdown
from r2.lib.template_helpers import static
from r2.lib.utils import timesince
%>
<%namespace file="utils.html" import="submit_form, plain_link"/>
<%namespace file="utils.html" import="submit_form, plain_link, timestamp"/>
<%namespace file="printablebuttons.html" import="toggle_button"/>
<div class="titlebox">
@@ -129,7 +128,7 @@
%endif
<span class="age">
${_("redditor for %(time)s") % dict(time=timesince(thing.user._date))}
${_("redditor for")}&#32;${timestamp(thing.user)}
</span>
</div>

View File

@@ -22,12 +22,11 @@
<%!
import locale
from r2.lib.utils import timesince
from r2.lib.strings import strings, Score
from r2.lib.pages import WrappedUser
%>
<%namespace file="utils.html" import="plain_link"/>
<%namespace file="utils.html" import="plain_link, timestamp"/>
<%namespace file="subreddit.html" import="addremove_button" />
<%namespace file="printablebuttons.html" import="ynbutton, state_button" />
@@ -70,7 +69,7 @@
%endif
<span class="age">
${_("a community for %(time)s") % dict(time=timesince(thing.sr._date))}
${_("a community for")}&#32;${timestamp(thing.sr)}
</span>
</div>

View File

@@ -23,7 +23,7 @@
<%!
from r2.lib.filters import spaceCompress, unsafe
from r2.lib.template_helpers import add_sr
from r2.lib.utils import cols
from r2.lib.utils import cols, long_datetime, timesince
%>
<%def name="tags(**kw)">
%for k, v in kw.iteritems():
@@ -476,6 +476,14 @@ ${unsafe(txt)}
</div>
</%def>
<%def name="timestamp(thing, since=None)">
## todo: use pubdate attribute once things are <article> tags.
## note: comment and link templates will pass a CachedVariable stub as since.
<time title="${long_datetime(thing._date)}" datetime="${thing._date.isoformat()}">
${unsafe(since or timesince(thing._date))}
</time>
</%def>
<%def name="percentage(slice, total)">
%if total is None or total == "" or total == 0 or slice is None or slice == "":
--