Arlen22 / TiddlyServer

v2 - A static file server that can also save files and mount TiddlyWiki folders
https://arlen22.github.io/tiddlyserver/
MIT License
256 stars 36 forks source link

Documentation on Data Folders is Very Unclear #95

Open ohare93 opened 4 years ago

ohare93 commented 4 years ago

Hello, I was drawn to TiddlyServer as a way to get my TiddlyWiki instance loading smoother by separating out the images and media files. Using the default Lazy Load was giving terrible load times for the images, so I hoped TiddlyServer could be the answer.

Going over the documentation it is very unclear:

  1. How to actually setup a "Data Folder"
  2. How to reference those files inside another TiddlyWiki file
  3. How to upload new files

None of the documentation actually says what to do in regards to data files. I only worked out what the features of a data folder was from your comments here, and I only gathered that I need to enable them in the config from your comments on #94. Though I am still lost as to what their intention is or what I should do to reference the files in them, or how to upload a file to an actual data folder.

So what I wanted to achieve in the beginning is to run my normal server TiddlyWiki (called "Personal") inside TiddlyServer, while having a place to put the images separately which can still be seen/used in my Personal wiki. Though a lot of googling and trial and error I have the following:

My Personal Wiki (which works fine) and an Images folder. image

Inside that Images folder is a bunch of images I was using to test, however I could not reference them. Then after finding the ability to enable the datafolder in bindInfo/localAddressPermissions from one of your comments I got the button "Data Folder" below, which presumable creates a data folder. So I made one called "Test" image

But this "data folder" is just a TiddlyWiki...? When I open it there is a blank TiddlyWiki. Am I supposed to upload images to this "data folder" via the normal TiddlyWiki drag/drop? Will this allow me to reference those images inside my Personal wiki?

Though some more trial and error I have found that simply placing an image into Test/Tiddlers/ allows me to reference and see it inside the Test wiki. Though it has the full path, for some reason. And I cannot reference these inside my Personal wiki.

image

Summary

So, how can I achieve my goal of linking to images from my Personal file? Have I missed something? Thanks

Arlen22 commented 4 years ago

Good work, you've definitely gotten things figured out. I'm sorry that it is sometimes hard to figure out. I don't always know how to explain things clearly.

You have two folders, images and personal. You also added another data folder called test. The button appeared because you also added the mkdir permission when you added the datafolder permission. The datafolder permission is enabled by default and actually sets whether the user is allowed to access data folders on the server (because they can easily gain access to the file system by creating a server startup module and reloading the wiki). You can find more info on these permissions here: https://arlen22.github.io/tiddlyserver/docs/serverconfig.html#localaddresspermissions-hashmap

If you have files in your images folder you can refer to them in any valid URL format. So /images/Lakes.jpg or ../images/Lakes.jpg.

Though some more trial and error I have found that simply placing an image into Test/Tiddlers/ allows me to reference and see it inside the Test wiki. Though it has the full path, for some reason. And I cannot reference these inside my Personal wiki.

This is because it is loaded from the file system as a tiddler (because it is in the tiddlers folder), and the file path is the default title if there is no meta file next to it. If you want files to remain inside the data folder, you should create a files folder beside the tiddlers folder in the data folder and store files in there. Then you access them via /Personal/files/Lakes.png.

https://tiddlywiki.com/#Using%20the%20integrated%20static%20file%20server

TiddlyServer never serves files inside a data folder. All requests that fall under a datafolder are handed off to that datafolder so they act identical to the Node TiddlyWiki server including any plugins which apply to that data folder.

This is part is for once you're familiar with data folders. You probably won't normally use this.

Optional parameters may be set on a datafolder property at the top level of the config file (not to be confused with datafolder boolean property on the permissions object). In most cases, however, the defaults work fine. Individual datafolder authentication is disabled in favor of the cookie based login that TiddlyServer provides through authAccounts.

{ 
  "tree": [],
  "authAccounts": {},
  "datafolder": {}
}
ohare93 commented 4 years ago

Ahh I've gotten it to work by referencing it as an External file with [img[../Images/black_knives.png]]! I was trying permeations of {{Images/Lakes.png}} :sweat_smile: Thank you very much! :+1:

However this shows I still do not seem to understand something about this structure :thinking: So I can reference any file in my Test folder above simply because I have added that to the Tree in the config. Then what exactly is a "data folder"? Why would I want to create one? The name implies (to me) that is a folder where data can be stored and referenced. Is that wrong?

Arlen22 commented 4 years ago

Test is another data folder, like Personal. Yes, it is an external file because it is not a tiddler, which is what you stated you wanted at the beginning (because lazy load wasn't working well). I prefer external files for most things as well. But everything is either a tiddler or an external file.

You could lookup _canonical_uri. It might let you transclude an external file.

ohare93 commented 4 years ago

Sorry for the late reply!

Thanks for the help, I have found TiddlyServer to be very useful 👍 a few quick questions though:

  1. What is the purpose of the create "Data folder" button? It will not add items to my settings config, right?
  2. Is it possible to get a list of files inside a folder, from TiddlyWiki? Sometimes I just wish to show all the files, but have to manually do each 😓
  3. Do you have any of your wikis running on TiddlyServer exposed to the web? If so, how do you secure them. I am looking into creating a Nginx gateway (as stated here) but was just wondering if there's an easier way with TiddlyServer.

Thanks for your work, mate.

Arlen22 commented 4 years ago
  1. No, it only creates a new data folder with a prefilled tiddlywiki.info file.
  2. Currently there is not, although the code I use in TiddlyServer would not be hard to adapt.
  3. It does have the capability of running directly facing the web. The code is fairly simple, and yes I think it is secure. Make sure you setup HTTPS, otherwise all bets are off. An NGINX HTTPS server is fine as well.