June has arrived. Time's up for Timimi?

The forum won’t let me upload a python file. Maybe I can paste it below? So I just run that, then open up the wiki file with the plugin I referenced above and it works. I don’t think I even had to change any settings. Just save the code below with a .py extension and then double click on it (as long as you have python installed).

"""
    A simple python saver for tiddlywiki for use with the BobSaver or
    compatible plugins.
"""

# To use a saver key set it here.
# The quotes are necessary and are not part of the key.
# Example: saverKey = "a key"
saverKey = ""

# Advanced settings, changing these will break things if you don't know what
# you are doing.
port = 61192
host = "127.0.0.1"

#====================== DON'T EDIT BELOW HERE ================================#

from http.server import HTTPServer, BaseHTTPRequestHandler
import re
import sys

class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
    def do_OPTIONS(self):
        self.send_response(200)
        self.send_header('Access-Control-Allow-Origin', '*')
        self.send_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
        self.send_header('Access-Control-Allow-Headers', 'Content-Type, x-saver-key, x-file-path')
        self.end_headers()

    def do_POST(self):
        if self.path.endswith("/check"):
            self.send_response(200)
            self.send_header('Content-type', 'application/json')
            self.send_header("Access-Control-Allow-Origin", "*")  # or restrict to specific origin
            self.send_header("Access-Control-Allow-Headers", "Content-Type, x-saver-key, x-file-path")
            self.end_headers()
            self.wfile.write(b"{\"ok\":\"yes\"}")
            return
        elif self.path.endswith("/save"):
            content_length = int(self.headers['Content-Length'])
            body = self.rfile.read(content_length)
            # The body should be the html text of a wiki
            body = re.sub(r"^message=", '', body.decode("utf-8"))
            headers = self.headers
            filepath = 'x-file-path' in self.headers and self.headers['x-file-path'] or False
            key = 'x-saver-key' in self.headers and self.headers['x-saver-key']
            match = key == saverKey
            if len(body) != 0 and match and filepath and (filepath.endswith('.html') or filepath.endswith('.htm') or filepath.endswith('.hta')):
                # make sure file path exists!!
                with open(filepath, 'w', encoding='utf-8') as f:
                    # Write the file
                    f.write(body)
                self.send_response(200)
                self.send_header('Content-Type', 'application/json')
                self.send_header("Access-Control-Allow-Headers", "Content-Type, x-saver-key, x-file-path")
                self.send_header("Access-Control-Allow-Origin", "*")  # or restrict to specific origin
                self.end_headers()
                self.wfile.write(b'{"ok":"yes"}')
            else:
                self.send_response(403)
                self.send_header('Content-Type', 'application/json')
                self.send_header("Access-Control-Allow-Origin", "*")  # or restrict to specific origin
                self.send_header("Access-Control-Allow-Headers", "Content-Type, x-saver-key, x-file-path")
                self.end_headers()
                self.wfile.write(b'{"ok":"no"}')
        else:
            pass

def startServer():
    print("Starting Server...")
    # Start up the server
    httpd = HTTPServer((host, port), SimpleHTTPRequestHandler)
    print("Server listening using port {} on {}".format(port,host))
    print("Open any single file wiki with the BobSaver plugin and it should save without anything else.")
    print("Edit the BobSaverServer.py file to set a saver key or change the port used.")
    print("If you have changed the settings you need to set them in the wiki(s) you want to save also.")
    print("Press ctrl+c to stop server.")
    httpd.serve_forever()

if __name__ == '__main__':
    try:
        startServer()
    except KeyboardInterrupt:
        sys.exit()

Update on my experiments

  1. I do appreciate the hard work you guys have all put into creating these tools, and helping me in both the old thread and here.

  2. I hope you can appreciate the time commitment this morning, and my willingness to experiment with these options. This is really taxing for me. I am a team leader, teacher/preacher, and content creator. Tech stuff is not my area of expertise. There are posts on some of this where I can only understand every other word. Someone is sending me a “Python server” as a 4k file. I think of servers as something online, who knows what. And Pythons eat you for breakfast in the jungle.

  3. Options B (TW native saver) and G (TiddlyWiki app) are my likeliest candidates. Perhaps I will end up using both. Native saver has the advantage of working with single files in my browser, where I can keep an eye on my other work stuff. TiddlyWiki-app has the advantage of being away from my browser, when I want to do deep work. So I could decide which files I want as standalones and which to have as tid files opened by TiddlyWiki-app, I think.

  4. As mentioned, I have new questions about TiddlyWiki-app. See my update to post 7 here.

  5. As for what to recommend to newbies…I think if someone can create and maintain a demo-install version of the TW native saver with slightly clearer instructions, I could recommend that. The dialog box is off putting but the instructions might help. Not much more work than managing the Timimi extension, but for some people a Chrome extension area feels “safer” than a dialog box with undecipherable options showing up in a file they just downloaded.

  6. Okay, I need to focus on other things for the rest of the day. I will keep an eye on new comments though. I hope my comments on this thread are educational for some on the need for clear documentation and thinking through in advance the obstacles in language and UI for new people, including avoiding GitHub wherever possible.

1 Like

Pythons don’t each preachers. :wink:

1 Like

But they tempt them with apples.

:rofl: Yes, they sure do. That’s why I hate snakes.

Did you ever notice that the mac logo has an apple with a bite taken out of it? Original sin = using a mac…just sayin…

Thats for already existing node js wikis. May be @oeyoews could change the title for those menu optioins.

Option for importing single file wikis is as shown in the screenshot below

image

It’s actually an homage to Alan Turing, the man who built the first useful electric computer.

Why would anyone need a save mechanism for node js? Or is the idea to make a central dashboard?

