Skip to content
This repository was archived by the owner on Nov 1, 2017. It is now read-only.

Commit e852fc6

Browse files
committed
Upgrade to Nanoc 4
1 parent dec1cf3 commit e852fc6

25 files changed

+82
-155
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
22

33
gem 'builder'
44
gem 'kramdown', '~> 0.13.2'
5-
gem 'nanoc', '~> 3.7'
5+
gem 'nanoc', '~> 4.0'
66
gem 'nokogiri', '~> 1.6.0'
77
gem 'rouge', '~> 1.4'
88
gem 'rake', '~> 0.9.2'

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GEM
99
timers (~> 1.1.0)
1010
coderay (1.1.0)
1111
colored (1.2)
12-
cri (2.6.1)
12+
cri (2.7.0)
1313
colored (~> 1.2)
1414
ethon (0.7.4)
1515
ffi (>= 1.3.0)
@@ -42,7 +42,7 @@ GEM
4242
mercenary (0.3.5)
4343
method_source (0.8.2)
4444
mini_portile (0.6.2)
45-
nanoc (3.7.1)
45+
nanoc (4.0.0)
4646
cri (~> 2.3)
4747
nokogiri (1.6.6.2)
4848
mini_portile (~> 0.6.0)
@@ -74,7 +74,7 @@ DEPENDENCIES
7474
guard-nanoc
7575
html-proofer (~> 2.5)
7676
kramdown (~> 0.13.2)
77-
nanoc (~> 3.7)
77+
nanoc (~> 4.0)
7878
nokogiri (~> 1.6.0)
7979
rake (~> 0.9.2)
8080
rouge (~> 1.4)

Rakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require_relative 'lib/resources'
2-
require 'nanoc3/tasks'
32
require 'tmpdir'
43

54
task :default => [:test]
@@ -10,7 +9,7 @@ task :compile do
109
end
1110

1211
desc "Test the output"
13-
task :test => [:clean, :remove_output_dir, :compile, :run_proofer]
12+
task :test => [:remove_tmp_dir, :remove_output_dir, :compile, :run_proofer]
1413

1514
desc "Run the HTML-Proofer"
1615
task :run_proofer do
@@ -25,6 +24,11 @@ task :run_proofer do
2524
HTML::Proofer.new("./output", :href_ignore => ignored_links, :href_swap => href_swap).run
2625
end
2726

27+
desc "Remove the tmp dir"
28+
task :remove_tmp_dir do
29+
FileUtils.rm_r('tmp') if File.exist?('tmp')
30+
end
31+
2832
desc "Remove the output dir"
2933
task :remove_output_dir do
3034
FileUtils.rm_r('output') if File.exist?('output')

Rules

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,19 @@
44
#
55
# * The order of rules is important: for each item, only the first matching
66
# rule is applied.
7-
#
8-
# * Item identifiers start and end with a slash (e.g. “/about/” for the file
9-
# “content/about.html”). To select all children, grandchildren, … of an
10-
# item, use the pattern “/about/*/”; “/about/*” will also select the parent,
11-
# because “*” matches zero or more characters.
127

138
# Reset search-index by deleting it every time
149
preprocess do
1510
File.delete("output/search-index.json") if File.exists?("output/search-index.json")
1611
generate_redirects(config[:redirects])
1712
end
1813

19-
compile '/static/*' do
14+
compile '/static/**/*' do
2015
end
2116

22-
compile '/CNAME/' do
23-
end
17+
passthrough '/CNAME'
2418

25-
compile '/feed/' do
19+
compile '/feed.*' do
2620
filter :erb
2721
filter :kramdown, :toc_levels => [2]
2822
end
@@ -33,10 +27,10 @@ compile '/integrations-directory/*' do
3327
filter :tip_filter
3428
filter :colorize_syntax,
3529
:colorizers => {:javascript => :rouge}
36-
layout item[:layout] || 'integrations-directory'
30+
layout item[:layout] || '/integrations-directory.*'
3731
end
3832

39-
compile '/v3/*' do
33+
compile '/v3{.*,/**/*}' do
4034
filter :search
4135
filter :erb
4236
filter :kramdown, :toc_levels => [2]
@@ -45,58 +39,56 @@ compile '/v3/*' do
4539
filter :tip_filter
4640
filter :colorize_syntax,
4741
:colorizers => {:javascript => :rouge}
48-
layout item[:layout] || 'api'
42+
layout(item[:layout] ? "/#{item[:layout]}.*" : '/api.*')
4943
end
5044

51-
%w(v3 */).each do |version|
52-
compile "/changes/#{version}" do
53-
filter :erb
54-
filter :kramdown, :toc_levels => [2]
55-
filter :colorize_syntax,
56-
:colorizers => {:javascript => :rouge}
57-
layout 'changes' if version[0] == '*'
58-
layout item[:layout] || 'blog'
59-
end
45+
compile "/changes/20*" do
46+
filter :erb
47+
filter :kramdown, :toc_levels => [2]
48+
filter :colorize_syntax,
49+
:colorizers => {:javascript => :rouge}
50+
layout '/changes.*'
51+
layout(item[:layout] ? "/#{item[:layout]}.*" : '/blog.*')
6052
end
6153

