Opened 9 years ago

Closed 7 years ago

Last modified 7 years ago

#394 closed enhancement (fixed)

Fuzzy timestamps

Reported by: Jef van Schendel Owned by: Jessica Tallon
Priority: minor Milestone: 0.4.0
Component: programming Keywords:
Cc: deletesoftware@… Parent Tickets:

Description

Current: "Added on 2011-02-14."

Better would be: "Added 1 month ago."

This also goes for comment timestamps, which are currently shown as "08:35PM 2012-02-09" which is all kinds of horrible.

I have no idea how to do this though. It might already be possible with the software we're using, who knows. It also wouldn't be hard to find a jQuery plugin such as http://timeago.yarp.com/, but I'm not sure if that's the right way to go.

Subtickets

Attachments (1)

timesince.patch (10.7 KB) - added by Jessica Tallon 7 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 9 years ago by Aleksej

Cc: deletesoftware@… added
Milestone: 0.2.1
Priority: blockerminor

comment:2 Changed 9 years ago by Aleksej

It must still be possible to get the absolute value with some precision (unless the uploader or site owner hides it, if that’s possible).

comment:3 Changed 8 years ago by Christopher Allan Webber

Component: component1programming

comment:4 Changed 8 years ago by ShawnRisk

Owner: somebody deleted
Status: newassigned

comment:5 Changed 7 years ago by Jessica Tallon

Owner: set to Jessica Tallon
Status: newassigned

comment:6 Changed 7 years ago by Christopher Allan Webber

So I say that we add this feature but... I think that aleksej is right that we want to be able to get the absolute value with precision. Thankfully, there's a really easy option for that:

  <span title="exact date here">1 month ago</span>

As for implementation, several things:

  • We could implement this ourselves, or we could lift the timesince utility out of django (django/utils/timesince.py). Implement this as a generic function somewhere in mediagoblin/tools/
  • We'll definitely want tests for this utility, so please add them. Again, if adapting from Django, we can borrow and adapt their test.
  • Just be sure if adapting from Django that we follow: http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
  • We'll also then want to pass this into the global template context. It seems this would be useful pretty much everywhere, so see where we add common utilities to templates in mediagoblin.tools.template:get_jinja_env
  • Then you'd want to make use of it in the appropriate templates. In fact, wrapping it in a span might be a common enough operation that you might want to add a macro to the utils/ templates section... that's optional though.

That should do it, I think... happy to answer questions!

Changed 7 years ago by Jessica Tallon

Attachment: timesince.patch added

comment:7 Changed 7 years ago by Jessica Tallon

I've put it on a branch (394-fuzzy-timestamp) which you can find:
https://gitorious.org/~tsyesika/mediagoblin/tsyesikas-mediagoblin/commits/394-fuzzy-timestamp

comment:8 Changed 7 years ago by Christopher Allan Webber

Resolution: fixed
Status: assignedclosed

I merged it!

AWESOME work Tsyesika! You picked this up and ran with it super fast!

comment:9 Changed 7 years ago by Christopher Allan Webber

Milestone: 0.4.0
Note: See TracTickets for help on using tickets.