I will create a public wiki using Tiddlywiki available at tonycodes.com/wiki. The wiki will be read only. It will be derived from a subset of my private wiki based on a special "Live" tag.

First, I need to decide how to derive the public wiki. I could use bash, but it will be a bit complicated. I want to see if it's possible using the tiddlywiki 5 command line. I know there are some filtering tools. Let's investigate.

The goal would be create a new set of tiddles from an existing set, based on the existence of the "Live" tag.

  1. Using the Build Command

The build command is for rendering a tiddlywiki, and this is what I want to do. The question is then how to filter the private wiki. A couple of options there:

1. bash 1. tiddlywiki cli filter option

I know how to do it with bash. Let's look at the CLI.

  1. Using the Tiddlywiki CLI Filter

Looks like the saveWikiFolder is the option I am looking for.

Ok that worked, with the command

$ tiddlywiki --load myWiki/ --savewikifolder ./testWikiPublic [tag[Live]]

Next I need to run serve the wiki, which I can do that simply with tiddlywiki --listen. However, I am getting the site served with no styling. Maybe I need to fix something in how I load and filter the wiki.

Ok, I think the issue is that none of the system tiddlers are moved. I would like to avoid doing that with bash; but it's an option of the TW CLI doesn't support what I want.

Maybe I should simply update my filter to include Live tiddlers or system tiddlers. Let's try that. Ok so a small update; with a space between filters as shown below, it grabs anything matching either filter:

 $ tiddlywiki --load myWiki/ --savewikifolder ./testWikiPublic '[tag[Live]] [is[system]]'

Ok, that kind of worked, but not really. I also needed to manually move the tiddlywiki.info file. And there are some other issues with some of the custom settings that should not really be moved over. Maybe I need to just move the tiddlers and then build the tiddlers into a static html. Let me try that.

The problem is formatting and system tiddlers. The load/save mechanism is just the tiddlers. That is fine, but I'll need to move them into a space with the right configuration files. For some reason the load/save is not allowed to be targetting a non-empy directory.

Ok, so starting with the old public wiki configuration and tiddlers, I ran

# from testPublicWiki direcotry; delete all normal tiddlers
find tiddlers/ -type f ! -name '$__*' -delete
# move in the Live tiddlers
tiddlywiki --load myWiki/ --output testWikiPublic/tiddlers --save [tag[Live]]
# build
tiddlywiki testWikiPublic/ --build
# remove current served page
sudo rm -rf /var/www/html/tonycodes.com/*
# copy in the new site files
sudo cp -r testWikiPublic/output/* /var/www/html/tonycodes.com/

And that worked and looks great! Now I need to move the public wiki to the intended domain. That is an easy change to the nginx config.

  location /wiki {
    proxy_pass http://127.0.0.1:1445/;
  }

Now, I need to actually host the files locally on port 1445, instead of serving them directly behind nginx. For this I'll use the tiddlywiki command line again, and making sure to keep the wiki as readonly.

I want to use pm2 in order to have a centralized tool for hosing the various applications I like to run.

First though, I'll experiment with readonly using the TW CLI.

    • Note, that I'll need to use the credentials option in order to protect my password, with the file git ignored.**

Ok, so I was able to serve the files pm2 serve ./testWikiPublic/output/ 1445directly using pm2. For that I just needed to install and serve:

$ npm i -g pm2
$ pm2 serve ./testWikiPublic/output/ 1445

Now I want to make sure the service runs as a system daemon so that it restarts when the server restarts. Let's look into how to do that. See systemctl.

Actually, I think I will do that later.