Does anyone have a strategy for automatically reloading TW when the underlying file changes?

720 views
Skip to first unread message

Rob Hoelz

unread,
Jan 4, 2017, 2:24:45 PM1/4/17
to TiddlyWiki
Hi TiddlyWiki users and devs!

I've been using TiddlyWiki for a while now, and I've had an issue that I'm finally trying to solve.

I use TiddlyWiki on multiple machines, and in order to synchronize changes between them, I took a dumb, but simple and effective,
route of just storing my wiki.html file in a Git repository and pushing/pulling between the various machines.  This works pretty well,
only there's a small caveat: if I pull and forget to reload the TiddlyWiki page, I can end up potentially undoing changes I made on another
machine.

For example, let's say I'm working on machine S and I make a series of changes, which we'll call version A.  I pull the changes onto machine
T, reload the tab, and then I make some more changes, which we'll call B.  I go back to S and pull, but forget to refresh the page with TiddlyWiki open.  If
I make some edits and push that up, it'll be some sort of version A', which will have blown away all of the changes I made between A and B.

Since this is in a Git repostory, it's not the end of the world - I can recover the change through the commit history.  However, this has bit me a
few times (and it's rather annoying to recover from), and I don't know if there are times it has happened and I've continued to use my wiki unawares
(I'm working on a script to detect this).  I would really like to automate this to prevent this from happening again.

I saw this discussion[1] while searching, mentioning syncing of TiddlyWikis; there are some interesting ideas there, but I didn't see mention of the problem
I've been experiencing.  I've been using the auto reload firefox extension[2] for the last few days, and it largely does the job, but unfortunately it's a bit
overzealous - it reloads the wiki every time I save it!  It'll work for now, but I was wondering if other users had some tips or ideas on how to handle this issue.
Perhaps TiddlyFox could be modified to reload a wiki if it's been changed outside of the browser?

Thanks for any help/insight you can offer!

-Rob

[1] https://groups.google.com/d/topic/tiddlywiki/irgt8hUmADQ/discussion
[2] https://addons.mozilla.org/en-US/firefox/addon/auto-reload/?src=api

Danielo Rodríguez

unread,
Jan 4, 2017, 4:39:49 PM1/4/17
to TiddlyWiki
Would you consider testing another approach?
Noteself (noteself.github.io) provides exactly that, synchronization between multiple devices in real time. Not as reliable as git is, but much simpler.

Regards

Evade Flow

unread,
Jan 4, 2017, 6:24:27 PM1/4/17
to TiddlyWiki
Well... it's only a partial solution (and perhaps you're already aware), but you can execute an arbitrary script after running git pull in a local working copy by creating a post-merge hook like this:

$ cat > .git/hooks/post-merge << EOF
heredoc
> #!/bin/sh
heredoc
> exec touch I-LIKE-TRAFFIC-LIGHTS.txt
heredoc
> EOF

The problem, of course, is figuring out what to run instead of touch I-LIKE-TRAFFIC-LIGHTS.txt, but it's a start...

Evade Flow

unread,
Jan 5, 2017, 9:35:25 AM1/5/17
to TiddlyWiki
> Well... it's only a partial solution (and perhaps you're already aware), but you can execute an arbitrary script after running git pull ...

Since I will shortly have a similar itch to scratch, I had a peek around the Interwebs this morning for utilities that might do the trick. On Windows, this post:
suggests using a small VB script (via WSH). (I can also recommend AutoHotkey, but it might be overkill.)

For Linux, I found these links/suggestions:
Using a local post-merge hook to trigger one of these utilities (or something similar) ought to allow your TW page to auto-refresh whenever git pull receives new objects from the remote...

Mark S.

unread,
Jan 5, 2017, 9:42:34 AM1/5/17
to TiddlyWiki
Just a thought.

If the same command line where you do the pull is the one where you launch node.js, then you'll always restart node.js after the pull. Because node.js was off, the browser page at this point will be full of little yellow warnings, which will remind you to refresh it before continuing.

Good luck,
Mark

Rob Hoelz

unread,
Jan 5, 2017, 11:11:36 AM1/5/17
to TiddlyWiki
Thanks for the input, everyone!  I like the node.js restart suggestion a lot - I'm currently using the standalone HTML version, but I've been thinking about switching to the node version.

Penguinlay

unread,
Jan 9, 2017, 3:12:41 AM1/9/17
to TiddlyWiki
Do you need to use Git or is that a choice?

If it is a choice, then I recommend you to use Dropbox and Firefox.

