Command line export, then title changes

85 views
Skip to first unread message

Kalcifer Kandari

unread,
May 24, 2020, 11:00:22 PM5/24/20
to TiddlyWikiDev
So, I'm working on a fancy script to publish my site by just running a single command. I want to do this because the working wiki is a mix of public and private tiddlers, which is much easier to work with that 2 separate wikis, given they share a lot of tiddlers. I'm using the standalone wiki, because far as I know, exposing the node.js version to the internet is not viable as visitors could edit the site.

The command will do something like this:
  1. robocopy /mir the local folder to a staging folder.
  2. In the staging folder, from the original HTML file export some tiddlers based on this filter[all[]]-[tag[private]] to a new HTML file, then delete the original HTML file.
  3. Then rename a few tiddlers, such as index--public to index.
  4. robocopy /mir the staging folder to the server, and delete the staging folder.
So 2 and 3 are where I'm at.

For 2: I'm trying to use tiddlywiki wiki.html --render "[all[]]-[tag[private]]", but it's just throwing an error:

Error: ENOENT: no such file or directory, open 'E:\path\wiki.html\output\$:\boot\boot.css.html'

My suspicion is that the tiddlywiki command only works for node.js wikis?

For 3: I've looked at the tiddlywiki wiki.html --setField documentation, and it says "templatetitle - the tiddler to wikify into the specified field. If blank or missing then the specified field is deleted", I'm not clear on what that means. I would expect to be able to run tiddlywiki wiki.html --setField "[title[index--public]]" "title" "index", although I haven't got so far to be able to try that out yet.

Thanks,

Kalcifer

Mohammad Rahmani

unread,
May 24, 2020, 11:21:27 PM5/24/20
to tiddly...@googlegroups.com

Use
tiddlywiki mywiki --render "[all[]]-[tag[private]]"

change mywiki with your wiki folder name. This is when you run the command from a parent folder
if not give the correct wiki folder path, if you run from inside the wiki folder just issue
tiddlywiki  --render "[all[]]-[tag[private]]"  

Best wishes
Mohammad


--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/5cf4d25b-5d4e-42ed-b9c9-1429c0030ed9%40googlegroups.com.

Kalcifer Kandari

unread,
May 25, 2020, 12:41:54 AM5/25/20
to TiddlyWikiDev
Thanks, but that still give a similar error:

Error: ENOENT: no such file or directory, open 'E:\path\local\output\$:\boot\boot.css.html'

Kalcifer
To unsubscribe from this group and stop receiving emails from it, send an email to tiddly...@googlegroups.com.

Mohammad Rahmani

unread,
May 25, 2020, 1:28:14 AM5/25/20
to tiddly...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/2b94bea4-5d7b-4734-a75f-f118ccb3b5c4%40googlegroups.com.

Kalcifer Kandari

unread,
May 25, 2020, 1:35:32 AM5/25/20
to TiddlyWikiDev
I'm not trying to generate a static site, rather export part of a standalone site to another standalone site, then do some renaming.

I get the impression that, with the command line, you can convert a standalone wiki to a node.js wiki, but not the other way around, or from standalon to standalone.

Kalcifer

Kalcifer Kandari

unread,
May 25, 2020, 6:46:02 PM5/25/20
to TiddlyWikiDev
How viable would it be to make a command module to delete some tiddlers, rename some, then save the file? How would you run it from the command line? Well maybe I just found out:

This is an interesting command from build-site.sh.
node $TW5_BUILD_TIDDLYWIKI \
    $TW5_BUILD_MAIN_EDITION
\
   
--verbose \
   
--version \
   
--load $TW5_BUILD_OUTPUT/build.tid \
   
--output $TW5_BUILD_OUTPUT \
   
--build favicon static index \
   
|| exit 1

It doesn't use the tiddlywiki command from npm, it uses the node command to run tiddlywiki.js directly as a command, passing the command line arguments to the boot kernel, which is the thing that gets tiddlywiki started. So you could make a custom command module then run it this way, though I'm not sure it would work with a standalone TiddlyWiki. You would have to use --savewikifolder to convert the standalone to a node version, then run node tiddlywiki.js with some arguments, then this command which I found hidden away here: tiddlywiki --verbose --load wiki.html --rendertiddler "$:/core/save/all" "index.html" "text/plain", to convert it back to a standalone TiddlyWiki. This would allow you to manipulate a TiddlyWiki in literally any way you wanted from the command line, which would enable the automation of a lot of tasks.

I think many users would be able to utilise this given some guidance on how to make command modules, and greater clarity on all the options available to them with regards to the command line.

Side note: Found this nifty command while trying to understand what the build command does, it does do what I wanted earlier, renders standalone to standalone, brilliant.
tiddlywiki --verbose --load wiki.html --rendertiddler "$:/core/save/all" "index.html" "text/plain"
Makes me wonder if there are more core modules that do useful things when used in combination with the command line arguments.

By the way, the build command just runs some commands stored in the tiddlywiki.info file.

Kalcifer

TonyM

unread,
May 25, 2020, 6:47:40 PM5/25/20
to TiddlyWikiDev
Kalcifer,

Consider using the Innerwiki plugin, you can generate a new wiki inside an iframe with the core and tiddlers you specify. You can then save the generated wiki all in single file.

Regards
Tony

Kalcifer Kandari

