jekyll-geolexica 1.8.15 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/jekyll-geolexica.gemspec +1 -0
- data/lib/jekyll/geolexica/configuration.rb +5 -0
- data/lib/jekyll/geolexica/glossary.rb +17 -65
- data/lib/jekyll/geolexica/version.rb +1 -1
- data/lib/jekyll/geolexica.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bf9198ece6031ea2db54e9a6f4f8d236dbcf253aba824e92db8a103a4f650f8
|
4
|
+
data.tar.gz: 7d03d364470f0a219cb98ca1832d7fb046dbe170808588861dc090d4af927c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3c019c8c9be5691fa0e836352d4973efdbb3ad0f8570fac50ff748562382042b645fd54f1ea6a0f77617d445464f2aed32a1f2cf4e4f111883a31b751144866
|
7
|
+
data.tar.gz: e0c1764ad91b3d49ed30fa235e1714af75571e1578f1d32872320d864bb92bb64e12a413752a96822eae21c428283f3a31605bac32520d36da7a7efc4f5461ba
|
data/jekyll-geolexica.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
36
|
spec.require_paths = ["lib"]
|
37
37
|
|
38
|
+
spec.add_runtime_dependency "glossarist", "~> 2.0"
|
38
39
|
# Jekyll 4.1.0 adds some breaking changes which are reverted in 4.1.1.
|
39
40
|
# I doubt we should be worried, but there is no good reason to allow them
|
40
41
|
# either.
|
@@ -13,11 +13,27 @@ module Jekyll
|
|
13
13
|
|
14
14
|
def initialize(site)
|
15
15
|
@site = site
|
16
|
+
@collection = Glossarist::ManagedConceptCollection.new
|
16
17
|
end
|
17
18
|
|
18
19
|
def load_glossary
|
19
20
|
Jekyll.logger.info('Geolexica:', 'Loading concepts')
|
20
|
-
|
21
|
+
@collection.load_from_files(glossary_path)
|
22
|
+
|
23
|
+
@collection.each do |managed_concept|
|
24
|
+
concept_hash = {
|
25
|
+
"id" => managed_concept.uuid,
|
26
|
+
"term" => managed_concept.default_designation,
|
27
|
+
"termid" => managed_concept.id,
|
28
|
+
}.merge(managed_concept.to_h)
|
29
|
+
|
30
|
+
managed_concept.localizations.each do |lang, localization|
|
31
|
+
concept_hash[lang] = localization.to_h["data"]
|
32
|
+
end
|
33
|
+
|
34
|
+
preprocess_concept_hash(concept_hash)
|
35
|
+
store(Concept.new(concept_hash))
|
36
|
+
end
|
21
37
|
end
|
22
38
|
|
23
39
|
def store(concept)
|
@@ -37,70 +53,6 @@ module Jekyll
|
|
37
53
|
|
38
54
|
protected
|
39
55
|
|
40
|
-
def load_concept(concept_file_path)
|
41
|
-
Jekyll.logger.debug('Geolexica:',
|
42
|
-
"reading concept from file #{concept_file_path}")
|
43
|
-
|
44
|
-
concept_hash = if glossary_format == 'paneron'
|
45
|
-
read_paneron_concept_file(concept_file_path)
|
46
|
-
else
|
47
|
-
read_concept_file(concept_file_path)
|
48
|
-
end
|
49
|
-
|
50
|
-
preprocess_concept_hash(concept_hash)
|
51
|
-
store Concept.new(concept_hash)
|
52
|
-
rescue StandardError
|
53
|
-
Jekyll.logger.error('Geolexica:',
|
54
|
-
"failed to read concept from file #{concept_file_path}")
|
55
|
-
raise
|
56
|
-
end
|
57
|
-
|
58
|
-
# Reads and parses concept file located at given path.
|
59
|
-
def read_concept_file(path)
|
60
|
-
YAML.safe_load(File.read(path), permitted_classes: [Time])
|
61
|
-
end
|
62
|
-
|
63
|
-
def read_paneron_concept_file(path)
|
64
|
-
safe_load_options = { permitted_classes: [Date, Time] }
|
65
|
-
concept = YAML.safe_load(File.read(path), **safe_load_options)
|
66
|
-
concept['termid'] = concept['data']['identifier']
|
67
|
-
|
68
|
-
(concept['data']['localizedConcepts'] || []).each do |lang, local_concept_id|
|
69
|
-
localized_concept_path = File.join(localized_concepts_path, "#{local_concept_id}.yaml")
|
70
|
-
concept[lang] = YAML.safe_load(File.read(localized_concept_path), **safe_load_options)['data']
|
71
|
-
|
72
|
-
next unless concept[lang]
|
73
|
-
|
74
|
-
normalize_sources(concept[lang])
|
75
|
-
concept['term'] = concept[lang]['terms'].first['designation'] if lang == 'eng'
|
76
|
-
end
|
77
|
-
|
78
|
-
concept
|
79
|
-
end
|
80
|
-
|
81
|
-
def normalize_sources(concept)
|
82
|
-
authoritative_sources = concept.delete('authoritativeSource') || []
|
83
|
-
concept['sources'] ||= []
|
84
|
-
|
85
|
-
authoritative_sources.each do |authoritative_source|
|
86
|
-
if authoritative_source['relationship']
|
87
|
-
status = authoritative_source['relationship']['type']
|
88
|
-
modification = authoritative_source['relationship']['modification']
|
89
|
-
end
|
90
|
-
|
91
|
-
concept['sources'] << {
|
92
|
-
"status" => status,
|
93
|
-
"modification" => modification,
|
94
|
-
"origin" => {
|
95
|
-
'ref' => authoritative_source['ref'],
|
96
|
-
'clause' => authoritative_source['clause'],
|
97
|
-
'link' => authoritative_source['link'],
|
98
|
-
}.compact,
|
99
|
-
'type' => 'authoritative'
|
100
|
-
}.compact
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
56
|
# Does nothing, but some sites may replace this method.
|
105
57
|
def preprocess_concept_hash(concept_hash); end
|
106
58
|
|
data/lib/jekyll/geolexica.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-geolexica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: glossarist
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: jekyll
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|