munge 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0a3b52e10d621eb9279d8e67047237914533a18
4
- data.tar.gz: 772664c0d20c42a8ebc98bf158cef506429b73cf
3
+ metadata.gz: a89ec9386b6243aad9b81eefacf82593e7ed7398
4
+ data.tar.gz: 207829f90d9401f2e67515ab50c8bbfb236d1bfb
5
5
  SHA512:
6
- metadata.gz: 146e9511c1b41e8326657a16e20993fc44506d35b784194e8c182a2c60d0f1744a7ea85a222320ed28eb038b99e8ef9093996f7860058c377815fdeeaf7a2439
7
- data.tar.gz: 77d5320774df65fd79e61dc417f2a9a4c7fd3856da5654b7055553d56d9607bbd93f3d98b9b83bd1981d178bb4330235a1f2ae3bcd75554ab6d43843a809f161
6
+ metadata.gz: 88bda267fc35cf2ff6b74e4e2500505aca408d306fabdc2201386721d82b801cb1bd70ee43f015caec48356d13b84f5f8c5d2922d2c2da34b03fa695996dceaa
7
+ data.tar.gz: acd79ec11a7b1fc356aaa3323e51c748bcbbf24add3d37ebc826dd510a8dacfb9cc9d73efdaa15c7fd0d11087987bec2a94fe880e74af332599d78aa14a7335c
data/README.md CHANGED
@@ -87,6 +87,11 @@ app.create("blog/index.html.erb", "", posts: posts_for_index)
87
87
  ```
88
88
 
89
89
 
90
+ ## Guides
91
+
92
+ - [FAQ](guides/faq.md)
93
+
94
+
90
95
  ## Contributing
91
96
 
92
97
  Bug reports and pull requests are welcome on GitHub at https://github.com/zachahn/munge.
@@ -15,18 +15,24 @@ module Munge
15
15
  content_tag(:script, options)
16
16
  end
17
17
 
18
+ def image_tag(basename, options = {})
19
+ options[:src] ||= image_path(basename)
20
+
21
+ empty_tag(:img, options)
22
+ end
23
+
18
24
  def inline_stylesheet_tag(basename, options = {})
19
- inline_asset_tag_helper(stylesheets_root, basename, :style, options)
25
+ inline_asset_tag_helper(:stylesheet_path, basename, :style, options)
20
26
  end
21
27
 
22
28
  def inline_javascript_tag(basename, options = {})
23
- inline_asset_tag_helper(javascripts_root, basename, :script, options)
29
+ inline_asset_tag_helper(:javascript_path, basename, :script, options)
24
30
  end
25
31
 
26
32
  private
27
33
 
28
- def inline_asset_tag_helper(root, basename, tag, options)
29
- rendered_asset = render(items["#{root}/#{basename}"])
34
+ def inline_asset_tag_helper(asset_path_method, basename, tag, options)
35
+ rendered_asset = render(send(asset_path_method, basename))
30
36
 
31
37
  content_tag(tag, rendered_asset, options)
32
38
  end
@@ -3,7 +3,7 @@ module Munge
3
3
  module Link
4
4
  def path_to(itemish)
5
5
  item =
6
- if item.is_a?(String)
6
+ if itemish.is_a?(String)
7
7
  system.items[itemish]
8
8
  else
9
9
  itemish
@@ -7,7 +7,7 @@ module Munge
7
7
  end
8
8
 
9
9
  def call(relpath)
10
- dirname = Munge::Util::Path.dirname(relpath)
10
+ dirname = Munge::Util::Path.ensure_relpath(Munge::Util::Path.dirname(relpath))
11
11
  basename = Munge::Util::Path.basename_no_extension(relpath)
12
12
  extensions = Munge::Util::Path.extnames(relpath)
13
13
 
data/lib/munge/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Munge
2
- VERSION = "0.13.0".freeze
2
+ VERSION = "0.14.0".freeze
3
3
  end
@@ -0,0 +1,7 @@
1
+ <% layout("default") do %>
2
+ <ul>
3
+ <% posts.each do |post| %>
4
+ <li><a href="<%= path_to(post) %>"><%= post.basename %></a></li>
5
+ <% end %>
6
+ </ul>
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% layout("default") do %>
2
+ <h1>Blog</h1>
3
+
4
+ <% posts.each do |post| %>
5
+ <%= render(post) %>
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <% layout("default") do %>
2
+ <%= yield %>
3
+ <% end %>
data/seeds/lib/routing.rb CHANGED
@@ -3,22 +3,26 @@ if ENV["MUNGE_ENV"] == "production"
3
3
  Routers::Fingerprint.new(
4
4
  extensions: config[:bin_extensions] + config[:bintext_extensions],
5
5
  separator: config[:fingeprint_separator]
6
- ))
6
+ )
7
+ )
7
8
  end
8
9
 
9
10
  system.router.register(
10
11
  Routers::RemoveIndexBasename.new(
11
12
  html_extensions: config[:text_extensions],
12
13
  index: config[:index]
13
- ))
14
+ )
15
+ )
14
16
 
15
17
  system.router.register(
16
18
  Routers::AddIndexHtml.new(
17
19
  html_extensions: config[:text_extensions],
18
20
  index: config[:index]
19
- ))
21
+ )
22
+ )
20
23
 
21
24
  system.router.register(
22
25
  Routers::AutoAddExtension.new(
23
26
  keep_extensions: config[:bin_extensions] + config[:bintext_extensions]
24
- ))
27
+ )
28
+ )
data/seeds/rules.rb CHANGED
@@ -1,35 +1,65 @@
1
- # HTML rules
1
+ # General route helpers
2
+ transform = -> (item) { item.transform }
3
+
4
+ # Blog rules
5
+ blog_items =
6
+ app.nonrouted
7
+ .select { |item| item.relpath?("blog") }
8
+ .sort_by { |item| item.basename }
9
+ .each { |item| item[:hide] = item.extensions.include?("draft") }
10
+ .each { |item| item[:text] = item.content.valid_encoding? }
11
+ .each { |item| item.route = "blog/#{item.basename}" }
12
+ .reverse
13
+
14
+ blog_public_items = blog_items.select { |i| !i[:hide] && i[:text] }
15
+ blog_index_items = blog_public_items[0..7]
16
+
17
+ blog_items
18
+ .select { |item| item[:text] }
19
+ .each { |item| item.layout = "blog_show" }
20
+ .each(&transform)
21
+
22
+ app.create("blog-index.html.erb", "", posts: blog_index_items)
23
+ .each { |item| item.route = "blog" }
24
+ .each { |item| item.layout = "blog_index" }
25
+ .each(&transform)
26
+
27
+ app.create("blog-archive.html.erb", "", posts: blog_public_items)
28
+ .each { |item| item.route = "blog/archives" }
29
+ .each { |item| item.layout = "blog_archives" }
30
+ .each(&transform)
31
+
32
+ # Home page rules
2
33
  app.nonrouted
3
- .select { |item| item.extensions.include?("html") }
4
- .each { |item| item.route = item.basename }
34
+ .select { |item| item.relpath?("home") }
35
+ .each { |item| item.route = "#{item.id.sub(%r{^home/}, "")}" }
5
36
  .each { |item| item.layout = "default" }
6
- .each { |item| item.transform }
37
+ .each(&transform)
38
+
39
+ # Asset route helpers
40
+ def app_asset(subdir)
41
+ app.nonrouted
42
+ .select { |item| item.relpath?("assets/#{subdir}") }
43
+ .reject { |item| item.basename[0] == "_" }
44
+ end
7
45
 
8
46
  # Font rules
9
- app.nonrouted
10
- .select { |item| item.relpath?("assets/fonts") }
11
- .reject { |item| item.basename[0] == "_" }
12
- .each { |item| item.route = item.relpath }
47
+ app_asset("fonts")
48
+ .each { |item| item.route = "/assets/#{item.filename}" }
13
49
 
14
50
  # Image rules
15
- app.nonrouted
16
- .select { |item| item.relpath?("assets/images") }
17
- .reject { |item| item.basename[0] == "_" }
18
- .each { |item| item.route = item.relpath }
51
+ app_asset("images")
52
+ .each { |item| item.route = "/assets/#{item.filename}" }
19
53
 
20
54
  # JS rules
21
- app.nonrouted
22
- .select { |item| item.relpath?("assets/javascripts") }
23
- .reject { |item| item.basename[0] == "_" }
24
- .each { |item| item.route = "/#{item.dirname}/#{item.basename}.js" }
25
- .each { |item| item.transform }
55
+ app_asset("javascripts")
56
+ .each { |item| item.route = "/assets/#{item.basename}.js" }
57
+ .each(&transform)
26
58
 
27
59
  # CSS rules
28
- app.nonrouted
29
- .select { |item| item.relpath?("assets/stylesheets") }
30
- .reject { |item| item.basename[0] == "_" }
31
- .each { |item| item.route = "/#{item.dirname}/#{item.basename}.css" }
32
- .each { |item| item.transform }
60
+ app_asset("stylesheets")
61
+ .each { |item| item.route = "/assets/#{item.basename}.css" }
62
+ .each(&transform)
33
63
 
34
64
  # Sitemap
35
65
  html_pages =
@@ -0,0 +1,3 @@
1
+ ## First Post
2
+
3
+ I love using munge!
@@ -0,0 +1,3 @@
1
+ ## Wow!
2
+
3
+ This is really cool!
@@ -0,0 +1,3 @@
1
+ ## This is a draft
2
+
3
+ This file is hidden from the primary view, but it is still compiled.
@@ -7,5 +7,3 @@ title: About
7
7
  <p>
8
8
  This is an example of a cool About page.
9
9
  </p>
10
-
11
- <%= render(layouts["sitemap"]) %>
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: Welcome
2
+ title: Woohoo!
3
3
  ---
4
4
 
5
5
  <h1><%= title %></h1>
@@ -28,12 +28,17 @@ title: Welcome
28
28
  <code>setup.rb</code>.
29
29
  </p>
30
30
 
31
- <h2>Links</h2>
31
+ <h2>Example Links</h2>
32
+
33
+ <ul>
34
+ <li><%= link_to(items["blog-index.html"], "Example blog") %></li>
35
+ <li><%= link_to(items["home/about.html"], "Example page") %></li>
36
+ </ul>
37
+
38
+ <h2>Munge Links</h2>
32
39
 
33
40
  <ul>
34
41
  <li><a href="https://github.com/zachahn/munge">Munge homepage</a></li>
35
42
  <li><a href="https://github.com/zachahn/munge/issues">Munge issues</a></li>
36
43
  <li><a href="https://rubygems.org/gems/munge">Gem homepage</a></li>
37
44
  </ul>
38
-
39
- <%= render(layouts["sitemap"]) %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: munge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-21 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -288,27 +288,7 @@ dependencies:
288
288
  - - "~>"
289
289
  - !ruby/object:Gem::Version
290
290
  version: '3.4'
291
- - !ruby/object:Gem::Dependency
292
- name: rack
293
- requirement: !ruby/object:Gem::Requirement
294
- requirements:
295
- - - ">="
296
- - !ruby/object:Gem::Version
297
- version: '1.0'
298
- - - "<"
299
- - !ruby/object:Gem::Version
300
- version: '2.0'
301
- type: :runtime
302
- prerelease: false
303
- version_requirements: !ruby/object:Gem::Requirement
304
- requirements:
305
- - - ">="
306
- - !ruby/object:Gem::Version
307
- version: '1.0'
308
- - - "<"
309
- - !ruby/object:Gem::Version
310
- version: '2.0'
311
- description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.13.0/README.md
291
+ description: Documentation for this release is located in https://github.com/zachahn/munge/blob/v0.14.0/README.md
312
292
  email:
313
293
  - zach.ahn@gmail.com
314
294
  executables:
@@ -373,6 +353,9 @@ files:
373
353
  - seeds/Gemfile.tt
374
354
  - seeds/config.yml
375
355
  - seeds/data.yml
356
+ - seeds/layouts/blog_archives.html.erb
357
+ - seeds/layouts/blog_index.html.erb
358
+ - seeds/layouts/blog_show.html.erb
376
359
  - seeds/layouts/default.html.erb
377
360
  - seeds/layouts/sitemap.html.erb
378
361
  - seeds/lib/_asset_roots.rb
@@ -381,13 +364,16 @@ files:
381
364
  - seeds/lib/view_helpers.rb
382
365
  - seeds/rules.rb
383
366
  - seeds/setup.rb
384
- - seeds/src/about.html.erb
385
367
  - seeds/src/assets/fonts/.empty_directory
386
368
  - seeds/src/assets/images/.empty_directory
387
369
  - seeds/src/assets/javascripts/.empty_directory
388
370
  - seeds/src/assets/stylesheets/_vars.scss
389
371
  - seeds/src/assets/stylesheets/basic.css.scss
390
- - seeds/src/index.html.erb
372
+ - seeds/src/blog/01-first-post.md
373
+ - seeds/src/blog/02-second-post.md
374
+ - seeds/src/blog/03-third-post.draft.md
375
+ - seeds/src/home/about.html.erb
376
+ - seeds/src/home/index.html.erb
391
377
  homepage: https://github.com/zachahn/munge
392
378
  licenses:
393
379
  - MIT
@@ -408,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
408
394
  version: '0'
409
395
  requirements: []
410
396
  rubyforge_project:
411
- rubygems_version: 2.4.5
397
+ rubygems_version: 2.5.2
412
398
  signing_key:
413
399
  specification_version: 4
414
400
  summary: Static site generator aiming to simplify complex build rules