unread,
May 25, 2020, 6:58:49 PM5/25/20
to TiddlyWikiDev
It's interesting, but not perfectly suited to this problem. Part of the exercise here isn't just making a new wiki from another one, it's also pushing it to a server, all with just one command. I am planning on updating and publishing this wiki everyday. Laziness is serious business.

Kalcifer

Kalcifer Kandari

unread,
May 26, 2020, 4:42:56 AM5/26/20
to TiddlyWikiDev
Does anyone know how to save a node.js wiki using a JavaScript module? There's a thousand matches for 'save' in the source code, aaaa.

Kalcifer

Kalcifer Kandari

unread,
May 26, 2020, 5:10:11 AM5/26/20
to TiddlyWikiDev
I've found SaveHandler.saveWiki("save"), but not sure how to get to it from a command module.

Kalcifer

Kalcifer Kandari

unread,
May 26, 2020, 8:28:08 AM5/26/20
to TiddlyWikiDev
I'm confused on many levels.
  • Is there even a saver for the command line? SaverHandler needs to initialise a 'saver' from $:core/modules/savers, but none of them seems to work.
  • If there is no way to save from the command line, what does the setfield command even do? I'm looking at the source code and it doesn't look like it saves.
  • If there is no saver, does that mean innerwiki needs to be used to create a 'fake' browser and then save?
I'm going to look at this tomorrow.

Kalcifer

TonyM

unread,
May 26, 2020, 8:20:39 PM5/26/20
to TiddlyWikiDev
Kalcifer Kandari

In the innerwiki plugin I mentioned there are some command line tips to capture an image of the resulting iFrame to generate documentation. But this is only an interesting fact that may lead you somewhere

By passing the appropriate tiddlers to the innerwiki you may be able to trigger an automatic save of that wiki to a set filename. You also get to preview it.

Others can help you with node or JS solutions, I do things in TW5 single files mostly, to keep them interactive, and independant of the server if possible.

Regards
Tony

Kalcifer Kandari

unread,
May 26, 2020, 10:09:53 PM5/26/20
to TiddlyWikiDev
I'll have a look at an innerwiki solution now. You can mess with it from a module, so I'll have to create a fake browser to save, I think anyway. This is brutal without documentation, but the API is not that bad once you get an idea of where everything is, as long as you have an IDE like netbeans to jump to declarations easily.

I thought maybe the setfield command was doing something special to save, so I learnt how to use it. As predicted, no, it doesn't save. So I have no idea what use it is, it seems to be pointless. UNLESS that's what the --build command is for! You run a few command WHILE THE SAME WIKI IS LOADED, so you make changes to the loaded wiki THEN build! Or maybe you can string arguments together? YOU CAN. WE DID IT!

Check this out.
  • So I have a file called local/index--private.html, which is a standalone TiddlyWiki.
  • I then convert that to a node.js wiki using --savewikifolder.
  • Then I run --setfield to fix the names of some tiddlers, but that duplicates them for some reason, so
  • I then delete the duplicates using --deletetiddlers.
  • Then I set the output location using --output.
  • Then I render the whole thing back to a standalone TiddlyWiki using --rendertiddler.
  • Later I will add the rest of the script, that does all the robocopying and delete the temporary node.js wiki.
tiddlywiki --verbose --load "./local/index--private.html" --savewikifolder ./temp "[all[]]-[tag[private]]"

tiddlywiki temp
--verbose --setfield "[[index--public]] [[quick--public]] [[license--public]]" "title" "publify--name--template" "text/plain" --deletetiddlers "[[index--public]] [[quick--public]] [[license--public]]" --output ./local --rendertiddler "$:/core/save/all" "index.html"

I did try to use the following command, to avoid the node.js part, but --setfield didn't work.
tiddlywiki --verbose --load "./index--private.html" --deletetiddlers "[tag[private]]" --setfield "[[index--public]] [[quick--public]] [[license--public]]" "title" "publify--name--template" "text/plain" --deletetiddlers "[[index--public]] [[quick--public]] [[license--public]]" --output ./ --rendertiddler "$:/core/save/all" "index.html" "text/plain"

Well I learnt how to make a command macro for nothing. Oh well! I'll make a proper tutorial for all of this later. We need documentation. That should have taken me half an hour, but it took days!

Kalcifer

Kalcifer Kandari

unread,
May 27, 2020, 12:45:16 AM5/27/20
to TiddlyWikiDev
I've managed to get it in a single command.

tiddlywiki --verbose --load "./index--private.html" --deletetiddlers "[tag[private]]" --setfield "[has:field[name--public]]" "title" "publify--name--template-2" "text/plain" --setfield "[has:field[name--public]]" "name--public" "" "text/plain" --deletetiddlers "[[index--public]] [[quick--public]] [[license--public]]" --output "./" --rendertiddler "$:/core/save/all" "index.html" "text/plain"

So the reason --setfield didn't work before was because when you --load a standalone wiki, its custom modules aren't loaded. Given you don't need to use --load for a node wiki, then its custom modules are loaded.

"publify--name--template" used a custom JavaScript macro to fix the name, so that wasn't loading. "publify--name--template-2" sets the title as a field that the relevant tiddlers have, so it doesn't need a custom JavaScript module. That field is then deleted using the --setfield command again, because it isn't necessary anymore.

Here is the "publify--name--template-2" tiddler:
\define publify--name()
<$view field="name--public" />
\end
<!--page-created: 2020-05-27-05-20-47-->
<<publify--name>>

Kalcifer
Reply all
Reply to author
Forward
0 new messages