Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

suggestion: don't modify the date when edit/revise #24

Closed
nsklaus opened this issue Aug 10, 2019 · 1 comment
Closed

suggestion: don't modify the date when edit/revise #24

nsklaus opened this issue Aug 10, 2019 · 1 comment

Comments

@nsklaus
Copy link

nsklaus commented Aug 10, 2019

hi
just a quick suggestion,
it would be nice if there could be a way for lb not to modify the date once it have been set at creation time.

while testing out lb, changing some stuffs.. the layout and such, at some point i had to modify all the entries i previously made last month in order to make sure all my articles do pick up the changes i made, and as a result all my entries are now displaying the date at time of editing instead of creation date, giving the impression the article is new while it's not. so i'm reporting this as suggestion for enhancement.

anyway, thanks for lb, it's cool.

@ryanthomas-org
Copy link

ryanthomas-org commented Jan 11, 2020

This is an important feature for me as well, so I've figured it out. Have a look a the "publish()" function.

It looks like lb never modifies the date as it's originally generated in the "database" (.htaccess) file at the time of the initial creation of the entry. It actually just updates a string called "$webdate" on each revision while leaving "$rssdate" intact.

Any time a new or existing entry is published, the publish function checks to make sure "$rssdate" exists and thus leaves it alone, creating a new one only if it doesn't exist (meaning, in such cases, the publish function is posting a new entry and not modifying an old one).

Since "$webdate" is defined after "$rssdate" anyway (both just a few lines into the function), we can actually redefine it to reflect "$rssdate" pretty easily. Look for this line as it appears by default and which we'll have to replace:

webdate="$(date '+%a, %d %b %Y %H:%M:%S %z')" # But this visible date you can set to any format.

The date command at least on my system has a "-d" flag you can use which applies the subsequent formatting to whatever date you input into it (as opposed to "right now"). So we can use this with reference to the "$rssdate" string and still apply whatever format we want. In my case, I'll go with this:

webdate="$(date -d "$rssdate" '+%a, %d %b %Y %H:%M')"

That appears to do the trick!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants