forked from openshift-cs/devcenter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rb
143 lines (129 loc) · 4.99 KB
/
config.rb
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
require 'yaml'
###
# Settings
###
set :site_title, "OpenShift Developer Portal"
set :site_url, 'https://developers.openshift.com/'
set :openshift_assets, 'https://assets.openshift.net/content'
set :asciidoc_attributes, %w(icons=font source-highlighter=coderay coderay-css=style)
set :haml, { :ugly => true, :format => :html5 }
###
# Assets
###
set :css_dir, 'stylesheets'
set :fonts_dir, 'fonts'
set :images_dir, 'images'
set :js_dir, 'javascripts'
###
# Page command
###
page "/sitemap.xml", layout: false
# activate :navtree do |options|
# options.data_file = 'tree.yml' # The data file where our navtree is stored.
# options.automatic_tree_updates = true # The tree.yml file will be updated automatically when source files are changed.
# options.ignore_files = ['sitemap.xml', 'robots.txt', 'index.adoc', 'contact.adoc', 'search.html.erb', 'report.html.erb'] # An array of files we want to ignore when building our tree.
# options.ignore_dir = ['assets', '_fragments'] # An array of directories we want to ignore when building our tree.
# options.home_title = 'Home' # The default link title of the home page (located at "/"), if otherwise not detected.
# #options.promote_files = ['index.adoc'] # Any files we might want to promote to the front of our navigation
# options.ext_whitelist = [] # If you add extensions (like '.md') to this array, it builds a whitelist of filetypes for inclusion in the navtree.
# end
helpers do
# Builds breadcrumbs for the top of the pages
def build_breadcrumb(current_page)
breadcrumbs = {}
current_path = []
current_page.path.split(File::SEPARATOR).each do |element|
current_path.push element
if element == current_page.path.split(File::SEPARATOR).last
breadcrumbs["#{current_page.data.title}"] = "/"+current_path.join(File::SEPARATOR)
else
breadcrumbs["#{displayname(element)}"] = "/"+current_path.join(File::SEPARATOR)
end
end
html = ""
breadcrumbs.each_pair do |key,value|
html += "<li><a href='#{value}'>#{key}</a></li>"
end
return html
end
def build_navtree(root = nil)
html = ""
if root == nil
root = navtree_yaml = YAML.load_file('data/tree.yml')
end
root.each_pair do |folder,contents|
if contents.is_a?(String)
extensionlessPath = sitemap.extensionless_path(contents)
else
extensionlessPath = sitemap.extensionless_path(folder)
end
if extensionlessPath.end_with? ".html"
resource = sitemap.find_resource_by_path(extensionlessPath)
if resource.nil?
puts extensionlessPath
end
html << "<li><a href='#{resource.url}' class='#{resource == current_page ? 'active' : ''}'>#{resource.data.title}</a></li>"
else
if current_page.path.split(File::SEPARATOR).count > 1
html << "<li><a href='/#{current_page.path.split(File::SEPARATOR).first}/#{folder}' class=''>#{displayname(folder)}</a></li>"
else
html << "<li class='parent nav-header'><label class='toggle'><span class='symbol fa fa-angle-right'></span> #{displayname(folder)}</label>"
end
html << "<ul>"
#html << build_navtree(contents)
if current_page.path.split(File::SEPARATOR).count < 2
contents.each do |k,v|
if v.is_a?(String)
extensionlessPath = sitemap.extensionless_path(v)
else
extensionlessPath = sitemap.extensionless_path(k)
end
if extensionlessPath.end_with? ".html"
resource = sitemap.find_resource_by_path(extensionlessPath)
html << "<li><a href='#{resource.url}' class='#{resource == current_page ? 'active' : ''}'>#{resource.data.title}</a></li>"
else
html << "<li><a href='#{folder}/#{k}' class=''>#{displayname(k)}</a></li>"
end
end
end
html << "</ul>"
html << "</li>"
end
end
return html
end
def nav_index(current_page)
path = current_page.path.split(File::SEPARATOR)
if path.count == 1
return data.tree
elsif path.count == 2
return data.tree[path[0]]
elsif path.count == 3
return data.tree[path[0]][path[1]]
end
end
def displayname(name)
if data.displaynames[name]
return data.displaynames[name]
else
return name.titlecase
end
end
end
# Build-specific configuration
configure :build do
config.ignored_sitemap_matchers[:source_dotfiles] = proc { |file|
file =~ %r{/\.} && file !~ %r{/\.(openshift|htaccess|htpasswd|nojekyll|git)}
}
activate :minify_css
activate :minify_javascript
end
# Deployment configuration
activate :deploy do |deploy|
deploy.method = :git
deploy.build_before = false # default: false
deploy.remote = 'production' # remote name or git url, default: origin
deploy.strategy = :force_push
deploy.branch = 'master' # default: gh-pages
end
activate :sitemap, :gzip => false, :hostname => "https://developers.openshift.com"