#73 Use proper time tag

Cerrada
abierta hace 6 años por necklace · 3 comentarios

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 comentado hace 6 años
Propietario

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.

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 comentado hace 6 años
Propietario

Merged it. Seems to work fine.

Merged it. Seems to work fine.
Inicie sesión para unirse a esta conversación.
Sin etiquetas
Sin Milestone
Sin asignado
2 participantes
Cargando...
Cancelar
Guardar
Aún no existe contenido.