-
Notifications
You must be signed in to change notification settings - Fork 234
Description
This a tracking bug and "design doc" for the next mayor update that will be about extension support.
Requirement:
- Users should be able extend the app without rebuilding the application
- app restart after a new extension install is acceptable
- "extending the app" mean business logic changes on both server and client-side
- extensions should also support at least some UI modifications
- Extensions should be configurable (should show in the settings)
- There should be a repository where users can easily download extensions from. Preferably integrated in the app.
Design ideas
Extension will live in their own folder, next to the config.json file. config folder is by default writable from the docker setup, so it should be easy to add there more files.
It will be written in Javascript (I hope its not a question :) ).
server side extension
Creating a server side extension is the easy part. The app will assume a presence of an server.js
that has a function init(app)
function. App will call the init function of all extensions on startup.
If the folder has package.json, the app will run an npm isntall
so that the extension developers can use external libraries (like if someone wants to develop an extension to support bmp files).
The app
object in the init
function will represent an interface to the app, where extension developers can subscribe to certain events of the app. These events will be, like: before directory scanning
or after directory scanning
. With this developers can override the input and the output of the directory scanning event. (So things like also indexing doc files or skipping files that start with _
can be added).
Furthermore app
object will also export low level api. Low level API will be less stable than the exported events, but with that developers can override any aspect of the app without restriction.
app
object will also export the currently used config.
client side extensions
This is the tricky one as the client side is built and minified and localized AOT with webpack. Therefore there is one build app for all language. Exposing the full client app to the extension is not an option as its is not possible to know in extension development time how webapck will minify the function names.
I also could not find a way to add new angular component to the app after compile. Eg.: So I do not see a way to add UI for supporting docx files on UI through extensions.
I was thinking about exposing callback for the client extension, where developers can add icons or buttons in a very restrictive way to the app. And also here could the developer inject some business logic to the client.
repository
I do not want to host a custom repository. I think I will just "hack" it into a readme file. Developers will maintain extensions on github and add a link to their repo to to a readme file in the repository. This way the app will be able to auto discover the list of extensions.
Future work
Security can be implemented in the future where the app makes it explicit what resources an extension uses. Like it changes the config or touches low-level APIs.
Open questions
I don't really know how to solve the client side extension support properly
Sub tasks
- Create server side extension API #753
- Create extension repo #783
- Create settings panel to add extensions #784
- Create client side extension API