Tidgi is also a node js wiki based app. May be the intention was to import wikis from tidgi app or native node js wikis into the Tiddlywiki app

I have tried your script on Android, by running it in Termux, just out of curiousity.

The good news is that it worked :+1: . Very likely it shall work on Windows as well, as you said, as long as Windows has a working Python install (I’ve no Windows to test), thanks to 10. Brief Tour of the Standard Library — Python 3.13.3 documentation

The big question here is how do you push your version upstream to BobSaver — Version 0.2.1 so it replaces the original one there, or at least it is listed there as alternative. As a first time user investigating saver options, if I would’ve found the BobSaver plugin by searching online, without knowing about this forum thread - I would’ve tried that version of the Python script, it wouldn’t work, so I would’ve abandoned the quest entirely, since I wouldn’t be able to fix the script myself like you did.

I suspect you were hoping people would read between the lines to respond to you. Never take the responce here as a judgement of your words, there are so many variables in if people will see or understand content here. Shout it out, if you think it importiant.

@DaveGifford I think we should push to maintain Timimi even as a core team solution. However if we need to resort to the native file saver I have a method that will make it a little simpler.

Customise the save button to first copy the full path and filename (to the clipboard) from a config tiddler, you need to set this once and is the path where the wiki is saved localy.

  • Now click save and in the filename use ctrl-V to past the full path. Click save and select overwrite.
  • Now you do not need to remember the full path and filename as its always available as you use the native file saver.

I have not revisited lately but I found TiddlyServer by @Arlen22 a close equivalent to Timimi in allowing you to browse a filesystem and click to open a single file wiki in a tab (at a local address).

  • There was an added layer of work to publish the root folders for all you local single file:/ wikis but once set you can forget and browse subfolders.
  • This additional layer is a powerful addition once you got used to it because it added another management layer to the way you arranged folders of single file wikis, but from memory also node/file/folder implementations.
1 Like

@Arlen22 perhaps we could publish some portable even .exe zip files to assist novice users adopt TiddlyServer.

  • the ability to add content to the server page would be helpful
1 Like

The fundamental problem with TiddlyServer was that I expected people to configure it with a JSON file. Since there’s so much behind the scenes overlap between TiddlyServer and MWS, I’ll probably end up just writing a TiddlyServer plugin for MWS that adds file and folder serving and integrates into the admin UI properly.

Thanks Tones for the customization idea for Native Saver. I will try that out. Add a step at the beginning, and it will save many many steps later. Fine for me.

Hi @DaveGifford and @TW_Tones

I use a different trick with Native Saver on Windows: each time I create a new wiki, I also add a windows shortcut to this wiki in my default “Documents” folder (the one Native Saver opens when you click its “Save” button).
Then, each time I open the wiki, I click on “Save”, scroll to the shortcut, double-click it and confirm replacement. Done.

Hope this helps,

Fred

1 Like

Nice to see another approach @tw-FRed one issue for me is that I dont have a fixed download folder as I select it each time, for a number of reasons.

  • Are you saying saving over the shortcut saves to the address in the shortcut?

[EDIT:]Neither do I With Native Saver it’s mandatory, but regardless of configured target download folder configuration,[/EDIT] on my machine Native Saver always opens the same default folder each time I open my wiki and click “Save” in the popup:

So all I have to do is place all my wiki shortcuts there.

Exactly! I’ve been a happy user of this trick for a few years now :slightly_smiling_face:

Fred

I can also confirm it works the same with symbolic links to single file wikis on Linux! I never tried before now, but it just works! :partying_face:

Option A: TiddlyStow

  1. So, I tried going to TiddlyStow in 3 separate tabs, and opened three standalone files and asked TiddlyStow to save for each. But after doing the third tab, I realized the other two tabs had reverted back to the TiddlyStow webpage. So, there is no way to use TiddlyStow to have three tabs (or at least three browswer instances) open at once and saving on each? I ask because I was hoping for this to be my answer for the most commonly used standalones.

A few more words on Native Saver on Windows, where I use this setup:

  • I use Edge browser for TW on Windows, not because I like it but because it’s preinstalled with Windows…
    • I only use Edge for TW, so I can tweak Edge configuration for TW + Native Saver without impact on my usual internet browsing
    • Edge is configured to always download to a dedicated “savetrail” folder (more on this later)
  • My TWs are all located in a personal network folder, let’s call it NetShare:
    • I use Windows native “Windows Sync Center” to access NetShare folder when I’m offline
    • “savetrail” folder is actually “NetShare\savetrail”, but maybe this isn’t relevant :sweat_smile:
  • Native Saver “Save” button always opens “Documents” folder when clicked, so this is where I create shortcuts to all my wikis
  • I install and activate the official TW “Save Trail” plugin in every wiki:
    • SaveTrail automagically saves each modified/created tiddler to a single-tiddler timestamped json file as soon as you exit edit mode. It means you can’t lose any tiddler modification any more. Deleted tiddlers are also saved before deletion.
    • Once or twice a year, when I do a lot of online/offline/online/offline cycles without rebooting, Edge won’t save my latest changes and fail with a cryptic message along the lines of “current wiki cannot be saved because its internal state is corrupted”. Save Trail backup files help me recover my latest modifications, as Save Trail always works even when Edge fails like this.
    • Save Trails creates a lot of files so I archive them in Zips from time to time.

With this setup I get:

  • Online/offline transparency
  • Automatic saving of the wiki each time I exit edit mode or delete a tiddler
  • Automatic backup + history of every modification, tiddler by tiddler
  • Ease of use
  • Robustness

And all this without installing any software.

Fred

1 Like