Project

munge

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
== Documentation Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.19.0/README.md
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.9
~> 0.6
~> 5.8
~> 0.6
~> 10.0
~> 3.3
~> 0.32
~> 0.10
~> 0.8
~> 0.9.0

Runtime

~> 1.2
~> 0.5.0
< 3.1, ~> 3.0
< 3.0, >= 1.99.1
~> 0.6
~> 3.4
~> 0.19
~> 2.0
 Project Readme

Munge

Build Status Code Climate Test Coverage

Munge is a static site generator aiming to simplify complex build rules.

It's built partially to emulate unix pipes and scripts; small transformations can be joined, composed, and applied to create almost any site you can think up.

SemVer will be followed once 1.0.0 is released. Until then, the API should be considered experimental.

Features

  • No DSL
  • No metaprogramming
  • LiveReload
  • Optional frontmatter
  • Suitable for large, complex sites (e.g., multiple blogs with different templates, a single blog with multiple data sources)
  • Very configurable
  • Concise rule definition
  • Rules defined by iterating through arrays and modifying matching objects

Caveats

  • Not yet optimized (Pull requests welcome, gradual optimizations preferred)
  • User facing API has mostly stabilized, but plugins have yet to be fully worked out

Installation

Add this line to your application's Gemfile:

gem "munge"

And then execute:

$ bundle

Or install it yourself as:

$ gem install munge

Usage

After installing your gem, you can start a project using the command line client.

munge init path/to/project  # create a barebones project
cd path/to/project
munge server                # starts auto-compiling dev server http://localhost:7000/
munge build                 # compiles your project for production
munge view                  # preview production build on http://localhost:7000/

The three main files of your application are config.yml, data.yml, and rules.rb.

Here's an example rules.rb for a blog.

# home page
app.unrouted
  .select { |item| item.id == "home" }      # looks for items where path is "src/home.*"
  .each   { |item| item.route = "" }        # sets output file to "/index.html"
  .each   { |item| item.layout = "default"} # sets layout to "layouts/default.*"
  .each   { |item| item[:title] = "home" }  # sets additional frontmatter variables
  .each   { |item| item.transform(:tilt) }  # have Tilt compile this file

# blog posts
app.unrouted
  .select { |item| item.relpath?("posts") }               # looks for items in "src/posts/**/*"
  .each   { |item| item.route = "blog/#{item.basename}" } # sets output file to "/blog/#{basename}/index.html"
  .each   { |item| item.layout = "post" }
  .each   { |item| item.transform }                       # sets transform to Tilt (default)

# blog index
posts_for_index =
  app.routed
    .select  { |item| item.route?("blog") }
    .sort_by { |item| item.route }
    .reverse

app.create("blog/index.html.erb", "", posts: posts_for_index)
  .each { |item| item.route = "blog" }
  .each { |item| item.layout = "list" }
  .each { |item| item.transform }

Guides

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/zachahn/munge.

Please open an issue before creating a pull request to discuss whether any new feature should be included as part of the core library or as an external plugin.

License

The gem is available as open source under the terms of the MIT License.