kontent-jekyll 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +53 -53
- data/.rspec +1 -1
- data/.travis.yml +20 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +143 -133
- data/LICENSE +21 -21
- data/README.md +41 -41
- data/Rakefile +6 -6
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/kontent-jekyll.gemspec +72 -72
- data/lib/kontent-jekyll.rb +14 -14
- data/lib/kontent-jekyll/constants/item_element_type.rb +17 -17
- data/lib/kontent-jekyll/constants/kentico_config_keys.rb +10 -10
- data/lib/kontent-jekyll/constants/page_type.rb +14 -14
- data/lib/kontent-jekyll/gem_name.rb +5 -5
- data/lib/kontent-jekyll/generator.rb +105 -105
- data/lib/kontent-jekyll/resolvers/content_link_resolver.rb +14 -14
- data/lib/kontent-jekyll/resolvers/content_resolver.rb +47 -47
- data/lib/kontent-jekyll/resolvers/data_resolver.rb +46 -46
- data/lib/kontent-jekyll/resolvers/filename_resolver.rb +52 -52
- data/lib/kontent-jekyll/resolvers/front_matter_resolver.rb +163 -163
- data/lib/kontent-jekyll/resolvers/inline_content_item_resolver.rb +15 -15
- data/lib/kontent-jekyll/site_processing/custom_site_processor.rb +12 -12
- data/lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb +88 -88
- data/lib/kontent-jekyll/site_processing/site_processor.rb +248 -248
- data/lib/kontent-jekyll/utils/normalize_object.rb +87 -87
- data/lib/kontent-jekyll/version.rb +5 -5
- metadata +3 -2
data/README.md
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
# Jekyll Kentico
|
2
|
-
|
3
|
-
Jekyll Kentico is utilizing Kentico Kontent, headless CMS, as a content repository and integrates it with Jekyll static site generator. You can generate posts, pages, collections and data items.
|
4
|
-
|
5
|
-
## Examples
|
6
|
-
|
7
|
-
For a working example see [this project](https://github.com/RadoslavK/kontent-jekyll-blog).
|
8
|
-
|
9
|
-
## Installation
|
10
|
-
|
11
|
-
Add this to your gem's Jekyll plugins:
|
12
|
-
|
13
|
-
```ruby
|
14
|
-
source 'https://rubygems.org'
|
15
|
-
|
16
|
-
group :jekyll_plugins do
|
17
|
-
gem 'kontent-jekyll'
|
18
|
-
end
|
19
|
-
```
|
20
|
-
|
21
|
-
And then execute `bundle install`
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
Run `bundle exec jekyll build` as you would normally build your Jekyll site.
|
26
|
-
You can also run `bundle exec jekyll serve` to run the built site.
|
27
|
-
|
28
|
-
## Configuration
|
29
|
-
|
30
|
-
To configure the extension, add the following configuration block to Jekyll's `_config.yml`:
|
31
|
-
|
32
|
-
For full configuration [see wiki](https://github.com/RadoslavK/kontent-jekyll/wiki).
|
33
|
-
|
34
|
-
```yaml
|
35
|
-
plugins:
|
36
|
-
- kontent-jekyll
|
37
|
-
kentico:
|
38
|
-
project_id: 2dd742d6-107b-48b0-8335-6674c76c9b93
|
39
|
-
posts:
|
40
|
-
type: blog_post
|
41
|
-
```
|
1
|
+
# Jekyll Kentico
|
2
|
+
|
3
|
+
Jekyll Kentico is utilizing Kentico Kontent, headless CMS, as a content repository and integrates it with Jekyll static site generator. You can generate posts, pages, collections and data items.
|
4
|
+
|
5
|
+
## Examples
|
6
|
+
|
7
|
+
For a working example see [this project](https://github.com/RadoslavK/kontent-jekyll-blog).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this to your gem's Jekyll plugins:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
source 'https://rubygems.org'
|
15
|
+
|
16
|
+
group :jekyll_plugins do
|
17
|
+
gem 'kontent-jekyll'
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute `bundle install`
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Run `bundle exec jekyll build` as you would normally build your Jekyll site.
|
26
|
+
You can also run `bundle exec jekyll serve` to run the built site.
|
27
|
+
|
28
|
+
## Configuration
|
29
|
+
|
30
|
+
To configure the extension, add the following configuration block to Jekyll's `_config.yml`:
|
31
|
+
|
32
|
+
For full configuration [see wiki](https://github.com/RadoslavK/kontent-jekyll/wiki).
|
33
|
+
|
34
|
+
```yaml
|
35
|
+
plugins:
|
36
|
+
- kontent-jekyll
|
37
|
+
kentico:
|
38
|
+
project_id: 2dd742d6-107b-48b0-8335-6674c76c9b93
|
39
|
+
posts:
|
40
|
+
type: blog_post
|
41
|
+
```
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core/rake_task'
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
5
|
-
|
6
|
-
task :default => :spec
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
task :default => :spec
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "kontent-jekyll"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "kontent-jekyll"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/kontent-jekyll.gemspec
CHANGED
@@ -1,73 +1,73 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
4
|
-
require 'kontent-jekyll/version'
|
5
|
-
require 'kontent-jekyll/gem_name'
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = Kentico::Kontent::GEM_NAME
|
9
|
-
spec.version = Kentico::Kontent::VERSION
|
10
|
-
spec.licenses = ['MIT']
|
11
|
-
spec.authors = ['RadoslavK']
|
12
|
-
spec.email = ['RadoslavK@kentico.com']
|
13
|
-
|
14
|
-
spec.summary = 'Kentico Kontent plugin for Jekyll'
|
15
|
-
spec.description = 'Kontent Jekyll is utilizing Kentico Kontent, headless CMS, as a content repository and integrates it with Jekyll static site generator. You can generate posts, pages, collections and data items.'
|
16
|
-
spec.homepage = 'https://github.com/RadoslavK/kontent-jekyll'
|
17
|
-
|
18
|
-
# Specify which files should be added to the gem when it is released.
|
19
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
-
end
|
23
|
-
spec.bindir = 'exe'
|
24
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
-
spec.require_paths = ['lib']
|
26
|
-
|
27
|
-
spec.required_ruby_version = '>= 2.6.3'
|
28
|
-
|
29
|
-
spec.add_development_dependency 'bundler', '~> 2.0'
|
30
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
-
spec.add_development_dependency 'rack-jekyll', '0.5'
|
33
|
-
spec.add_development_dependency 'capybara', '3.29.0'
|
34
|
-
spec.add_development_dependency 'jekyll', '3.8.6'
|
35
|
-
|
36
|
-
spec.add_runtime_dependency 'kontent-delivery-sdk-ruby', '~> 2.0'
|
37
|
-
end
|
38
|
-
|
39
|
-
# Local gem dependency when developing locally
|
40
|
-
#embedded_gemspec = Gem::Specification::load('C:\kontent-delivery-sdk-ruby\kontent-delivery-sdk-ruby.gemspec')
|
41
|
-
#
|
42
|
-
#Gem::Specification.new do |spec|
|
43
|
-
# spec.name = Kentico::Kontent::GEM_NAME
|
44
|
-
# spec.version = Kentico::Kontent::VERSION
|
45
|
-
# spec.licenses = ['MIT']
|
46
|
-
# spec.authors = ['RadoslavK']
|
47
|
-
# spec.email = ['RadoslavK@kentico.com']
|
48
|
-
#
|
49
|
-
# spec.summary = 'Kentico Kontent plugin for Jekyll'
|
50
|
-
# spec.description = 'Jekyll Kentico is utilizing Kentico Kontent, headless CMS, as a content repository and integrates it with Jekyll static site generator. You can generate posts, pages, collections and data items.'
|
51
|
-
# spec.homepage = 'https://github.com/RadoslavK/kentico-jekyll'
|
52
|
-
#
|
53
|
-
# # Specify which files should be added to the gem when it is released.
|
54
|
-
# # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
55
|
-
# spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
56
|
-
# `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
57
|
-
# end
|
58
|
-
# spec.files += embedded_gemspec.files
|
59
|
-
# spec.bindir = 'exe'
|
60
|
-
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
61
|
-
# spec.require_paths = ['lib']
|
62
|
-
#
|
63
|
-
# spec.required_ruby_version = '>= 2.6.3'
|
64
|
-
#
|
65
|
-
# spec.add_development_dependency 'bundler', '~> 2.0'
|
66
|
-
# spec.add_development_dependency 'rake', '~> 10.0'
|
67
|
-
# spec.add_development_dependency 'rspec', '~> 3.0'
|
68
|
-
# spec.add_development_dependency 'rack-jekyll', '0.5'
|
69
|
-
# spec.add_development_dependency 'capybara', '3.29.0'
|
70
|
-
# spec.add_development_dependency 'jekyll', '3.8.6'
|
71
|
-
#
|
72
|
-
# embedded_gemspec.runtime_dependencies.each { |d| spec.add_dependency d }
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'kontent-jekyll/version'
|
5
|
+
require 'kontent-jekyll/gem_name'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = Kentico::Kontent::GEM_NAME
|
9
|
+
spec.version = Kentico::Kontent::VERSION
|
10
|
+
spec.licenses = ['MIT']
|
11
|
+
spec.authors = ['RadoslavK']
|
12
|
+
spec.email = ['RadoslavK@kentico.com']
|
13
|
+
|
14
|
+
spec.summary = 'Kentico Kontent plugin for Jekyll'
|
15
|
+
spec.description = 'Kontent Jekyll is utilizing Kentico Kontent, headless CMS, as a content repository and integrates it with Jekyll static site generator. You can generate posts, pages, collections and data items.'
|
16
|
+
spec.homepage = 'https://github.com/RadoslavK/kontent-jekyll'
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'exe'
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
|
27
|
+
spec.required_ruby_version = '>= 2.6.3'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'rack-jekyll', '0.5'
|
33
|
+
spec.add_development_dependency 'capybara', '3.29.0'
|
34
|
+
spec.add_development_dependency 'jekyll', '3.8.6'
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'kontent-delivery-sdk-ruby', '~> 2.0'
|
37
|
+
end
|
38
|
+
|
39
|
+
# Local gem dependency when developing locally
|
40
|
+
#embedded_gemspec = Gem::Specification::load('C:\kontent-delivery-sdk-ruby\kontent-delivery-sdk-ruby.gemspec')
|
41
|
+
#
|
42
|
+
#Gem::Specification.new do |spec|
|
43
|
+
# spec.name = Kentico::Kontent::GEM_NAME
|
44
|
+
# spec.version = Kentico::Kontent::VERSION
|
45
|
+
# spec.licenses = ['MIT']
|
46
|
+
# spec.authors = ['RadoslavK']
|
47
|
+
# spec.email = ['RadoslavK@kentico.com']
|
48
|
+
#
|
49
|
+
# spec.summary = 'Kentico Kontent plugin for Jekyll'
|
50
|
+
# spec.description = 'Jekyll Kentico is utilizing Kentico Kontent, headless CMS, as a content repository and integrates it with Jekyll static site generator. You can generate posts, pages, collections and data items.'
|
51
|
+
# spec.homepage = 'https://github.com/RadoslavK/kentico-jekyll'
|
52
|
+
#
|
53
|
+
# # Specify which files should be added to the gem when it is released.
|
54
|
+
# # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
55
|
+
# spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
56
|
+
# `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
57
|
+
# end
|
58
|
+
# spec.files += embedded_gemspec.files
|
59
|
+
# spec.bindir = 'exe'
|
60
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
61
|
+
# spec.require_paths = ['lib']
|
62
|
+
#
|
63
|
+
# spec.required_ruby_version = '>= 2.6.3'
|
64
|
+
#
|
65
|
+
# spec.add_development_dependency 'bundler', '~> 2.0'
|
66
|
+
# spec.add_development_dependency 'rake', '~> 10.0'
|
67
|
+
# spec.add_development_dependency 'rspec', '~> 3.0'
|
68
|
+
# spec.add_development_dependency 'rack-jekyll', '0.5'
|
69
|
+
# spec.add_development_dependency 'capybara', '3.29.0'
|
70
|
+
# spec.add_development_dependency 'jekyll', '3.8.6'
|
71
|
+
#
|
72
|
+
# embedded_gemspec.runtime_dependencies.each { |d| spec.add_dependency d }
|
73
73
|
#end
|
data/lib/kontent-jekyll.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require 'kontent-jekyll/version'
|
2
|
-
require 'kontent-jekyll/generator'
|
3
|
-
|
4
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/front_matter_resolver'
|
5
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/content_resolver'
|
6
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/data_resolver'
|
7
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/filename_resolver'
|
8
|
-
|
9
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/content_link_resolver'
|
10
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/inline_content_item_resolver'
|
11
|
-
|
12
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/constants/item_element_type'
|
13
|
-
require File.dirname(__FILE__) + '/kontent-jekyll/constants/page_type'
|
14
|
-
|
1
|
+
require 'kontent-jekyll/version'
|
2
|
+
require 'kontent-jekyll/generator'
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/front_matter_resolver'
|
5
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/content_resolver'
|
6
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/data_resolver'
|
7
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/filename_resolver'
|
8
|
+
|
9
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/content_link_resolver'
|
10
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/resolvers/inline_content_item_resolver'
|
11
|
+
|
12
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/constants/item_element_type'
|
13
|
+
require File.dirname(__FILE__) + '/kontent-jekyll/constants/page_type'
|
14
|
+
|
15
15
|
require File.dirname(__FILE__) + '/kontent-jekyll/utils/normalize_object'
|
@@ -1,17 +1,17 @@
|
|
1
|
-
module Kentico
|
2
|
-
module Kontent
|
3
|
-
module Constants
|
4
|
-
module ItemElementType
|
5
|
-
ASSET = 'asset'
|
6
|
-
DATE_TIME = 'date_time'
|
7
|
-
LINKED_ITEMS = 'modular_content'
|
8
|
-
MULTIPLE_CHOICE = 'multiple_choice'
|
9
|
-
NUMBER = 'number'
|
10
|
-
RICH_TEXT = 'rich_text'
|
11
|
-
TAXONOMY = 'taxonomy'
|
12
|
-
TEXT = 'text'
|
13
|
-
URL_SLUG = 'url_slug'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
module Kentico
|
2
|
+
module Kontent
|
3
|
+
module Constants
|
4
|
+
module ItemElementType
|
5
|
+
ASSET = 'asset'
|
6
|
+
DATE_TIME = 'date_time'
|
7
|
+
LINKED_ITEMS = 'modular_content'
|
8
|
+
MULTIPLE_CHOICE = 'multiple_choice'
|
9
|
+
NUMBER = 'number'
|
10
|
+
RICH_TEXT = 'rich_text'
|
11
|
+
TAXONOMY = 'taxonomy'
|
12
|
+
TEXT = 'text'
|
13
|
+
URL_SLUG = 'url_slug'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module Kentico
|
2
|
-
module Kontent
|
3
|
-
module Constants
|
4
|
-
module KenticoConfigKeys
|
5
|
-
PROJECT_ID = 'project_id'
|
6
|
-
SECURE_KEY = 'secure_key'
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module Kentico
|
2
|
+
module Kontent
|
3
|
+
module Constants
|
4
|
+
module KenticoConfigKeys
|
5
|
+
PROJECT_ID = 'project_id'
|
6
|
+
SECURE_KEY = 'secure_key'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module Kentico
|
2
|
-
module Kontent
|
3
|
-
module Constants
|
4
|
-
##
|
5
|
-
# Options provided to a front matter resolver's resolve method.
|
6
|
-
# They determine type of the page that will have the front matter injected.
|
7
|
-
|
8
|
-
module PageType
|
9
|
-
PAGE = 'page'
|
10
|
-
POST = 'post'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
module Kentico
|
2
|
+
module Kontent
|
3
|
+
module Constants
|
4
|
+
##
|
5
|
+
# Options provided to a front matter resolver's resolve method.
|
6
|
+
# They determine type of the page that will have the front matter injected.
|
7
|
+
|
8
|
+
module PageType
|
9
|
+
PAGE = 'page'
|
10
|
+
POST = 'post'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module Kentico
|
2
|
-
module Kontent
|
3
|
-
GEM_NAME = 'kontent-jekyll'
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Kentico
|
2
|
+
module Kontent
|
3
|
+
GEM_NAME = 'kontent-jekyll'
|
4
|
+
end
|
5
|
+
end
|
@@ -1,106 +1,106 @@
|
|
1
|
-
require 'kontent-jekyll/site_processing/custom_site_processor'
|
2
|
-
require 'kontent-jekyll/site_processing/kentico_kontent_importer'
|
3
|
-
require 'kontent-jekyll/site_processing/site_processor'
|
4
|
-
|
5
|
-
module Kentico
|
6
|
-
module Kontent
|
7
|
-
##
|
8
|
-
# This class generates content stored in Kentico Cloud CMS and populute
|
9
|
-
# particular Jekyll structures so the website is correctly outputted
|
10
|
-
# during the build process.
|
11
|
-
|
12
|
-
class ContentGenerator < Jekyll::Generator
|
13
|
-
include SiteProcessing
|
14
|
-
DEFAULT_LANGUAGE = nil
|
15
|
-
|
16
|
-
safe true
|
17
|
-
priority :highest
|
18
|
-
|
19
|
-
def generate(site)
|
20
|
-
Jekyll::logger.info 'Importing from Kentico Kontent...'
|
21
|
-
|
22
|
-
config = parse_config(site)
|
23
|
-
|
24
|
-
load_custom_processors!(config)
|
25
|
-
process_site(site, config)
|
26
|
-
|
27
|
-
Jekyll::logger.info 'Import finished'
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
##
|
33
|
-
# Parses Jekyll configuration into OpenStruct structure.
|
34
|
-
|
35
|
-
def parse_config(site)
|
36
|
-
JSON.parse(
|
37
|
-
JSON.generate(site.config),
|
38
|
-
object_class: OpenStruct
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
##
|
43
|
-
# Load custom resolvers from the _plugins/kentico directory.
|
44
|
-
|
45
|
-
def load_custom_processors!(config)
|
46
|
-
mapper_search_path = File.join(config.source, config.plugins_dir, 'kentico')
|
47
|
-
mapper_files = Jekyll::Utils.safe_glob(mapper_search_path, File.join('**', '*.rb'))
|
48
|
-
|
49
|
-
Jekyll::External.require_with_graceful_fail(mapper_files)
|
50
|
-
end
|
51
|
-
|
52
|
-
##
|
53
|
-
# Processed the site.
|
54
|
-
# It imports KC content for every language from the config file.
|
55
|
-
# Then it pass the content to the site processor to populate Jekyll structures.
|
56
|
-
|
57
|
-
def process_site(site, config)
|
58
|
-
kentico_config = config.kentico
|
59
|
-
importer = create_importer(kentico_config)
|
60
|
-
|
61
|
-
processor = SiteProcessor.new(site, kentico_config)
|
62
|
-
|
63
|
-
all_items_by_type = {}
|
64
|
-
|
65
|
-
languages = kentico_config.languages || [DEFAULT_LANGUAGE]
|
66
|
-
languages.each do |language|
|
67
|
-
items_by_type = importer.items_by_type(language)
|
68
|
-
|
69
|
-
all_items_by_type.merge!(items_by_type) do |key, currentItems, newItems|
|
70
|
-
currentItems || newItems
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
taxonomies = importer.taxonomies
|
75
|
-
|
76
|
-
processor.process_pages(all_items_by_type)
|
77
|
-
processor.process_posts(all_items_by_type)
|
78
|
-
processor.process_data(all_items_by_type)
|
79
|
-
processor.process_taxonomies(taxonomies)
|
80
|
-
|
81
|
-
unique_items = all_items_by_type
|
82
|
-
.values
|
83
|
-
.flatten(1)
|
84
|
-
.uniq{ |i| "#{i.system.language};#{i.system.id}" }
|
85
|
-
|
86
|
-
kentico_data = OpenStruct.new(
|
87
|
-
items: unique_items,
|
88
|
-
taxonomy_groups: taxonomies,
|
89
|
-
)
|
90
|
-
|
91
|
-
custom_site_processor = CustomSiteProcessor.for(kentico_config)
|
92
|
-
custom_site_processor&.generate(site, kentico_data)
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
##
|
97
|
-
# Creates a desired content importer. RACK_TEST_IMPORTER class name and implementation
|
98
|
-
# is specified in RSpec tests.
|
99
|
-
|
100
|
-
def create_importer(kentico_config)
|
101
|
-
importer_name = ENV['RACK_TEST_IMPORTER'] || KenticoKontentImporter.to_s
|
102
|
-
Module.const_get(importer_name).new(kentico_config)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
1
|
+
require 'kontent-jekyll/site_processing/custom_site_processor'
|
2
|
+
require 'kontent-jekyll/site_processing/kentico_kontent_importer'
|
3
|
+
require 'kontent-jekyll/site_processing/site_processor'
|
4
|
+
|
5
|
+
module Kentico
|
6
|
+
module Kontent
|
7
|
+
##
|
8
|
+
# This class generates content stored in Kentico Cloud CMS and populute
|
9
|
+
# particular Jekyll structures so the website is correctly outputted
|
10
|
+
# during the build process.
|
11
|
+
|
12
|
+
class ContentGenerator < Jekyll::Generator
|
13
|
+
include SiteProcessing
|
14
|
+
DEFAULT_LANGUAGE = nil
|
15
|
+
|
16
|
+
safe true
|
17
|
+
priority :highest
|
18
|
+
|
19
|
+
def generate(site)
|
20
|
+
Jekyll::logger.info 'Importing from Kentico Kontent...'
|
21
|
+
|
22
|
+
config = parse_config(site)
|
23
|
+
|
24
|
+
load_custom_processors!(config)
|
25
|
+
process_site(site, config)
|
26
|
+
|
27
|
+
Jekyll::logger.info 'Import finished'
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
##
|
33
|
+
# Parses Jekyll configuration into OpenStruct structure.
|
34
|
+
|
35
|
+
def parse_config(site)
|
36
|
+
JSON.parse(
|
37
|
+
JSON.generate(site.config),
|
38
|
+
object_class: OpenStruct
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Load custom resolvers from the _plugins/kentico directory.
|
44
|
+
|
45
|
+
def load_custom_processors!(config)
|
46
|
+
mapper_search_path = File.join(config.source, config.plugins_dir, 'kentico')
|
47
|
+
mapper_files = Jekyll::Utils.safe_glob(mapper_search_path, File.join('**', '*.rb'))
|
48
|
+
|
49
|
+
Jekyll::External.require_with_graceful_fail(mapper_files)
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Processed the site.
|
54
|
+
# It imports KC content for every language from the config file.
|
55
|
+
# Then it pass the content to the site processor to populate Jekyll structures.
|
56
|
+
|
57
|
+
def process_site(site, config)
|
58
|
+
kentico_config = config.kentico
|
59
|
+
importer = create_importer(kentico_config)
|
60
|
+
|
61
|
+
processor = SiteProcessor.new(site, kentico_config)
|
62
|
+
|
63
|
+
all_items_by_type = {}
|
64
|
+
|
65
|
+
languages = kentico_config.languages || [DEFAULT_LANGUAGE]
|
66
|
+
languages.each do |language|
|
67
|
+
items_by_type = importer.items_by_type(language)
|
68
|
+
|
69
|
+
all_items_by_type.merge!(items_by_type) do |key, currentItems, newItems|
|
70
|
+
currentItems || newItems
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
taxonomies = importer.taxonomies
|
75
|
+
|
76
|
+
processor.process_pages(all_items_by_type)
|
77
|
+
processor.process_posts(all_items_by_type)
|
78
|
+
processor.process_data(all_items_by_type)
|
79
|
+
processor.process_taxonomies(taxonomies)
|
80
|
+
|
81
|
+
unique_items = all_items_by_type
|
82
|
+
.values
|
83
|
+
.flatten(1)
|
84
|
+
.uniq{ |i| "#{i.system.language};#{i.system.id}" }
|
85
|
+
|
86
|
+
kentico_data = OpenStruct.new(
|
87
|
+
items: unique_items,
|
88
|
+
taxonomy_groups: taxonomies,
|
89
|
+
)
|
90
|
+
|
91
|
+
custom_site_processor = CustomSiteProcessor.for(kentico_config)
|
92
|
+
custom_site_processor&.generate(site, kentico_data)
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
##
|
97
|
+
# Creates a desired content importer. RACK_TEST_IMPORTER class name and implementation
|
98
|
+
# is specified in RSpec tests.
|
99
|
+
|
100
|
+
def create_importer(kentico_config)
|
101
|
+
importer_name = ENV['RACK_TEST_IMPORTER'] || KenticoKontentImporter.to_s
|
102
|
+
Module.const_get(importer_name).new(kentico_config)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
106
|
end
|