Justicar
A Ruby obsessed static website generator that does web development Justice!
Installation
Install the gem:
$ gem install Justicar
Usage
Using the CLI:
$ justicar my_project # <- this generates a new project
$ cd my_project
$ bundle install # <- installs dependencies
$ bundle exec rake build # <- generates the website
$ bundle exec rake serve # <- locally host the project
To deploy using something like Cloudflare Pages use this as the build command:
bundle install && bundle exec rake build
And set the build output directory to build
How it works when your run rake serve
:
- Preprocess special files in Source Dir
- Process remaining files in Source Dir
- Copy Public Dir to Build Dir
- Write the Source Hash into Build Dir
- Note this can cause the Source Hash to overwrite files copied from the Public Dir
File types
.html.rb, .css.rb
These files are executed and the resulting string gets saved in a file using its respective relative path as well as using its filename(sans the .rb
) as the resulting file's name
.js.rb
These files get read and passed into the Opal parser to generate the resulting javascript. This gets saved in a file similiarly as html.rb
files.
.pre.rb
These are files that are executed before the file generation phase but do not get written anywhere. Here you should create a proc and store it in Justicar::PreProcessor
(see sample project for an example). These are files generally used for templates or articles where you want a table of contents.
.post.rb
These are files that are executed during the file generation phase but do not themselves get written anywhere. These files are generally used for programmatically generating multiple files (such as creating a bunch of article pages stored in the preprocessor). See sample project for an example.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/realtradam/Justicar.
License
The gem is available as open source under the terms of the MIT License.