jekyll-theme-isotc154-helpers 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 97cf5ce895c3d7054c9953c732302f6afe9e91b067f2b83cfd1d63307cac4f9e
4
+ data.tar.gz: 226f566899fc5d24f0693607c09ef793bdd9ff9e15aa788f249bbc370447e30d
5
+ SHA512:
6
+ metadata.gz: da1af7113d0e5df7b3db1ea48477708b90504311c6121222358bd9ec5eb91eb06050ca3d0ed7f5e3c4d08fe57772affa2b9e6bf92119092490ad41e306a07370
7
+ data.tar.gz: 9271d44bf90cca5a6f503a0fb698da56ae30c0022c7ab80bcde28a9257e0130feacc80a95e589d327bbee62ae1f0daef42a8c16b73642d8d969b080fc957788d
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 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.
@@ -0,0 +1,7 @@
1
+ # ISO/TC 154 theme helpers
2
+
3
+ Jekyll plugin for the https://github.com/riboseinc/jekyll-theme-isotc154[ISO/TC 154 gem-based Jekyll theme]
4
+ by Ribose.
5
+
6
+ Provides the data reading and page generation capabilities
7
+ required by the theme.
@@ -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-isotc154-helpers-*.gem
16
+ gem build -q jekyll-theme-isotc154-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-isotc154-helpers-*.gem | sed 's/^jekyll-theme-isotc154-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-isotc154-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-isotc154-helpers'
5
+ s.version = '0.0.1'
6
+ s.authors = ['Ribose Inc.']
7
+ s.email = ['open.source@ribose.com']
8
+
9
+ s.summary = 'Helpers for Ribose’s ISO/TC 154 Jekyll theme'
10
+ s.homepage = 'https://github.com/riboseinc/jekyll-theme-isotc154-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', '~> 4.0'
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,8 @@
1
+ require 'jekyll-theme-isotc154-helpers/events'
2
+ require 'jekyll-theme-isotc154-helpers/headerlinks'
3
+
4
+
5
+ module Jekyll
6
+ module ISOTC154Helpers
7
+ end
8
+ end
@@ -0,0 +1,36 @@
1
+ module Jekyll
2
+
3
+ class Site
4
+ def read_events
5
+ unfinished_events = []
6
+
7
+ self.data['events'].each do |event_id, event_data|
8
+ event_start = event_data['time']['from']['date']
9
+ event_end = event_data['time']['to']['date']
10
+
11
+ if event_end >= (Date.today + 1)
12
+ event = event_data.clone
13
+
14
+ event['id'] = event_id
15
+
16
+ if event_start < (Date.today - 1)
17
+ event['current'] = true
18
+ end
19
+
20
+ unfinished_events << event
21
+ end
22
+ end
23
+
24
+ self.data['unfinished_events'] = unfinished_events
25
+ end
26
+ end
27
+
28
+ class EventReader < Generator
29
+ safe true
30
+ priority :low
31
+
32
+ def generate(site)
33
+ site.read_events
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,37 @@
1
+ require 'nokogiri'
2
+ require 'uri'
3
+
4
+ # Given hostname and content, updates <hN> tags, adding trailing <a class="anchor-link"></a>.
5
+ def process_content(site_hostname, content, anchor_contents)
6
+ content = Nokogiri::HTML(content)
7
+ content.css('main h2[id], main h3[id], main h4[id], main h5[id]').each do |el|
8
+ html_id = el.get_attribute('id')
9
+ el.inner_html = "#{el.inner_html}<a class='anchor-link' href='./##{html_id}'>#{anchor_contents}</a>"
10
+ end
11
+ return content.to_s
12
+ end
13
+
14
+ # Keeps track of already processed items to avoid duplicate anchors.
15
+ $processed_urls = []
16
+
17
+ # Jekyll hook handler function.
18
+ def process_doc_or_page(doc)
19
+ site_hostname = URI(doc.site.config['url']).host
20
+
21
+ # TODO: Read anchor_contents from site config
22
+ anchor_contents = "<i class='fas fa-link'></i>"
23
+
24
+ unless doc.respond_to?(:asset_file?) and doc.asset_file?
25
+ if doc.respond_to?(:id)
26
+ if $processed_urls.include? doc.id
27
+ return
28
+ end
29
+ $processed_urls << doc.id
30
+ end
31
+ doc.output = process_content(site_hostname, doc.output, anchor_contents)
32
+ end
33
+ end
34
+
35
+ Jekyll::Hooks.register :documents, :post_render do |doc| process_doc_or_page(doc) end
36
+
37
+ Jekyll::Hooks.register :pages, :post_render do |page| process_doc_or_page(page) end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-theme-isotc154-helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-28 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: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
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.adoc
64
+ - develop/release
65
+ - jekyll-theme-isotc154-helpers.gemspec
66
+ - lib/jekyll-theme-isotc154-helpers.rb
67
+ - lib/jekyll-theme-isotc154-helpers/events.rb
68
+ - lib/jekyll-theme-isotc154-helpers/headerlinks.rb
69
+ homepage: https://github.com/riboseinc/jekyll-theme-isotc154-helpers/
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.0.6
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: Helpers for Ribose’s ISO/TC 154 Jekyll theme
92
+ test_files: []