Upgrade to Nanoc 4.0

* Update Ruby gems.
* Remove nanoc-cachebuster due to incompatibility.
* Add README item about GitHub auth to improve build reliability.
* Fix various required config changes for 4.0
Signed-off-by: 's avatarBen Kochie <superq@gmail.com>
parent 1572d2ae
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'nanoc' gem 'nanoc', '~> 4.0'
gem 'adsf' gem 'adsf'
gem 'kramdown' gem 'kramdown'
gem 'guard-nanoc' gem 'guard-nanoc'
...@@ -12,7 +12,6 @@ gem 'builder' ...@@ -12,7 +12,6 @@ gem 'builder'
gem 'rb-inotify', :require => false gem 'rb-inotify', :require => false
gem 'rb-fsevent', :require => false gem 'rb-fsevent', :require => false
gem 'rb-fchange', :require => false gem 'rb-fchange', :require => false
gem 'nanoc-cachebuster'
group :test do group :test do
gem 'rspec' gem 'rspec'
......
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
adsf (1.2.0) addressable (2.5.2)
rack (>= 1.0.0) public_suffix (>= 2.0.2, < 4.0)
adsf (1.4.1)
rack (>= 1.0.0, < 3.0.0)
builder (3.2.2) builder (3.2.2)
celluloid (0.16.0) coderay (1.1.2)
timers (~> 4.0.0)
coderay (1.1.0)
colored (1.2) colored (1.2)
cri (2.6.1) concurrent-ruby (1.0.5)
cri (2.10.1)
colored (~> 1.2) colored (~> 1.2)
ddmemoize (1.0.0)
ddmetrics (~> 1.0)
ref (~> 2.0)
ddmetrics (1.0.1)
ddplugin (1.0.2)
diff-lcs (1.2.5) diff-lcs (1.2.5)
em-websocket (0.5.1) em-websocket (0.5.1)
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
eventmachine (1.0.8) eventmachine (1.2.7)
ffi (1.9.6) ffi (1.9.25)
formatador (0.2.5) formatador (0.2.5)
guard (2.6.1) guard (2.14.2)
formatador (>= 0.2.4) formatador (>= 0.2.4)
listen (~> 2.7) listen (>= 2.7, < 4.0)
lumberjack (~> 1.0) lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12) pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1) thor (>= 0.18.1)
guard-livereload (2.3.1) guard-compat (1.2.1)
guard-livereload (2.5.2)
em-websocket (~> 0.5) em-websocket (~> 0.5)
guard (~> 2.0) guard (~> 2.8)
guard-compat (~> 1.0)
multi_json (~> 1.8) multi_json (~> 1.8)
guard-nanoc (1.0.2) guard-nanoc (2.1.2)
guard (>= 1.8.0) guard (~> 2.8)
nanoc (>= 3.6.3) guard-compat (~> 1.0)
hitimes (1.2.2) nanoc (>= 4.3.8, < 5.0)
hamster (3.0.0)
concurrent-ruby (~> 1.0)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
kramdown (1.4.2) kramdown (1.17.0)
listen (2.7.11) listen (3.1.5)
celluloid (>= 0.15.2) rb-fsevent (~> 0.9, >= 0.9.4)
rb-fsevent (>= 0.9.3) rb-inotify (~> 0.9, >= 0.9.7)
rb-inotify (>= 0.9) ruby_dep (~> 1.2)
lumberjack (1.0.9) lumberjack (1.0.13)
method_source (0.8.2) method_source (0.9.0)
mini_portile2 (2.3.0) mini_portile2 (2.3.0)
multi_json (1.11.2) multi_json (1.13.1)
nanoc (3.7.3) nanoc (4.9.3)
cri (~> 2.3) addressable (~> 2.5)
nanoc-cachebuster (0.3.1) cri (~> 2.8)
nanoc (>= 3.3.0) ddmemoize (~> 1.0)
ddmetrics (~> 1.0)
ddplugin (~> 1.0)
hamster (~> 3.0)
parallel (~> 1.12)
ref (~> 2.0)
slow_enumerator_tools (~> 1.0)
tomlrb (~> 1.2)
nenv (0.3.0)
nokogiri (1.8.4) nokogiri (1.8.4)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
pry (0.10.1) notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
parallel (1.12.1)
pry (0.11.3)
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.9.0)
slop (~> 3.4) public_suffix (3.0.2)
pygments.rb (1.2.1) pygments.rb (1.2.1)
multi_json (>= 1.0.0) multi_json (>= 1.0.0)
rack (1.5.2) rack (2.0.5)
rb-fchange (0.0.6) rb-fchange (0.0.6)
ffi ffi
rb-fsevent (0.9.4) rb-fsevent (0.10.3)
rb-inotify (0.9.5) rb-inotify (0.9.10)
ffi (>= 0.5.0) ffi (>= 0.5.0, < 2)
redcarpet (3.2.0) redcarpet (3.2.0)
ref (2.0.0)
rspec (3.5.0) rspec (3.5.0)
rspec-core (~> 3.5.0) rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0) rspec-expectations (~> 3.5.0)
...@@ -73,10 +99,11 @@ GEM ...@@ -73,10 +99,11 @@ GEM
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0) rspec-support (~> 3.5.0)
rspec-support (3.5.0) rspec-support (3.5.0)
slop (3.6.0) ruby_dep (1.5.0)
thor (0.19.1) shellany (0.0.1)
timers (4.0.1) slow_enumerator_tools (1.1.0)
hitimes thor (0.20.0)
tomlrb (1.2.7)
PLATFORMS PLATFORMS
ruby ruby
...@@ -87,8 +114,7 @@ DEPENDENCIES ...@@ -87,8 +114,7 @@ DEPENDENCIES
guard-livereload guard-livereload
guard-nanoc guard-nanoc
kramdown kramdown
nanoc nanoc (~> 4.0)
nanoc-cachebuster
nokogiri nokogiri
pygments.rb pygments.rb
rb-fchange rb-fchange
......
...@@ -33,6 +33,11 @@ make build ...@@ -33,6 +33,11 @@ make build
The resulting static site will be stored in the `output` directory. The resulting static site will be stored in the `output` directory.
Optionally, you can use an API token to avoid rate limits on the API. You can get an API token from https://github.com/settings/tokens/new.
```bash
export GITHUB_AUTHENTICATION='-u user:token'
```
## Development Server ## Development Server
To run a local server that displays the generated site, run: To run a local server that displays the generated site, run:
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
# item, use the pattern “/about/*/”; “/about/*” will also select the parent, # item, use the pattern “/about/*/”; “/about/*” will also select the parent,
# because “*” matches zero or more characters. # because “*” matches zero or more characters.
passthrough '/assets/**'
compile '/_redirects/' do compile '/_redirects/' do
end end
...@@ -20,19 +22,6 @@ route '/_redirects/' do ...@@ -20,19 +22,6 @@ route '/_redirects/' do
'/_redirects' '/_redirects'
end end
compile '/assets/*' do
end
route '/assets/*' do
# Cachebuster currently doesn't fingerprint all needed files (SVG and font
# extensions are missing), so we need to differentiate here.
if Nanoc::Cachebuster::FILETYPES_TO_FINGERPRINT.include?(item[:extension])
item.identifier[0..-(3 + item[:extension].length)] + fingerprint(item[:filename]) + '.' + item[:extension]
else
item.identifier[0..-2]
end
end
# TODO(ts): Remove these hacks once the nanoc4 upgrade is done. # TODO(ts): Remove these hacks once the nanoc4 upgrade is done.
compile '*/images/*' do compile '*/images/*' do
end end
...@@ -78,8 +67,6 @@ compile '*' do ...@@ -78,8 +67,6 @@ compile '*' do
else else
layout 'default' layout 'default'
end end
filter :cache_buster
end end
route '/blog/' do route '/blog/' do
...@@ -97,10 +84,10 @@ end ...@@ -97,10 +84,10 @@ end
route '*' do route '*' do
if item[:extension] == 'css' if item[:extension] == 'css'
# Write item with identifier /foo/ to /foo.css # Write item with identifier /foo/ to /foo.css
item.identifier.chop + fingerprint(item[:filename]) + '.css' item.identifier.chop + '.css'
elsif item.binary? elsif item.binary?
# Write item with identifier /foo/ to /foo.ext # Write item with identifier /foo.dat to /foo.dat
item.identifier.chop + '.' + item[:extension] item.identifier.to_s
else else
# Write item with identifier /foo/ to /foo/index.html # Write item with identifier /foo/ to /foo/index.html
item.identifier + 'index.html' item.identifier + 'index.html'
......
# TODO(ts): Rewrite data source and use one single instance to combine all # TODO(ts): Rewrite data source and use one single instance to combine all
# different versions for a given path. # different versions for a given path.
class RepoDocsDataSource < ::Nanoc::DataSources::FilesystemUnified class RepoDocsDataSource < ::Nanoc::DataSources::Filesystem
identifier :repo_docs identifier :repo_docs
PATH = "repositories" PATH = "repositories"
...@@ -24,15 +24,16 @@ class RepoDocsDataSource < ::Nanoc::DataSources::FilesystemUnified ...@@ -24,15 +24,16 @@ class RepoDocsDataSource < ::Nanoc::DataSources::FilesystemUnified
def items def items
c = config.fetch(:config) c = config.fetch(:config)
super.map do |item| super.map do |item|
item[:repo_docs] = c attrs = item.attributes.dup
item[:repo_docs][:items_root] = config.fetch(:items_root) attrs[:repo_docs] = c
attrs[:repo_docs][:items_root] = config.fetch(:items_root)
# TODO(ts): Remove assumptions about the path layout, rewrite datasource. # TODO(ts): Remove assumptions about the path layout, rewrite datasource.
item[:repo_docs][:version_root] = config.fetch(:items_root).sub(%r{(.+/)[^/]+/\Z}, '\\1') attrs[:repo_docs][:version_root] = config.fetch(:items_root).sub(%r{(.+/)[^/]+/\Z}, '\\1')
# TODO(ts): Document that repo doc index.md will be ignored. # TODO(ts): Document that repo doc index.md will be ignored.
if item.identifier == '/' if item.identifier == '/'
item[:nav] = { strip: true } attrs[:nav] = { strip: true }
end end
item new_item(item.content, attrs, item.identifier)
end end
end end
......
# All files in the 'lib' directory will be loaded # All files in the 'lib' directory will be loaded
# before nanoc starts compiling. # before nanoc starts compiling.
require 'nanoc/cachebuster'
include Nanoc::Helpers::LinkTo include Nanoc::Helpers::LinkTo
include Nanoc::Helpers::Rendering include Nanoc::Helpers::Rendering
include Nanoc3::Helpers::Blogging include Nanoc::Helpers::Blogging
include Nanoc3::Helpers::Tagging include Nanoc::Helpers::Tagging
include Nanoc::Helpers::CacheBusting
module BlogHelper module BlogHelper
def get_pretty_date(post) def get_pretty_date(post)
......
...@@ -33,11 +33,13 @@ prune: ...@@ -33,11 +33,13 @@ prune:
# hashes; each array element represents a single data source. By default, # hashes; each array element represents a single data source. By default,
# there is only a single data source that reads data from the “content/” and # there is only a single data source that reads data from the “content/” and
# “layout/” directories in the site directory. # “layout/” directories in the site directory.
string_pattern_type: legacy
data_sources: data_sources:
- -
# The type is the identifier of the data source. By default, this will be # The type is the identifier of the data source. By default, this will be
# `filesystem_unified`. # `filesystem_unified`.
type: filesystem_unified type: filesystem_unified
identifier_type: legacy
# The path where items should be mounted (comparable to mount points in # The path where items should be mounted (comparable to mount points in
# Unix-like systems). This is “/” by default, meaning that items will have # Unix-like systems). This is “/” by default, meaning that items will have
...@@ -63,6 +65,7 @@ data_sources: ...@@ -63,6 +65,7 @@ data_sources:
encoding: utf-8 encoding: utf-8
- -
type: repo_docs type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/latest/ items_root: /docs/prometheus/latest/
config: config:
name: 'latest (2.3)' name: 'latest (2.3)'
...@@ -70,6 +73,7 @@ data_sources: ...@@ -70,6 +73,7 @@ data_sources:
refspec: release-2.3 refspec: release-2.3
- -
type: repo_docs type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.3/ items_root: /docs/prometheus/2.3/
config: config:
name: '2.3' name: '2.3'
...@@ -78,6 +82,7 @@ data_sources: ...@@ -78,6 +82,7 @@ data_sources:
canonical: /docs/prometheus/latest/ canonical: /docs/prometheus/latest/
- -
type: repo_docs type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.2/ items_root: /docs/prometheus/2.2/
config: config:
name: '2.2' name: '2.2'
...@@ -86,6 +91,7 @@ data_sources: ...@@ -86,6 +91,7 @@ data_sources:
canonical: /docs/prometheus/latest/ canonical: /docs/prometheus/latest/
- -
type: repo_docs type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.1/ items_root: /docs/prometheus/2.1/
config: config:
name: '2.1' name: '2.1'
...@@ -94,6 +100,7 @@ data_sources: ...@@ -94,6 +100,7 @@ data_sources:
canonical: /docs/prometheus/latest/ canonical: /docs/prometheus/latest/
- -
type: repo_docs type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.0/ items_root: /docs/prometheus/2.0/
config: config:
name: '2.0' name: '2.0'
...@@ -103,6 +110,7 @@ data_sources: ...@@ -103,6 +110,7 @@ data_sources:
outdated: /docs/prometheus/latest/ outdated: /docs/prometheus/latest/
- -
type: repo_docs type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/1.8/ items_root: /docs/prometheus/1.8/
config: config:
name: '1.8' name: '1.8'
...@@ -111,8 +119,10 @@ data_sources: ...@@ -111,8 +119,10 @@ data_sources:
canonical: /docs/prometheus/latest/ canonical: /docs/prometheus/latest/
outdated: /docs/prometheus/latest/ outdated: /docs/prometheus/latest/
- -
type: static type: filesystem
items_root: /assets/ items_root: /assets
content_dir: static
layouts_dir: null
# Configuration for the “check” command, which run unit tests on the site. # Configuration for the “check” command, which run unit tests on the site.
checks: checks:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment