Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce "Multi Wiki Server" Plugin #7915

Draft
wants to merge 296 commits into
base: master
Choose a base branch
from
Draft

Conversation

Jermolene
Copy link
Member

@Jermolene Jermolene commented Jan 2, 2024

Introduction

Please see https://mws.tiddlywiki.com/ for instructions on how to use MWS

This PR introduces the "Multi Wiki Server" (MWS) plugin. It adds support for hosting multiple wikis at the same time. For performance and scalability, it uses SQLite to store tiddlers.

Hosted wikis are independent of the main wiki, which is still used for administration functions:

  • storing configuration for managing the hosted wikis
  • generating templates for static HTML routes

Related Work

SQLite Browser Wasm Experiments

Last year, I worked on #7329 which involved using the Wasm version of SQLite in the browser to make an alternate implementation of the wiki store object. The current status is that everything works but the overall performance is worse than the current JavaScript store implementation. I believe that it is possible to significantly improve on the JS performance by compiling filters directly into SQL. I hope to return to that work, but in the meantime I think we can get a lot of value from SQLite on the server without requiring the ability to execute filters against tiddlers in the database.

Bob.Exe

MWS has similar goals to @inmysocks's Bob.Exe at https://github.com/OokTech/TW5-Bob with the key differences being:

  • MWS uses SQLite for storing the content of the wikis
  • MWS uses the recipe/bag model for sharing content

Progress

  • New tiddler schema that uses a record for each field instead of trying to pack them into a single record
  • SqlTiddlerStore class for storing and retrieving tiddlers with bags and recipes
  • Tests for the SqlTiddlerStore class
  • New /wiki/:recipe_name HTTP route that serves a TW5 wiki template with the tiddlers from a given recipe spliced in
  • Support for hosted wikis to synchronise via the API
  • Use a persistent disk-based database
  • Improved syncing that has persistent tiddler revision numbers, and thus can cope with server restarts
  • Allow configuration of the hosted wikis via the main wiki (without needing a restart of the server) [much more to do, but the basics are there]
  • Support for use of _canonical_uri for tiddlers >10MB
  • Support for fields containing large blobs that are stored in a separate content addressable file store indexed by the MD5 hash of the content of the blob. This will allow seamless handling of very large tiddlers (eg video files)
  • Support for authentication and authorisation
  • Consider caching the wiki template
  • Instant syncing from server to browser
  • Fix uploading the same attachment twice – in particular, might be problematic if done via two browsers that happen to send a different content type
  • Fix editing tiddlers that contain attachments
  • Avoid making text tiddlers become attachments
  • Support for deleting attachments when the associated tiddler is modified or deleted
  • Update --mws-save-archive to handle attachments
  • Apply length limits while processing multipart form data to prevent DDOS attacks
  • Support HTTP range requests to allow streaming videos to support seeking within video

Copy link

vercel bot commented Jan 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Jul 16, 2024 9:38am

@pmario
Copy link
Member

pmario commented Jan 3, 2024

@Jermolene -- Is this PR intended to collect early feedback, or just to track your own progress?

@Jermolene
Copy link
Member Author

@Jermolene -- Is this PR intended to collect early feedback, or just to track your own progress?

It's no different from any other draft PR, which is to say that it is the product of working in the open, and is published so that others can review and provide feedback.

@linonetwo
Copy link
Contributor

Cool, can different bags belong to different folders?

(So they can be synced to different Github repos, some of them are private bags and in private Github repo, and some public will be used to build public gh pages blog).

@Jermolene
Copy link
Member Author

Hi @linonetwo

Cool, can different bags belong to different folders?

This is not a hierarchical structure; bags are flat and do not contain other bags.

Bag can appear in multiple recipes at the same time.

(So they can be synced to different Github repos, some of them are private bags and in private Github repo, and some public will be used to build public gh pages blog).

That is correct, there are several motivations that might apply for placing a particular set of tiddlers in a bag of their own:

  • To be able to independently include those tiddlers in any other recipe (ie to reuse them in other wikis)
  • To make it easier to sync those tiddlers independently
  • To be able to apply access controls to those tiddlers (bags represent access control boundaries)

@linonetwo
Copy link
Contributor

Sorry for the confusion,

can different bags belong to different folders?

I want to ask about the folder structure on the file system, will it still be one tiddlers/ folder?

I know bag is a field on the .tid file or .meta file, so maybe all of these "bags" are still on the same tiddlers/ folder on the file system?

@Jermolene
Copy link
Member Author

I want to ask about the folder structure on the file system, will it still be one tiddlers/ folder?

The tiddlers for the hosted wikis are stored in a SQLite database, they are not stored as files in the file system.

Otherwise tiddlers containing `</script>` will break TiddlyWiki
@HwWobbe
Copy link

HwWobbe commented Nov 16, 2024

It's nice to see this here and to have a chance to use and use this variant now.

  • I am considering how to best share my testing insights
    • one way might be to focus on my use of exotic UniCode characters since Jeremy has indicated he occasionally finds anomalies from that.

pmario and others added 2 commits November 17, 2024 10:35
…st (#8717)

* move test dependencies to devDep. Update better-sqlite3 to latest

* update Node version for workflow

* downgrade engines - node

* adjust wasm package
@pmario
Copy link
Member

pmario commented Nov 17, 2024

@Jermolene -- Where can I change the content which is published at mws.tiddlywiki.com? There are some commands missing at the Installation descriptions.

@Jermolene
Copy link
Member Author

@Jermolene -- Where can I change the content which is published at mws.tiddlywiki.com? There are some commands missing at the Installation descriptions.

Hi @pmario mws.tiddlywiki.com is built from the edition at https://github.com/TiddlyWiki/TiddlyWiki5/tree/multi-wiki-support/editions/multiwikidocs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.