Interesting hack save anything to any file

116 views
Skip to first unread message

TonyM

unread,
Jul 13, 2019, 2:06:38 PM7/13/19
to TiddlyWikiDev
I have being struggling to enable check in an out on wikis. To do this I need to read and write to the server. In this case a php server housing tw-reciever.

I just discovered if I change the save all filter and the tiddler wiki file name within tw-reciever the next save will save the subset of tiddlers to the new filename on the server. I can then restore the settings.

Thus it is now possible to do a lot of great things. Like save the current users tiddlers to disk in a separate file not only local storage and re import them to the master wiki after reviewing them.

I would prefer if there was a mechanisium to do this or a plugin rather than this hack. Then it would be easy to generate a locked file, checked out to user etc. Which I can now do using the hack .

I expect this to work on firefox with timimi as well.

Regards
Tony

TonyM

unread,
Jul 13, 2019, 2:24:07 PM7/13/19
to TiddlyWikiDev
Also

I would like a user to fill out a survey, save it as a json file the provide a mailto that attaches the file and send it to me.

Regards
Tony

Jan

unread,
Jul 14, 2019, 7:13:02 AM7/14/19
to tiddly...@googlegroups.com
Hi Tony,
as promised here is a php and a json. The php works when it is put in
the same directory as the index.html.
To call it, you need the tiddlers in the .json-file.
If you install them, you get a button to upload the tiddler if it is
tagged post.
So to create your survey pointing to fields in the tiddler and tag it
"Post."

Cheers Jan
post.php
tiddlers.json

TonyM

unread,
Jul 14, 2019, 9:07:16 AM7/14/19
to TiddlyWikiDev
Jan,

Thanks. I will check it out tomorrow.

Do we discuss this elsewhere?

I appreciate your effort. I am likely to use this like a script kiddy and see what else I can achieve such as check in/out lock.

Regards
Tony

TonyM

unread,
Jul 14, 2019, 10:35:32 PM7/14/19
to TiddlyWikiDev
Jan,

I got it working on php with tw-receiver. Thanks 

I appreciate it when someone helps me open a new "can of worms" :)

A special note:
I am looking at building additional functionality and server options (including single file) for integration and messaging, and exporting content from posts to websites. It is however important to understand I have no desire to compromise the TiddlyWiki single file standard, to the contrary, I want to extend it and allow almost serverless implementations.

I had to do the following to get it working
  • Create the /post folder
Other changes
  • A few customisations (for debug) and translation of 2 words
I observed
  1. After saving a tid, I can view a known tid in the browser with a link eg http://ampps.local/tw/post/Tony Post Test.tid
  2. The post folder must exist first but I can "upload" any new tid filename
  3. I can use the import button and provide the above link and the import mechanism is triggered
  4. Using import and providing the path only http://ampps.local/tw/post/ tries to import a html document which contains a directory list of the post folder.
    This only works if I preview the import and copy and paste the content, and some icons are broken.
The following is about my journey, of course I would love feedback but it is here to share where I am going with this, no obligations to respond.

Questions I will try and answer
  • Will this work without TW receiver active (not yet tested) 
  • Can I use something similar to post multiple files or tids at once? (Not only one json file as below)
  • I wonder if there is a way to allow browsing the posts folder (on server) to selectively import?
  • Is there a way to also delete a post tid from inside the browser on the server?
    or from a button?
  • I wonder if the php / server could be configured to only allow saving to a particular folder or filename?, 
    • perhaps after a login process or given a pre-configured username and pass phrase
Speculation
  • It seems to me we could generalise this PHP post mechanism into a macro or widget so that it can be used for any number of circumstances.
    • Write a lock file if it is not already existing/ detect the presence of a lock file and place the wiki in read only mode/ delete the lock file when done
    • Use the browser/close tab function to delete the lock file (freeing it for the next user) even oneself.
  • Save a json file of filtered tiddlers (a bundle), then present a link to the JSON  to publish. 
    • Use this link to selectively import multiple tiddlers or trigger an action to do so silently (Prefix or Naming standards could avoid conflict) 
    • Other wikis with this can optionally import the content of the json (a way of publishing content in bundles and plugins)
    • Use this as a selective backup process eg dump to user filename based on [haschanged[]] or local storage (5.1.20+) then reload automatically.
    • Use this to submit changes requests by tiddler or group of tiddlers to be committed to the wiki master itself.
    • Allow a user to only save to their own folder and with a size limit to stop hacks and DDoS
  • Export one or more static html tiddlers for consumption by the wiki or other browsing (a semi-manual version of what we can do with node static tiddlers)
  • Generate and Export a full html website constructed from content in the wikis tiddlers.
  • In the case of no server rights allow 
    • file download (already possible but integrate to make seamless), 
    • or in Timimi save to filesystem when has rights to do so as if on a server, this would allow emulation of a server install without one.
  • Could we post an email file and have another server process send it for us? - and other messaging systems.
I continue exploring.

Regards
Tony

Jan

