Unverified Commit 7eb591a4 authored by Ben Kochie's avatar Ben Kochie Committed by GitHub

Merge pull request #1130 from prometheus/superq/nanoc

Upgrade to Nanoc 4.0
parents 1cb44b8c 1c4d72e0
source 'https://rubygems.org'
gem 'nanoc'
gem 'nanoc', '~> 4.0'
gem 'adsf'
gem 'kramdown'
gem 'guard-nanoc'
......@@ -12,7 +12,6 @@ gem 'builder'
gem 'rb-inotify', :require => false
gem 'rb-fsevent', :require => false
gem 'rb-fchange', :require => false
gem 'nanoc-cachebuster'
group :test do
gem 'rspec'
......
GEM
remote: https://rubygems.org/
specs:
adsf (1.2.0)
rack (>= 1.0.0)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
adsf (1.4.1)
rack (>= 1.0.0, < 3.0.0)
builder (3.2.2)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
coderay (1.1.2)
colored (1.2)
cri (2.6.1)
concurrent-ruby (1.0.5)
cri (2.10.1)
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)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.0.8)
ffi (1.9.6)
eventmachine (1.2.7)
ffi (1.9.25)
formatador (0.2.5)
guard (2.6.1)
guard (2.14.2)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-livereload (2.3.1)
guard-compat (1.2.1)
guard-livereload (2.5.2)
em-websocket (~> 0.5)
guard (~> 2.0)
guard (~> 2.8)
guard-compat (~> 1.0)
multi_json (~> 1.8)
guard-nanoc (1.0.2)
guard (>= 1.8.0)
nanoc (>= 3.6.3)
hitimes (1.2.2)
guard-nanoc (2.1.2)
guard (~> 2.8)
guard-compat (~> 1.0)
nanoc (>= 4.3.8, < 5.0)
hamster (3.0.0)
concurrent-ruby (~> 1.0)
http_parser.rb (0.6.0)
kramdown (1.4.2)
listen (2.7.11)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
lumberjack (1.0.9)
method_source (0.8.2)
kramdown (1.17.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.13)
method_source (0.9.0)
mini_portile2 (2.3.0)
multi_json (1.11.2)
nanoc (3.7.3)
cri (~> 2.3)
nanoc-cachebuster (0.3.1)
nanoc (>= 3.3.0)
multi_json (1.13.1)
nanoc (4.9.3)
addressable (~> 2.5)
cri (~> 2.8)
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)
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)
method_source (~> 0.8.1)
slop (~> 3.4)
method_source (~> 0.9.0)
public_suffix (3.0.2)
pygments.rb (1.2.1)
multi_json (>= 1.0.0)
rack (1.5.2)
rack (2.0.5)
rb-fchange (0.0.6)
ffi
rb-fsevent (0.9.4)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redcarpet (3.2.0)
ref (2.0.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
......@@ -73,10 +99,11 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
slop (3.6.0)
thor (0.19.1)
timers (4.0.1)
hitimes
ruby_dep (1.5.0)
shellany (0.0.1)
slow_enumerator_tools (1.1.0)
thor (0.20.0)
tomlrb (1.2.7)
PLATFORMS
ruby
......@@ -87,8 +114,7 @@ DEPENDENCIES
guard-livereload
guard-nanoc
kramdown
nanoc
nanoc-cachebuster
nanoc (~> 4.0)
nokogiri
pygments.rb
rb-fchange
......
......@@ -33,6 +33,11 @@ make build
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
To run a local server that displays the generated site, run:
......
......@@ -13,6 +13,8 @@
# item, use the pattern “/about/*/”; “/about/*” will also select the parent,
# because “*” matches zero or more characters.
passthrough '/assets/**'
compile '/_redirects/' do
end
......@@ -20,19 +22,6 @@ route '/_redirects/' do
'/_redirects'
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.
compile '*/images/*' do
end
......@@ -78,8 +67,6 @@ compile '*' do
else
layout 'default'
end
filter :cache_buster
end
route '/blog/' do
......@@ -97,10 +84,10 @@ end
route '*' do
if item[:extension] == 'css'
# Write item with identifier /foo/ to /foo.css
item.identifier.chop + fingerprint(item[:filename]) + '.css'
item.identifier.chop + '.css'
elsif item.binary?
# Write item with identifier /foo/ to /foo.ext
item.identifier.chop + '.' + item[:extension]
# Write item with identifier /foo.dat to /foo.dat
item.identifier.to_s
else
# Write item with identifier /foo/ to /foo/index.html
item.identifier + 'index.html'
......
# TODO(ts): Rewrite data source and use one single instance to combine all
# different versions for a given path.
class RepoDocsDataSource < ::Nanoc::DataSources::FilesystemUnified
class RepoDocsDataSource < ::Nanoc::DataSources::Filesystem
identifier :repo_docs
PATH = "repositories"
......@@ -24,15 +24,16 @@ class RepoDocsDataSource < ::Nanoc::DataSources::FilesystemUnified
def items
c = config.fetch(:config)
super.map do |item|
item[:repo_docs] = c
item[:repo_docs][:items_root] = config.fetch(:items_root)
attrs = item.attributes.dup
attrs[:repo_docs] = c
attrs[:repo_docs][:items_root] = config.fetch(:items_root)
# 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.
if item.identifier == '/'
item[:nav] = { strip: true }
attrs[:nav] = { strip: true }
end
item
new_item(item.content, attrs, item.identifier)
end
end
......
# All files in the 'lib' directory will be loaded
# before nanoc starts compiling.
require 'nanoc/cachebuster'
include Nanoc::Helpers::LinkTo
include Nanoc::Helpers::Rendering
include Nanoc3::Helpers::Blogging
include Nanoc3::Helpers::Tagging
include Nanoc::Helpers::CacheBusting
include Nanoc::Helpers::Blogging
include Nanoc::Helpers::Tagging
module BlogHelper
def get_pretty_date(post)
......
......@@ -33,11 +33,13 @@ prune:
# 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
# “layout/” directories in the site directory.
string_pattern_type: legacy
data_sources:
-
# The type is the identifier of the data source. By default, this will be
# `filesystem_unified`.
type: filesystem_unified
identifier_type: legacy
# The path where items should be mounted (comparable to mount points in
# Unix-like systems). This is “/” by default, meaning that items will have
......@@ -63,6 +65,7 @@ data_sources:
encoding: utf-8
-
type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/latest/
config:
name: 'latest (2.3)'
......@@ -70,6 +73,7 @@ data_sources:
refspec: release-2.3
-
type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.3/
config:
name: '2.3'
......@@ -78,6 +82,7 @@ data_sources:
canonical: /docs/prometheus/latest/
-
type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.2/
config:
name: '2.2'
......@@ -86,6 +91,7 @@ data_sources:
canonical: /docs/prometheus/latest/
-
type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.1/
config:
name: '2.1'
......@@ -94,6 +100,7 @@ data_sources:
canonical: /docs/prometheus/latest/
-
type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/2.0/
config:
name: '2.0'
......@@ -103,6 +110,7 @@ data_sources:
outdated: /docs/prometheus/latest/
-
type: repo_docs
identifier_type: legacy
items_root: /docs/prometheus/1.8/
config:
name: '1.8'
......@@ -111,8 +119,10 @@ data_sources:
canonical: /docs/prometheus/latest/
outdated: /docs/prometheus/latest/
-
type: static
items_root: /assets/
type: filesystem
items_root: /assets
content_dir: static
layouts_dir: null
# Configuration for the “check” command, which run unit tests on the site.
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