62-
compile '/guides/*' do
54+
compile '/guides/**/*' do
6355
filter :kramdown, :toc_levels => [2]
6456
filter :tip_filter
6557
filter :erb
6658
filter :colorize_syntax, :default_colorizer => :rouge
67-
layout item[:layout] || 'guides'
59+
layout(item[:layout] ? "/#{item[:layout]}.*" : '/guides.*')
6860
end
6961

70-
compile '/webhooks/*' do
62+
compile '/webhooks/**/*' do
7163
filter :kramdown, :toc_levels => [2]
7264
filter :tip_filter
7365
filter :erb
7466
filter :colorize_syntax, :default_colorizer => :rouge
75-
layout item[:layout] || 'webhooks'
67+
layout(item[:layout] ? "/#{item[:layout]}.*" : '/webhooks.*')
7668
end
7769

78-
compile '*' do
70+
compile '/**/*' do
7971
filter :erb
8072
filter :kramdown, :toc_levels => [2]
8173
filter :colorize_syntax,
8274
:colorizers => {:javascript => :rouge}
83-
layout item[:layout] || 'default'
75+
layout(item[:layout] ? "/#{item[:layout]}.*" : '/default.*')
8476
end
8577

86-
route '/static/*' do
87-
item.identifier[7..-2]
78+
route '/static/**/*' do
79+
item.identifier.to_s.sub(/\A\/static/, '')
8880
end
8981

90-
route '/CNAME/' do
91-
'/CNAME'
82+
route '/feed.*' do
83+
'/changes.atom'
9284
end
9385

94-
route '/feed' do
95-
'/changes.atom'
86+
route '/**/index.*' do
87+
item.identifier.without_ext + '.html'
9688
end
9789

98-
route '*' do
99-
item.identifier + 'index.html'
90+
route '/**/*' do
91+
item.identifier.without_ext + '/index.html'
10092
end
10193

102-
layout '*', :erb
94+
layout '/**/*', :erb

config.yaml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,13 @@ enable_output_diff: false
2525
# “layout/” directories in the site directory.
2626
data_sources:
2727
-
28-
# The type is the identifier of the data source. By default, this will be
29-
# `filesystem_unified`.
30-
type: filesystem_unified
31-
32-
# The encoding to be used (on Windows this is not utf-8 by default)
28+
type: filesystem
3329
encoding: utf-8
34-
35-
# The path where items should be mounted (comparable to mount points in
36-
# Unix-like systems). This is “/” by default, meaning that items will have
37-
# “/” prefixed to their identifiers. If the items root were “/en/”
38-
# instead, an item at content/about.html would have an identifier of
39-
# “/en/about/” instead of just “/about/”.
40-
items_root: /
41-
42-
# The path where layouts should be mounted. The layouts root behaves the
43-
# same as the items root, but applies to layouts rather than items.
44-
layouts_root: /
45-
4630
-
47-
type: static
31+
type: filesystem
4832
items_root: /static
33+
content_dir: static
34+
layouts_dir: nil
4935

5036
# For the atom feed.
5137
base_url: http://developer.github.com

content/changes/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
layout: blog
44
---
55

6-
<%= render '_changes', :changes => api_changes %>
6+
<%= render '/_changes.*', :changes => api_changes %>
77

content/integrations-directory/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Integrations Directory | GitHub API
3-
layout: integrations-directory
3+
layout: /integrations-directory.*
44
---
55

66
# Overview

layouts/_changes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% @changes.each do |article| %>
22
<div class="change" id="<%= article.path %>">
3-
<%= render '_meta', :item => article %>
3+
<%= render '/_meta.*', :item => article %>
44
<%= article.compiled_content %>
55
</div>
66
<% end %>

layouts/api.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<%= render 'head' %>
1+
<%= render '/head.*' %>
22

33
<body class="api <%= ENV['DEV_MODE'] ? 'dev-mode' : '' %>">
4-
<%= render 'header' %>
4+
<%= render '/header.*' %>
55

66
<div class="sub-nav">
77
<h2><a href="/v3/">API</a></h2>
@@ -19,9 +19,9 @@ <h2><a href="/v3/">API</a></h2>
1919
<%= yield %>
2020
</div>
2121

22-
<%= render 'sidebar' %>
22+
<%= render '/sidebar.*' %>
2323
</div><!-- #wrapper -->
2424

25-
<%= render 'footer' %>
25+
<%= render '/footer.*' %>
2626
</body>
2727
</html>

layouts/blog.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<%= render 'head' %>
1+
<%= render '/head.*' %>
22

33
<body class="blog">
4-
<%= render 'header' %>
4+
<%= render '/header.*' %>
55

66
<div id="wrapper">
77
<div class="content">
88
<%= yield %>
99
</div>
1010

1111
<div class="sidebar-shell">
12-
<%= render 'headlines', :changes => api_changes %>
12+
<%= render '/headlines.*', :changes => api_changes %>
1313

1414
<div class="sidebar-module notice"><a class="rss-subscribe" href="/changes.atom">Subscribe to the RSS feed</a></div>
1515
</div>
1616
</div>
1717

18-
<%= render 'footer' %>
18+
<%= render '/footer.*' %>
1919
</body>
2020
</html>

0 commit comments

Comments
 (0)