unread,
Jul 15, 2019, 5:20:24 AM7/15/19
to tiddly...@googlegroups.com
Hi Tony,
I got it working on php with tw-receiver.
I works completely independent from the tw-reciever. (by the way, I still use a modified Version of store.php to save my wiki.)

A special note:
I am looking at building additional functionality and server options (including single file) for integration and messaging, and exporting content from posts to websites. It is however important to understand I have no desire to compromise the TiddlyWiki single file standard, to the contrary, I want to extend it and allow almost serverless implementations.
This is exactly my intention.
I love the independency of TW, php allows you (apart form saving to web) to embed Interaction with users...which is otherwise difficult in TW if you do not use a Node-Implementation.

I had to do the following to get it working
  • Create the /post folder
Ah, thats right, I forgot that because it was the first php I did.

I observed
  1. After saving a tid, I can view a known tid in the browser with a link eg http://ampps.local/tw/post/Tony Post Test.tid
  2. The post folder must exist first but I can "upload" any new tid filename
  3. I can use the import button and provide the above link and the import mechanism is triggered
  4. Using import and providing the path only http://ampps.local/tw/post/ tries to import a html document which contains a directory list of the post folder.
    This only works if I preview the import and copy and paste the content, and some icons are broken.
Importing tid files from the web is difficult.
You can create a php showing the files in the directory and transclude it in an to TW in an Iframe, but so far I did not find an elegant way to Import tid or text files directly. I think half of my threads circle arround that subject.

-You can download the .tids to your harddrive an import them by dragging.
-You can make an external Tiddler like in TiddlyWiki.com "Alice in Wonderland" but then you loose the field information.

-Some time ago Jeremy wrote that the only Format that could be imported by click is jsonp, but I could not find out how this work so far.

With php (which to me was much easier to learn than js) you can export any file you can produce with a macro or filter.




The following is about my journey, of course I would love feedback but it is here to share where I am going with this, no obligations to respond.

Questions I will try and answer
  • Can I use something similar to post multiple files or tids at once? (Not only one json file as below)
Yes, just modify the content of the textarea in the Tiddler PostForm in the .json.
  • I wonder if there is a way to allow browsing the posts folder (on server) to selectively import?
Yes, you could have an Iframe pointing to a php which is generating an index. I put copy/pasted an rough example for you into this mail.
Put it into the post-Folder.  You should change the password in a text-editor.

  • Is there a way to also delete a post tid from inside the browser on the server?
    or from a button?
This could also be done by that php.

  • I wonder if the php / server could be configured to only allow saving to a particular folder or filename?, 
    • perhaps after a login process or given a pre-configured username and pass phrase
certainly



Speculation
  • It seems to me we could generalise this PHP post mechanism into a macro or widget so that it can be used for any number of circumstances.
    • Write a lock file if it is not already existing/ detect the presence of a lock file and place the wiki in read only mode/ delete the lock file when done
???

    • Use the browser/close tab function to delete the lock file (freeing it for the next user) even oneself.
???

  • Save a json file of filtered tiddlers (a bundle), then present a link to the JSON  to publish. 
    • Use this link to selectively import multiple tiddlers or trigger an action to do so silently (Prefix or Naming standards could avoid conflict) 
    • Other wikis with this can optionally import the content of the json (a way of publishing content in bundles and plugins)
    • Use this as a selective backup process eg dump to user filename based on [haschanged[]] or local storage (5.1.20+) then reload automatically.
    • Use this to submit changes requests by tiddler or group of tiddlers to be committed to the wiki master itself.
    • Allow a user to only save to their own folder and with a size limit to stop hacks and DDoS
Yes, all this is possible - only reimporting is difficult, partly for security reasons, partly due to the lack of infrastructure for this in TW

  • Export one or more static html tiddlers for consumption by the wiki or other browsing (a semi-manual version of what we can do with node static tiddlers)
  • Generate and Export a full html website constructed from content in the wikis tiddlers.
Yes

  • In the case of no server rights allow 
    • file download (already possible but integrate to make seamless), 
    • or in Timimi save to filesystem when has rights to do so as if on a server, this would allow emulation of a server install without one.
  • Could we post an email file and have another server process send it for us? - and other messaging systems.
Yes, PHP can send emails.

I think this is a usefull discussion in the Mailgroup because the possibilities of php-scripts are a little underestimated here. Especially if you want a way to define interactions with users of your Wiki.

I hope I could help you to get a start
Jan










I continue exploring.

Regards
Tony


On Sunday, July 14, 2019 at 11:07:16 PM UTC+10, TonyM wrote:
Jan,

Thanks. I will check it out tomorrow.

Do we discuss this elsewhere?

I appreciate your effort. I am likely to use this like a script kiddy and see what else I can achieve such as check in/out lock.

Regards
Tony

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/a18474af-09f7-4193-9333-68e5e4d101c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

index.php

TonyM

unread,
Jul 17, 2019, 3:08:10 AM7/17/19
to TiddlyWikiDev
Jan,

Thanks again. I will digest this potential ASAP.

Regards
Tony
To unsubscribe from this group and stop receiving emails from it, send an email to tiddly...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages