jekyll-geolexica 1.8.5 → 1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/geolexica/configuration.rb +11 -0
- data/lib/jekyll/geolexica/glossary.rb +46 -19
- data/lib/jekyll/geolexica/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16891afbfd31bfa320715e20de559a8ae6b96eecc2cfc53b38ab1654f5c1e156
|
4
|
+
data.tar.gz: 1fb4b721b4029abaa5d1c6fdb5f4026ef1eca64fc4f29288bc81f8edfb6be7b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b2fcbcebd7174d974e5579caf37f921f245f47bd68c824c6bce4ebe70db6c5356ee769fd7a3998a7b80080fe8b38c97c42af8333a0ae221acf05159fd90a1d
|
7
|
+
data.tar.gz: 2f6a10a96391e6384f1c4a2b3e97d6ea62ba2eccbdcff936adf199c3dc4412625f7d9ca2b0bf4a87ee9acae804ec11e70b670ab29b199fd62d0ad2cd033eb9c7
|
@@ -9,6 +9,17 @@ module Jekyll
|
|
9
9
|
File.expand_path(glob_string, site.source)
|
10
10
|
end
|
11
11
|
|
12
|
+
def localized_concepts_path
|
13
|
+
path = glossary_config["localized_concepts_path"]
|
14
|
+
return nil if path.nil? || path.empty?
|
15
|
+
|
16
|
+
File.expand_path(path, site.source)
|
17
|
+
end
|
18
|
+
|
19
|
+
def glossary_format
|
20
|
+
glossary_config["format"]
|
21
|
+
end
|
22
|
+
|
12
23
|
def images_path
|
13
24
|
glossary_path = glossary_config["glossary_path"]
|
14
25
|
return nil if glossary_path.nil? || glossary_path.empty?
|
@@ -8,20 +8,20 @@ module Jekyll
|
|
8
8
|
|
9
9
|
attr_reader :site
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
alias each_concept each_value
|
12
|
+
alias each_termid each_key
|
13
13
|
|
14
14
|
def initialize(site)
|
15
15
|
@site = site
|
16
16
|
end
|
17
17
|
|
18
18
|
def load_glossary
|
19
|
-
Jekyll.logger.info(
|
19
|
+
Jekyll.logger.info('Geolexica:', 'Loading concepts')
|
20
20
|
Dir.glob(concepts_glob).each { |path| load_concept(path) }
|
21
21
|
end
|
22
22
|
|
23
23
|
def store(concept)
|
24
|
-
super(concept.data[
|
24
|
+
super(concept.data['termid'], concept)
|
25
25
|
end
|
26
26
|
|
27
27
|
def language_statistics
|
@@ -31,21 +31,27 @@ module Jekyll
|
|
31
31
|
# Defines how Glossary is exposed in Liquid templates.
|
32
32
|
def to_liquid
|
33
33
|
{
|
34
|
-
|
34
|
+
'language_statistics' => language_statistics
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
38
38
|
protected
|
39
39
|
|
40
40
|
def load_concept(concept_file_path)
|
41
|
-
Jekyll.logger.debug(
|
42
|
-
|
43
|
-
|
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
|
+
|
44
50
|
preprocess_concept_hash(concept_hash)
|
45
51
|
store Concept.new(concept_hash)
|
46
|
-
rescue
|
47
|
-
Jekyll.logger.error(
|
48
|
-
|
52
|
+
rescue StandardError
|
53
|
+
Jekyll.logger.error('Geolexica:',
|
54
|
+
"failed to read concept from file #{concept_file_path}")
|
49
55
|
raise
|
50
56
|
end
|
51
57
|
|
@@ -54,15 +60,36 @@ module Jekyll
|
|
54
60
|
YAML.safe_load(File.read(path), permitted_classes: [Time])
|
55
61
|
end
|
56
62
|
|
57
|
-
|
58
|
-
|
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
|
+
concept['term'] = concept[lang]['terms'].first['designation'] if lang == 'eng'
|
75
|
+
|
76
|
+
if concept[lang]['status'] && !concept[lang]['status'].empty? &&
|
77
|
+
(concept[lang]['entry_status'].nil? || concept[lang]['entry_status'].empty?)
|
78
|
+
concept['entry_status'] = concept[lang]['status']
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
concept
|
59
83
|
end
|
60
84
|
|
85
|
+
# Does nothing, but some sites may replace this method.
|
86
|
+
def preprocess_concept_hash(concept_hash); end
|
87
|
+
|
61
88
|
def calculate_language_statistics
|
62
|
-
unsorted = each_value.lazy
|
63
|
-
|
64
|
-
|
65
|
-
|
89
|
+
unsorted = each_value.lazy
|
90
|
+
.flat_map { |concept| term_languages & concept.data.keys }
|
91
|
+
.group_by(&:itself)
|
92
|
+
.transform_values(&:count)
|
66
93
|
|
67
94
|
# This is not crucial, but gives nicer output, and ensures that
|
68
95
|
# all +term_languages+ are present.
|
@@ -72,7 +99,7 @@ module Jekyll
|
|
72
99
|
class Concept
|
73
100
|
attr_reader :data
|
74
101
|
|
75
|
-
# TODO Maybe some kind of Struct instead of Hash.
|
102
|
+
# TODO: Maybe some kind of Struct instead of Hash.
|
76
103
|
attr_reader :pages
|
77
104
|
|
78
105
|
def initialize(data)
|
@@ -81,7 +108,7 @@ module Jekyll
|
|
81
108
|
end
|
82
109
|
|
83
110
|
def termid
|
84
|
-
data[
|
111
|
+
data['termid']
|
85
112
|
end
|
86
113
|
|
87
114
|
class LiquidCompatibleHash < Hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-geolexica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.7
|
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: 2023-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|