Please disregard this and look at the next post. I am keeping this here as a reference to my own dingdongness
Use: take a directory of images/files and load them into wiki then move
them to external folder served by webserver (ie nginx) and (optional)
move 'placeholder' files (meta files) to subdirectory.
Method:
create subdirectory called loadfiles (doesn't matter) in tiddlers
directory. create
tiddlywiki.files in loadfiles directory with
following:
{
"directories": [
{
"path": "./",
"filesRegExp": "^.*\\.(jpg|png|jpeg)$",
"isTiddlerFile": false,
"fields": {
"title": {"source": "filename"},
"type": "image/jpeg"
}
]
}
place all your image files in this directory.
start
your wiki if it's not already running. create a tiddler titled
set-image-ph-to-yes with the text
yes and (optional) create/modify
$:/config/FileSystemPaths with text
[is[image]addprefix[placehold/images/]] (as per
customize file name).
now make a script
loadfiles.sh and run:
#!/bin/bash
node /path/to/tiddlywiki.js \
/path/to/wiki \
--output /path/to/where/nginx/serves/images/ \
--save [!image-ph[yes]is[image]] \
--setfield [!image-ph[yes]is[image]] _canonical_uri $:/core/templates/canonical-uri-external-image text/plain \
--setfield [!image-ph[yes]is[image]] text "" text/plain \
--setfield [!image-ph[yes]is[image]] image-ph set-image-ph-to-yes text/plain \
Result: Images/files in loadfiles directory are in the directory nginx serves from
and placeholder/reference files (jpg and meta) are in placeholder/images
subdirectory of tiddler directory with field image-ph set to yes. This
is important so that these reference files do not overwrite the actual
image files when you run this next time. Verify everything worked and
delete files - except the tiddlywiki.files! - in the loadfiles
directory.
NOTE: the files won't show up in your wiki until you restart and tiddlywiki loads the meta files but nginx will be able to serve them right away. If you use 'savetiddlers' instead of 'save' you have to use the 'noclean' option.
EDIT: make sure that the path in
$:/core/templates/canonical-uri-external-image points to the address in your site's nginx configuration file.