Query -- Are we neglecting "Restore" from default "Download Saves"?

709 views
Skip to first unread message

@TiddlyTweeter

unread,
May 20, 2019, 9:05:35 AM5/20/19
to tiddl...@googlegroups.com
At the moment, on modern browsers, saving TW without any custom saver, means the save ends up in "Downloads".

We have no tool to "auto resurrect" and copy back that save for those kinds of saves. Copying back has to be manual and can get complicated in a forest of downloads.

The more I think about this the more odd it seems.

I mean, with an "AUTO-RESTORE" from saves in Download to a wiki directory ANY browser could be used and with ANY version of TW. We would not be dependent on specific solutions.

Any thoughts on how to do this? And its probable value?

I know Mark S. has thought about it.

Best wishes
Josiah

@TiddlyTweeter

unread,
May 20, 2019, 9:06:14 AM5/20/19
to TiddlyWiki
Repeat for email users...


On Monday, 20 May 2019 15:05:35 UTC+2, @TiddlyTweeter wrote:
At the moment, on modern browsers, saving TW without any custom saver, means the save ends up in "Downloads".

We have no tool to auto/resurrect and copy back that save for those kinds of saves. Copying back has to be manual and can get complicated in a forest of downloads.

The more I think about this the more odd it seems.

I mean, with an "AUTO-RESTORE" from saves in Download to a wiki directory ANY browser could be used and with ANY version of TW. We would would not be dependent on specific solutions.


Any thoughts on how to do this? And its probable value?

I know Mark S. has thought about.

Best wishes
Josiah

PMario

unread,
May 20, 2019, 1:14:18 PM5/20/19
to TiddlyWiki
On Monday, May 20, 2019 at 3:06:14 PM UTC+2, @TiddlyTweeter wrote:
Repeat for email users...

Hi, ------------- OT
What is this post good for?
-m

@TiddlyTweeter

unread,
May 20, 2019, 1:50:19 PM5/20/19
to TiddlyWiki
For some time Google has blocked my posts to email users on first post. I still don't know why.

FYI ...

Annotation 2019-05-20 194752.jpg

Best wishes
Josiah

Mark S.

unread,
May 20, 2019, 5:41:19 PM5/20/19
to TiddlyWiki
I'm not a PowerShell aficionado, so even a short script takes some time. If you're feeling daring, and have backups, you can try.

At the top of the script is a list of your file stem names. They should match the capitalization of your real files because sometimes Windows gets confused.

The second list is the list of the directories those respective stems go in. There should be a one-to-one correlation. Maybe tomorrow I will learn how to split out file name/paths so that two lists are not necessary ;-)

There's a variable that sets how many seconds to wait before checking the files again. I have it set to 10 seconds.

To launch, open a powershell, go to the downloads directory used by your browser, which should also be where you put the script, and type ./launch_all_tw.ps1 <enter>

To launch from a regular batch file would take a magic invocation, so that's why I'm starting with the powershell.

I had to add a kludge factor of 1 second to get the datestamp to compare correctly. Possibly this would mean that if you did two rapid-fire changes in a row, the 2nd one might not be picked up. But I don't know. It might be fine.

A script for Linux would be similar, but need completely different code.
 
-- Mark




# File Stem names. Capitalize per actual file name.
# Stem must be absolutely unique! Otherwise it might detect wrong file.
$stemlist
= @("notes","Todo")

# List of target directories in same order as stem names
$dirlist
= @("D:\data\Wikis\notes","D:\data\TW2014")

# How many seconds to wait before checking again.
$waitSeconds
= 10

#-- SOURCE DIRECTORY -- NOT USED YET ----------
$downloaddir
= "C:\Users\Mark\Downloads"


while(1) {
   
for($i=0;$i -lt $stemlist.Length; $i++) {
      $stem
= $stemlist[$i]
      $stem
      $dir
= $dirlist[$i]
     
#$dir
      $copyme
= ls $stem*.html | sort LastWriteTime | select -last 1
      $copyme
= $copyme.FullName
     
#$copyme
      $destination
= Get-Item  "$dir\$stem.html"
      $source
= Get-Item "$copyme"
     
#echo Source: $source.LastWriteTime
     
#echo Destination: $destination.LastWriteTime
     
If($source.LastWriteTime -gt $destination.LastWriteTime.addSeconds(1) ) {
     
#echo "Source: " $source.LastWriteTime "greater than " $destination.LastWriteTime.addSeconds(1)
       
Copy-Item $copyme -Destination "$dir\$stem.html"
        echo
"Copying $copyme to $dir\$stem.html"
     
} Else {
        echo
"Will not be copying"
     
}
   
}
    echo
"Going to sleep..."
    start
-sleep -seconds $waitSeconds
}


@TiddlyTweeter

unread,
May 21, 2019, 3:59:21 AM5/21/19
to tiddl...@googlegroups.com
Wow. Thanks Mark! I'll test and get back to you.  

Looking at it you deal with the tricky issue of how to identify the latest download version in a possible mass of files. 

I managed to do it with a batch file but for only one wiki. I think powershell  is a better equipped way to go than batch. Assume, later, it can be invoked from batch, if needed. 

Best wishes
Josiah

@TiddlyTweeter

unread,
May 24, 2019, 5:29:48 AM5/24/19
to tiddl...@googlegroups.com
Ciao Mark S.

It works! :-)

Some initial comments .

Tested on ...
Windows 10 64-bit tablet
PowerShell: 6 
Browsers: Vivaldi, Firefox, Edge, Chrome, 2 other Chromium


TEETHING PROBLEMS

 -- PowerShell would not run the script till I ran the (session only) command ...
    "Set-ExecutionPolicy -scope CurrentUser -executionPolicy Unrestricted" 

I'm not sure that's a healthy way to do it, but it worked :-).


BROWSERS -- SMALL ISSUE 

 To my surprise not all modern browsers save the version number exactly the same way. Both "name (2).html" and "name(2).html" occur.


STEMMING

I don't understand how to do it but I think the stemming issue with possible overwrite could be avoided by using a regular expression rather than the general wildcard?
This looks like it might work .... 

"$stem(\s*\(\d+\))?$"



INSTANCES?

Just a thought for later. Based on my working practice.

In actual usage I'd be more likely to set "$waitSeconds" to 600 since I don't write that much.

What I'm interested in knowing is if one could run a second instance of the script--identical except it just does a restore of wiki and then exits? 

An "Instant Restore". 

The case use is a common one for me ... I installed a plugin and need to do a refresh. Rest of the time I rarely need a restore, just saves (downloads).


FURTHER TESTS

--- I will play with running it via a batch file. 

--- See how it works with portable addressing (not for download folder, but for everything else).

Many thanks!
Josiah


On Monday, 20 May 2019 23:41:19 UTC+2, Mark S. wrote:

Mark S.

unread,
May 24, 2019, 12:48:52 PM5/24/19
to TiddlyWiki
Hi TiddlyTweeter,


On Friday, May 24, 2019 at 2:29:48 AM UTC-7, @TiddlyTweeter wrote:
Ciao Mark S.

It works! :-)

Some initial comments .

Tested on ...
Windows 10 64-bit tablet
PowerShell: 6 
Browsers: Vivaldi, Firefox, Edge, Chrome, 2 other Chromium


Wow -- very thorough. I should say, your setup outstrips mine. I think I'm still on PS 4, Windows 7. Every day my Google News feeds reports problems people are having with updates on Windows 10. Makes me wonder if I should stick with Windows when support for 7 is dropped.
 
TEETHING PROBLEMS

 -- PowerShell would not run the script till I ran the (session only) command ...
    "Set-ExecutionPolicy -scope CurrentUser -executionPolicy Unrestricted" 


How did you discover the secret recipe? I wonder if that's a PS6 thing? I imagine that it's possible to set this in your profile.
 

BROWSERS -- SMALL ISSUE 

 To my surprise not all modern browsers save the version number exactly the same way. Both "name (2).html" and "name(2).html" occur.


Well, they should both match the stem, so it should still be OK.
 
STEMMING

I don't understand how to do it but I think the stemming issue with possible overwrite could be avoided by using a regular expression rather than the general wildcard?
This looks like it might work .... 

"$stem(\s*\(\d+\))?$"



That document explains how to do string matching. File globbing looks like regular expressions, but it's not. Possibly it would be possible to insert code that analyzes the output as strings. So one line of code would become 10 ;-)
but it's unclear -- is there an actual problem that would be fixed by this approach?
 
INSTANCES?

Just a thought for later. Based on my working practice.

In actual usage I'd be more likely to set "$waitSeconds" to 600 since I don't write that much.

I've been running several days with 180 seconds. I assume that the smaller the number the larger performance hit. But that hit is likely still way less than the browser itself. On my system it's less than the node.js instance. And uses a fourth of the internal memory.


 
What I'm interested in knowing is if one could run a second instance of the script--identical except it just does a restore of wiki and then exits? 

For the moment you could just stop and restart the script. It should be possible to add an argument to the code so you could run it like 'tw_launch_all.ps1 -mode="onetime" ' and it would run just once.

 

FURTHER TESTS

--- I will play with running it via a batch file. 


Here's the code I used to launch from a batch :

powershell -executionpolicy bypass -File .\launch_all_tw.ps1

It might work for you too.

Thanks!
-- Mark

@TiddlyTweeter

unread,
May 25, 2019, 5:07:03 AM5/25/19
to TiddlyWiki
TT wrote: 
 -- PowerShell would not run the script till I ran the (session only) command ...
    "Set-ExecutionPolicy -scope CurrentUser -executionPolicy Unrestricted" 
 
Mark S. asked:
How did you discover the secret recipe? I wonder if that's a PS6 thing?

 TBH, the "Stab-in-the-dark" method. I found the Microsoft documents on Execution Policy confusing.


I don't know if there are PS version differences on Execution Policy. 

Best wishes
Josiah

TonyM

unread,
May 25, 2019, 5:52:37 AM5/25/19
to TiddlyWiki
Folks,

I may have discovered a path to a universal install.

I am discovering a lot of power with links to files, and executables and batches. With some recently developed methods to customize and export scripts to the local computer. Further a custom protocol as an alternative to file:// can actually pass parameters to the Operating system. In time I hope to pass larger payloads at a click of a button or link.

The annoying thing is this only works on top of TiddlyDesktop with its local rights as a fully fledged application. Installing and managing solutions that Mark has developed would be so easy, but users will have had to of installed tiddlydesktop first which misses the point.

However this has made me realise what if we provided a custom browser, you install (Like TiddlyDesktop) but one designed to open .tw files (TiddlyWiki.html in disguise) (Even a specific tiddlywiki) and this browser can install on any OS, people could get a "management wiki" with a single install script for each alternative build or solution. In some ways this solves the platform issues, if at that point we present ways to obtain all the other possible methods with install scripts it would open it up to multiple setups. 

So to use tiddlwiki on any computer install the "tiddlywiki manager" app. A Custom browser that loads a helper wiki. This can be used to open tiddlywikis, will automatically open .tw files but also has oneclick installs of The powershell script, TiddlyDesktop, TiddlySever, Node, Bob, Timimi and even support installing tw-receiver to a local server (WebDav, AMPPS/Apache etc...). Why so powerful?, because we are working behind the "firewall" called a browser.

Perhaps just building this resource into a build of TiddlyDesktop and its backstage, would be a quick remedy. Even if users do not continue to use tiddleyDesktop, it will manage the other options.

Regards
Tony

@TiddlyTweeter

