forked from co-cddo/api-catalogue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.rb
58 lines (49 loc) · 1.5 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
require 'govuk_tech_docs'
require 'lib/api_catalogue'
require 'lib/dashboard_stats'
require 'lib/url_helpers'
GovukTechDocs.configure(self)
# Without prefix for 'middleman serve'
set(:govuk_assets_path, "/assets/govuk/assets/")
# Add '/api-catalogue/' for 'middleman build', for Github Pages compatibility
configure :build do
set(:build_dir, "build/api-catalogue")
set(:http_prefix, "/api-catalogue/")
set(:govuk_assets_path, "/api-catalogue/assets/govuk/assets/")
end
helpers UrlHelpers
csv_path = File.expand_path("data/inputs/apic.csv", __dir__)
api_catalogue = ApiCatalogue.from_csv(csv_path)
# Order organisations from A-Z in the Table of Contents,
# leaving a buffer from 0-999 for static content to be given priority
initial_org_weight = 1_000
api_catalogue.organisations_apis.each.with_index(initial_org_weight) do |(organisation, apis), org_weight|
proxy(
UrlHelpers.organisation_path(organisation),
"organisation_index.html",
locals: { organisation: organisation, apis: apis },
data: {
title: organisation.name,
weight: org_weight,
},
ignore: true,
)
apis.each_with_index do |api, api_weight|
proxy(
UrlHelpers.api_path(organisation: organisation, api: api),
"api_details.html",
locals: { api: api },
data: {
title: api.name,
weight: api_weight,
},
ignore: true,
)
end
end
proxy(
"/dashboard/index.html",
"dashboard.html",
locals: { dashboard_stats: DashboardStats.new(api_catalogue) },
ignore: true,
)