New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read :LOGBOOK: drawer for metadata and modification timestamps #203

Open
alphapapa opened this Issue Sep 6, 2018 · 11 comments

Comments

Projects
None yet
3 participants
@alphapapa
Copy link

alphapapa commented Sep 6, 2018

Hi Kaushal,

Reading about ox-hugo again, and thinking about giving it a try, I thought I would post this idea that I was thinking about last night, which I'd like to have in my "ideal" Org blogging engine:

I'd like the :LOGBOOK: drawer to act as a log of changes for each post. e.g. if I updated a post that was already published, I could use org-add-log-note (C-c C-z) to make a note, like "Updated link and corrected typos." Then when I republished or reexported the blog, the note from the logbook would be put in the HTML in the appropriate place, and the last-modified timestamp would be taken from the most recent logbook entry.

Also, quick question: Is it possible to set up ox-hugo so that only posts with a certain to-do keyword are published? The workflow I was thinking of was to have TODO entries be ideas for posts, another keyword for drafts, and a PUBLISHED keyword (configured as a "done" keyword in Org) for posts I want to be published.

Thanks.

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 6, 2018

I like the LOGBOOK feature, and probably something that I would use too.

A long time back, I tried using the log book but it never worked for me.. I couldn't get the TODO/DONE state changes to log in the LOGBOOK drawer. And as it wasn't a pressing matter, I didn't did into what I should need to set in my config to make that work.

In addition to changelog recording, I would also like to get the TODO state transitions recorded in there.

Is it possible to set up ox-hugo so that only posts with a certain to-do keyword are published?

Yes, sort of.

