MoreaGenerator plugin
The Morea plugin is a Jekyll plugin written in Ruby and located in the _plugins
directory.
The plugin code is pretty straightforward, though not well-written. (Part of the attraction of developing the Morea Framework for me was the chance to try Ruby, so MoreaGenerator is my first and (at the time of writing) only Ruby program I have ever written.) I would gratefully accept pull requests that improve the structure and use of Ruby language idioms.
The plugin works as follows:
The
generate()
method reads in all of the files in themorea/
directory. All files that end in the extension.md
are assumed to be "real" Morea files, in that they should have morea IDs and so forth. These files are processed in theprocessMoreaFile()
method. Other files not ending in.md
are just handed off to Jekyll for standard processing through theprocessNonMoreaFile()
method.The
processMoreaFile()
method creates a newMoreaPage
instance corresponding to each file. AMoreaPage
is just a regular JekyllPage
with some additional state, such as the related outcomes, referencing assessments, referencing modules, etc.The
processMoreaFile()
method also figures out the type of the instance (i.e. Module, Outcome, Reading, Experience, or Assessment) and updates site variables that hold all of the defined Morea instances of each type. In the case of Modules, there is a special instance calledModulePage
that is created.There is data validation done in both
processMoreaFile()
(where each page is checked for required YAML front matter, such as a morea_id field) and in thegenerate()
method (after all of the pages are read in, we check to make sure that a reference to a morea_id has an associated instance and so forth.If we have read in all of the files and didn't detect any data validation errors, then the plugin ends normally after printing out some summary statistics. If any fatal data validation errors occur, then the plugin prints out a message indicating the problem and calls
exit
to terminate Jekyll immediately. Though experience, I've found it's more user friendly to "fail fast" and force you to fix errors right away.