metanorma-release 0.2.17 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd193b321dc862e5773523c57a82a37966b93a087cd6354486ad067b50d2b992
|
|
4
|
+
data.tar.gz: 40f1dd74b4409040d1cd625477d0787b07f6fc29eed1e98c6210e4f229ce2464
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc2f1951bded304c45d587a0b57ebc2d4946aae4633748f6008588a5aa764a99c20f7a04a3ef8b8eb0034ac605ff582106cc621592c20710c7c6d5e3ec2a9963
|
|
7
|
+
data.tar.gz: 51c29d6cf3d483e33dca8c5a13bf4f4564e1f25077b306015ec0bc09cc77dde50382c3767d2fc76b346d794413ba8060af756f4a3b556ba4d26a49626d47385f
|
|
@@ -29,7 +29,7 @@ module Metanorma
|
|
|
29
29
|
|
|
30
30
|
index = build_index(result)
|
|
31
31
|
site = Site.new(index: index, output_dir: @config.output_dir,
|
|
32
|
-
data_dir: @config.data_dir)
|
|
32
|
+
data_dir: @config.data_dir, org_config: @org_config)
|
|
33
33
|
site.write!
|
|
34
34
|
site.enrich!
|
|
35
35
|
site.package! if @config.create_zip
|
|
@@ -66,6 +66,20 @@ module Metanorma
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
def display_categories
|
|
70
|
+
@data.fetch("display_categories", [])
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def display_category_for(doctype)
|
|
74
|
+
return nil if doctype.nil? || doctype.empty?
|
|
75
|
+
|
|
76
|
+
display_categories.each do |cat|
|
|
77
|
+
doctypes = cat["doctypes"] || []
|
|
78
|
+
return { "name" => cat["name"], "slug" => cat["slug"] } if doctypes.include?(doctype)
|
|
79
|
+
end
|
|
80
|
+
nil
|
|
81
|
+
end
|
|
82
|
+
|
|
69
83
|
private
|
|
70
84
|
|
|
71
85
|
def dig_defaults_routing(key)
|
|
@@ -9,10 +9,11 @@ module Metanorma
|
|
|
9
9
|
class Site
|
|
10
10
|
attr_reader :index, :output_dir
|
|
11
11
|
|
|
12
|
-
def initialize(index:, output_dir:, data_dir: nil)
|
|
12
|
+
def initialize(index:, output_dir:, data_dir: nil, org_config: nil)
|
|
13
13
|
@index = index
|
|
14
14
|
@output_dir = output_dir
|
|
15
15
|
@data_dir = data_dir
|
|
16
|
+
@org_config = org_config
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def write!
|
|
@@ -84,28 +85,39 @@ module Metanorma
|
|
|
84
85
|
|
|
85
86
|
def flatten_for_site(doc)
|
|
86
87
|
bib = doc["bibliographic"] || {}
|
|
87
|
-
doc_id = resolve_doc_id(bib, doc)
|
|
88
|
-
stage = (doc["stage"] || "published").to_s.downcase
|
|
89
88
|
doctype = extract_doctype(bib) || doc.fetch("doctype", "")
|
|
90
89
|
formats = doc["formats"] || []
|
|
91
|
-
{
|
|
90
|
+
base = {
|
|
92
91
|
"slug" => doc["id"],
|
|
93
|
-
"id" =>
|
|
92
|
+
"id" => resolve_doc_id(bib, doc),
|
|
94
93
|
"title" => doc["title"].to_s,
|
|
95
94
|
"abstract" => extract_abstract(bib),
|
|
96
|
-
"stage" => stage,
|
|
95
|
+
"stage" => (doc["stage"] || "published").to_s.downcase,
|
|
97
96
|
"doctype" => doctype,
|
|
98
97
|
"edition" => doc["edition"],
|
|
99
98
|
"date" => extract_date(doc),
|
|
100
99
|
"channels" => doc["channels"] || [],
|
|
101
100
|
"formats" => formats,
|
|
102
101
|
"files" => doc["files"] || [],
|
|
103
|
-
"has_html" => formats.include?("html"),
|
|
104
|
-
"has_pdf" => formats.include?("pdf"),
|
|
105
|
-
"has_xml" => formats.include?("xml"),
|
|
106
|
-
"stage_css" => stage.gsub(/\s+/, "-"),
|
|
107
|
-
"doctype_class" => "type-#{doctype.downcase}",
|
|
108
102
|
}
|
|
103
|
+
add_format_flags(base, formats)
|
|
104
|
+
add_display_category(base, doctype)
|
|
105
|
+
add_contributors(base, bib)
|
|
106
|
+
base
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def add_format_flags(hash, formats)
|
|
110
|
+
hash["has_html"] = formats.include?("html")
|
|
111
|
+
hash["has_pdf"] = formats.include?("pdf")
|
|
112
|
+
hash["has_xml"] = formats.include?("xml")
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def add_display_category(hash, doctype)
|
|
116
|
+
cat = resolve_display_category(doctype)
|
|
117
|
+
hash["stage_css"] = hash["stage"].gsub(/\s+/, "-")
|
|
118
|
+
hash["doctype_class"] = "type-#{doctype.downcase}"
|
|
119
|
+
hash["display_category"] = cat&.fetch("name", nil)
|
|
120
|
+
hash["display_category_slug"] = cat&.fetch("slug", nil)
|
|
109
121
|
end
|
|
110
122
|
|
|
111
123
|
def resolve_doc_id(bib, doc)
|
|
@@ -152,6 +164,69 @@ module Metanorma
|
|
|
152
164
|
at = entry["at"]
|
|
153
165
|
at ? at.to_s.split(/[T ]/).first : nil
|
|
154
166
|
end
|
|
167
|
+
|
|
168
|
+
def resolve_display_category(doctype)
|
|
169
|
+
return nil unless @org_config
|
|
170
|
+
|
|
171
|
+
@org_config.display_category_for(doctype)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def add_contributors(hash, bib)
|
|
175
|
+
contribs = bib["contributor"] || []
|
|
176
|
+
persons, committees = partition_contributors(contribs)
|
|
177
|
+
hash["authors"] = persons
|
|
178
|
+
hash["committee"] = committees.first
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def partition_contributors(contribs)
|
|
182
|
+
persons = contribs.filter_map { |c| parse_person(c) }
|
|
183
|
+
committees = contribs.filter_map { |c| parse_committee(c) }
|
|
184
|
+
[persons, committees]
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def parse_person(contrib)
|
|
188
|
+
return nil unless contrib["person"]
|
|
189
|
+
|
|
190
|
+
name = extract_person_name(contrib["person"])
|
|
191
|
+
return nil unless name
|
|
192
|
+
|
|
193
|
+
role = (contrib["role"] || []).first&.fetch("type", nil)
|
|
194
|
+
{ "name" => name, "role" => role }
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def parse_committee(contrib)
|
|
198
|
+
return nil unless contrib["organization"]
|
|
199
|
+
|
|
200
|
+
extract_org_subdivision(contrib["organization"])
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def extract_person_name(person)
|
|
204
|
+
n = person["name"] || {}
|
|
205
|
+
complete = n["completename"]
|
|
206
|
+
return complete["content"] if complete.is_a?(Hash) && complete["content"]
|
|
207
|
+
return complete if complete.is_a?(String)
|
|
208
|
+
|
|
209
|
+
surname = n["surname"]
|
|
210
|
+
given = n["given"]
|
|
211
|
+
given_str = given.is_a?(Hash) ? given["content"].to_s : given.to_s
|
|
212
|
+
parts = [given_str, surname].compact
|
|
213
|
+
parts.empty? ? nil : parts.join(" ")
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def extract_org_subdivision(org)
|
|
217
|
+
subs = org["subdivision"]
|
|
218
|
+
return nil unless subs&.any?
|
|
219
|
+
|
|
220
|
+
sd = subs.first
|
|
221
|
+
sd_name = sd["name"]
|
|
222
|
+
if sd_name.is_a?(Array)
|
|
223
|
+
sd_name.first&.dig("content")
|
|
224
|
+
elsif sd_name.is_a?(Hash)
|
|
225
|
+
sd_name["content"]
|
|
226
|
+
else
|
|
227
|
+
sd_name.to_s
|
|
228
|
+
end
|
|
229
|
+
end
|
|
155
230
|
end
|
|
156
231
|
end
|
|
157
232
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-release
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.19
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: relaton-bib
|