You can have posts without DONE state to not get published by Hugo (but they still will be exported with the draft front-matter set to true. Hugo doesn't publish such posts by default.)

Just mark all posts to be drafts by default by putting #+hugo_draft: true at the top of the Org file. Then only the posts marked DONE will have the draft set to false and thus will be published (#171 (comment)).

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 6, 2018

@alphapapa I need to may be set some defcustoms to get notes going into LOGBOOK drawer?

In a plain heading, doing C-c C-z and typing "Test note." gives:

* Taking notes
- Note taken on [2018-09-06 Thu 10:18] \\
  Test note.

So I need to put a hack to interpret a list item beginning with "Note taken on " as something special? (which is not something I'd want to do).

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 6, 2018

Hmm.. C-c C-z is bound to org-add-note for me (default). And org-add-log-note is not an interactive function. I need to "get" this note taking in logbook flow then. Any help will be appreciated :)

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 6, 2018

OK, I needed #+startup: logdrawer and C-c C-z (org-add-note) does this:

* Notes in LOGBOOK
:LOGBOOK:
- Note taken on [2018-09-06 Thu 10:38] \\
  New note.
:END:

Also finally the mystery clears on why I wasn't able to see state changes in LOGBOOK:

Since it is normally too much to record a note for every state, Org mode expects configuration on a per-keyword basis for this. This is achieved by adding special markers ‘!’ (for a timestamp)


#+title: LOGBOOK testing
#+startup: logdrawers
#+seq_todo: TODO(!) DRAFT(!) DONE(!)

* Notes in LOGBOOK
:LOGBOOK:
- Note taken on [2018-09-06 Thu 10:38] \\
  New note.
:END:
* Log each state with only a time
:LOGBOOK:
- State "DONE"       from "DRAFT"      [2018-09-06 Thu 10:52]
- State "DRAFT"      from "TODO"       [2018-09-06 Thu 10:52]
- State "TODO"       from              [2018-09-06 Thu 10:52]
:END:

@kaushalmodi kaushalmodi changed the title Suggestion: Read :LOGBOOK: drawer for metadata and modification timestamps Read :LOGBOOK: drawer for metadata and modification timestamps Sep 6, 2018

@takaxp

This comment has been minimized.

Copy link
Contributor

takaxp commented Sep 6, 2018

Additionally, if you set org-todo-keywords like (sequence "TODO(t)" "|" "PUBLISHED(p@/!)"), then org-add-note will automatically popup when changing Org status to "PUBLISHED".

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 6, 2018

@takaxp Thanks. I read about @ too, though not sure if I will use it. It would be too prompty for me when marking posts as DONE (or PUBLISHED).

PS: ox-hugo hasn't hard-coded the DONE keyword. So #+seq_todo: TODO(!) PUBLISHED(@/!) will also work.

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 6, 2018

@alphapapa Would you like to make this a reality?

I have just added tests marked as noexport for now: 7e45592

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 6, 2018

Some initial work in https://github.com/kaushalmodi/ox-hugo/tree/logbook.

Exporting the "Parsing notes from LOGBOOK" tests prints this:

[ox-hugo logbook] elem type: drawer
[ox-hugo logbook] list content: Note taken on <span class="timestamp-wrapper"><span class="timestamp">[2018-09-06 Thu 11:45] </span></span> <br />
Another note **bold** _italics_.
 [2 times]
[ox-hugo logbook] ts: [2018-09-06 Thu 11:45]
[ox-hugo logbook] list content: Note taken on <span class="timestamp-wrapper"><span class="timestamp">[2018-09-06 Thu 11:37] </span></span> <br />
A note `mono`.
 [2 times]
[ox-hugo logbook] ts: [2018-09-06 Thu 11:37]
[ox-hugo logbook] list content: State "DONE"       from "DRAFT"      <span class="timestamp-wrapper"><span class="timestamp">[2018-09-06 Thu 11:25]</span></span>
 [2 times]
[ox-hugo logbook] ts: [2018-09-06 Thu 11:25]
[ox-hugo logbook] list content: State "DRAFT"      from "TODO"       <span class="timestamp-wrapper"><span class="timestamp">[2018-09-06 Thu 11:25]</span></span>
 [2 times]
[ox-hugo logbook] ts: [2018-09-06 Thu 11:25]
[ox-hugo logbook] list content: State "TODO"       from              <span class="timestamp-wrapper"><span class="timestamp">[2018-09-06 Thu 11:25]</span></span>
 [2 times]
[ox-hugo logbook] ts: [2018-09-06 Thu 11:25]
@alphapapa

This comment has been minimized.

Copy link
Author

alphapapa commented Sep 7, 2018

Hi Kaushal,

Would you like to make this a reality?

Well, I don't actually use Hugo (yet?), and I don't have much experience with org-export code, so I probably won't be contributing any patches--at least, not unless I actually start using this. :) I just wanted to toss the idea out there in case you thought it was worth doing, because it's a feature I would like to use myself.

Thanks.

@kaushalmodi

This comment has been minimized.

Copy link
Owner

kaushalmodi commented Sep 7, 2018

@alphapapa

Well, I don't actually use Hugo (yet?)

Got it. :)

I thought you would be a good candidate as I was stumbling through this initial commit for parsing logbook: 7872a01 .. org-element-map and stuff.

In any case, thanks for suggesting logbook notes.. I think I can use those to replace my "update" Org macros:
image

@alphapapa

This comment has been minimized.

Copy link
Author

alphapapa commented Sep 7, 2018

I thought you would be a good candidate as I was stumbling through this initial commit for parsing logbook: 7872a01 .. org-element-map and stuff.

Maybe so! I actually found that code very interesting, how you used 4 lambdas nested with org-element-map. I haven't seen it used that way before. At first I was surprised, but then I realized that it makes sense. (I feel like it's begging for some kind of org-element-recursive-map macro, though...) I've tried to write code making heavy use of org-element-map before, but I've never gotten the hang of it. Something about the structure of the parsed elements confuses me. Sometimes I wonder if it ought to use structs to help, if it would.

In any case, thanks for suggesting logbook notes.. I think I can use those to replace my "update" Org macros:

Yep, that's exactly what I was thinking it would be useful for!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment