TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.02k stars 1.19k forks source link

[IDEA] Saving imported images to e.g. gitlab/github instead of embedding #5491

Open cemerick opened 3 years ago

cemerick commented 3 years ago

Is your feature request related to a problem? Please describe. Single-file operation is highly desirable, but embedding images as base64 is not.

Describe the solution you'd like Let's store images, PDFs, etc via our configured saving mechanism, and refer to them via _canonical_uri instead. I'm using gitlab, but the same approach should work just fine for other quasi-filesystem backends as well, e.g. github, webdav, s3, etc.

I have set up a tiddlywiki to save changes to gitlab, and enabled gitlab pages for the corresponding repository, so I always load my wiki from https://username.gitlab.com/repository/index.html (presuming the tw html file is in the repository @ https://gitlab.com/username/repository/index.html).

At import-time, pushing images to the same (gitlab) repository would involve:

  1. Figuring the canonical path of each imported image/file (e.g. files/image1.png)
  2. Sending each imported image to gitlab via the existing save mechanism. This will require changing the save signature to accept an array of [path, content] pairs, and using the gitlab commits API to effect the change instead of a simple single-path create/update
  3. Setting the _canonical_uri on each of the newly-created image tiddlers and stripping their base64'd contents

FWIW, I've implemented a similar workflow with a custom "Add image" button that doesn't go through the existing import facility, and works with just one image at a time. It works well enough, but generalizing it to multi-file usage and savers other than gitlab seems like a worthwhile improvement.

saqimtiaz commented 3 years ago

This now possible via the FileUploads plugin.

More details.