unread,
May 25, 2019, 8:11:44 AM5/25/19
to TiddlyWiki
Mark S. wrote:
Every day my Google News feeds reports problems people are having with updates on Windows 10. Makes me wonder if I should stick with Windows when support for 7 is dropped.

Dunno. I just buy computer and put up with it. 

Win. 10 for me has been fine. Updates, no problem.

But I like 7 (other computer) much better. Why? Because its more like XP. 

10, for me, is too locked-down. For instance, its over complex to get it to recognise file associations. It really does not like portability.

Side, OT thoughts.

Josiah

@TiddlyTweeter

unread,
May 25, 2019, 9:52:51 AM5/25/19
to TiddlyWiki
Seeing this in action might be useful where it supports the thread intent. Does it? It seems not to be.

This is not a negative comment. Rather, right now, we need feedback on the actual running of the basic script. Your comment is somewhat complex and I don't fully understand it.

Josiah

TonyM

unread,
May 25, 2019, 7:25:40 PM5/25/19
to TiddlyWiki
Josiah,

I suppose the degree of brainstorming and experimentation on my part sounds like it is Off Topic. I thought you were more general in your question. 

Since marks script appears later in the thread do you want to focus on it for now?

However I do think this has inspired an important innovation below.

To summarise my rambling post;
  • If we have a clear way for all users to configure their computer for tiddlywiki handling, browser or OS independently we would all be happy
  • TiddlyWiki can be used to do this itself (if running under tiddlydesktop) including setting up the above script of Marks, but then they have already had to install tiddlydesktop
