jekyll-theme-isotc211-helpers 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b77dd5b596a1a94b89e1decfca8be4d5a28f0f906ac05ad4f61fbe438197dac0
4
+ data.tar.gz: c3ba656da24b3e34184cfc9f1b20cc02373543aed580e668701ad13b9f1566dd
5
+ SHA512:
6
+ metadata.gz: 6151f0976c7309442e354699f195a0901bd541b79821e53c834ddeb127c2e3d8b03466b62da063c7f3a969c943e48d67fadb02c88d10112d02ddf43f3d7c5eac
7
+ data.tar.gz: 69cee40ad8cc1e51add6f81e84b02fa29d41efcaea5b615457af270fff1db9c3b3d41e4a54ac9e395f76030af4d1d031a91b1e0758956919cf05862ad5cea522
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Ribose
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # ISO TC 211 theme helpers
2
+
3
+ Jekyll plugin for the ISO TC 211 gem-based Jekyll theme by Ribose.
4
+
5
+ It provides the data reading and page generation capabilities
6
+ required by the theme.
data/develop/release ADDED
@@ -0,0 +1,41 @@
1
+ #!/bin/sh
2
+ # Tag and push a release.
3
+
4
+ set -e
5
+
6
+ # Make sure we're in the project root.
7
+
8
+ cd $(dirname "$0")/..
9
+
10
+ # Make sure the darn thing works? Meh.
11
+ # bundle update
12
+
13
+ # Build a new gem archive.
14
+
15
+ rm -rf jekyll-theme-isotc211-helpers-*.gem
16
+ gem build -q jekyll-theme-isotc211-helpers.gemspec
17
+
18
+ # Make sure we're on the master branch.
19
+
20
+ (git branch | grep -q 'master') || {
21
+ echo "Only release from the master branch."
22
+ exit 1
23
+ }
24
+
25
+ # Figure out what version we're releasing.
26
+
27
+ tag=v`ls jekyll-theme-isotc211-helpers-*.gem | sed 's/^jekyll-theme-isotc211-helpers-\(.*\)\.gem$/\1/'`
28
+
29
+ # Make sure we haven't released this version before.
30
+
31
+ git fetch -t origin
32
+
33
+ (git tag -l | grep -q "$tag") && {
34
+ echo "Whoops, there's already a '${tag}' tag."
35
+ exit 1
36
+ }
37
+
38
+ # Tag it and bag it.
39
+
40
+ gem push jekyll-theme-isotc211-helpers-*.gem && git tag "$tag" &&
41
+ git push origin master && git push origin "$tag"
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'jekyll-theme-isotc211-helpers'
5
+ s.version = '0.4.9'
6
+ s.authors = ['Ribose Inc.']
7
+ s.email = ['open.source@ribose.com']
8
+
9
+ s.summary = 'Helpers for the ISO TC 211 Jekyll theme'
10
+ s.homepage = 'https://github.com/riboseinc/jekyll-theme-isotc211-helpers/'
11
+ s.license = 'MIT'
12
+
13
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
14
+
15
+ s.add_runtime_dependency 'jekyll', '~> 3.8'
16
+ s.add_development_dependency 'rake', '~> 12.0'
17
+ s.add_development_dependency 'rubocop', '~> 0.50'
18
+
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,137 @@
1
+ require 'pathname'
2
+
3
+ module Jekyll
4
+
5
+ class ResourceListingPage < Page
6
+ def initialize(site, base_dir, url, layout, header, resources)
7
+ @site = site
8
+ @base = base_dir
9
+ @dir = url
10
+ @name = "index.html"
11
+
12
+ self.process(@name)
13
+
14
+ self.data = {
15
+ 'layout' => layout || 'resource-index',
16
+ 'title' => header,
17
+ 'resources' => resources,
18
+ }
19
+ end
20
+ end
21
+
22
+ class ResourcePage < Page
23
+ def initialize(site, base_dir, index_url, index_label, layout, id, label, meta, contents)
24
+ @site = site
25
+ @base = base_dir
26
+ @dir = File.join(index_url, id)
27
+ @name = "index.html"
28
+
29
+ self.process(@name)
30
+
31
+ self.data = {
32
+ 'layout' => layout || 'resource-page',
33
+ 'title' => "#{label.capitalize} #{id}",
34
+ 'parent_title' => index_label,
35
+ 'parent_link' => "/#{index_url}",
36
+ 'meta' => { "id" => id },
37
+ 'contents' => contents,
38
+ }
39
+ end
40
+ end
41
+
42
+ class Site
43
+
44
+ def write_resource_listing_page(listing_id, resources)
45
+ cfg = self.config['resource_listings'][listing_id]
46
+
47
+ self.pages << ResourceListingPage.new(
48
+ self,
49
+ self.source,
50
+ cfg['index_url'],
51
+ cfg['index_layout'],
52
+ cfg['index_title'],
53
+ resources)
54
+ end
55
+
56
+ def write_resource_page(listing_id, resource_id, contents)
57
+ cfg = self.config['resource_listings'][listing_id]
58
+
59
+ self.pages << ResourcePage.new(
60
+ self,
61
+ self.source,
62
+ cfg['index_url'],
63
+ cfg['index_title'],
64
+ cfg['resource_layout'],
65
+ resource_id,
66
+ cfg['resource_label'],
67
+ {},
68
+ contents)
69
+ end
70
+
71
+ def read_resource_contents(dir, id, listing_id)
72
+ cfg = self.config['resource_listings'][listing_id]
73
+ return directory_hash(dir, "#{cfg['resource_label'].capitalize} #{id}")
74
+ end
75
+
76
+ def read_resources
77
+ if self.config.key?('resource_listings')
78
+
79
+ self.config['resource_listings'].each do |listing_id, cfg|
80
+ resources = {}
81
+
82
+ Pathname(cfg['resource_root']).children.each do |resource_dir|
83
+ basename = File.basename(resource_dir)
84
+ if basename[0] == '.'
85
+ # Ignore dot-directories
86
+ next
87
+ end
88
+ id = basename
89
+ resources[id] = {}
90
+ contents = self.read_resource_contents(resource_dir.to_s, id, listing_id)
91
+ self.write_resource_page(listing_id, id, contents)
92
+ end
93
+
94
+ self.write_resource_listing_page(listing_id, resources)
95
+ end
96
+
97
+ end
98
+ end
99
+
100
+ end
101
+
102
+ class ResourceReader < Generator
103
+ safe true
104
+ priority :high
105
+
106
+ def generate(site)
107
+ site.read_resources
108
+ end
109
+ end
110
+
111
+ end
112
+
113
+
114
+ def directory_hash(path, name=nil, level=0)
115
+ data = {
116
+ "data" => (name || path),
117
+ "full_path" => path,
118
+ "level" => level,
119
+ }
120
+ data["children"] = children = []
121
+
122
+ level += 1
123
+
124
+ Dir.foreach(path) do |entry|
125
+ next if (entry == '..' || entry == '.')
126
+
127
+ full_path = File.join(path, entry)
128
+
129
+ if File.directory?(full_path)
130
+ children << directory_hash(full_path, entry, level=level)
131
+ else
132
+ children << { "data" => entry, "full_path" => full_path, "level" => level }
133
+ end
134
+ end
135
+
136
+ return data
137
+ end
@@ -0,0 +1,7 @@
1
+ require 'jekyll-theme-isotc211-helpers/resource_listing'
2
+
3
+
4
+ module Jekyll
5
+ module ISOTC211Helpers
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-theme-isotc211-helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.9
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.50'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.50'
55
+ description:
56
+ email:
57
+ - open.source@ribose.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.txt
63
+ - README.md
64
+ - develop/release
65
+ - jekyll-theme-isotc211-helpers.gemspec
66
+ - lib/jekyll-theme-isotc211-helpers.rb
67
+ - lib/jekyll-theme-isotc211-helpers/resource_listing.rb
68
+ homepage: https://github.com/riboseinc/jekyll-theme-isotc211-helpers/
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 2.7.6.2
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Helpers for the ISO TC 211 Jekyll theme
92
+ test_files: []