First pass at a Powershell launch script file for TW files

132 views
Skip to first unread message

Mark S.

unread,
Jul 24, 2017, 4:30:00 PM7/24/17
to TiddlyWiki
The default mechanism for saving in both Firefox and Chrome is to write out files with names like

tw_fun(5).html
tw_fun(6).html
tw_fun(7).html
tw_fun(8).html

This doesn't typically put your files where you want them, or with the name that you want them.

Since TiddlyFox is going away, it occurred to me that one way around this is to use a script file to pick out the latest tw file and launch it for you. It turns out that the powershell (tm) code is pretty simple (so far).

To run this, you need Powershell, of course, which I believe comes standard with Windows these days.

I put a file, launch_tw.ps1 in the same directory as the default downloads:

param([string]$stem="foo", [string]$dir="")
$copyme
= ls $stem*.html | sort LastWriteTime | select -last 1
$copyme
= $copyme.FullName
Copy-Item $copyme -Destination $dir\$stem.html
Invoke-Item $dir\$stem.html

Then, for each TW file I want to launch I put a batch file (e.g. "launch_tw_fun.bat") in the same directory:

powershell -executionpolicy bypass -File .\launch_tw.ps1 -stem "tw_fun" -dir c:\temp\twtests

The bt file indicates the stem name of the target file and the directory where to put the selected file. AFAIK It's necessary to use a bt file to launch the ps file because there is otherwise too many security restrictions on ps files. But perhaps power users would have a better way.

You can copy the batch file from explorer and make a shortcut to it on your desktop for easy access.

Then, to start a session, you double click on the shortcut and the TW file comes up in your default browser. You save the same way you've always done using the default mechanism.

Although this was done with powershell, I'm sure the same thing could be worked out in script files for other platforms.

I haven't tried or worked out yet what happens if you have file and directory names with spaces. One thing at a time.

This version doesn't delete anything, so it's up to the user to occasionally clean up their download directory.

Stem names need to be unique. If you have tw_fun.pdf and tw_fun.html there is a possibility that your browser will launch a PDF file (if the PDF happens to be newer).

If you try this, remember it's all experimental. Be sure to make backups!

Thoughts?
Mark

Jeebus K

unread,
Aug 2, 2017, 11:27:20 AM8/2/17
to TiddlyWiki
Interesting idea, this seems to me like more of a band-aid when we really need a better solution for save/sync. I'm looking at TiddlyDesktop right now, bark'n up the right tree though it's not perfect yet.

On Monday, July 24, 2017 at 4:30:00 PM UTC-4, Mark S. wrote:
The default mechanism ... doesn't typically put your files where you want them...
... use a script file to pick out the latest tw file and launch it for you. It turns out that the powershell (tm) code is pretty simple (so far)...

Arlen Beiler

unread,
Aug 2, 2017, 12:10:16 PM8/2/17
to TiddlyWiki
If you're looking at TiddlyDesktop, you may also be interested in TiddlyChrome (https://github.com/Arlen22/tiddly-chrome-app) or TiddlyServer (https://github.com/Arlen22/TiddlyServer). 

TiddlyChrome is a Chrome App which is probably going to become defunct next year due to changes in Chrome. However, until then, it works just fine. 

TiddlyServer is a new app that I published recently which allows you to load TiddlyWiki files (and data folders as well) in the browser and edit them. The saving works similar to TiddlyFox for individual files, and uses the Node Server command for saving data folders.

Enjoy!
-Arlen

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/6907d954-c0ab-498f-9e7c-de09f2c6b766%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mark S.

unread,
Aug 2, 2017, 12:32:46 PM8/2/17
to TiddlyWiki
It seems unlikely that we will ever have the ease of saving via a plugin again. So bandages are all we are likely to have.  Each bandage has its own problems and advantages.

My suggestion is the least bandage-like solution available because it uses the native download mechanism, which is likely to be around as long as viable browsers are around. It uses 6 lines of easily understood code. With tiddly desktop you have to run and install a separate executable just to enable a javascript program to run.

The method I suggested doesn't require an executable, or a server running in the background. I'm sure that it could be adapted for linux, if there's interest. I believe Apple also has a batch/script system available. Further down the road, an Android program could be written to do a similar thing on those devices that don't block file saving in non-app assigned locations.

Mark

Lost Admin

unread,
Aug 2, 2017, 1:00:39 PM8/2/17
to TiddlyWiki
I did some poking around and there appears to be a few very simple powershell scripts that implement a single-thread static file web server.

I wonder if one could be adapted that would support get/post/put to allow the webdav (also in core tiddlywiki) saver to work? If it's restricted to a single file (or directory) and only listens on localhost it should be pretty safe for a desktop.

My powershell skills are limited to almost being able to get a general idea of what someone else's powershell script might be doing without actually being certain.
Reply all
Reply to author
Forward
0 new messages