buggyj / tiddlyclip-plugin

tw plugin for tiddlyclip
MIT License
13 stars 1 forks source link

Can savemedia be hacked to use 'files' instead of 'media' ? #94

Open Marxsal opened 2 years ago

Marxsal commented 2 years ago

'Files' is used by the node.js server, and by (I think) Bob.

buggyj commented 2 years ago

The savemedia mechanism is through browser download, and uses 'media' as a subdir to the location of the tiddlywiki in use, therefore it is not possible to use the save with nodejs.

Marxsal commented 2 years ago

You misunderstand my intent. I know you can't use it with node.js. But node.js and Bob use "files". So you could download your files using media save and then later, in another session, use it with node.js or Bob. It would just work better if everyone used the same subdir for external files.

buggyj commented 2 years ago

Ok I now understand.

The subdir is hardcoded in the csaver macro in tiddler /home/buggyj/Documents/dev/js/TiddlyWiki5/plugins/bj/tiddlyclip-plugin/tw5/csaver.js i.e. var subdir = "media";

the most obvious change would be to have a configuration file e.g

var subdir = $tw.wiki.getTiddlerText("$:/plugin/bj/tiddlyclip-plugin/tw5/media-sub-directory").trim();

however not all characters are allowed in a directory name and this varies with system. We could restrict the subdirectory to be alphanumeric with spaces:

subdir=(subdir.match(/^[0-9 a-z]+$/))?subdir:"media";

what do you think?

buggyj commented 2 years ago

To be clear tiddlyclip can be used with nodejs or any other file server, it is just local saving of clips that is different.

buggyj commented 2 years ago

the config would better be var subdir = $tw.wiki.getTiddlerText("$:/plugin/bj/savemedia/tw5/media-sub-directory").trim();

buggyj commented 2 years ago

is it 'Files' or 'files'?

Marxsal commented 2 years ago

Having a configuration for it would be the best. Perhaps there could be a warning about what language sets can be used. But if that's not possible, or too inconvenient, then just being able to set it to "files" would make it cross-compatible with the other node.js products.

buggyj commented 2 years ago

At present I am not going to handle different languages.

There needs to be a global setting of the subdir, which will be the setting for all tiddlywikis, but this should be overridden by a setting in individual tiddlywikis. Therefore there need to be a config here in the tiddlyclip plugin (local setting) and a config page created in the savemedia download (global setting). In both places the only options will be 'files' or 'media'.

arunnbabu81 commented 1 year ago

Therefore there need to be a config here in the tiddlyclip plugin (local setting) and a config page created in the savemedia download (global setting). In both places the only options will be 'files' or 'media'.

Can this config option be added to the tiddlyclip plug in and savemedia add on

buggyj commented 1 year ago

I plan to implement this, but, as I am not planning to use this new feature, it is not high on my list of things to do.

arunnbabu81 commented 1 year ago

It's for compatibility with the file upload plug in which might get into the core in the future

arunnbabu81 commented 1 year ago

I would like this feature to be added along with the save media addon configuration option (for download location or the saving folder). This is mainly for compatibility when wiki is used in node.js mode and if files upload plug in is also used along with it. Again this is important to me since I am using relative path for displaying images within my wiki.

buggyj commented 1 year ago

I have added a config tiddler to enable 'files' or 'media' to be selected.

arunnbabu81 commented 10 months ago

I have added a config tiddler to enable 'files' or 'media' to be selected.

Where is this config tiddler ?

This one right ?

image

buggyj commented 10 months ago

I replaced this with the savetofiles macro

arunnbabu81 commented 10 months ago

I have added a config tiddler to enable 'files' or 'media' to be selected.

Where is this config tiddler ?

This one right ?

image

This was also working.

How to use the savetofiles macro

buggyj commented 10 months ago

$:/plugin/bj/savemedia/useFilesDir is available in the latest pre-release.

savetofiles macro is the same as csaver macro.

arunnbabu81 commented 10 months ago

$:/plugin/bj/savemedia/useFilesDir

What's the use of this config tiddler. I can see that in my wiki. How to make use of it?

I guess I know how to use the savetofile macro..I will do some testing with it.

buggyj commented 10 months ago

if $:/plugin/bj/savemedia/useFilesDir contains 'yes' then csaver puts clips into 'files' subdir, otherwise it puts them into 'media' subdir