-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@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. |
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). |
Hi @linonetwo
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.
That is correct, there are several motivations that might apply for placing a particular set of tiddlers in a bag of their own:
|
Sorry for the confusion,
I want to ask about the folder structure on the file system, will it still be one I know |
The tiddlers for the hosted wikis are stored in a SQLite database, they are not stored as files in the file system. |
May not actually be needed
* fix breaking bug in image tiddler attachment * fix comments * fix code format * refactor processIncomingTiddler flow * remove whitespaces after if statements * refactor attachment_blob persistence flow * refactor process tiddler to support different attachments * add tests for attachment * add more attachement test cases * working on adding instanbul for test coverage report * code coverage report generation * remove unnecessary packages * fix comments
* fix breaking bug in image tiddler attachment * fix comments * fix code format * refactor processIncomingTiddler flow * remove whitespaces after if statements * refactor attachment_blob persistence flow * refactor process tiddler to support different attachments * add tests for attachment * add more attachement test cases * working on adding instanbul for test coverage report * code coverage report generation * remove unnecessary packages * fix comments * handle directory creation if doesn't exist for test store * resolve issue with CI tests failure
So that we can run on older Node.js versions
@Jermolene -- Which tools do you use to inspect the SQLite database. So I can see recipes, bags and tiddlers -- for dev testing |
@pmario I use this: https://sqliteonline.com/ But I would love to spend a little time at some point making it possible to import arbitrary SQLite database files into TW as tiddlers, and then run SQL queries to extract/insert data as tiddlers. That would make a very nice extensible version of https://sqliteonline.com/ that users could customise with UI that directly reflects the schemas they are working with. |
* mws authentication * add more tests and permission checkers * add logic to ensure that only authenticated users' requests are handled * add custom login page * Implement user authentication as well as session handling * work on user operations authorization * add middleware to route handlers for bags & tiddlers routes * add feature that only returns the tiddlers and bags which the user has permission to access on index page * refactor auth routes & added user management page * fix Ci Test failure issue * fix users list page, add manage roles page * add commands and scripts to create new user & assign roles and permissions * resolved ci-test failure * add ACL permissions to bags & tiddlers on creation * fix comments and access control list bug * fix indentation issues * working on user profile edit * remove list users command & added support for database in server options * implement user profile update and password change feature * update plugin readme * implement command which triggers protected mode on the server * revert server-wide auth flag. Implement selective authorization * ACL management feature * Complete Access control list implementation * Added support to manage users' assigned role by admin * fix comments * fix comment
* mws authentication * add more tests and permission checkers * add logic to ensure that only authenticated users' requests are handled * add custom login page * Implement user authentication as well as session handling * work on user operations authorization * add middleware to route handlers for bags & tiddlers routes * add feature that only returns the tiddlers and bags which the user has permission to access on index page * refactor auth routes & added user management page * fix Ci Test failure issue * fix users list page, add manage roles page * add commands and scripts to create new user & assign roles and permissions * resolved ci-test failure * add ACL permissions to bags & tiddlers on creation * fix comments and access control list bug * fix indentation issues * working on user profile edit * remove list users command & added support for database in server options * implement user profile update and password change feature * update plugin readme * implement command which triggers protected mode on the server * revert server-wide auth flag. Implement selective authorization * ACL management feature * Complete Access control list implementation * Added support to manage users' assigned role by admin * fix comments * fix comment * Add user profile management and account deletion functionality
"@playwright/test": "^1.47.2", | ||
"better-sqlite3": "^9.4.3", | ||
"node-sqlite3-wasm": "^0.8.10", | ||
"playwright": "^1.47.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need @playwright/test
and playwright
as project dependencies. I think they should be moved to devDependencies
@@ -27,15 +27,23 @@ | |||
"eslint": "^9.12.0", | |||
"@eslint/js": "^9.12.0" | |||
}, | |||
"bundleDependencies": [], | |||
"license": "BSD", | |||
"engines": { | |||
"node": ">=0.8.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should update minimum Node version. This one is "stone age"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very true, but needs to be addressed in "master", not here
@@ -2,6 +2,8 @@ | |||
|
|||
# test TiddlyWiki5 for tiddlywiki.com | |||
|
|||
npm install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 15 there is npm install playwright ...
which is also added to package.json, which is installed here. -- I think line 15 is redundant
@@ -10,6 +10,7 @@ fi | |||
|
|||
# tw5.com readmes | |||
node $TW5_BUILD_TIDDLYWIKI \ | |||
+plugins/tiddlywiki/multiwikiserver \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does readme-bld.sh need the multiwikiserver plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a temporary measure while the PR is in development. It allows us to include content from the MWS plugin in the readme.
"@playwright/test": "^1.47.2", | ||
"better-sqlite3": "^9.4.3", | ||
"node-sqlite3-wasm": "^0.8.10", | ||
"playwright": "^1.47.2" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better sqlite3 version does not "npm install" on my Windows machine using Node.js 22.10.0
Version 11.5.0 which is latest does install.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better-sqlite3 v11.0.0 -- dropped support for Node.js v21 -- see: https://github.com/WiseLibs/better-sqlite3/releases/tag/v11.0.0
"user-initials": user.username.split(" ").map(name => name[0]).join(""), | ||
"user-role": JSON.stringify(userRole), | ||
"all-roles": JSON.stringify(allRoles), | ||
"is-current-user-profile": state.authenticatedUser && state.authenticatedUser.user_id === $tw.utils.parseInt(user_id, 10) ? "yes" : "no", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@webplusai - If you use $tw.utils.parseInt(str)
there is no need to add the radix param. Since the utility function takes care of it. See:
TiddlyWiki5/core/modules/utils/utils.js
Lines 980 to 982 in c7531e5
exports.parseInt = function(str) { | |
return parseInt(str,10) || 0; | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JFTR, you don't need it with the language's parseInt
either, if you're calling it as a global function, where the radix defaults to 10
. Of course if you're passing a reference to it into a function that calls it with additional parameters, you can be in for a surprise or two. The classic example is:
['1.1', '2.2', '3.3'].map(parseFloat) //=> [1.1, 2.2, 3.3]
// but
['1', '2', '3'].map(parseInt) //=> [1, NaN, NaN]
// hmm
That is not an issue, though with the current usage, either of the native version or the TW utility.
✅ Deploy Preview for symphonious-seahorse-84f7f9 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Tests were breaking in GitHub Actions but work OK on my machine. Problem was better-sqlite3 not being prebuilt, so I am testing to see if an update helps.
Introduction
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:
Recipe/bag Model
Hosted wikis can share content using the recipe/bag model from @cdent's TiddlyWeb. This is a simple but powerful way to organise content:
A very simple example of the recipe/bag model might be for a single user who maintains the following bags:
Those bags would be used with the following recipes:
All of this will work dynamically, so changes to the app bag will instantly ripple into the affected hosted wikis.
A more complex example might be for a teacher working with a group of students:
Those bags would be exposed through the following hosted wikis:
Usage
Then visit the administration interface in a browser: http://127.0.0.1:8080/
The
npm start
command is a shortcut for the following command:Note that changes are written to the topmost bag in a recipe.
Note that until syncing is improved it is necessary to use "Get latest changes from the server" to speed up propogation of changes between users.
To run the tests:
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:
Progress
SqlTiddlerStore
class for storing and retrieving tiddlers with bags and recipesSqlTiddlerStore
class/wiki/:recipe_name
HTTP route that serves a TW5 wiki template with the tiddlers from a given recipe spliced in--mws-save-archive
to handle attachments