#73 Use proper time tag

已关闭
necklace6 年之前创建 · 3 条评论

Currently the template looks like this:

<em><a href="post/{{ post.hashId }}">{{ post.created|ago }}</a></em>

Which generates html like this:

<a href="post/afcpgbmx1i">3 hours ago</a>

This makes it hard to know exactly when a post was really posted, especially when it says "x years ago", which really could mean anything.

Instead, the template should use the time tag, and generate html like this:

<time title="May 28, 2018, 3:47 PM PST">six minutes ago</time>

This allows users to hover their mouse over to get the exact time.

Though since this is a link I'll assume it really should generate html like this:

<em><a href="post/{{ post.hashId }}"><time title="May 28, 2018, 3:47 PM PST">six minutes ago</time></a></em>

But this is beyond the point and implicitly implied.

My example is from the index.twig template, but this should really be applied everywhere time is needed.

Currently the template looks like this: ``` <em><a href="post/{{ post.hashId }}">{{ post.created|ago }}</a></em> ``` Which generates html like this: ``` <a href="post/afcpgbmx1i">3 hours ago</a> ``` This makes it hard to know exactly when a post was really posted, especially when it says "x years ago", which really could mean anything. Instead, the template should use the [time](https://dev.w3.org/html5/html-author/#the-time-element) tag, and generate html like this: ``` <time title="May 28, 2018, 3:47 PM PST">six minutes ago</time> ``` This allows users to hover their mouse over to get the exact time. Though since this is a link I'll assume it really should generate html like this: ``` <em><a href="post/{{ post.hashId }}"><time title="May 28, 2018, 3:47 PM PST">six minutes ago</time></a></em> ``` But this is beyond the point and implicitly implied. My example is from the index.twig template, but this should really be applied everywhere time is needed.
zPlus 评论于 6 年之前
所有者

This is a good idea. The reason to use "ago" was simply to avoid timezones, but using a <time> tag like that (maybe with UTC) would be perfectly fine.

This is a good idea. The reason to use "ago" was simply to avoid timezones, but using a `<time>` tag like that (maybe with `UTC`) would be perfectly fine.
Nichlas Severinsen 评论于 6 年之前
发布者

Just to clarify, I don't mind the "ago" in the text part of it, that's perfectly fine (and pretty much standard now a days), I just think there should be a way to see exactly when. I was thinking UTC - not sure how it's stored in the DB - but I notice now that my example has "PST" in it, sorry 'bout that. Either way, whichever is easier, if the server isn't UTC then use whatever timezone the data is stored in.

I'm not very familiar with the code base but with a quick git grep on |ago it seems these are the templates that need changing (with line number):

template/comment.twig:25:
template/edit_comment.twig:10:
template/edit_post.twig:16:
template/index.twig:55:
template/post.twig:26:
template/reply.twig:7:
template/search.twig:21:
template/user.twig:25:
template/user.twig:83:
template/user_comments.twig:14:
template/user_posts.twig:22:
template/user_replies.twig:15:
Just to clarify, I don't mind the "ago" in the text part of it, that's perfectly fine (and pretty much standard now a days), I just think there should be a way to see exactly when. I was thinking UTC - not sure how it's stored in the DB - but I notice now that my example has "PST" in it, sorry 'bout that. Either way, whichever is easier, if the server isn't UTC then use whatever timezone the data is stored in. I'm not very familiar with the code base but with a quick `git grep` on `|ago` it seems these are the templates that need changing (with line number): ``` template/comment.twig:25: template/edit_comment.twig:10: template/edit_post.twig:16: template/index.twig:55: template/post.twig:26: template/reply.twig:7: template/search.twig:21: template/user.twig:25: template/user.twig:83: template/user_comments.twig:14: template/user_posts.twig:22: template/user_replies.twig:15: ```
zPlus 评论于 6 年之前
所有者

Merged it. Seems to work fine.

Merged it. Seems to work fine.
zPlus6 年之前 关闭
登录 并参与到对话中。
未选择标签
未选择里程碑
未指派成员
2 名参与者
正在加载...
取消
保存
这个人很懒,什么都没留下。