-
Notifications
You must be signed in to change notification settings - Fork 327
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
Plugin bootstrap proof of concept #78
base: master
Are you sure you want to change the base?
Conversation
Feel free to try https://github.com/rajmahendra/JBakeProject This is done in same approach what you have shared. The code now become old since i took but @jonbullock need to take a path from V3 to modularize the jbake project structure. The one i have has broken the core jbake project and created 4 sub projects. |
I see there are two approach we can design the Plugin
Some use case are
For above plugin need to get the current processing page/post and work basked on that. (My plugin is not yet ready in this)
Some use case are
I have dilemma between these two approach i feel if our plugin supports both its nice. Also user some time have adding of the Templates also! this approach is too abstract but this is also a feature where the plugin developer have control of the current template also! As i mentioned above that it uses a lifecycle.. we can even build a plugin based on lifecycle of jbake also! Event-driven plugin ! (Just a wild guess! ) |
Great work and discussions going on here everyone. I've not forgotten about this, once the internal modularisation is complete plugin support is the next big feature to add. :) |
Note that in #68 (which I'm already using in production), I already allow custom page types, with custom templates. This is done only by declaring a new page type in jbake.properties, by convention:
Then you can use the "users" type in any content page. |
@melix users! you mean people involved in a website as authors right ? i feel we can call it Author :) |
I chose |
I went through your code. I saw the use of ServiceLoader, but how do the plugins actually get on the classpath (when JBake is used from the CLI, rather than embedded)?
Wouldn't these kinds of social plugins need to be in a template, rather than in post metadata? So the template could contain ${social_comments_fb} for Facebook comments, for example, which would be replaced by the appropriate HTML/JS. This would require plugins to be able to add entries to the data model. I don't understand the second set of usecases, as those seem to be handled just fine as templates? 2.2.1 even adds a sitemap template. Have plugin usecases been discussed anywhere else? |
Here's my original vision for plugins/extensions: There will be a number of hook or extension points in the JBake API, each at various points along the processing pipeline. Such as content crawling & parsing (to include more content than just static files), pre-processing (allowing modification of content before format conversion say from Markdown to HTML), post-processing (allowing modification of the HTML to be rendered), rendering (allowing template engine related alterations), and asset processing (allowing minification of CSS & JS or conversion from LESS to CSS). Each of these points will have their own plugin interface to allow multiple types of plugins, so there can be multiple plugins for each extension point. What each plugin can do depends on the interface for that extension point in the processing pipeline, so at the content crawling and parsing stage the plugin can interact with the content store. At the asset processing stage the plugin will be passed each asset file and it's up to the plugin to decide whether to perform additional processing on the file or not. I realise this is a proof of concept and slightly different to what I've just outlined however I can see having an init method potentially beneficial. I also like the idea of having a separate plugins folder. Anyway I just wanted to get my vision out into the public so it can be discussed, changed, fixed or updated. All comments welcome! I'll also knock up some diagram and post this to the dev mailing list too. |
Not really meant to be pulled, just an example how a plugin system could be bootstrapped:
plugin
directory is created next tolib
. JARs can be dropped in here.jbake
script addsplugin
to classpath (jbake.bat
not modified and only tested on Ubuntu, not Mac).JBakePlugin
interface and declare themselves as a service for that interface.Main
, aServiceLoader
picks up all implementations ofJBakePlugin
and callsinit
on each one.