This is a continuation of https://groups.google.com/forum/#!topic/tiddlywiki/tMLfNs1K3JU%5B1-25%5D that got too long.
Mark: I'm not exactly sure how to use the PollyDev wiki.
Mark: You're going to write an entire setup wizard in PS ?
For documentation, if you're going to have diagrams, you could launch a TiddlyWiki file with the default browser. I suppose it could be used for setup too.
polly-01i-TT.ps1 -----------------------------------------
Added: Console Buffer setting so very long paths don't wrap and ruin the layout Simplified: Menu options hiding. Now if settings don't have options set for them the display of them is always hidden Added: Menu item "B - Backups" to list content of Backup & Zip Archive folders Added: Menu item "P - Parrots", just a **placeholder** for now Added: Two new URLS to web links Added: DESCRIPTION to the settings (optional): useful if you have more than one .ini file
Added: "#region Name ... #endregion Name" psuedo-comment pairs (in PowerShell IDE they
let you collapse/expand sections). Purely for my own use. In run they are ignored.
Revised: Directory displays to be more relevantly laid out and compact Removed: "Run Info" from the "U - Usage" screen to simplify it Replaced: "E - Edit Settings" with "S - My Settings" that displays a settings sub-screen Moved: "Run Info" display into "S - My Settings" sub-screen Revised: Many cosmetic aspects of the interface, especially feedback when The Restorer is running Removed: Most of my "dead wood" comments
Get-IniContent.ps1 --------------------------------------
Revised: (a) "-" in addition to ";" as a comment start (b) discard whitespace both before and after [section] (c) discard trailing whitespace on "key=value"
polly.txt -----------------------------------------------
Revised: Trying to combine your useful text with mine (**half-done**) But, I'm not sure how much text is workable paged in PowerShell. It maybe, other than a summary note, that using TW would be much better??
Knowing how much info is needed is quite difficult.
Note for Mark S.: In your central Restorer "while" loop I've added slightly different messaging for the end user. I hope you think its okay. Its left-offset at the moment so you can quickly see what it is. Let me know what you think.
Added: DESCRIPTION to the settings (optional): useful if you have more than one .ini file
Added: "#region Name ... #endregion Name" psuedo-comment pairs (in PowerShell IDE they
let you collapse/expand sections). Purely for my own use. In run they are ignored.
19/07/20 -- There are issues with .\lib\Get-IniContent related to whitespace handling. In the "test" version of Polly I discovered that IF a "[parrots]" setting line has trailing spaces it will fail to parrot. I'll change the module's regular expressions for next version so this is, hopefully, no longer an issue. The draft code changes are at: https://tidbits.wiki/polly/polly.html#Get-IniContent.ps1%20-versioned under "Info > Versions > item 2"
.... Have you tried the TiddlywikiWatcher
#$ini[$section][$name] = $value
In my own copy I've used your GIC from tidbits but adding "continue". So if I'm the next one to update
both sets of changes will be there. I've also listed your changes and my changes in the comments at the
top to ease confusion.
1.4 - 2019/07/18 - Various changes to section tests (TT)
1.5 - 2019/07/22 - Needs 'continue' at bottom of section test (MAS)
Thanks!
It's probably time to reconsider the file-globbing versus regular expression approach. File-globbing was good, but it does limit the name comparisons.You're good with regular expressions ;-)
What would be a good matching rule so that stem matchesstem(1)stem (1)stem (1)(2)BUT NOTstem (old)stem (john)I'm thinking that a match that searches for stem<space>*<left brace><number><non-greedy-indicator>
This would mean people couldn't deliberately use (number) in their stem names, but would open up stems that
currently would match (e.g. polly vs polly-dev)
(a) describing Polly got easier;
Its a Minority Report.It saves wiki, does backup (timestamped, zip or normal, or both), plus auto-cloning of wiki to secondary locations.
Regardless of browser. Any modern browser will do. No plugins.
Its complimentary to other TW saving methods. Its additive, or it can be used just on its own to restore downloads.
@TiddlyTweeter wrote:Its a Minority Report.It saves wiki, does backup (timestamped, zip or normal, or both), plus auto-cloning of wiki to secondary locations.Automatically, right?
Regardless of browser. Any modern browser will do. No plugins.
No plugins in the browser, right? Beause it is a TW plugin... or is it a separate software that I need to run every time I start up TW?
If the latter, does it do this for all active TWs or must I manually "add" each TW that it is supposed to work for?
Its complimentary to other TW saving methods. Its additive, or it can be used just on its own to restore downloads.You mean the features that it has that other savers do not? And no conflicts with other savers?
What does "restore a download" mean? Maybe overwrite the latest file with a backup file?
... must I manually "add" each TW that it is supposed to work for?
[wikiname-literal][regex-of-number-cruft][.extension-literal]
(\s*\(\d+\))*
01j-MS is ... Looking good!
Over next few days I'll do second test set that is less noisy and gives better feedback on outcome.
TT
"-run parrot-now"
Q: SHOULD they be stamped with the moment of CREATION of the backup or Archive?
Or should they be stamped with a cloned time of the LASTWRITETIME of the Wiki Backed-up or Zip Archived?
Pollie Fallory (74): https://www.youtube.com/watch?v=kG4ukbx97Vw
At the time I made it I was mostly worried about creating unique file names that wouldn't clobber each other.
1 - basic tests on name & number in downloads removal of numbers for save (files are given content on phase 1 so you can see time AND size in results)
2 - advanced tests on name and number (basically, the regex works)
3 - basic reporting on backups and zip archives
4 - parroting check.
At some point, if we can figure how to do it, it would make more sense to stamp them with the original date stamp, since that'swhat you're going to be looking for if you have to do a restore-from-backup.
...\backupdir\wikiname-ext\wikiname-datestamp.ext
I'm working on the new timestamp and subdirectories routines.I think adding zips to a single archive would be inadvisable since as it increases in size it will takelonger and longer for the backup to process. Eventually it will probably crash.
An ambitious enhancement would be to delete all but the last x number of backups. Of course, it'salways a little worrying to be deleting things.
polly-01k-MS.zipThis should be the "complete" kit for anyone following along. Not complete in terms of documentation.
| WHAT DOES POLLY DO? | | Restore - Without any plugin saver TiddlyWiki uses the browser "downloads" folder | ------- to save files like this ... | | mywiki (3).html | mywiki (2).html | mywiki.html | | With each new save the number increases by 1. | | Polly works out what wiki saved which file and RESTORES the | latest version, removing the number and overwriting the original. | | When the user RELOADS their wiki in the browser the restored version | loads. | | Backup - Polly can make a copy of your wikis and time-stamp them to a | ------ backup directory. | | The latest backup is always of the previous version of a wiki, | not the latest restored version. | | Zip Archive - Polly can create a zip archive of your wiki and archive a | ----------- time-stamped version to a Zip file. | | The latest archive is always of the previous version of a wiki, | not the latest restored version. | | Parrot - A "parrot" is a clone, or copy, of a wiki to another | ------ location. Parrots include TiddlyWiki based websites being | prepared for upload to the internet. Automating this | process through Polly is labour saving. | | Note: Parroted wikis get over-written by the latest | restored version of the wiki. | | Parrot Mode - There is also a "parrot" (only) mode. This "parrots" | any files under [wikis] listed for cloning in [parrots]. | It copies the files regardless of whether they are restored or not | Its most useful if you are maintaining a secondary repository. [NOT YET DONE].
| INSTALLATION | | TiddlyWiki 5 - Polly works with TW5 on all modern browsers. Any browser | with "download saving" should work with Polly. | | TW Classic - Polly works with TWC on most modern browsers. [NEEDS CHECKING] | An exception is Edge. Chromium/ Edge (expand) work with TWC. | | Requirements - ??? Windows ver? Powershell lowest ver? | ------------ | Polly installation makes NO changes to your computer's | setup. | | Note: you may need to grant permissions, after installing, | to let it run. | | STEPS | | 1. Download - ??? What, where?. | -------- | Downloads of Polly carry their version as a 3 character string. | For instance: "polly-01p.zip" is "version '01', edition 'p'. | The version will be displayed when you run Polly. You can | ignore it, unless you have a problem to report. | | 2. Unblock - Once you have downloaded "polly-xxx.zip", navigate to | ------- downloads in a file explorer and right-click the file. | Click on "Properties" and look for "Unblock" and select and | Apply it. | | This will "Unblock" all scripts in the downloaded zip file. | | 3. Un-Zip - Once you have "Unblocked" the downloaded the zip, right click | ------ to "Extract All". | | 4. Folder - Create a folder where you want to install Polly. (It can | ------ be anywhere.) Copy the contents of the un-zipped "polly-xxx" | folder to it. | | Polly should now be installed on your computer | | PERMISSIONS POLICY CODA | | Polly is written in the Windows scripting language "PowerShell". | | In can happen that, initially, running scripts may not be allowed due to | an existing "ExecutionPolicy" on the computer. | | Its easy to change the policy to be able to run Polly. There are | notes on Permissions here ... [EXPAND]
| FIRST USE: CREATE INITIAL SETTINGS.INI FILE | | Start - Click "polly.bat" to start Polly. On first run you may see a | ----- message saying ... [NOT DONE YET] | | "Now, let's create your first settings file!" | | Your first settings file must be called "settings.ini". Polly detects | if it exists and will prompt you to make it if it doesn't. | Once created you can have as many additional ".ini" setting files | as you want. | | Naming - BEFORE you add any settings for Polly its important to | ------ understand it utilises the "downloads" folder. And the downloads | folder can only accurately save files with unique names. | | So, all wikis monitored by Polly, MUST have *UNIQUE* names. | | Paths - All *wiki files* you want Polly to monitor and their *directories* should | ----- exist before you enter them in settings. | | All *directories* for Backups, Zip Archives and Parrots should exist before. | you enter them in settings. | | If paths don't exist when Polly runs a restore PowerShell will present error messages. | | Portable - Polly can be used portably from a USB stick if paths [NOT WORKING YET] | Pathing in settings to wikis use relative addressing. All relative pathing needs | ------- to be relative to the application directory. | | Note: the "Downloads" folder still needs to be at an | absolute address. This is because most browsers require it. | | .INI FILE | | "*" indicates minimal settings required for Polly to function. | | * [general] - Required. Section header for basic settings | | inidescription= | Optional. Useful if you have more than one .ini file. | | waitseconds= | Optional. Seconds to wait between checks in "auto" mode. | Defaults to 60 seconds. | | * downloaddir= | Required. Directory where browser downloads are saved. | | wikidir= | Optional. Useful if your wikis are nested under one directory. | | backupdir= | Optional. Directory to create date-stamped backups in. | | backupzipdir= | Optional. Directory to create date-stamped zip archives in. | | A basic settings file might look like this ... | | [general] | inidescription=My Basic Settings | downloaddir=C:\Users\Polly\Downloads | wikidir=C:\Users\Polly\Documents\tw-wikis | | If a setting is not defined its corresponding menu | item in Polly in "menu" mode is not shown. | | * [wikis] - Required. And you need at least one wiki under it. In this section you | add the paths to the wikis you want Polly to monitor & | restore. One wiki per line, for example ... | | [wikis] | file1=C:\users\jon\notes.html | toDoWiki=C:\users\jon\mywikis\todo.html | ;file2=C:\photos\photo-album.htm | | Wiki names must be UNIQUE. | | Each file is preceded by a unique identifer, e.g. | "file1" followed by "=". The identifier should | only contain letters or numbers. No spaces or | special punctuation. | | Lines starting ";" are ignored. This lets you | switch off restoration for that wiki. | | [parrots] - Optional. Under this section you add paths in the same way | as for [wikis] ... | | [parrots] | parrot1=C:\users\jon\Dropbox\notes.html | parrot2=C:\website\photo-album.htm | | The names of parrot wiki need to match the names of | items in the [wikis] section since [parrots] clone items | in [wikis] | | Parrots can include any type of file.
| USAGE | | powershell -file .\polly.ps1 [-ini "settingsfile.ini"] [-run "menu"|"auto"|"once"|"parrot"] | | -ini "settingsfile.ini", a user defined settings file | | without an -ini parameter Polly loads "settings.ini" | without "settings.ini" present Polly prompts the user to create it [NOT YET DONE] | | -run "menu" displays menu (which can start all other modes) | "auto" checks & restores wikis at user set intervals | "once" checks & restores wikis, then exists | "parrot" runs extended parroting (only), then exits [NOT YET DONE] | | without a -run parameter Polly runs "menu" mode | | Polly comes with three ready to run batch files ... | | "polly.bat" runs Polly in "menu" mode | "polly-auto.bat" runs Polly in "auto" mode | "polly-once.bat" runs Polly in "once" mode | | all load the default "settings.ini" file
But without a settings editor or method to make an .ini and instructions on how to I don't think it will be a happy experience trying to use it :-(. Maybe I'm wrong?
I working on a settings editor. It will take me some time as I'm very slow, not being a programmer by trade. I looked at the same library that Get-IniContent came from and see there was a proto-editor. I might try use it?
On Monday, July 29, 2019 at 11:47:19 AM UTC-7, @TiddlyTweeter wrote:But without a settings editor or method to make an .ini and instructions on how to I don't think it will be a happy experience trying to use it :-(. Maybe I'm wrong?The settings are easier to read and set than for Bob or TiddlyServer.
That looks very nice. Are you using notepad for all this?
| wikidir=| Optional. Useful if your wikis are nested under one directory.I've been thinking that the way it might work is instead to have a section "wikidirs". Then underthe section you could havemydir1=c:\temp\mywikismydir2=d:\other\path\wikisAt start-up, the process would examine each of these directories, and then add any htm, html, tw files to the existing listof files to be restored. The obvious caveat would be that the directories could not contain any htm, html, tw files thatyou would not want to be written over from their corresponding file in the downloads directory. TiddlyWiki.html and empty.htmlfiles would be the more obvious examples. And of course the stem names should not clash with names that are already beingrestored via file=...\my.html.
It could just post a warning at the end of the menu if key settings are missing. And the various routines refuse to run (with a message) if the downloads orother essential settings are missing.
My sense is that anyone who is challenged by a simple ini file (pre-filled with sample data) won't be helped much by a wizard or step-by-step process ...or am I overly pessimistic?
[wikis];--- WIKIS FOR RESTOREfile6=..\..\..\tw-wikidir\parrot\parrot-red.htmlfile7=..\..\..\tw-wikidir\parrot\parrot-green.html
[wikidir];--- WIKIDIR (??optional??): directories that hold wikis that get auto-added, should not contain any html files other than wikis.
mydir1=c:\temp\mywikismydir2=d:\other\path\wikis
[parrots];--- PARROTS (optional): auto-updated secondary copies of wikis parrot1=..\..\..\tw-sites\www.polly.net\parrot-red.htmlparrot2=..\..\..\tw-sites\www.polly.net\parrot-green.html
[wikis];--- WIKIS FOR RESTOREfile6=..\..\..\tw-wikidir\parrot\parrot-red.htmlfile7=..\..\..\tw-wikidir\parrot\parrot-green.html
[otherfiles];--- OTHER FILES (optional): non-wiki files Polly manages for Parrots
other1=..\..\..\tw-wikidir\parrot\parrot-red.icoother2=..\..\..\tw-wikidir\parrot\parrot-green.ico
other3=..\..\..\tw-wikidir\parrot\parrot-red.pdfother4=..\..\..\tw-wikidir\parrot\parrot-green.pdf [wikidir];--- WIKIDIR (??optional??): directories that hold wikis that get auto-added, should not contain any html files other than wikis.
mydir1=c:\temp\mywikismydir2=d:\other\path\wikis
[parrots];--- PARROTS (optional): auto-updated secondary copies of wikis parrot1=..\..\..\tw-sites\www.polly.net\parrot-red.htmlparrot2=..\..\..\tw-sites\www.polly.net\parrot-green.html
parrot3=..\..\..\tw-sites\www.polly.net\parrot-red.icoparrot4=..\..\..\tw-sites\www.polly.net\parrot-green.ico
parrot5=..\..\..\tw-sites\www.polly.net\parrot-red.pdfparrot6=..\..\..\tw-sites\www.polly.net\parrot-green.pdf
1 - Open wiki. Using a settings file run in a new "launch" mode, i.e. -run "launch"
I been testing the idea in PowerShell. There are some issues in that I haven't yet found a reliable single way to assemble a command line all browsers accept. There are some differences between them. But perhaps its possible.
You could then get Polly to start a session in a specific browser, open wiki, & start monitoring.
function fetchTests {# --- TT FETCHiwr -uri https://tiddlywiki.com/prerelease/ -OutFile ..\..\P\Users\Polly\Downloads\tw_fetch\tw5-pre-$(get-date -f yyyy-MM-dd).html}
tricky-polly-.zip
# MAKE ARCHIVE STRING FROM DATE, STEM, AND EXTEN
function generate-archivestring {
param( [datetime]$dt, [string]$pStem, [string]$pExten)
return "$pStem-$pExten-$(get-date -year $dt.year -month $dt.month -day $dt.day -hour $dt.hour -minute $dt.minute -second $dt.second -millisecond $dt.millisecond -f yyyy-MM-dd_HHmmss).$pExten"
}
Ok. Great. I would just patch my own version, but I know you've already made changes to yours. So I'll describe what to do next.
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d0fe6222-ca4d-46af-be34-9b2daa8fa550%40googlegroups.com.
* Are you planning to allow the launch of a wiki from within the menu?
* Instead of using C:\Users\joeuser\downloads I'd love to be able to use system variables like this: %userprofile%\downloads
* Also appears relative paths don't work today. Like if I have c:\polly and my wikis are in c:\polly\tiddlywiki I was thinking I could do .\tiddlywiki\mywiki.html but that doesn't work. Actually, this tries to work but I think it looks for a path relative to the downloads folder.
* Another enhancement would be to check for the existence of the backup and parrots folders and create it if it doesn't exist.
Hello Scott,It's possible that you are our entire user base ;-)
On Thursday, August 1, 2019 at 5:18:16 PM UTC-7, Scott Kingery wrote:* Are you planning to allow the launch of a wiki from within the menu?Would that be helpful? If there's 20 wikis, would the user need to select and launch?
* Instead of using C:\Users\joeuser\downloads I'd love to be able to use system variables like this: %userprofile%\downloadsHave you tried this? I'm wondering if it might accidentally work already.
* Also appears relative paths don't work today. Like if I have c:\polly and my wikis are in c:\polly\tiddlywiki I was thinking I could do .\tiddlywiki\mywiki.html but that doesn't work. Actually, this tries to work but I think it looks for a path relative to the downloads folder.We probably need to do a refactor to make this possible, though I never envisaged that anyone would want to run from the polly directory.
* Another enhancement would be to check for the existence of the backup and parrots folders and create it if it doesn't exist.Some of that is already happening for the sub-directories for backup and zip.It's making directories all the way down that worries me.I cringe a little, because what if a user accidentally specifies a path to some place unintended? It's likely they'll complain that theirbackup directory is empty, while meanwhile the actual backup is filling up their USB drive or something. Or filling up a "download" directory instead of a "downloads" directory.
Is there a github repo, where I can have a look at the project / code? ... Is there a way to contribute?
Being able to launch individual wiki by single selectable choice? Not so sure on that. I think it could over-complicate Polly.
That should be quite easy to do. One approach is if you leave "downloaddir" $null it will revert to the Env variable for current users profile?
Mark, could you look into that? I ask because changing to always run in app dir will effect the "Restore" section most. That's where the change would have to be?
I agree with Mark. I'd be nervous of auto-creating the top level in a hierachy of folders because of the potential for unanticipated results. But any sub-dir below an existing directory I think is fine. So, for instance we maybe could eventually create sub-folder structure for parrots--provided the top dir exists?
Scott, great questions! Thanks.
On Thursday, August 1, 2019 at 10:06:27 PM UTC-7, @TiddlyTweeter wrote:Being able to launch individual wiki by single selectable choice? Not so sure on that. I think it could over-complicate Polly.That's what I was thinking. It doesn't have a real graphical interface, and that wasn't the primary object.That should be quite easy to do. One approach is if you leave "downloaddir" $null it will revert to the Env variable for current users profile?We should find out if some version of "%userprofile%/downloads" will work out of the box. Then that can be our default in the settings,and the user can change it if they have some special download location.
# --- DOWNLOADS DIRECTORY: where browser downloads go $downloaddir = $general["downloaddir"] # If not defined use o/s "userprofile" if ([string]::IsNullOrEmpty($downloaddir)){$downloaddir = "$Env:userprofile\Downloads"}
@TiddlyTweeter wrote:Being able to launch individual wiki by single selectable choice? Not so sure on that. I think it could over-complicate Polly.
Mark S. wrote:That's what I was thinking. It doesn't have a real graphical interface, and that wasn't the primary object.
I got something working on that. IF no setting in ini is made then the settings will be to the Powershell "$Env:userprofile\downloads", like this ...
# --- DOWNLOADS DIRECTORY: where browser downloads go$downloaddir = $general["downloaddir"]# If not defined use o/s "userprofile"if ([string]::IsNullOrEmpty($downloaddir)){$downloaddir = "$Env:userprofile\Downloads"}
Would that be enough to cover the case?
Would that mean that wiki "tricky.tw", "tricky.html", "tricky.htm" would all end up stamped the same, e.g. as "tricky-zip-2019-08-02_184838.zip"?
TT
# MAKE ARCHIVE STRING FROM DATE, STEM, AND EXTEN
function generate-archivestring {
param( [datetime]$dt, [string]$pFilename, [string]$pExten)
return "$pFilename-$(get-date -year $dt.year -month $dt.month -day $dt.day -hour $dt.hour -minute $dt.minute -second $dt.second -millisecond $dt.millisecond -f yyyy-MM-dd_HHmmss).$pExten"
}
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/0457248b-5a4f-4041-8a76-c65cfe630419%40googlegroups.com.
You are right, Polly is more of a saving/restoring solution than a launcher and development should go in that direction
The %userprofile%/downloads was just an example. I could easily see where I'd put my wikis in Google Drive (for example) and reference them locally as %userprofile%\Google Drive\tiddlywiki This has the potential of only needing 1 .ini file across my synced devices.
Can I run Polly.bat with different ini files? I see that is available with polly-once.bat
Oops. Ok, changes ...
Mark: * We should probably make our own routine library file at this point
Did you find any actual downside? Once we have a function in place, it shouldn't be hard to implement. We just have to"sanitize" the four+ directory types. Unless of course ... it breaks relative addressing or something.