jekyll-emd-generator 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ee2a0a897767f9dea1a33cab9f022090b96ad0f1a0c2e7b8ce151d550e69d497
4
+ data.tar.gz: 26998ef548172ccb4a5f0c8a9e7839e4bd83b0bd8f54d184bf338c2cb87922f0
5
+ SHA512:
6
+ metadata.gz: 8b7cb5b30009f6d32fb98a600577f654aa302db468d62fbd55fe1abeebaf3340e9f91a0d5de571fc25050bbee61f7a4c762240e7056a358a0908b021d32177c8
7
+ data.tar.gz: 602b22af063464bc26cc0675c1bbd0c225545c9d8c07dc4abfc14f7e6f0ed3c8e8d211cc7e095dca326f6c5c8520f1f3b03ffd4ec4c0f71095ce16de8580b963
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'jekyll'
4
+ gem 'fastimage'
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 StoryFaktor.de and the jekyll-emd-generator contributors
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # jekyll-emd-generator
2
+ Enhance Jekyll Frontmatter from JSON Files
@@ -0,0 +1,29 @@
1
+ require_relative 'lib/jekyll-emd-generator/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "jekyll-emd-generator"
5
+ spec.version = EnhanceMetaData::Generator::VERSION
6
+ spec.authors = ["Michael Gerzabek"]
7
+ spec.email = ["michael.gerzabek@gmail.com"]
8
+
9
+ spec.summary = "A Jekyll plugin to add metadata to the frontmatter of individual pages."
10
+ spec.homepage = "https://github.com/storyfaktor/jekyll-emd-generator"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
13
+
14
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ spec.metadata["changelog_uri"] = "https://github.com/storyfaktor/jekyll-emd-generator/blob/main/CHANGELOG.md"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "jekyll", ">= 3.8", "< 5.0"
29
+ end
@@ -0,0 +1,77 @@
1
+ require 'jekyll'
2
+ require 'fastimage'
3
+ require 'jekyll-emd-generator/version'
4
+
5
+ module EnhanceMetaData
6
+ class Generator < Jekyll::Generator
7
+
8
+ def generate(site)
9
+
10
+ site.pages.each do |page|
11
+ #if File.fnmatch( "index.{html,md}", page.path, File::FNM_EXTGLOB )
12
+ # ["elements"].each do |method|
13
+ # Generator.method(method).call page
14
+ # end
15
+ #end
16
+ #if File.fnmatch( "**/index.{html,md}", page.path, File::FNM_EXTGLOB )
17
+ if File.fnmatch( "**index.{html,md}", page.path, File::FNM_EXTGLOB )
18
+ ["product", "elements"].each do |method|
19
+ Generator.method(method).call page
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ def self.product(doc)
26
+
27
+ dir = File.dirname(doc.path)
28
+ file = dir + "/product.json"
29
+ if File.exist?(file)
30
+
31
+ doc.data['product'] = SafeYAML.load_file(file)
32
+ #
33
+ #Jekyll.logger.info "", file
34
+ #
35
+ # jekyll-seo-plugin @title
36
+ # Der Product.name wird zu @title falls nicht im
37
+ # Frontmatter überschrieben
38
+ if doc.data['title'].nil?
39
+ doc.data['title'] = doc.data['product']['name']
40
+ end
41
+ # jekyll-seo-plugin @description
42
+ # Product.description wird zu @description falls nicht
43
+ # im Frontmatter überschrieben
44
+ if doc.data['description'].nil?
45
+ doc.data['description'] = doc.data['product']['description']
46
+ end
47
+ # jekyll-seo-plugin @image
48
+ # Product.image wird zu @image falls nicht im
49
+ # Frontmatter überschrieben
50
+ if doc.data['image'].nil?
51
+ image = "#{dir}/#{doc.data['product']['image']}"
52
+ if File.exist?(image)
53
+ dimensions = FastImage.size(image)
54
+ doc.data['image'] = {}
55
+ doc.data['image']['path'] = '/' + image
56
+ doc.data['image']['width'] = dimensions[0]
57
+ doc.data['image']['height'] = dimensions[1]
58
+ else
59
+ Jekyll.logger.warn "Missing:", image
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ def self.elements(doc)
66
+
67
+ dir = File.dirname(doc.path)
68
+ file = dir + "/elements.json"
69
+ if File.exist?(file)
70
+ #
71
+ #Jekyll.logger.info "", file
72
+ #
73
+ doc.data['elements'] = SafeYAML.load_file(file)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,5 @@
1
+ module EnhanceMetaData
2
+ class Generator
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-emd-generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Gerzabek
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-21 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
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.8'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ description:
34
+ email:
35
+ - michael.gerzabek@gmail.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".gitignore"
41
+ - CHANGELOG.md
42
+ - Gemfile
43
+ - LICENSE.txt
44
+ - README.md
45
+ - jekyll-emd-generator.txt
46
+ - lib/jekyll-emd-generator.rb
47
+ - lib/jekyll-emd-generator/version.rb
48
+ homepage: https://github.com/storyfaktor/jekyll-emd-generator
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ allowed_push_host: https://rubygems.org
53
+ homepage_uri: https://github.com/storyfaktor/jekyll-emd-generator
54
+ source_code_uri: https://github.com/storyfaktor/jekyll-emd-generator
55
+ changelog_uri: https://github.com/storyfaktor/jekyll-emd-generator/blob/main/CHANGELOG.md
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 2.4.0
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubygems_version: 3.1.2
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: A Jekyll plugin to add metadata to the frontmatter of individual pages.
75
+ test_files: []