Node.js save mechanism (to interface with git)

158 views
Skip to first unread message

Conner Phillips

unread,
May 20, 2017, 12:23:27 PM5/20/17
to TiddlyWiki
Hi everyone, I would like to look into writing an extension to interface the node.js save mechanism to trigger a git add and commit. There are libraries out there to call git from node.js but I am left scratching my head trying to see where the actual saving happens. I've been searching through files like savehandlers and savetiddler.js but it all seems to bounce back and forth in my eyes. Could you give me some hints to how this mechanism works?

Thanks, have a nice weekend y'all.

Conner Phillips

unread,
May 20, 2017, 1:20:46 PM5/20/17
to TiddlyWiki
A little more digging, I think plugins/tiddlywiki/filesystem/filesystemadaptor.js with the save and delete functions at lines 146 and 199 would be the proper place to implement such a feature. Am I on the right track?

PMario

unread,
May 21, 2017, 4:53:46 AM5/21/17
to TiddlyWiki
Hi Conner,

have a look here:
https://github.com/Jermolene/TiddlyWiki5/blob/master/editions/server/tiddlywiki.info#L4-L5

those 2 plugins are needed if you run in server mode.

-m

Conner Phillips

unread,
May 23, 2017, 4:54:31 PM5/23/17
to TiddlyWiki
This should probably get it's own thread, but since I already mentioned git in the title I will just run with it. I'm wondering about the best way to transfer the commit message to the node server? Possible solutions:

Using a edit-text to write to a Shadow tiddler with saving disabled
Field which then gets cleared by the git process
Some other mystery way to pass a string to the node server???

Any thoughts from the more experienced useres out there?

And just as a note, I've played around with simple-git and it seems to work really well. I should expect to have a protoype relatively quickly :)

Matthew Lauber

unread,
May 24, 2017, 11:15:06 AM5/24/17
to TiddlyWiki
I'll be honest, I went with KISS.  A cron job to run git commit (including the timestamp).  Only commits when files are saved.  But if you want to try to trigger git from nodejs, I'd say look at the $:/temp/ prefix for the commit message.  Anything starting with $:/temp/ doesn't get saved/synced.  

jwd

unread,
Jun 3, 2017, 9:45:08 PM6/3/17
to TiddlyWiki
Coming late to this but , you could also delegate the git interface to a separate nodejs process using something like https://www.npmjs.com/package/watch-fs to watch for tiddler updates.
Reply all
Reply to author
Forward
0 new messages