This led me to conclude if we could have a minimalistic application install (With built in standards browser, like TiddlyDesktop's Chromium), with versions for each platform, containing a single backstage tiddlywiki which has all the setup scripts and documentation needed including TiddlyDesktop, Marks script, Timimi, tw-receiver and setup node, tiddlyserver, bob, android and IOS? and any future configuration.  Lets call this the TiddlyWikiManager and we could also associate .tw files with it. 
  • The point being for any saving method other than default save there is one path for users to follow to edit and save wikis locally on any platform. Works out of the box, then once someone is persuaded TiddlyWiki is "the best thing since sliced bread" they can make guided choices on OS, Browser and server configurations all from a single app designed to help them.
Finally,
  • I think we should develop tiddlywiki into a compliant "Progressive Web App" because it is the future, self installable, OS independent etc...

Regards
Tony

@TiddlyTweeter

unread,
May 27, 2019, 3:00:35 AM5/27/19
to tiddl...@googlegroups.com
@TiddlyTweeter wrote:
 
STEMMING

I don't understand how to do it but I think the stemming issue with possible overwrite could be avoided by using a regular expression rather than the general wildcard?
This looks like it might work .... 

"$stem(\s*\(\d+\))?$"



 Mark S. wrote: 
That document explains how to do string matching. File globbing looks like regular expressions, but it's not. Possibly it would be possible to insert code that analyzes the output as strings. So one line of code would become 10 ;-)

Ciao Mark S. 
 
but it's unclear -- is there an actual problem that would be fixed by this approach?

Here is a case that I think is possible. Certainly in my usage.

Say you have  wiki1  you are working on and clone it (to run a test safely)--running the clone  wiki1-b  . Currently any "Download Save" of it would restore and over-write wiki1.

PowerShell console:
wiki1
Copying C:\Users\Josiah\Downloads\wiki1-b(2).html to C:\scrap\wiki1\wiki1.html

In the use-case, in reality I don't need wiki1-b "restoring" because its a throw away I'll later delete; nor do I want it overwriting anything. 

One issue that is a bit clearer to  me now is it could get cumbersome having to rename such test cases uniquely stemmed?

I think it makes more sense they are just ignored unless you really need a restoration--in which case then its name should go in PS script settings as a wiki to restore (to its own name)??

Hope this is clearer!

Best wishes
Josiah

@TiddlyTweeter

unread,
May 27, 2019, 3:35:12 AM5/27/19
to tiddl...@googlegroups.com
Ciao TonyM ...
  • If we have a clear way for all users to configure their computer for tiddlywiki handling, browser or OS independently we would all be happy
  • TiddlyWiki can be used to do this itself (if running under tiddlydesktop) including setting up the above script of Marks, but then they have already had to install tiddlydesktop
Yes. And TD is good because it looks like an application and is self-contained. (FYI, I tried to re-bundle it with 3 Wiki for a project on the novel & films of Great Expectations. But I hit the problem I couldn't get the pathing to the included wiki to use relative addressing so an install-able single bundle didn't work out. Maybe with next version of TD  it would be easier?)

Its backup is good (though the number of backups can get too many). 

And, right, TD backups are compatible with Mark S. script for "restore" since they use unique name stemming (though the directories for them are nested (/top/wikiname.html_backup/wikiname.TIME.html) so the pathing needs some work).

Best wishes
Josiah

Mark S.

unread,
May 27, 2019, 11:44:43 AM5/27/19
to TiddlyWiki
There is the edge case where the $stem file is new, and there are no other $stem (\d).html files. Probably can be ignored ...

Thanks!

@TiddlyTweeter

unread,
May 28, 2019, 8:09:16 AM5/28/19
to TiddlyWiki
Mark S. wrote:
There is the edge case where the $stem file is new, and there are no other $stem (\d).html files. Probably can be ignored ...

Probably!

But there is the case that IF a user deleted it in Downloads their next save would again be  $stem , not  $stem (N) ... I think?

In practice, with regular use, of your script I think that is maybe likely to happen as a user does routine housekeeping to prevent Downloads becoming a swamp of excess saved wiki? 

I did test of Downloads in Chrome with 20 numeric versions of $stem (N). Then, (1) Delete $stem with no number; (2) Next save to Downloads from wiki -> Result: next save is  $stem not-numbered .

Just an observation on browser behaviour!

Best wishes
Josiah

@TiddlyTweeter

unread,
Jun 10, 2019, 5:35:19 AM6/10/19
to tiddl...@googlegroups.com
Having used this now for a little while I want to comment that I think the general idea is really good!

It works.

The main advantage is it works with every single wiki scenario the majority of users would ever use. Just one method to learn. No plugins needed.

Works with every modern browser. Not limited to Firefox or Chrome. ANY browser. ANY version of TW or TWC.

This is very good in: 

(1) not having to be browser focused [why should a user need to choose a specific browser brand? They should not have to!] 

(2) Works the same way for all browsers  and all versions of TiddlyWiki.

In tests it has proved robust.

It builds off the "default HTML5 saver" fallback method--meaning modern browsers that save to the "downloads" folder. The work is in how it auto-resurrects saves.

There are a bunch of directions this could develop into something that could go further. 

(But that is unlikely to happen unless it gets tried more by more people!) At the moment its two men and a three-legged dog using it.

And, it could, in theory, be used as a complementary method to other approaches (TiddlyDesktop, Timimi, PMario's saver). Its not in conflict with other approaches. Its additive and freeing.

The approach is focused on "Restore" rather than "Save", which is left to the browser. 

By focusing on "Restore" it solves a bunch of problems. That also opens the way to a "pan-restore system" that could, in principle, work with different existing backup systems used in TW.

Its a different approach to keep your wiki updated. 

One that has great merit because of its wide functionality. And deserving exploration.

At the moment its a Windows based solution only, but could be converted for Mac & Unix pretty easily by the look of it. 

Best wishes
Josiah



On Monday, 20 May 2019 23:41:19 UTC+2, Mark S. wrote:

@TiddlyTweeter

unread,
Jun 12, 2019, 6:48:08 AM6/12/19
to TiddlyWiki
Ciao Mark S.

FYI, you might be interested in this TWC  thread that indicates there is confusion about your PowerShell script. I was slightly gob-smacked. But it may be only you, I, and the three-legged dog "get" it so far? Though it might be me confusing Yakov.


To get attention it maybe needs an ABC?

Not sure.
Josiah

TonyM

unread,
Jun 12, 2019, 6:30:40 PM6/12/19
to TiddlyWiki
Also posted in TWC Forum

Josiah,

This threads title does little to promote this great idea. Which I only now understand because I spent a little time working through the conversations. I know much of this has being said but its being in discussion rather than statements.

Please let me try

When using the default save mechanism in any browser, you can save changes resulting in a download of the whole Wiki, having an automatic process on your computer, the wiki can then be copied back to your original single file wiki. There by keeping the original upto date. This is done by running a monitor and copy process in your local computer.

Open a tiddlywiki.html file (by another name) using your local file manager and it will open in your default browser. Without any other save mechanism in place, Each time you save, the browser will download the latest version of the wiki into your downloads folder. This means the updated version is not saved over the original version you opened, but you have a copy of the latest version.

(As I understand it) Mark S solution is to run a batch process on the computer to take any updated wiki copy in the downloads folder and copy it back to its source wikifile, thus keeping the original up to date.

My View on this
Josiah and Mark are right to think this could be a ground breaking way to manage wiki saves. Mark has done a good job of building a Powershell to do this. We can write batch shell scripts for every operating system and share these quite easily.

Personally I think an executable program to do the same, or even just install and help configure, may be a better option in time, allowing it to be installed Quickly and a version for each Operating system made available. These executables my just create the correct scripts.

Although this process seems somewhat universal it does expect a certain behaviour from the browser(s) which could actually change in time. We need to monitor this and add additional methods if these change.

Love your work

Regards
Tony

@TiddlyTweeter

unread,
Jun 17, 2019, 6:03:07 AM6/17/19
to TiddlyWiki
TonyM wrote:
When using the default save mechanism in any browser, you can save changes resulting in a download of the whole Wiki, having an automatic process on your computer, the wiki can then be copied back to your original single file wiki. There by keeping the original upto date. This is done by running a monitor and copy process in your local computer.

Much better description! 

Personally I think an executable program to do the same, or even just install and help configure, may be a better option in time, allowing it to be installed Quickly and a version for each Operating system made available.

Once the workings get clear and tested this should be possible. In my own case I'm playing with a fairly crude approach to launch the PS script from a simple batch file that does other things, like list directories. The only reason I that is because I have a tool to compiles a batch files into an executable in windows and I don't have skill to do more.

Right now Mark S.' base PS script, I think, needs using a bit by a few people to highlight aspects of it that might be expanded/improved. He's not a PowerShell guru so there may be things to notice before its ready for other aspects. And other people my understand how to address those issues.

Best wishes
Josiah

@TiddlyTweeter

unread,
Jun 17, 2019, 6:08:22 AM6/17/19
to TiddlyWiki
Folk wondering What is this about? What are the advantages of "Restore from downloads?" may, in addition to the discussion above, read the post by Mark S. in the TWC group that presents the aim & function of his PowerShell Script well and briefly ...

TonyM

unread,
Jun 17, 2019, 8:20:19 AM6/17/19
to TiddlyWiki
Josiah,

I wrote a large post and lost it. I can repost soon. Its key items were,

I have identified a way to make the sentenial batch very efficient and potentially configureless. no need to worry about timing or performance impact. The same should work for bash scripts, but I could not write the bash one, except slowly. Perhaps I can even simplify it from a user and filename perspective including providing multi folder handling eg empty lives in documents/empty folder and prerelease in documents/prerelease.

However I must review marks script in detail first.

This is leading us down an interesting path which seems to be getting smoother as the idea matures.

What I can bring to this is my history as a batchfile guru many years ago, and some tricks I have up my sleeves.

Chat soon
Tony

@TiddlyTweeter

unread,
Jun 17, 2019, 9:03:05 AM6/17/19
to TiddlyWiki
Mark S. wrote:
There is the edge case where the $stem file is new, and there are no other $stem (\d).html files. Probably can be ignored ...

Ciao Mark

IF, the wiki has not been saved to the downloads folder or a user deletes all the saved versions (probable at of housekeeping from time to time) you get a HUGE error message ... like this ...

wiki1
Get-Item : Cannot bind argument to parameter 'Path' because it is an empty
string.
At C:\bag\z_pa\PortableApps\tw_nine-lives\tw_nine-lives_v01.ps1:37 char:26
+       $source = Get-Item "$copyme"
+                          ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingVal
   idationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAl
   lowed,Microsoft.PowerShell.Commands.GetItemCommand

My wonder  is could the error message be something less verbose  and intimidating? Like ...

wiki1
There are no downloads of this Wiki!

Similarly for the wiki itself, if its incorrectly named, or you moved or deleted it, you get ...

wiki1
Get-Item : Cannot find path 'C:\scrap\wiki1\wiki1.html' because it does not
exist.
At C:\bag\z_pa\PortableApps\tw_nine-lives\tw_nine-lives_v01.ps1:36 char:22
+       $destination = Get-Item  "$dir\$stem.html"
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\scrap\wiki1\wiki1.html:Strin
   g) [Get-Item], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetIt
   emCommand

etc...

This would be just as informative ...

wiki1
The Wiki 'C:\scrap\wiki1\wiki1.html' does not exist!

In neither case is the error fatal. 

In fact as soon as you create the needed file things carry on as normal.

Best wishes
Josiah

@TiddlyTweeter

unread,
Jun 25, 2019, 1:50:46 AM6/25/19
to tiddl...@googlegroups.com
TonyM wrote:

I have identified a way to make the sentenial batch very efficient and potentially configureless. 

 

This is leading us down an interesting path which seems to be getting smoother as the idea matures.

What I can bring to this is my history as a batchfile guru many years ago, and some tricks I have up my sleeves.


Ciao TonyM

In trying to think through what would be useful for my use case I wrote a crude batch file that launches Mark's PS1 script ...

You will be able to understand it. It won't generalise as is as the settings are currently hard coded (but you can modify them at the start of the file if you want to test what it does).

---

After experimentation I determined that for the "Restore" method (I provisionally named "Nine-Lives" following a suggestion from Mark) I'd optimally want on startup...

   1 -- to see a listing of my wiki(s);

   2 -- to see a listing of files in the "downloads" folder (all .html & .htm)

   3 -- a way to alter the settings interactively (done crudely at the moment by opening the PS1 script in a text editor)

   4 -- have a "Restore & Quit" option (NOT finished or working). The point being you only really need to run the script when you need to reload the wiki (i.e. before start or after installing a plugin). So having a simple way to restore immediately would be handy.

I thought you'd be interested. This is NOT meant to be anything but a set of rough ideas. 

I'm not sure that having a batch file in addition to a Powershell script is ideal. But its all I'm capable of. I think a single PS script would be best. Maybe with at BAT merely to ease launching it?

It invokes a very slightly modified version of Mark's PS1 script (which I will post seperately). The BAT & PS1 go in the same directory, which can be anywhere.

Take a look ... any thoughts?

@echo off && color 0e && mode con:cols=85 && setlocal

:SETTINGS
  set "wikiDir=C:\bag\tw5\tws\"
  set "dldsDir=C:\Users\Josiah\Downloads\"

  set "scriptVer=NINE-LIVES v0.1"
  set "ps1Script=tw_nine-lives_v01.ps1"
  set "startDelay=20"
  set "ps1Editor=notepad.exe"

:TITLE-WINDOW
  title %scriptVer% 

:MENU
  echo:
  echo   +============================+
  echo    %scriptVer% - Start Menu
  echo   +============================+
  echo   ^| A - Auto-Monitor           ^|
  echo   ^| R - Restore ^& Quit         ^|
  echo   ^| T - TiddlyWiki             ^|
  echo   ^| D - Downloads (HTML/HTM)   ^|
  echo   ^| E - Edit PowerShell Script ^|
  echo   ^| Q - Quit                   ^|
  echo   +============================+
  echo     Auto-Monitor in %startDelay% seconds 
  choice /c:ARTDEQ /d:A /t:%startDelay% /n /m "?   Key: "
    if %errorlevel% equ 1 cls && echo: && goto RESTORE-MONITOR
    if %errorlevel% equ 2 cls && echo: && goto RESTORE-ONCE 
    if %errorlevel% equ 3 cls && echo: && goto LIST-WIKI
    if %errorlevel% equ 4 cls && echo: && goto LIST-DOWNLOADS
    if %errorlevel% equ 5 echo: && goto EDIT-PS1-SCRIPT
    if %errorlevel% equ 6 endlocal && exit

:LIST-WIKI
  echo   ^| WIKI FILES in "%wikiDir%"
  echo:
  dir /a /b /s /o:gn /t:w %wikiDir%*??.htm? 
  echo:
  echo   ^| EDIT SCRIPT "%ps1Script%"
  choice /c:YN /d:N /t:30 /n /m "?   Key: Y/N" 
    if %errorlevel% equ 1 echo: && goto EDIT-PS1-SCRIPT
    if %errorlevel% equ 2 cls && goto MENU

:LIST-DOWNLOADS
  echo   ^| HTML ^& HTM FILES in "%dldsDir%"
  echo:
  dir /a /b /s /o:gn /t:w %dldsDir%*??.htm? 
  echo:
  echo   ^| EDIT SCRIPT "%ps1Script%"
  choice /c:YN /d:N /t:30 /n /m "?   Key: Y/N" 
    if %errorlevel% equ 1 echo: && goto EDIT-PS1-SCRIPT
    if %errorlevel% equ 2 cls && goto MENU

:EDIT-PS1-SCRIPT
  "%ps1Editor%" "%ps1Script%"
  cls && goto MENU

:RESTORE-ONCE
  :: NOT FINISHED
  :: The PS1 script needs to be in same directory as this batch file
  :: The script contains its own settings
  :: Need to pass parameter to run-once
  :: powershell.exe -file "%ps1Script%" -mode="run-once"

:RESTORE-MONITOR
  :: The PS1 script needs to be in same directory as this batch file
  :: The script contains its own settings
  powershell.exe -file "%ps1Script%"


@TiddlyTweeter

unread,
Jun 25, 2019, 2:05:50 AM6/25/19
to TiddlyWiki
Mark S. wrote:
I'm not a PowerShell aficionado, so even a short script takes some time. 

Ciao Mark

In the process of noodling about with your script I made a few, mainly cosmetic, changes. The only real difference is to be able to put the script anywhere (I hope :-).

Merely suggestive. Related to previous post to TonyM.

Best wishes
Josiah

Set-ExecutionPolicy -scope CurrentUser -executionPolicy Unrestricted

# SETTINGS -----------------------------------

  # --- WIKI STEM NAMES: list of wiki stem names
  # Wiki name stem must be unique!! Case sensitive naming!!
  $stemlist = @("wiki1","wiki2")

  # --- WIKI DIRECTORIES: list in same order as stem names
  $dirlist = @("C:\scrap\wiki1","C:\scrap\test\wiki2")

  # --- DOWNLOADS DIRECTORY: where your browser(s) save downloads
  $downloaddir = "C:\Users\Josiah\Downloads"

  # --- TIMING: How many seconds to wait between checks
  $waitSeconds = 60

# SCRIPT --------------------------------------
cls
cd $downloaddir
echo ""
echo "  | NINE-LIVES v0.1 (test)"
echo "  |"
echo "  | Every $waitSeconds secs checks for new saves in ..."
echo "  |"
echo "  | $downloaddir "
echo "  |"
echo "  | Press [Ctrl+C] to exit"
echo ""

while(1) {
    for($i=0;$i -lt $stemlist.Length; $i++) {
      $stem = $stemlist[$i]
      $stem
      $dir = $dirlist[$i]
      #$dir
      $copyme = ls $stem*.html | sort LastWriteTime | select -last 1
      $copyme = $copyme.FullName
      #$copyme
      $destination = Get-Item  "$dir\$stem.html"
      $source = Get-Item "$copyme" 
      #echo Source: $source.LastWriteTime
      #echo Destination: $destination.LastWriteTime 
      If($source.LastWriteTime -gt $destination.LastWriteTime.addSeconds(1) ) {
      #echo "Source: " $source.LastWriteTime "greater than " $destination.LastWriteTime.addSeconds(1) 
        Copy-Item $copyme -Destination "$dir\$stem.html"
        echo "  Copying $copyme to $dir\$stem.html"
        echo ""
      } Else {
        echo "  ... is unchanged" 
        echo ""
      }
    }
    echo "  | Sleep for $waitSeconds seconds ..."
    start-sleep -seconds $waitSeconds 
    echo ""
}



@TiddlyTweeter

unread,
Jun 25, 2019, 4:54:17 AM6/25/19
to TiddlyWiki
TonyM 
Personally I think an executable program to do the same, or even just install and help configure, may be a better option in time, 

Side note ... I agree in the sense that via an exe you can more easily provide a full installable solution without having to understand PS or BAT files?

Just FYI I'm already running it as an exe. Its a trick that various good Batch-to-Exe utilities do well on Windows for non-programmers. Basically you write a BAT file and use the tool to embed the BAT, the PS1, and an ICON in an executable. On run it extracts the bat and ps1 to a Temp directory and initiates the bat. Deletes on exit. Works well. I got into the method a lot as PortableApps will natively recognise ".exe" but not ".bat" without a lot of extra work.

The downsides are ...

1 -- That won't work well for "locked-down" systems that won't allow installion of exe

2 -- The Configuration/Settings would need to be external to the ps1 script (but that's not a bad thing!)

Thoughts
Josiah

@TiddlyTweeter

unread,
Jun 25, 2019, 5:35:11 AM6/25/19
to tiddl...@googlegroups.com
Mark S. wrote:
I'm not a PowerShell aficionado, so even a short script takes some time. 
Dear Non-Aficionado

As the 3-Legged Dog in this tiny ship of interest I am a Seriously Hobbled Participant at the mainmast. Trying to be competent is a heavy burden.

After walkies with the code and exhausting trials with my master I can hazard a few barks ...
 
woof 1 -- the settings part is fine for one or two wiki;
 
woof 2 -- the settings will likely be error prone (they will get messy, especially with long paths) if he has more than a few wiki, which he does;
 
woof 3 -- the "stemming" approach, rather than full specification (full path) of the Target Cat, may prove troublesome for Support Services as unanticipated overwrite restores remain possible;
 
woof 4 -- the essential dogfood point is that, maybe, "Nine-Lives" (provisional name), needs an additional first routine that can read a config file that parses exact full addresses and assembles an array of them for the main PS1? From, e.g. something like an "ini" file ...

[wikis]
C
:\mylargedog\smallvariant\doggie\rover.html
C
:\myhates\thosecats\gingerrrr.htm

[download-dir]
C
:\User\Shep\Downloads

[timing]
60

Yours in walkies (slightly off-kilter)
Shep

TonyM

unread,
Jun 25, 2019, 7:10:43 AM6/25/19
to TiddlyWiki
Josiah,

A revised approach I have being researching and not yet made public seems to have predicted the above woofs.

Watch this space.

Tony

Mark S.

unread,
Jun 25, 2019, 11:01:40 AM6/25/19
to TiddlyWiki
I like what you're doing with the scripts, TT -- Your batch script is really neat and organized. I had forgotten that crazy way that
windows batch scripts use errors to make choices.

Re your ps script, I don't see where "downloaddir" gets used -- am I missing something?

Re the woofs, I had been thinking of having a separate configuration file. It might be easier to implement in powershell as a JSON file. Admittedly, your configuration
file would be easier to read. Do you think JSON will be adequate?

Re stemming ... I'm not sure what the alternative is. It's the download saver that sort of forces the approach. Or are you just saying it's easier on the user to specify a single file/path at once? I can see that.
I just want the user to think a little bit about the stem issue. They might not realize that "mytiddlywiki.html" will overwrite "mytiddlywiki5.html". But maybe just emphasizing this in the documents
is sufficient?

I'm not sure what exe brings to the table. I guess it's a way to reduce every thing (initially) to a single file. But the user will still need to hand-edit a configuration file, so does it matter?

Windows now has zip ability, so it's possible to package things without shipping as an executable.

I'm guessing that an unsigned exe will create alarm bells with a lot of AV software out there. Any problems with Windows Defender?

The charm of a simple ps script is that anyone can eyeball it and see that it's mostly harmless. Not so much with exe's.

Thanks!

@TiddlyTweeter

unread,
Jun 26, 2019, 2:45:55 AM6/26/19
to tiddl...@googlegroups.com
Mark S. wrote:
Re your ps script, I don't see where "downloaddir" gets used -- am I missing something?

Its simply an added line ...

cd $downloaddir

 The idea is to have script run in "downloads" but can be located elsewhere.

I had been thinking of having a separate configuration file. It might be easier to implement in powershell as a JSON file. Admittedly, your configuration
file would be easier to read. Do you think JSON will be adequate?

Yeah, I think INI is an easy user readable format. But I think JSON should not be much more difficult to read or edit. 
 
... are you just saying it's easier on the user to specify a single file/path at once? I can see that.

Exactly that. It visually works better and I think less likely to lead to entry errors.
 
I just want the user to think a little bit about the stem issue. They might not realize that "mytiddlywiki.html" will overwrite "mytiddlywiki5.html".

Right. I looked around for PS examples of how to precisely split out the exact NAME.EXT from a full path (rather than $stem). Hopefully that would reduce the potential overwrite problem? Unfortunately I didn't find one yet.
 
I'm not sure what exe brings to the table. I guess it's a way to reduce every thing (initially) to a single file. But the user will still need to hand-edit a configuration file, so does it matter?

I don't think it matters. I mentioned it partly for TonyM to show how I personally convert Batch to Exe sometimes for convenience. But thats not I think an easily generalisable idea. More an indication that some end users can launch the PS script, and supplement it, in several ways quite easily. 

My thinking now, having read you comments, is basic release might be ...

 1 - settings file
 2 - PS1 script
 3 - Plus a very simple BAT file that launches PS with the script. (I don't mean my custom batch which stands currently only as a use case)

All three placed in the same directory. Something like that?

Best wishes
Josiah

@TiddlyTweeter

unread,
Jun 29, 2019, 1:24:23 PM6/29/19
to tiddl...@googlegroups.com
Ciao Mark S., TonyM & intererested cats

Mark S., whilst I'm sure its true that "saving" TW is no longer a pressing issue, I feel your "restore" (Nine-Lives ?) script very much to the point in that its a properly univeral method that should work with any modern browser.

I'm currently finishing up with a revised take on my previous DOS batch file---now converted to Powershell and much better integrated with your script.

An issue that has become clearer to me is the likely need for "modes" of running ... 

MODES

I think practically there may be three viable "run modes" which can be all acheived via one PS1 script ...
  • "auto" mode  -- This behaves as your published script, basically as it was when you released it. An effective loop of "check & restore."
  • "once" mode -- So you can run a "restore" once and exit. To enable that in your script I added a sub-clause near its end ...
    if($mode -eq "once") {
      echo "  | $ninelives"
      echo "  |"
      echo "  | Run mode ""$mode"" completed!" 
      echo "  |"
      echo "  | Closes in $closeSeconds seconds ..."
      start-sleep -seconds $closeSeconds
      cls
      exit
    }
 
Much to my surprise I got it working. The "$closeSeconds" (default "10") in the script mod is so the user has a few seconds to see what was restored before the script teminates.
 
The command line launch string needs the "-run [option]". For instance ...

 powershell -file .\tw_nine-lives_v01bTT.ps1 -executionpolicy bypass -run once

Works well.  To garner the value of "-run" the very *first* line of the PS1 script needs be ...

 param ([string]$run)

A command line without a "-run" parameter will use the default mode ("menu").
 
I will post the whole script next so you can see it working.
  • "menu" mode -- so you can investigate what is going on, change settings & view basic help (and also manually launch the script into "auto" or "once" modes) ... here is what the "menu" looks like ...
    PowerShell: 5.1.17763.503

  +============================+
        NINE-LIVES v0.1bTT
  +============================+
  | A - Auto-Monitor           |
  | O - Restore Once & Quit    |
  | T - TiddlyWiki             |
  | D - Downloads (.html/.htm) |
  | E - Edit Settings          |
  | U - Usage                  |
  | Q - Quit                   |
  +============================+
?   Key: 

This is a mighty interesting project!

Best wishes
Josiah

@TiddlyTweeter

unread,
Jun 29, 2019, 2:42:44 PM6/29/19
to tiddl...@googlegroups.com
Ciao Mark S. & interested cats

I attach my revised experimental PS1 script, version "b". Its still largely a wrapper around your original script. 

I added a load of settings, but most of them are "internal" (i.e. will never need to be in a seperate settings file) and unproblemmatic. The only "USER SETTING" I added was for an address to a "parent" directory (recursive) for TiddlyWiki files (optional). Its "T - TiddlyWiki" on the menu.

I'm not sure that was a good idea as it assumes users have their TW all under one directory structure. On the other hand, it does no harm as its just informational.

Its working well for me but I'm concerned to see whether the script works for others.

USER SETTINGS

FYI, the User Settings look like this ...

# USER SETTINGS -------------------------------
# Note: ??User Settings may eventually be in an external file??
 
  # --- WIKI STEM NAMES: list of wiki stem names
  # Wiki name stem must be unique!! Case sensitive naming!!
  $stemlist = @("wiki1","wiki2")

  # --- WIKI PATHS: list in same order as stem names
  $dirlist = @("C:\scrap\wiki1","C:\scrap\test\wiki2")
  
  # --- DOWNLOADS DIRECTORY: where browser downloads go
  # Example path is the usual Windows location
  $downloaddir = "C:\Users\$Env:Username\Downloads"

  # --- WIKIS DIRECTORY (optional): useful if all wiki nest under one directory
  $wikidir = "C:\bag\tw5\tws"
  
  # --- TIMING: seconds to wait between checks
  $waitSeconds = 60

Hope its of interest!
Josiah

tw_nine-lives_v01bTT.ps1

TonyM

unread,
Jun 29, 2019, 9:08:59 PM6/29/19
to TiddlyWiki
Josiah,

I am glad you are continuing this conversation. I do not have the capacity to contribute as I would at present. So I thought I would dump some design patterns and ideas I had for this.

After the save to disk by the browser, a move rather than rename will be faster on the same disk. To do this the previous version in the selected folder needs to be moved to a backups folder first, and the oldest deleted. If all that takes place is renames and deletes, downloads to folders then backups will be fast, with the only full write to disk done by the browser.

Now if we have document folders that contain only tiddlywiki html files we could use the fact that mywiki.html exists in these folder to look for mywiki.html in the browser download folder(s). Add a new wiki to this folder and it automatically joins those to be collected.

each browser should have a default downloads folder thus our solution could use these first and only the exceptions configured.

If a tiddlywiki is collected and removed from downloads immediately, it will always save as the same and original filename. No confusing versions or overwrite prompts. We need to cater for versions if the batch is not running for a while, but it can just iterate the versions the same way with moves.

It would be possible to run a batch command in any folder that adds (appends) that folder to those to be scanned for in download folders. Even better would be to add this to the desktops file manager to get a r-click to select that folder. This iteration can also scan for subfolders.

In windows at least a simple registry entry can associate .tw files with your default browser and clicking a tw file will open as usual in the browser. If this is done tw files could be placed in any folder with any files including other html files and you could even auto detect downloaded tw files and move them to a default folder.

With .tw files you could select your documents folder and it and all its sub folders could be scanned to locate .tw files to check for in downloads, and to identify where they beling. Again reducing the need for configuration.

A recent change to tiddlywiki allows you to set the download filename before you download the first time. You could do this to ensure it is unique and maybe even name it to a .tw file. Then it would automagicaly be managed by the local scripts.

Whilst these solutions aim to be universal we do need a different one for each operating system, so will it ever be universal? A multiple os intaller could solve this. Having .tw files could make it possible to auto configure everything.

Using the above should be compatible with timimi being installed because once it is running you just open the wikis and timimi handles the save and no download occurs. Timimi already works with .tw files.

This process should work along with tiddlydesktop and tiddlyserver as well but we could consider some helper functions to make the transition simpler. Once again this can be improved by using .tw files because we can differentiate these from common or garden html files.

Finally we could integrate it with a node install by pointing to the right folder.

Regards
Tony

@TiddlyTweeter

unread,
Jun 30, 2019, 4:25:06 AM6/30/19
to tiddl...@googlegroups.com
Ciao Tony M.

Thanks for the useful thoughts!


Auto-Collation of paths to Wikis under a "Wikis Folder"?  
 

Now if we have document folders that contain only tiddlywiki html files we could use the fact that mywiki.html exists in these folder to look for mywiki.html in the browser download folder(s). Add a new wiki to this folder and it automatically joins those to be collected. 


Its a neat idea. But is it realistic? Possible issues ...
  • Whilst I keep my single-file wikis largely nested under one directory I also have other ".html / .htm" files in there too (e.g. output of static exports of TW) which would get erroneously listed under that system.
  • It suggests a user have a specific "TW Folder" (TWF) to store TW under. And you have "exceptions" too (i.e. paths outwithTWF could be manually added) ...
  • ... but with any "exception" you'd be back to the existing issue of selecting exact addresses. Overall, I think ONE method (manual) for adding candidate wiki is probably less complex to understand than having TWO (auto + manual "exceptions") in the end?
  • I don't think one should assume users actually organise their wiki this way as a norm? I mean, I don't know where users store their wiki.
        UPDATE for TonyM ... see Mark S' replies and my response for a way that should cope with both "one" AND "exceptions".

Immediate Move From Downloads? 

If a tiddlywiki is collected and removed from downloads immediately, it will always save as the same and original filename. No confusing versions or overwrite prompts.


Clever idea! Though, issues I think? 
  • A major issue would be TIMING. You'd need to have a script continuously polling every few seconds the downloads directory for new downloads of "mywiki.html".
 We need to cater for versions if the batch is not running for a while, but it can just iterate the versions the same way with moves.

  Exactly! 
  • IMO users should be able to restore without having to constantly run a script ...
  • ... which brings one back to a method to locate the latest  and copy and rename it--which is what Mark S.' script does already
  • Again, you seem to be suggesting TWO methods---one where you rapidly move a download save back with no name change, and---a second that renames and copy/moves back. Why not just ONE method? Since the second method removes the need for the first, why have the first?

Changing Content of Downloads?

  An additional point is perhaps more philosophical... 
  • In using a method to restore wiki from downloads I'm uncomfortable with idea we'd also be managing files in Downloads. Changing the content of downloads seems more for a dedicated backup system, or explicit deletion by the end user? 
  • In short, a "restore" script should not change anything in downloads?

Wiki Pathing Collation Tool!

It would be possible to run a batch command in any folder that adds (appends) that folder to those to be scanned for in download folders. Even better would be to add this to the desktops file manager to get a r-click to select that folder. This iteration can also scan for subfolders.

  Neat idea! Like it!
  • What you point to is some method / tool to more easily identify Wiki and get their paths into a settings file? 
        Yes?
  • I guess a standard "file picker" might also work? Maybe as part of a "configuration tool?" (I believe that might be possible via PowerShell? I just don't understand PS well enough to know how to do it). 

TW Files With Extension ".TW"
 

In windows at least a simple registry entry can associate .tw files with your default browser and clicking a tw file will open as usual in the browser. If this is done tw files could be placed in any folder with any files including other html files and you could even auto detect downloaded tw files and move them to a default folder.

With .tw files you could select your documents folder and it and all its sub folders could be scanned to locate .tw files to check for in downloads, and to identify where they beling. Again reducing the need for configuration.


I seen you mentioned the File Type ".tw" before in other threads. I think its interesting--as are many other of your ideas about leveraging the O/S & browsers to get a lovely system. Simple points ...
  • The current PS1 script could be modified, I think, to accept a range of extensions eventually. Like .html, .htm, .hta, .tw ...
  • In fact, I see no reason that it can't be totally agnostic about what file types it restores

Download Naming
 

A recent change to tiddlywiki allows you to set the download filename before you download the first time. You could do this to ensure it is unique and maybe even name it to a .tw file. Then it would automagicaly be managed by the local scripts.


Useful info! I take a look. 


Universal?
 

Whilst these solutions aim to be universal we do need a different one for each operating system, so will it ever be universal?


  My bad for not making clearer what I meant by "universal". I meant ...
  • Working in alignment with the standardised download saving and save naming mechanisms that all modern browsers support
  • In other words "universal" as "one standard method for any browser"
But you are right, that, if this approach, currently limited to a Windows scripting language (PowerShell) gets somewhere it would need writing in other platforms' script languages. But ...
  • ... its not exactly settled yet what it is on Windows. Though the basic "restore" function is there and working. Other platforms later? 
  • Installation territory et al. Well that seems like "Repository" territory. Not there yet. The approach needs a lot more interest and input I think to begin to approach that.

Compatability with Existing TW Savers? 

A multiple os intaller could solve this. Having .tw files could make it possible to auto configure everything.

Using the above should be compatible with timimi being installed because once it is running you just open the wikis and timimi handles the save and no download occurs. Timimi already works with .tw files.

This process should work along with tiddlydesktop and tiddlyserver as well 


Yeah, the method using Mark S.' script at its core is compatible with other saving mechanism in TW. For the simple reason ...
  • If you use a TW dedicated saver then no TiddlyWiki will get written to Downloads so co-existence with TW savers looks assurred.
  • But, say you worked with a TW in Edge where normally you run in Firefox with Timimi ... You could use the "Nine-lives" script to restore the Edge edited version and just go back to Firefox and carry on from where Edge left off, no problem ...
  • Basically the approach is Complementary to other methods of saving in TW. And its also Additive so you can include any browser brand. Using One method for all of them.
Tony, thanks very much for your very useful post. Please let me know if I misunderstood anything

Best wishes
Josiah

Mark S.

unread,
Jun 30, 2019, 7:26:13 PM6/30/19
to TiddlyWiki
Hi TT ,

Posting here so you won't think I've dropped off the edge of the earth. Yet.

Your code looks really good! You've obviously spent a lot of time putting things together. The only thing that needed changing was the "publisher" (matching set) quote
marks that you used around the title. The code wants "terminal" quotes (non-matching). Not sure what the terminology is.

I found some code that can read and parse an ini file, so I'm working on inserting that so that we can share the core code without having to paste in our own
personal settings values each time.

Tony's idea re a wikis directory is interesting. It occurs to me that you could run two instances of 9-lives, one in each mode.

Re the name, thinking maybe nein-lives (humour intended) or neun-lives just to avoid trademark infringement with the cat food company.

Thanks!

-- Mark

Mark S.

unread,
Jun 30, 2019, 7:35:03 PM6/30/19
to TiddlyWiki
So, thinking new tw_nine_lives.ini would look like:

[wikis]
file1=D:\data\Wikis\notes\notes.html
file2=D:\data\TW2014\Todo.html
[general]
; --- DOWNLOADS DIRECTORY: where browser downloads go
; Example path is the usual Windows location
downloaddir = "C:\Users\mark\Downloads"
; --- WIKIS DIRECTORY (optional): useful if all wiki are nest under one directory
wikidir = "C:\temp\wikis"
; --- TIMING: seconds to wait between checks
waitSeconds = 60


@TiddlyTweeter

unread,
Jul 1, 2019, 12:30:07 AM7/1/19
to TiddlyWiki
Ciao Mark

Looking good! Readable. Couple to queries ...

1 -- Can you have blank lines so, for instance, it could look like this?

[wikis]
file1
=D:\data\Wikis\notes\notes.html
file2
=D:\data\TW2014\Todo.html

[general]
; --- DOWNLOADS DIRECTORY: where browser downloads go
; Example path is the usual Windows location
downloaddir
= "C:\Users\mark\Downloads"

; --- WIKIS DIRECTORY (optional): useful if all wiki are nest under one directory
wikidir
= "C:\temp\wikis"

; --- TIMING: seconds to wait between checks
waitSeconds
= 60



2 -- IF a user removed a wiki so numbering was no longer sequential would it still work? For example ...

[wikis]
file1=D:\data\Wikis\notes\notes.html
file3=D:\data\TW2011\Todo.html
file4=D:\data\TW2012\Todo.html
file5=D:\data\TW2014\Todo.html
file9=D:\data\TWfuture\Todo.html


Thanks!
TT

@TiddlyTweeter

unread,
Jul 1, 2019, 1:18:07 AM7/1/19
to tiddl...@googlegroups.com
Ciao Mark S & TonyM ...

Mark S. wrote:
The only thing that needed changing was the "publisher" (matching set) quote
marks that you used around the title. The code wants "terminal" quotes (non-matching). Not sure what the terminology is.

Mark, could you post the code for that so I can see what you mean? (I don't get any error with it myself. Win 10, PS 5.1)

UPDATE for Mark. Its okay. I saw the issue. I'd missed I'd used curly brackets.

I found some code that can read and parse an ini file, so I'm working on inserting that so that we can share the core code without having to paste in our own
personal settings values each time.

That's really excellent! One query ...

    Can your code that splits the wiki full paths be agnostic about the file extension? 

I mean, keep it and use it, but not be bothered if it were ".tw", for instance. That would allow any type of file to be restored.

Tony's idea re a wikis directory is interesting. It occurs to me that you could run two instances of 9-lives, one in each mode.

Tony & Mark

In which case I'll leave the T - TiddlyWiki dir listing in. Its only for info but its recursive so would show target wiki. If I can I will add file type .tw, to .html & .htm I will (maybe in an internal setting).

I'll also see if we can have a second command line parameter for -ini [file.ini] for example ...

 powershell -file .\tw_nine-lives_v01bTT.ps1 -executionpolicy bypass -ini tonysettings.ini -run auto

This would load tonysettings.ini rather than the default. Not sure of it needs a change in Mark's code loop? Later.

I think PS should be fine with several instances running if needed?
 
Best wishes
Josiah

TonyM

unread,
Jul 1, 2019, 1:39:17 AM7/1/19
to TiddlyWiki
Some responses Josiah


Auto-Collation of paths to Wikis under a "Wikis Folder"?  
 

Now if we have document folders that contain only tiddlywiki html files we could use the fact that mywiki.html exists in these folder to look for mywiki.html in the browser download folder(s). Add a new wiki to this folder and it automatically joins those to be collected. 


Its a neat idea. But is it realistic? Possible issues ...
  • Whilst I keep my single-file wikis largely nested under one directory I also have other ".html / .htm" files in there too (e.g. output of static exports of TW) which would get erroneously listed under that system.
If you want lots of shared files and html in your folder then this option is not for you unless you go the .tw path, if you want this to be configure less.

 
  • It suggests a user have a specific "TW Folder" (TWF) to store TW under. And you have "exceptions" too (i.e. paths outwithTWF could be manually added) ...
Not sure what you are saying here
 
  • ... but with any "exception" you'd be back to the existing issue of selecting exact addresses. Overall, I think ONE method (manual) for adding candidate wiki is probably less complex to understand than having TWO (auto + manual "exceptions") in the end?
It may be easy to have an auto method, and if this is insufficient use manual config. 
 
  • I don't think one should assume users actually organise their wiki this way as a norm? I mean, I don't know where users store their wiki.

Immediate Move From Downloads? 

If a tiddlywiki is collected and removed from downloads immediately, it will always save as the same and original filename. No confusing versions or overwrite prompts.


Clever idea! Though, issues I think? 
  • A major issue would be TIMING. You'd need to have a script continuously polling every few seconds the downloads directory for new downloads of "mywiki.html".
Continuously polling is irrelevant especially if it is only testing for the existence of a file, then if it needs to do anything it is just file moves. I would let it poll as fast as it can. In this case almost all happens internally in memory and with cached directory etc...
 
 We need to cater for versions if the batch is not running for a while, but it can just iterate the versions the same way with moves.

  Exactly! 
  • IMO users should be able to restore without having to constantly run a script ...
I disagree if the scrip it launched at startup and polls all the folder you want it to poll ist a set and forget. If however you did not have it running and saved a few tiddlywiki (n).html files all I am saying is the batch knows how to handle them correctly.
  • ... which brings one back to a method to locate the latest  and copy and rename it--which is what Mark S.' script does already
Well I suggest no copy, just move,  My propose script does more than the current one and is low configuration.
  • Again, you seem to be suggesting TWO methods---one where you rapidly move a download save back with no name change, and---a second that renames and copy/moves back. Why not just ONE method? Since the second method removes the need for the first, why have the first?
No I am not really saying that.
 

Changing Content of Downloads?

  An additional point is perhaps more philosophical... 
  • In using a method to restore wiki from downloads I'm uncomfortable with idea we'd also be managing files in Downloads. Changing the content of downloads seems more for a dedicated backup system, or explicit deletion by the end user? 
I was not suggesting this so I am not sure what you mean. I say save in downloads, and the script will pull that away because you told it to. Most of the time there will be nothing in downloads only in your prefered folder.
 
  • In short, a "restore" script should not change anything in downloads?
Again I do not understand, I suggest no such thing except to keep the file (You used to open the wiki) up to date.
 

Wiki Pathing Collation Tool!

It would be possible to run a batch command in any folder that adds (appends) that folder to those to be scanned for in download folders. Even better would be to add this to the desktops file manager to get a r-click to select that folder. This iteration can also scan for subfolders.

  Neat idea! Like it!
  • What you point to is some method / tool to more easily identify Wiki and get their paths into a settings file? 
        Yes?

Using the command prompt go to a folder you want to include and type addtoscan.bat this can append the current directory to a batch file with echo >> scanfolders.bat that reads
twscan c:\tiddlywiki
twscan C:\Users\antho\Documents\bigdata

or better a file explorer extension r-click add to twscan.
  • I guess a standard "file picker" might also work? Maybe as part of a "configuration tool?" (I believe that might be possible via PowerShell? I just don't understand PS well enough to know how to do it). 
Yes but not necessary.
 

TW Files With Extension ".TW"
 

In windows at least a simple registry entry can associate .tw files with your default browser and clicking a tw file will open as usual in the browser. If this is done tw files could be placed in any folder with any files including other html files and you could even auto detect downloaded tw files and move them to a default folder.

With .tw files you could select your documents folder and it and all its sub folders could be scanned to locate .tw files to check for in downloads, and to identify where they beling. Again reducing the need for configuration.


I seen you mentioned the File Type ".tw" before in other threads. I think its interesting--as are many other of your ideas about leveraging the O/S & browsers to get a lovely system. Simple points ...
  • The current PS1 script could be modified, I think, to accept a range of extensions eventually. Like .html, .htm, .hta, .tw ...
  • In fact, I see no reason that it can't be totally agnostic about what file types it restores
Except if it is an extension we can presume to be a tiddlywiki we can depend on it being one. No possible conflicts. By the way the batch could run regedit32 tw.reg to do this.  
 

Download Naming
 

A recent change to tiddlywiki allows you to set the download filename before you download the first time. You could do this to ensure it is unique and maybe even name it to a .tw file. Then it would automagicaly be managed by the local scripts.


Useful info! I take a look. 

We could have some instructions or a method that you click on to use the .tw extencion.
 


Universal?
 

Whilst these solutions aim to be universal we do need a different one for each operating system, so will it ever be universal?


  My bad for not making clearer what I meant by "universal". I meant ...
  • Working in alignment with the standardised download saving and save naming mechanisms that all modern browsers support

Browser universal then. 
  • In other words "universal" as "one standard method for any browser"
But you are right, that, if this approach, currently limited to a Windows scripting language (PowerShell) gets somewhere it would need writing in other platforms' script languages. But ...
  • ... its not exactly settled yet what it is on Windows. Though the basic "restore" function is there and working. Other platforms later? 
of course, we are on the path 
  • Installation territory et al. Well that seems like "Repository" territory. Not there yet. The approach needs a lot more interest and input I think to begin to approach that.

Compatability with Existing TW Savers? 

A multiple os intaller could solve this. Having .tw files could make it possible to auto configure everything.

Using the above should be compatible with timimi being installed because once it is running you just open the wikis and timimi handles the save and no download occurs. Timimi already works with .tw files.

This process should work along with tiddlydesktop and tiddlyserver as well 


Yeah, the method using Mark S.' script at its core is compatible with other saving mechanism in TW. For the simple reason ...
  • If you use a TW dedicated saver then no TiddlyWiki will get written to Downloads so co-existence with TW savers looks assurred.
  • But, say you worked with a TW in Edge where normally you run in Firefox with Timimi ... You could use the "Nine-lives" script to restore the Edge edited version and just go back to Firefox and carry on from where Edge left off, no problem ...
Yes sure, but If its already running and does its job there is no needing to run anything. No "restoring" just automatic maintenance. This can be made very simple in that it saves tiddlywikis in a users document/tiddlywiki folder and they can run with that until the want to organise more deeply.
  • Basically the approach is Complementary to other methods of saving in TW. And its also Additive so you can include any browser brand. Using One method for all of them.
Tony, thanks very much for your very useful post. Please let me know if I misunderstood anything

Your welcome and I have, and Vica versa.

For example from a user perspective this is what I hope all they would need to know.
  1. Download and run this sentinel script
    1. It will create a documents folder called tiddlywiki
    2. Use the startup folder or scheduler to run this every time you start the computer or login
  2. Now place any tiddlywiki file in this folder, name it as you wish.
    1. Click on whichever wiki you want to open (in your default browser)
    2. Use your wiki and make changes as needed, then click save
    3. Without any other saver installed this will use the default saver and download your wiki to the download folder
    4. Just save with the default name.
  3. Keep using your wiki and save/download as many time as you want to the downloads folder
    1. Each time you save you wiki it will be automatically moved to your tiddlywiki folder. 
    2. Next time you save it will no longer be in your downloads folder and will save a fresh copy.
  4. If you script was not running you last save may still be there. so just save it as the recommended name 
    1. eg "tiddlywiki (1).html " "tiddlywiki (2).html"
    2. Next time you run the script these will be tidied up.
  5. Each time you wiki is saved the previous one is moved to the TiddlyWiki/backups folder and named tiddlywiki (1) ... (10)
    1. once more than 10 backups are available the oldest will be deleted (you can configure this)
Note: 3.1

For any file in your tiddlywiki folder the sentinel script, your download folder will be monitored for the existence of a file by the same name, if such a file appears because you used the download saver, it will promptly replace the on in your tiddlywiki folder, so you can open if from there rather than search your downloads folder.

Note: The first time you download a wiki Pick a unique filename for your tiddlywiki like not tiddlywiki.html or empty.html or you will replace the wiki of the same name in your tiddlywiki folder. Then use you file manager to move the downloaded wiki to your tiddlywiki folder. It will be processed by the script now.

Regards
TonyC:\Users\antho\Documents\bigdata

@TiddlyTweeter

unread,
Jul 1, 2019, 1:05:56 PM7/1/19
to TiddlyWiki
Ciao Mark S., TonyM and all,

Mark S. wrote:
Re the name, thinking maybe nein-lives (humour intended) or neun-lives just to avoid trademark infringement with the cat food company.

Okay. Slept on it. What about ... 

NINE-LIFE ?

TBH, I don't really mind what its called! :-) But I'd rather settle it so we can co-ordinate without ambiguity. 

["Hector" might be a good alternative :-). I thought Jed did well calling Bob "Bob":-)] 

Thoughts?

Best wishes
Josiah

@TiddlyTweeter

unread,
Jul 1, 2019, 3:05:19 PM7/1/19
to tiddl...@googlegroups.com
Dear TonyM

Thanks for taking precious time on this to reply in such detail. I really appreciate it. I will respond to the post details when I absorbed it fully.

But, before that, I wanted to comment that the aim in this is very pertinent.

In a quick, perhaps over-simple way, I'd say YOUR approach is about making the user experiece as easy as possibe? Mine definitely isn't (as yet).

IF what you layout in principle I can see in a working system I might give up what I am doing. But I grasp you are busy and maybe can't get to a working system at the  moment. 

Yet it could be very interseting if you did.

Best wishes
Josiah

TonyM wrote:... 
... For example from a user perspective this is what I hope all they would need to know.

Mark S.

unread,
Jul 2, 2019, 12:15:30 AM7/2/19
to TiddlyWiki
The attached is just to indicate that some progress is being made. The zip file has the PS file, the support library file, and the ini file. There's lots of stuff that needs to be tweaked, especially capturing the error messages -- maybe tomorrow? There's an S option on the menu that I used for testing that I need to take out. Probably the library needs to have the path to it specified.

I only tested it lightly, with one file /location. So, as usually, be sure to have backups.

Along the lines of "Bob", I was thinking maybe "Polly", like the parrot that repeats itself, which is what the script really does.

So eventually, if we settle on "polly", for example, there might be 5 or more files

polly.txt (for usage)
polly-vsn-initials.ps1 (the script)
polly.ini (the settings)
polly.bat (to launch with proper privileges)
Get-IniContent.ps1 (library for parsing ini file)

I say "or more" because it sounds like there are ideas out there for more advanced features that may also require libraries.

Thanks!
polly-01c-MS.zip

@TiddlyTweeter

unread,
Jul 2, 2019, 12:52:05 PM7/2/19
to tiddl...@googlegroups.com
Mark S. wrote ... 
... I was thinking maybe "Polly", like the parrot that repeats itself, which is what the script really does.

Ha! :-)  I like it! Not ostentatious. Quite descriptive. Why not?

Unless anyone else expresses an opionion I'm happy with that. Let's give it a couple of days and then settle on that perch?.

Best wishes
Josiah

@TiddlyTweeter

unread,
Jul 2, 2019, 1:04:45 PM7/2/19
to TiddlyWiki
Mark S. wrote:
The attached is just to indicate that some progress is being made.

Its looking good! I have it working. 

I hoping by tommorrow I can have ready for you a version that integrates your changes. Plus some changes I made. Like being able, from a paramater, to load different settings files. 

Regarding  your "test" menu option. I'll include it & give a switch in Internal Settings to turn it on/off. 

I am trying to be as quick as I can so we don't get out of step.

Best wishes
Josiah
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

@TiddlyTweeter

unread,
Jul 3, 2019, 11:45:41 AM7/3/19
to tiddl...@googlegroups.com
Ciao Mark

Its looking good! Your work--well, I could not have done it!! Molto grazie.

GG won't at the moment let me send attachments. But you should be able to download it from here ... 


 I hope it works for you. I don't see any issues but it was a lot to bring it together. 

I integrated you changes with my changes, I hope ok. But please let me know if I messed up. My changes were ...

-- Created a  # TEST  section that I hope will make your needed experiments easier

-- Shifted your ini processing library into the sub-dir  .\lib  (I fear the main directory will get cluttered if we don't)

-- Added a menu item for  R - Run Tests  and an internal setting for switching it on and off (its "on" in what I'll send)

-- Put  # RUN INFO  section into a seperate function to make it more re-usable (now it runs first every time you hit  "R - Run Tests" ) . Added the Timer settings.

-- Added ability to turn off menu option  T - TiddlyWiki Folder  listing (I think it could be confusing if you don't keep all wiki under one folder) in internal settings. ??But still not sure about it??

-- Replaced all instances of  "$ninelives"  with  $appAndVer 

-- Re-arranged  # INTERNAL SETTINGS  and removed dead-wood

-- Added command-line parameter  -ini  so you in can (in theory) have more than one instance of the script doing different things at the same time (this is in testing)

-- Added file type  .tw  to the two informational directory listings (wikis & downloads) -- largely because of TonyM's promotion of that idea and thoughts of possible interworking with his approach.

Quick note on files ...
 
Mark S. wrote:
So eventually, if we settle on "polly", for example, there might be 5 or more files

polly.txt (for usage)
polly-vsn-initials.ps1 (the script)
polly.ini (the settings)
polly.bat (to launch with proper privileges)
Get-IniContent.ps1 (library for parsing ini file)

Just FYI, I currently have, in addition ...

polly-menu.bat
polly-once.bat
polly-auto.bat

A limitation in Powershell is "switch" (used for the "menu") doesn't have a timeout like "choice" in bat files have. 
So you can't run the script in "menu" mode and expect it to switch to "auto" mode after a timeout. You have to explicitly select an option.
I'm sure there is a way to do it but its beyond me at the moment. The "mode" bats get around that. 

Menu mode is necessary for setup (its the default, same as "polly.bat"). 
After that you can just use "auto" to initiate the file monitor without  any menu.

Many thanks!

Best wishes
Josiah
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Mark S.

unread,
Jul 5, 2019, 11:50:34 PM7/5/19
to TiddlyWiki
Note: I can't attach the zip file at the moment. I'll have to find some other mechanism if G doesn't change its ways.
Very strange, since I was able to attach a zip just 2 days ago.

Hi TT,

Changes I made:

* Made the batch files refer to "shim.bat" so we only have to refer to the PS script by name once (otherwise we are likely to make a mistake sooner or later).
* Allow file names with a period in them
* Take extension from file name -- so now you can use htm, html, tw or whatever works for you
* Check for error where there is no download file yet.
* Added some basic explanation to polly.txt. It needs to be formatted better, but we'll have lots more text to add presumably.

Your original settings are in TT.ini.

Thanks!

@TiddlyTweeter

unread,
Jul 6, 2019, 8:54:32 AM7/6/19
to TiddlyWiki
Hi Mark S.

TX! Looking forward to it!

"Bypass" for Sub-Modules Issue in PowerShell

One issue I wanted to mention is that if you use dependent modules, like we do with the new ini parser, "bypass" is not active for that particular script. I'm unclear whether we can dynamically override its net origin in the script istelf?

Maybe we should do it via a PS command line in the polly.bat? Its silent so the user would not need to get scared?

Best wishes
Josiah

@TiddlyTweeter

unread,
Jul 6, 2019, 9:34:13 AM7/6/19
to tiddl...@googlegroups.com
Ciao Mark S.

PowerShell Permissions - Initial

I wrote an experimental crude batch file that  tries to deal with the two levels of permissions needed for PS script running. "Bypass" is  relatively easy. "-executiion-policy" where it is "Restricted" needs explicit action to change it, and often, elevated priveledge. 

I'm doubtful about including the tool in a release. 
I wrote it for testing permissions. And to quickly "Unblock" updated modules you send me.

Anyway, its here in a very early iteration, if you are interested: https://drive.google.com/file/d/18Pr1ISSeWj_ZKmE8EluXihRRAexzab0g/view?usp=sharing

Best wishes
Josiah

Mark S.

unread,
Jul 6, 2019, 9:39:32 AM7/6/19
to TiddlyWiki
So Gmail doesn't like the bat files, but it was just fine with powershell files. Maybe next time I'll try encryption. Meanwhile, here's the file

Mark S.

unread,
Jul 6, 2019, 9:42:40 AM7/6/19
to TiddlyWiki
What are you seeing when you run the scripts? When I run the scripts, I have to give it permission twice -- once for the outer script and once for the library.

Thanks!

@TiddlyTweeter

unread,
Jul 6, 2019, 9:49:27 AM7/6/19
to tiddl...@googlegroups.com
Eek! I should have said that experimental .bat should only be run from the sub-dir ".\kit" of Polly!


On Saturday, 6 July 2019 15:34:13 UTC+2, @TiddlyTweeter wrote:
Ciao Mark S.

PowerShell Permissions - Initial

I wrote an experimental crude batch file that  tries to deal with the two levels of permissions needed for PS script running. "Bypass" is  relatively easy. "-executiion-policy" where it is "Restricted" needs explicit action to change it, and often, elevated priveledge. 

I'm doubtful about including the tool in a release. 
I wrote it for testing permissions. And to quickly "Unblock" updated module you send me.

Anyway, its here in a very early iteration, if you are interested: https://drive.google.com/file/d/18Pr1ISSeWj_ZKmE8EluXihRRAexzab0g/view?usp=sharing

Best wishes
Josiah

@TiddlyTweeter

unread,
Jul 6, 2019, 9:54:53 AM7/6/19
to TiddlyWiki
My base PS permissions are ...

  CurrentUser    Unrestricted

i only see permissions prompts for downloaded scripts, but not even for them when execution-policy "bypass" is in place on a launch argument.

TT

@TiddlyTweeter

unread,
Jul 6, 2019, 10:35:33 AM7/6/19
to tiddl...@googlegroups.com
A bat file itself, on download, can need a permission to run.

- The advantage is that its easier than stricter PS scripts as its just one step.

- And once allowed to run, it can, for Polly, mark her scripts as runable (IF user is Unrestricted or Noremote). 

- Its PS scripts, I think, that get blocked, not PS itself, that continues to respond to the command line?

But something IS needed. 

For instance, if you simply move the scripts to a new directory the same issue can re-occur.

My feeling is to have a way to deal with it at initial run-time, once in bulk. Not have to do each module one-by-one.

Best wishes
Josiah

@TiddlyTweeter

unread,
Jul 6, 2019, 11:16:04 AM7/6/19
to tiddl...@googlegroups.com
Ciao Mark S.

The ".ini parser" library is very elegantly written. Its incredibly compact!

I been experimenting with it to allow Comment Lines to start "-" and not just ";".  (Easy, as its a simple regex in the lib)

Right, that breaks what an ".ini" is supposed to be. BUT it LOOKS better for our needs. 

Should I worry that the "trickydicky" option is ...
 

;--- WHERE TRICKYDICKY LIVES
trickydicky
=Barking


     or 


--- WHERE TRICKYDICKY LIVES
trickydicky
=Barking


I prefer the latter.
 
TT 

Mark S.

unread,
Jul 6, 2019, 12:37:46 PM7/6/19
to TiddlyWiki
Just be sure everything is launching OK.

The original library code bizarrely sent the comments back to the calling script. This would have called for a lot of additional complexity back in the script and forced a naming convention, so I took that part out.

Thanks! 

Mark S.

unread,
Jul 6, 2019, 1:18:19 PM7/6/19
to TiddlyWiki

Gasp! Can't ... catch ... up ...

Of course I made the mistake of running your script from the app directory.  ;-)

When running the script, after it lists the ps1 file, it dumps you at a prompt that looks like the powershell prompt. You think the script is done, but it's not. So, it seems to need the
action prompt there, or maybe a prompt "press any key to continue".

Outside of that, once it ran, I was able to run the scripts without getting prompted, which is nice.

Thanks!

  | UNBLOCK SCRIPTS
 
|
 
| Check the list of "Scripts Found" below.
 
| It should include "lib\Get-IniContent.ps1".
 
|
 
| If it does, click [U] to Unblock them all.
 
|
 
| [H] if you need further help (opens browser)

Scripts Found ...

polly
-01d-TT.ps1
polly
-01e-MS.ps1
lib
\Get-IniContent.ps1
PS C
:\Users\Mark\Downloads\polly-01e-MS> U
U
: The term 'U' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included,
verify that the path
is correct and try again.
At line:1 char:1
+ U
+ ~
   
+ CategoryInfo          : ObjectNotFound: (U:String) [], CommandNotFoundExcepti
   on
   
+ FullyQualifiedErrorId : CommandNotFoundException


? | Get Help (online), Unblock, return to Permissions, or Quit: [H,U,P,Q]?


@TiddlyTweeter

unread,
Jul 6, 2019, 1:52:54 PM7/6/19
to TiddlyWiki
Eek! I must be doing something wrong ...

I get this ...

? | Get Help (online), Unblock, return to Permissions, or Quit: [H,U,P,Q]?U

   | Unblock completed. Hopefully you saw no error messages.
   | Unblock only shows information when it can't complete.
   | With no errors you should be good to go.

? | Return to Permissions, or Quit: [P,Q]?

@TiddlyTweeter

unread,
Jul 6, 2019, 1:57:40 PM7/6/19
to TiddlyWiki
What version of Powershell are you on? I need rule out that is an issue, I think.

J.


On Saturday, 6 July 2019 19:18:19 UTC+2, Mark S. wrote:

Mark S.

unread,
Jul 6, 2019, 2:02:35 PM7/6/19
to TiddlyWiki
PS 4.

@TiddlyTweeter

unread,
Jul 6, 2019, 2:09:37 PM7/6/19
to TiddlyWiki
Tx. I wrote it in 5.1.  I need try rule out its a 4 to 5 issue first I think.

Later (somewhat slowed)
TT

@TiddlyTweeter

unread,
Jul 6, 2019, 2:57:27 PM7/6/19
to TiddlyWiki
I am making mistakes. 


--- WHERE TRICKYDICKY LIVES
trickydicky
=Barking


TrickyDicky really came from ... Billericay


--- WHERE TRICKYDICKY LIVES
trickydicky
=Billericay


 https://www.youtube.com/watch?v=0jrkWygIqt0

TT 

 

 

Mark S.

unread,
Jul 6, 2019, 3:42:20 PM7/6/19
to TiddlyWiki
Ok, I upgraded to 5.1 and now am seeing what you see.

Probably everyone who gets forced to upgrade to Win 10 will have 5.1+ automatically.

I always like to lag behind on upgrades in case something disastrous happens.

Thanks!

@TiddlyTweeter

unread,
Jul 6, 2019, 4:42:09 PM7/6/19
to TiddlyWiki
Thankyou for doing that Mark! 

You saved me a load of work! And relax me that I hadn't created some weird thing that only worked for me. 

It now looks very much like a "version" issue.

But it seems to me we should support 7 with 4. I'm trying to find any resource that lays out the differences to see if it fixable.

Best wishes
J.

Mark S.

unread,
Jul 6, 2019, 8:03:48 PM7/6/19
to TiddlyWiki
It appears that once you have unblocked a file, and then zipped it up, when you unzip it again it is still unblocked. Or at least preliminary results suggest that.
So only "super-users" need to worry about running the permissions unblock script (or the same thing, right clicking on files and unblocking them).

BTW, you were able to download polly-01e-MS.zip, right?

Thanks!

On Saturday, July 6, 2019 at 6:34:13 AM UTC-7, @TiddlyTweeter wrote:
Message has been deleted

Mark S.

unread,
Jul 7, 2019, 11:57:55 PM7/7/19
to TiddlyWiki

This is version polly-01f-MS.

Changes:

* A fix to Get-IniContent that was causing it to read commented files as active files.
* A change to menu item "T" (show tiddlers from wikidirectory) simplifying the code in preparation for a system that will monitor the wiki folder
* Permissions.bat is down in the dev directory -- for now

Hopefully I didn't mess anything up too bad. If so, it can be fixed on the next go around.

@TT I didn't see any changes in Get-IniContent that changed the commenting system -- were those changes only in your own kit?

Thanks!

@TiddlyTweeter

unread,
Jul 8, 2019, 7:00:19 AM7/8/19
to tiddl...@googlegroups.com
Tx Mark!

I'll get to it soon.

I got delayed. I'm working on a "demo/test" version that is a clone of the original but in which the "wiki" are dummy files with no content whose (fake) "downloads" get their write time changed automatically at set intervals. 

The idea is to launch a seperate "touch" process first before the "restore". 

It changes nothing in the main script.

It is to make "scenario" testing much easier, lighter weight (no actual TW needed, just pseudo-wiki and a pseudo "Downloads") and less potentially dangerous, as its contained.

A dopo
Josiah

@TiddlyTweeter

unread,
Jul 8, 2019, 7:49:01 AM7/8/19
to tiddl...@googlegroups.com
Ciao Mark

I wanted to log with you now that as this thing shapes its getting clearer to me it can be leveraged and add functions TW itself can't so easily do ...
 
Download saves enforce singular naming, so as a "surrogate central repository" of unique wiki its seems easy for modules to be added that don't just restore but also, for example ...
 
   1 - Create a copy into a consoldated single BACKUPS folder that Timestamp the saved wiki with a time prefix of their last-write time
     
   2 - Restore to mutiple places (simply using a different ini, same method) for, say "My Uploads to the internet" (using an .ini that will monitor a directory you actually never edit the wiki in but do need updating regularly). Handy if you regularly need to update upload folders.

   3 - Create COLLECTIONS. In addition to Restore original, by having ONE directory into which a copy of the latest versions of a wiki is written. Again its not for wiki you actually edit, but its a place you can gather all you have ...

Its a bit conceptually difficult at first? 

But the point is "Downloads" became a de-facto HUB which can be used in many ways to support diverse need and copy wiki to unlimited destinations in diverse ways.

Its not just restore we talking about, I think??

Hope this is clear!

Its interesting!

BTW, "POLLY" was a good suggestion on name by you!  It works well ...

Annotation 2019-07-08 140530.jpg


Best wishes
Josiah

@TiddlyTweeter

unread,
Jul 8, 2019, 8:09:42 AM7/8/19
to tiddl...@googlegroups.com
For those on email, I updated my last post to carify it. Best, TT

On Monday, 8 July 2019 13:49:01 UTC+2, @TiddlyTweeter wrote:
Ciao Mark

I wanted to log with you now that as this thing shapes its getting clearer to me it can be leveraged and add functions TW itself can't so easily do ...
 
Download saves enforce singular naming, so as a "surrogate central repository" of unique wiki it seems easy for modules to be added that don't just restore but also, for example ...
 
   1 - Create a copy into a consoldated single BACKUPS folder that Timestamp the saved wiki with a time prefix of their last-write time
     
   2 - Restore to mutiple places (simply using a different ini, same method) for, say "My Uploads to the internet" (using an .ini that will monitor a directory you actually never edit the wiki in but do need updating regularly). Handy if you regularly need to update upload folders.

   3 - Create COLLECTIONS. In addition to Restore original, by having ONE directory into which a copy of the latest versions of a wiki is written. Again its not for wiki you actually edit, but its a place you can gather all you have ...

Its a bit conceptually difficult at first? 

But the point is "Downloads" become a de-facto HUB which can be used in many ways to support diverse need and copy them to unlimited destinations in diverse ways.

Its not just restore we talking about, I think??

Hope this is clear!

Its interesting!

BTW, "POLLY" was a good suggestion on name by you!  It works well ...

@TiddlyTweeter

unread,
Jul 8, 2019, 9:25:09 AM7/8/19
to TiddlyWiki
Mark S. wrote:
* Permissions.bat is down in the dev directory -- for now

That seems right to me. To put it there. I fails with PS 4.

The whole PowerShell 4 v. 5 could be an issue? 

It worries me coding that looks fine to me (Win 10, PS 5.1) may fail on earlier versions on PS?

As far as I understand it, Win 7 is installed with PS 4? The PS docs docs don't clearly indicate the differences between versions. You have to worm your way through them case by case to figure it out.

Eventually I would like test in PS 6 (aka "PS 6 Core" that is cross platform). Just getting things to work is a lot. Later.

Best wishes
Josiah

Mark S.

unread,
Jul 8, 2019, 10:32:17 AM7/8/19
to TiddlyWiki
I'm a little vague about about the difference between #2 and #3.

Are parrots where you come from not obsessed by crackers?

Just in time, today's Bizarro:

Mark S.

unread,
Jul 8, 2019, 10:40:38 AM7/8/19
to TiddlyWiki
Actually, I think Windows 7 ships with Powershell 2. So I must have already run some updates. It gets worse. You
can have the same version of Powershell but on Windows 7 some of the commands may not do anything
because the framework code doesn't allow it (I don't recall which command ... probably something obscure
like determining mounted volumes).

Technically there's only 6 more months left of Windows 7 left, so the problem sort of fixes itself. I'm not fond of Windows 10.
It feels like you're working on sort of garrish cross between the loser at the quilting bee and a pin ball machine. Plus,
every week it seems I'm reading how another Win 10 update just bricked a few thousand more machines. But I suppose
it doesn't help to rail against the machine.

@TiddlyTweeter

unread,
Jul 8, 2019, 11:05:33 AM7/8/19
to tiddl...@googlegroups.com
Mark S. wrote:
Actually, I think Windows 7 ships with Powershell 2.

Ouch!
 
So I must have already run some updates. It gets worse. You
can have the same version of Powershell but on Windows 7 some of the commands may not do anything
because the framework code doesn't allow it (I don't recall which command ... probably something obscure
like determining mounted volumes).

You giving me nightmares that what we trying do is in the "too complicated" section :-)
 
Technically there's only 6 more months left of Windows 7 left, so the problem sort of fixes itself. I'm not fond of Windows 10.
It feels like you're working on sort of garrish cross between the loser at the quilting bee and a pin ball machine.

If we can support 7 I think it would be a good idea. Official death may be a few months away, but I doubt end users will murdered quickly? Thought.

I like 7. Its kinda XP with a good enough security guard that XP lacked. But I loved XP for its flex. 

10, its what I have now. Its par for the course.  Like it or lump it. 10 makes some previous easy things difficult (though does add useful integration of things like voice recognition). 

In particular, 10 does not like Portability that wants to use system file types. That conflict between local and (transient) portable file types is a major PITA for me. It got worse when browsers (for the same reasoning) lost their bollocks. 

Josiah

@TiddlyTweeter

unread,
Jul 8, 2019, 11:16:57 AM7/8/19
to TiddlyWiki

Polly, at this early stage of development, is seeking assurance ...

Annotation 2019-07-08 171125.jpg


On behalf of Polly
TT

@TiddlyTweeter

unread,
Jul 11, 2019, 1:55:45 PM7/11/19
to TiddlyWiki
Ciao Mark S.

Quick update. Your 01e-MS & 01f-MS seem fine. I test a bit more. 

I agree with your changes, particularly on the "T" option where you show understanding of PowerShell coding I don't have.

BLOCKS

Regarding Unblocking. ALL ".bat" and ".ps1" in your zip were Blocked. Windows 10 complains they are not signed. I expanded my permissions Block zapper to include ".bat". 

I think the blocking is an issue. Its a shame the zapper doesn't work on PS 4 cause all you'd need do is unblock the permissions.bat file and zap the rest. 

"Bypass", gets round it though, right? 

But I'm unclear when happens when one script loads another. Maybe there is a way to "Bypass" on those module loads too.

I have a demo version nearly working with auto creation of "downloads". I may need a few days to hone it.

Best wishes
Josiah

 

Mark S.

unread,
Jul 11, 2019, 2:13:50 PM7/11/19
to TiddlyWiki
I think if you right-click on the zip file and look at the properties you can unblock the zip file. Then everything that unzips from it will also be unblocked. I think. So just one unblock action required.

What do you mean by "auto creation of downloads" ?

I was vaguely thinking of working on zipped backups. Zipping is possible with 5.0. I would think anyone in a business environment will have PS 5. If not now,  then
certainly in January 2020. Anyone with a home machine can upgrade for free.

It's been pointed out to me that when you install git from github, you also get a free bash shell. So it might be that the ultimate universal batch file solution may run
in a bash shell. But the PS scripts could be used as a guide, especially the dialogs, where the code is nearly identical between systems.

@TiddlyTweeter

unread,
Jul 11, 2019, 2:32:31 PM7/11/19
to TiddlyWiki
Mark S. wrote:
I think if you right-click on the zip file and look at the properties you can unblock the zip file. Then everything that unzips from it will also be unblocked. I think. So just one unblock action required.

Good tip. I'll do that next time. 

What do you mean by "auto creation of downloads" ?

Rather than have to have a browser open and an actual wiki you manually save I am using a Powershell zombie "touch" function to auto-create and update pseudo-wiki files in the downloads folder at regular intervals. At the end of a cycle it starts over. You can run it in parralel with the Polly scripts. I think it will ease testing. I just need to test a little bit longer before sending it you.

I was vaguely thinking of working on zipped backups. Zipping is possible with 5.0. I would think anyone in a business environment will have PS 5. If not now,  then
certainly in January 2020. Anyone with a home machine can upgrade for free.

Very good idea. 

I had thought that in addition to restore process it would be easy to have (a) "collections" where all the wiki in a settings file can be copied to a single folder (in adition to restore of original). (b) Same thing to one folder but with a prefixed time-stamp to make them a permanent version/backup rather than an over-write.
 
It's been pointed out to me that when you install git from github, you also get a free bash shell. So it might be that the ultimate universal batch file solution may run
in a bash shell. But the PS scripts could be used as a guide, especially the dialogs, where the code is nearly identical between systems.

When its a big further on I want to see if what we did will work in PowerShell 6, which is cross-platform. If it does work in it it would be a further indication it could be converted for Bash I think. 

TT

Mark S.

unread,
Jul 11, 2019, 2:44:37 PM7/11/19
to TiddlyWiki
Hello TT


On Thursday, July 11, 2019 at 11:32:31 AM UTC-7, @TiddlyTweeter wrote:

Rather than have to have a browser open and an actual wiki you manually save I am using a Powershell zombie "touch" function to auto-create and update pseudo-wiki files in the downloads folder at regular intervals. At the end of a cycle it starts over. You can run it in parralel with the Polly scripts. I think it will ease testing. I just need to test a little bit longer before sending it you.


Wow. You're creating a test harness -- the way you're supposed to do things.
 

I was vaguely thinking of working on zipped backups. Zipping is possible with 5.0. I would think anyone in a business environment will have PS 5. If not now,  then
certainly in January 2020. Anyone with a home machine can upgrade for free.

Very good idea. 

I had thought that in addition to restore process it would be easy to have (a) "collections" where all the wiki in a settings file can be copied to a single folder (in adition to restore of original). (b) Same thing to one folder but with a prefixed time-stamp to make them a permanent version/backup rather than an over-write.

Is that 3 different things/directories/settings, or one thing all at once?
 
 
When its a big further on I want to see if what we did will work in PowerShell 6, which is cross-platform. If it does work in it it would be a further indication it could be converted for Bash I think. 


Cross-platform? Really? What platforms is it going to work on?

Thanks!

 

Mark S.

unread,
Jul 11, 2019, 5:44:18 PM7/11/19
to TiddlyWiki
polly-01g-MS


* Added backup to a date-stamped zip file if a backup zip directory is specified. There's a new INI setting that allows this.
* Found remaining ninelives variable and switched it to new version variable

The zip occurs *before* a file is *retored* from the download directory, on the theory that that way the version being saved will always be something
that was in the restore directory, and never something accidentally co-named in the download directory.

Note also that there is a message flashed on screen when the compression occurs. This comes from the PS utility itself. It might be possible to suppress that if desired.

Thanks!

On Thursday, July 11, 2019 at 11:32:31 AM UTC-7, @TiddlyTweeter wrote:

@TiddlyTweeter

unread,
Jul 12, 2019, 6:56:59 AM7/12/19
to tiddl...@googlegroups.com
Mark S. wrote:
TT: When its a big further on I want to see if what we did will work in PowerShell 6, which is cross-platform. If it does work in it it would be a further indication it could be converted for Bash I think. 


Cross-platform? Really? What platforms is it going to work on?

MacOS, Windows, Linux

Microsoft won't develop PS 5 further, only provide bug fixes.  6 (aka "PS Core")  is more limited than 5 because its cross platform.


How much Mac or Linux users will adopt it is unclear. What is clear is that if your PS code can run in 6 its likely very compatible with Bash.

Best, TT

@TiddlyTweeter

unread,
Jul 12, 2019, 9:49:12 AM7/12/19
to TiddlyWiki
Mark S. wrote:

BLOCKS  REVISITED

FYI, indeed, following your tip, Unblocking the ZIP was enough.

This is something for usage docs, I think, if we get that far.

All is well with "01f". I'll now play with "01g".

A dopo
Josiah

 

Mark S.

unread,
Jul 12, 2019, 10:36:02 AM7/12/19
to TiddlyWiki
That's interesting! Unexpected that 5.1 is end-of-the-road.

Offering another script technology to Linux users is like, how do you say it, "carrying coals to Newcastle" ?

@TiddlyTweeter

unread,
Jul 12, 2019, 10:43:13 AM7/12/19
to TiddlyWiki
Mark S. wrote:
.... "carrying coals to Newcastle" ?

That is my feeling too. 

@TiddlyTweeter

unread,
Jul 12, 2019, 1:37:19 PM7/12/19
to TiddlyWiki
Mark S. wrote:
polly-01g-MS
... there is a message flashed on screen when the compression occurs. This comes from the PS utility itself. It might be possible to suppress that if desired.

That turquoise "flash" of a message (you can't read, its too quick) makes you think something may be wrong. 

If it could be surpressed I think it would be a good idea.

The actual system of zipping seems very smooth in what I tested so far. This dimension of the tool illustrates well its more than just restore.

TT
It is loading more messages.
0 new messages