README.md in munge-0.1.0 vs README.md in munge-0.2.0
- old
+ new
@@ -1,74 +1,75 @@
# Munge
+[![Build Status](https://travis-ci.org/zachahn/munge.svg?branch=master)](https://travis-ci.org/zachahn/munge)
+[![Code Climate](https://codeclimate.com/github/zachahn/munge/badges/gpa.svg)](https://codeclimate.com/github/zachahn/munge)
+[![Test Coverage](https://codeclimate.com/github/zachahn/munge/badges/coverage.svg)](https://codeclimate.com/github/zachahn/munge/coverage)
+
Munge is a static site generator aiming to simplify complex build rules.
SemVer will be followed once 1.0.0 is released.
Until then,
the API should be considered experimental.
-## Usage
+## Installation
-**Directory structure**
+Add this line to your application's Gemfile:
+```ruby
+gem 'munge'
```
-dest/
-src/
- layouts/
- layout.html
- index.html
-application.rb
-config.yml
-Gemfile
-```
-**`application.rb`**
+And then execute:
-```ruby
-require "munge"
+ $ bundle
-app = Munge::Application.new("./config.yml")
+Or install it yourself as:
-app.source
- .reject { |item| item.path.relative =~ %r(^layouts/) }
- .each { |item| item.route = item.path.dirname }
- .map { |item| item.path.dirname }
+ $ gem install munge
-app.write
-```
-**`config.yml`**
+## Usage
-```yaml
----
-source: src
-dest: dest
-binary_extensions:
- - jpg
- - jpeg
- - png
- - gif
- - ico
-index: index.html
+After installing your gem, you can start a project using the command line client.
+
```
+munge init path/to/project
+```
+The three main files of your application are `config.yml`, `data.yml`, and `rules.rb`.
-## Installation
+Here's an example `rules.rb` for a blog.
-Add this line to your application's Gemfile:
-
```ruby
-gem 'munge'
-```
+# home page
+app.source
+ .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
-And then execute:
+# blog posts
+app.source
+ .select { |item| item.relpath =~ %r(^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)
- $ bundle
+# blog index
+posts_for_index =
+ app.source
+ .find_all { |item| item.route =~ %r(^blog/) }
+ .sort_by { |item| item.route }
+ .reverse
-Or install it yourself as:
-
- $ gem install munge
+app.create("blog/index.html.erb", "", posts: posts_for_index) do |item|
+ item.route = "blog" # sets output file to "/blog/index.html"
+ item.layout = "list"
+ item.transform
+end
+```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/zachahn/munge.