-
Notifications
You must be signed in to change notification settings - Fork 654
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
Add web plugins functionality. #245
base: master
Are you sure you want to change the base?
Conversation
7ea6879
to
4470b77
Compare
@rlidwka Any thoughts about this? |
@tuvistavie , well my thoughts were mostly around "oh my god I need to find a time to check this". What's Looks like a good change overall. |
config: config, | ||
logger: logger, | ||
auth: auth, | ||
storage: storage, |
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.
What auth
and storage
are supposed to be used for in plugins?
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.
For the auth
, it would be mostly useful to check the roles of the user, and dynamically change the content of the plugin depending on it.
For the storage
, it could be used to build some package related stuff, for example a plugin that could give more details about each package.
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.
By the way, for the auth
part, I am already using it in
https://github.com/tuvistavie/sinopia-users-management
For the moment, this allows me to add users easily through the web interface.
Hi, thank you for the feedback, I understand it is quite a heavy PR. |
Hi,
This is a proposal to make sinopia web interface extensible.
Background
I am currently using sinopia in production, and I like it a lot.
There are some things that I would like to be able to do through the web interface, for example managing users, but it seems that there is no such functionality for the moment.
I believe this is not something that should belong to the core, so it would be great to be able to plugin some functionality in the web interface.
Implementation
Extract layout from
index.hbs
so it can be sharedSet all variables needed for the layout in a middleware
Load all plugins listed in
config.web_plugins
and use them as an express middleware. Plugins should export a function called with the following parametersconfig
: Sinopia configurationlogger
: Sinopia loggerauth
: The authentication modulestorage
: The storage moduleHandlebars
: TheHandlebars
object with the registered layout (it does not seem to be possible to reuse the layout when requiring Handlebars from another file)and return an object with the following keys:
title
: The displayed title of the pluginbasePath
: The base path for the pluginmiddleware
: The express middleware for the pluginWith the above implementation, a plugin can be created with a code like this:
And will be available at
/-/users
(whereusers
is thebasePath
exported by the plugin).When present, plugins are available from the header as a dropdown menu.
This change only concerns the web interface, and does not change anything in the rest of the application nor makes anything incompatible with previous versions of sinopia.
Please tell me what you think about it.
Thanks.