-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathRules
166 lines (138 loc) · 3.85 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env ruby
# compilation rules
require 'httparty'
@@config = YAML.load_file("./config.yaml")
compile '/style/*/' do
filter :sass
end
compile '/sitemap/' do
#/ nothing
end
compile '/help/newsletters/*/' do
filter :erb
filter :kramdown, :auto_id_stripping => true
layout 'default'
end
compile '/help/publications/papers/pubmed/' do
filter :erb
end
compile '*' do
case item[:extension]
when /md$/, /markdown$/
filter :image_captions
filter :erb
filter :kramdown, :auto_id_stripping => true, :input => 'GFM',
:hard_wrap => false
when /haml$/
filter :haml
when /html$/
filter :erb
when /sass$/
filter :sass
end
if item[:layout]
layout item[:layout]
elsif !item.binary?
layout 'default'
end
filter :google_analytics unless item.binary?
end
# routing rules
route '/biostar_list/[0-9]+/' do
nil
end
route '/help/publications/papers/pubmed/*' do
nil
end
route '/sitemap/' do
item.identifier.to_s.chop + '.xml'
end
route '/style/*/' do
item.identifier.to_s.chop + '.css'
end
# biocViews hierarchy
route /BiocViews/ do
segs = item.identifier.to_s.split "/"
segs.pop
version = segs.pop
# note that we rely on the rake :pre_compile task to create duplicate versions of this file
# for each bioC version for which the "new" style BiocViews tree is created.
#"/help/bioc-views/#{config[:release_version]}/BiocViews.html"
"/packages/#{version}/BiocViews.html"
end
# index pages (package lists)
route /^\/help\/bioc-views\/package-pages\/all-/ do
segs = item.identifier.to_s.split("-")
version = segs.pop.gsub("/", "")
long_repo_name = segs.pop
repo_map = {"Software" => "bioc", "AnnotationData" => "data/annotation", "ExperimentData" => "data/experiment", "Workflow" => "workflows"}
version = item.attributes[:bioc_version_num]
"/packages/#{version}/#{repo_map[long_repo_name]}/index.html"
end
# package detail pages
route /^\/help\/bioc-views\/package-pages\// do
pkg_name = item.identifier.to_s.split("/").last
version = item.attributes[:bioc_version_num]
"/packages/#{version}/#{item.attributes[:repo]}html/#{pkg_name}.html"
end
route '*' do
if item.binary?
item.identifier.to_s.chop + "." + item[:extension]
else
item.identifier.to_s + 'index.html'
end
end
# layouting rules
layout '*', :erb
preprocess do
man_path = "../manifest/"
if (!File.directory?(man_path))
puts "no ../manifest directory; skipping package landing pages"
next
end
unless(ENV.has_key?("QUICK_NANOC_COMPILE") && ENV["QUICK_NANOC_COMPILE"] == "true")
puts "Getting manifest files..."
sconfig = YAML.load_file("./config.yaml")
sconfig[:release_dates] = sconfig["release_dates"]
sconfig[:release_dates] = sconfig[:release_dates].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
rel_ver = sconfig["release_version"]
dev_ver = sconfig["devel_version"]
all_ver = sconfig["release_dates"].keys
all_ver.push dev_ver
manifests = {}
all_ver.each { |v|
ver = v.gsub(/\./,"_")
manifests[v] = []
if v == dev_ver
system("git -C #{man_path} checkout devel")
else
system("git -C #{man_path} checkout RELEASE_#{ver}")
end
if $? == 0
soft="#{man_path}/software.txt"
File.open(soft, "r") do |f|
f.each_line do |line|
next unless line =~ /^Package: /
manifests[v].push line.chomp.sub(/^Package: /, "").strip
end
end
end
}
config[:manifests] = manifests
system("git -C #{man_path} checkout devel")
config[:manifest_keys] = manifests.keys.sort do |a,b|
amaj, amin = a.split(".")
bmaj, bmin = b.split(".")
amaj = Integer(amaj)
amin = Integer(amin)
bmaj = Integer(bmaj)
bmin = Integer(bmin)
if amaj == bmaj
amin <=> bmin
else
amaj <=> bmaj
end
end
puts "Processing site pages..."
end
end