This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Rules
97 lines (81 loc) · 2.75 KB
/
Rules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env ruby
require 'extended-markdown-filter'
require 'nanoc-redirector'
require_relative 'lib/filters/api_json_filter'
require_relative 'lib/redirects'
preprocess do
versions = @items.find_all('/api/*/*.json').map { |item| item.identifier.to_s.split('/')[2] }.uniq
versions.each do |version|
json_items_for_version = @items.find_all("/api/#{version}/*.json")
class_names_for_version = json_items_for_version.map { |item| File.basename(item.identifier, '.json') }
first_class_name_for_version = class_names_for_version.sort.first
create_item_with_redirect source: "/api/#{version}/index.md", destination: "/api/#{version}/#{first_class_name_for_version}"
@items.create('', {:api_version => version.tr('v', '')}, "/search/#{version}.json")
end
create_item_with_redirect source: '/api/index.md', destination: '/api/latest'
create_item_with_redirect source: '/api/latest.md', destination: "/api/v#{latest_atom_version_number}"
end
compile '/api/**/*.md' do
filter :redirect_to, { :redirect_to => @item[:redirect_to] }
end
compile '/index.html' do
filter :erb
layout '/toc.html'
end
compile '**/*.asciidoc' do
filter :html_pipeline, @config[:asciidoc_pipeline_config]
filter :erb
filter :colorize_syntax, :default_colorizer => :rouge
layout '/article.html'
end
compile '**/index.md' do
filter :html_pipeline, @config[:markdown_pipeline_config]
filter :erb
filter :colorize_syntax, :default_colorizer => :rouge
layout '/section.html'
end
compile '**/*.md' do
filter :html_pipeline, @config[:markdown_pipeline_config]
filter :erb
filter :colorize_syntax, :default_colorizer => :rouge
layout '/article.html'
end
compile '/api/**/*.json' do
class_name = File.basename(item.identifier.without_ext)
version = File.basename(File.dirname(item.identifier))
filter :api_json, class_name: class_name, version: version
filter :erb
layout '/api-class.html', :locals => { :version => version.tr('v', '') }
end
compile '/search.html' do
filter :erb
layout '/toc.html'
end
compile '/search/*.json' do
filter :erb
layout '/search.json'
write item.identifier
end
passthrough '/**/*.jpg'
passthrough '/**/*.jpeg'
passthrough '/**/*.png'
passthrough '/**/*.gif'
passthrough '/CNAME'
route '**/*' do
if item.binary?
item.identifier.chop + (item[:extension] ? '.' + item[:extension] : '')
elsif item.identifier == '/index.html'
'/index.html'
elsif item.identifier =~ /\/404.asciidoc/
'/404.html'
elsif item.identifier =~ /\/404.md/
'/404.html'
elsif item.identifier =~ /index.asciidoc/
File.dirname(item.identifier) + '/index.html'
elsif item.identifier =~ /index.md/
File.dirname(item.identifier) + '/index.html'
else
item.identifier.without_ext + '/index.html'
end
end
layout '/**/*', :erb