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

Rendering modularization #68

Merged
merged 18 commits into from
Jan 26, 2014
Merged

Conversation

melix
Copy link
Contributor

@melix melix commented Dec 24, 2013

Hi!

This is a pretty big pull request that refreshes the rendering architecture. With this patch:

  • JBake uses an internal, potentially in memory, database to store documents converted from markup engines
  • if using a local dabatase (default), then JBake now only renders pages that have changed
  • rendering can be forced using the --reset command line option
  • rendering will be forced if the templates change
  • separation of the template engine from core, making Freemarker optional
  • added an alternative, optional, Groovy template engine
  • template engines have access to the database, which means they can optimize memory usage (depending on the underlying engine, more difficult to do with Freemarker)
  • "index", "archive", "feed" are now considered as document types, meaning you can use them as you would use "page" or "post"
  • tags are still rendered with special handling
  • support for custom document types. The list of document types is extracted from the configuration file (template.[doctype].file

Comments welcome!

@melix
Copy link
Contributor Author

melix commented Jan 7, 2014

Actually the case where you need to flush the cache is more complex than just a template change. Take the index, for example. It depends on the list of posts, so if you add a post, you need to re-render the index. The caching strategy should ideally handle that, even if you can force rendering with --reset.

@jonbullock
Copy link
Member

@melix I'll have a look at that when I finally get round to merging this in.

@melix
Copy link
Contributor Author

melix commented Jan 10, 2014

Regarding the caching issue, I'm wondering if adding a jbake-render: always meta tag wouldn't help. In that case, the index would for example have that flag, forcing it to always be rendered again.

Otherwise, I don't see any solution apart from removing caching.

@jonbullock
Copy link
Member

Sounds like a reasonable option to me. Oh and thanks for removing the license headers!

@melix
Copy link
Contributor Author

melix commented Jan 14, 2014

Ok, I made the change, plus custom document types are now directly available from templates. For example, if you have a custom document type named foo, then foos in a template references the list of documents of type foo.

@glaforge
Copy link

What's the status of this PR?
Any plans for new releases including that PR?

@jonbullock
Copy link
Member

I'm aiming to get the v2.2.1 release out this weekend then this PR along with #67 will be included in the next release which is scheduled to be v2.3.0, ideally as soon as possible.

@melix
Copy link
Contributor Author

melix commented Jan 23, 2014

I am wondering how I should proceed, because master has changed a lot since this PR. In particular, mardown rendering engine has changed, which directly conflicts with the changes I made for parser modularization (#67).

Maybe a branch for 2.3 would be a good idea, that would avoid PRs to stay open for too long and get outdated. You could then backport (cherry pick) changes that you want in master back in 2.3.

@mwanji
Copy link
Contributor

mwanji commented Jan 23, 2014

@melix maybe it would be possible to split this up into several PRs, prioritise them and rework them on top of HEAD in priority order? That might not be less work, but it might make it easier for @jonbullock to merge in?

I see at least 3 different features:

  • incremental rendering
  • multiple template engines
  • custom document types

Personally, I'm most interested in incremental rendering, which would go great with watching for changes, so maybe I could help extract it, if you decide to do that?

@melix
Copy link
Contributor Author

melix commented Jan 23, 2014

Well, the problem is at the very beginning. For example, the switch to pegdown broke parsing modularization, because it doesn't use the rework, of course. I don't want to redo the job multiple times, so I'd prefer doing a merge at some point.

melix added 18 commits January 24, 2014 21:33
   * if a JBake supported engine is not found on classpath, we must skip it too
   * if a JBake supported engine is not found on classpath, we must skip it too
   * added an ErrorEngine so that the user gets nice error message on rendered page
   * make use of OrientDB to store documents converted by parsers
   * support for incremental rendering if source file changed
   * prepare work for multiple document types
   * prepare work for multiple template engines
   * Introduced abstract renderer
   * Freemarker is an implementation of a renderer
   * Renderer delegates to FreemarkerRenderer
    * Renamed renderers to template engines (closer to the concept)
    * introduced a delegating template engine
    * separated Freemarker from core and made it optional
    * tags do not require the full list of docs in RAM anymore
    * renamed org.jbake.parser.Engines.properties to MarkupEngines.properties
    * "index", "archive" and "feed" are normal document types (config options are now optional)
   * added GroovyTemplateEngine
   * GroovyRendererTest test case uses .gsp files equivalent to .ftl
   * read from configuration file (template.[doctype].file)
    * template change <=> force rendering of all documents
    * use SHA1 based hashing to compute a checksum of the templates directory
    * use the directory granularity because templates may include other templates
   * Writer is more modular
   * allows the Groovy template engine to gain access to the other rendering engines
   * so you can do "include 'freemarker-template.ftl' from a Groovy template
   * :jbake-cached: false inside Asciidoctor files
   * forces rendering of a page even if contents or template hasn't change
   * fix rendering of index
   * make all document types (including custom types) available from templates
@melix
Copy link
Contributor Author

melix commented Jan 24, 2014

Rebased onto master

@ghost ghost assigned jonbullock Jan 24, 2014
@jonbullock
Copy link
Member

Thanks again.

jonbullock added a commit that referenced this pull request Jan 26, 2014
@jonbullock jonbullock merged commit f5cf5be into jbake-org:master Jan 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants