maghoff / atomix

Atom feed generator that takes JSON input
ISC License
0 stars 0 forks source link

Get timestamps from files #2

Open maghoff opened 9 years ago

maghoff commented 9 years ago

In many cases, a post in the feed corresponds to a file in the filesystem or even in a source code repository.

It should be possible to automatically gather the "last changed" timestamp to use in the feed. It is tedious and error prone to keep such things in sync manually.

Possible implementation:

  1. If the post has a "date" field, use that
  2. Else, if "link" matches a file on disk, use the timestamp of that file (stat)

More advanced implementation of 2.: Can we find the given file in a local source code repo? (git&hg should be supported), if so get the last changed timestamp from the repo. This will be more accurate than using the date on the filesystem.

More advanced implementation of 1.: We could support explicitly specifying that it should get the timestamp from a file or a source code repo. Perhaps with a URI-scheme? "file:blah.html", "git:blah.html", "hg:blah.html"?

maghoff commented 9 years ago

git log -1 --format=%cd filename to get the last updated timestamp for a file in git.

hg log -l1 --template '{date|isodate}' filename for hg.