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 
<https://tiddlywiki.com/#tiddlywiki.files%20Files> 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 
<https://tiddlywiki.com/#Customising%20Tiddler%20File%20Naming>).

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.

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/585c45b1-96c3-4332-928b-33edc267ff86%40googlegroups.com.

Reply via email to