As a newbie TW learner and self-study semi-developer, I break my wiki a lot with different mistakes. But, Dropbox saves me every time.

  1. I use Google Chrome as my default browser.
  2. In Firefox, I set all my TW wikis as home pages. In setting, I update it so that every time I launch the app, my wikis will be opened. (You can customize here what to open.)
  3. I have TiddlyFox extension in Firefox which will track any tiddler changes except TW wiki's option changes, which you can click check-mark icon and save manually.
  4. My Wikis are located in Dropbox folder on my computer, and I let the Dropbox extension to run in background to sync itself.
  5. Every time, I make a changes to the file, Dropbox will save the versions. (I am sure it does save every time I change while I am connecting to the internet. While I am offline, I don't know if Dropbox would sync the latest version available or the whole version history.)
  6. If I want to go back to previous version, I just do it on dropbox.com or on my phone.
  7. Problem solved!
I hope this helps in case Git is not a requirement for your wiki. Even though I don't use multiple computers, the idea would be the same with Dropbox's background sync feature. I know sometimes, it takes time to sync files but it is fast enough for me so far.

Once my wiki gets large enough for the sync feature to take time, I am planning to adopt the Dropbox sharing feature for Tiddlywiki as mentioned on TW website, which might be able to serve the very purpose too.

However, both the above solutions need Internet connection to work as intended.

P.S.
This is the best solution for myself, but I am just a newbie. So, there might be a better way to do it. I am willing to learn and be corrected if I am wrong.


Best,

Penguinlay

On Wednesday, January 4, 2017 at 11:24:45 AM UTC-8, Rob Hoelz wrote:

jwd

unread,
Jan 11, 2017, 10:20:48 PM1/11/17
to tiddl...@googlegroups.com
I switched to the node.js version for just this reason. My single, standalone HTML versions got too big and I began experiencing a lot of problems merging the changes I'd made in separate tiddlers that git's diff-ing did not readily identify. I began doing a lot of manual editing of what was effectively TiddlyWiki internals. The tiddlywiki --server - tidders as separate files concept - instantly solved those, and several other problems. (E.g., no more browser plugin issues.) Tiddler files are much more amenable to the use case I share with you "TiddlyWiki on multiple machines, and in order to synchronize changes between them..." I rely on git.

Since I've switched to the node.js version I've begun taking another simple but dumb approach: when I have a tiddler that I want to share between tiddlywiki servers I simply create a symbolic link in one to the master version of that tiddler in the other. My TiddlyWiki's are beginning to get a lot more intertwined as a result. (I just need to remember to restart the servers when I merge changes.)

Rob Hoelz

unread,
Jan 12, 2017, 4:02:44 PM1/12/17
to TiddlyWiki
I think I may just switch to the node version then.  Did you import your single HTML version to transition?  If so, do you know if there's a way to import tiddlers and preserve the modification timestamp?  It seems that importing changes the timestamp to the current time, and I would really like to preserve the modification times if I can!

Jeremy Ruston

unread,
Jan 13, 2017, 1:04:39 PM1/13/17
to tiddl...@googlegroups.com
Hi Rob

On 12 Jan 2017, at 14:02, Rob Hoelz <rdh...@gmail.com> wrote:

It seems that importing changes the timestamp to the current time, and I would really like to preserve the modification times if I can!

In TiddlyWiki5, importing a tiddler should not change the modification timestamp so perhaps you’ve found a bug. Can you duplicate the behaviour?

Best wishes

Jeremy


Rob Hoelz

unread,
Jan 13, 2017, 1:53:25 PM1/13/17
to TiddlyWiki
I sure can!  Here's what I did:

  1. Download empty edition from tiddlywiki.com
  2. Open up empty.html in Firefox (which has TiddlyFox installed)
  3. Create a test tiddler - I note that the modification time is 12:35PM.
  4. (Wiki automatically saves due to TiddlyFox)
  5. Initialize a server wiki directory using tiddlywiki empty-wiki --init server (tiddlywiki --version reports 5.1.13)
  6. Change directory into empty-wiki/
  7. Fire up the server using tiddlywiki --server
  8. Navigate to localhost:8080 in Firefox
  9. Use the import tool to import empty.html
  10. Accept the imports from $:/Import

Pause - if you look at the test tiddler right now - its modification time is reported as 12:35!

  11. Look at the server running in the terminal, and let it flush changes.
  12. Reload localhost:8080
  13. Open test tiddler - modification time is now 12:43PM.

I can paste this into an issue on GitHub if you'd like!

jwd

unread,
Jan 14, 2017, 2:08:08 PM1/14/17
to TiddlyWiki
Close.  This is how I transitioned from a single file version to the node.js version; assuming I had a single file version called SingleFile.html
  1. mkdir SingleFile
  2. tiddlywiki SingleFile --init server
  3. tiddlywiki SingleFile --load SingleFile.html
  4. tiddlywiki SingleFile --server 9999
  5. Visit localhost:9999 in browser of choice, make new tiddlers, edit old tiddlers, ...

My SingleFile directory actually lives in a git repo with my other tiddlywiki --server directories, so my next steps are typically to check the status of the git repo with my git GUI tool of choice, (currently that is SourceTree), add the tiddlers that have been created or modified to the git index, commit those changes, push the updated index to other copies of my git repos; merge those changes at the other end, start up tiddlywiki --servers on those platforms; rinse and repeat. Those git repo commits are my tiddlywiki backups so it is easy to get back to a functioning state if I mess up.


If I have made changes to the same tiddlers in different copies of the git repo (rare but sometimes I do that) the git merges will have conflicts that I need to reconcile. Those that the diff tool I use (diffmerge) can't automatically handle I reconcile by hand. (Modification times will be in conflict for example.)


FWIW, I also have a .gitignore file that includes:

# TiddlyWiki elements that change on every update that I don't care about
$__StoryList.tid


Hope that helps

Rob Hoelz

unread,
Jan 14, 2017, 3:35:44 PM1/14/17
to TiddlyWiki
That did the trick, thanks!
Reply all
Reply to author
Forward
0 new messages