jekyll-potion 1.0.1
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.
- checksums.yaml +7 -0
- data/LICENSE +202 -0
- data/jekyll-potion.gemspec +17 -0
- data/lib/jekyll-potion/logger.rb +49 -0
- data/lib/jekyll-potion/models/favicon.rb +28 -0
- data/lib/jekyll-potion/models/page-potion.rb +86 -0
- data/lib/jekyll-potion/models/potion-page.rb +26 -0
- data/lib/jekyll-potion/models/potion-source-map-page.rb +15 -0
- data/lib/jekyll-potion/models/potion-static-file.rb +21 -0
- data/lib/jekyll-potion/potion.rb +136 -0
- data/lib/jekyll-potion/processor/base/jquery-3.6.0.min.js +2 -0
- data/lib/jekyll-potion/processor/base-template/code.js +40 -0
- data/lib/jekyll-potion/processor/base-template/navigation.js +43 -0
- data/lib/jekyll-potion/processor/base-template/tabs.js +38 -0
- data/lib/jekyll-potion/processor/header-template/header.js +31 -0
- data/lib/jekyll-potion/processor/make-base-javascript-processor.rb +59 -0
- data/lib/jekyll-potion/processor/make-date-processor.rb +30 -0
- data/lib/jekyll-potion/processor/make-empty-content-processor.rb +19 -0
- data/lib/jekyll-potion/processor/make-favicon-processor.rb +108 -0
- data/lib/jekyll-potion/processor/make-front-matter-processor.rb +21 -0
- data/lib/jekyll-potion/processor/make-header-link-processor.rb +103 -0
- data/lib/jekyll-potion/processor/make-navigation-processor.rb +55 -0
- data/lib/jekyll-potion/processor/make-og-tag-processor.rb +45 -0
- data/lib/jekyll-potion/processor/make-search-index-processor.rb +205 -0
- data/lib/jekyll-potion/processor/make-theme-processor.rb +197 -0
- data/lib/jekyll-potion/processor/make-title-processor.rb +53 -0
- data/lib/jekyll-potion/processor/rewrite-a-href-processor.rb +43 -0
- data/lib/jekyll-potion/processor/rewrite-img-processor.rb +42 -0
- data/lib/jekyll-potion/processor/search-template/search.js +123 -0
- data/lib/jekyll-potion/processor.rb +152 -0
- data/lib/jekyll-potion/site.rb +155 -0
- data/lib/jekyll-potion/tag.rb +176 -0
- data/lib/jekyll-potion/tags/alerts.rb +24 -0
- data/lib/jekyll-potion/tags/api.rb +105 -0
- data/lib/jekyll-potion/tags/code.rb +65 -0
- data/lib/jekyll-potion/tags/empty.rb +20 -0
- data/lib/jekyll-potion/tags/file.rb +22 -0
- data/lib/jekyll-potion/tags/link.rb +47 -0
- data/lib/jekyll-potion/tags/logo.rb +22 -0
- data/lib/jekyll-potion/tags/navigation.rb +35 -0
- data/lib/jekyll-potion/tags/pagination.rb +20 -0
- data/lib/jekyll-potion/tags/tabs.rb +62 -0
- data/lib/jekyll-potion/theme/proto/_includes/container.html +10 -0
- data/lib/jekyll-potion/theme/proto/_includes/head.html +4 -0
- data/lib/jekyll-potion/theme/proto/_includes/header.html +21 -0
- data/lib/jekyll-potion/theme/proto/_includes/image.html +5 -0
- data/lib/jekyll-potion/theme/proto/_includes/nav.html +3 -0
- data/lib/jekyll-potion/theme/proto/_includes/search.html +29 -0
- data/lib/jekyll-potion/theme/proto/_layouts/default.html +19 -0
- data/lib/jekyll-potion/theme/proto/_layouts/error.html +23 -0
- data/lib/jekyll-potion/theme/proto/_templates/alerts.liquid +4 -0
- data/lib/jekyll-potion/theme/proto/_templates/api.liquid +46 -0
- data/lib/jekyll-potion/theme/proto/_templates/api=description.liquid +3 -0
- data/lib/jekyll-potion/theme/proto/_templates/api=parameter.liquid +5 -0
- data/lib/jekyll-potion/theme/proto/_templates/api=response.liquid +7 -0
- data/lib/jekyll-potion/theme/proto/_templates/code.liquid +8 -0
- data/lib/jekyll-potion/theme/proto/_templates/empty.liquid +15 -0
- data/lib/jekyll-potion/theme/proto/_templates/file.liquid +8 -0
- data/lib/jekyll-potion/theme/proto/_templates/link.liquid +9 -0
- data/lib/jekyll-potion/theme/proto/_templates/logo.liquid +8 -0
- data/lib/jekyll-potion/theme/proto/_templates/navigation-page.liquid +14 -0
- data/lib/jekyll-potion/theme/proto/_templates/navigation.liquid +5 -0
- data/lib/jekyll-potion/theme/proto/_templates/pagination.liquid +30 -0
- data/lib/jekyll-potion/theme/proto/_templates/tabs.liquid +8 -0
- data/lib/jekyll-potion/theme/proto/_templates/tabs=content.liquid +5 -0
- data/lib/jekyll-potion/theme/proto/assets/css/main.scss +1254 -0
- data/lib/jekyll-potion/theme/proto/assets/css/syntax.css +80 -0
- data/lib/jekyll-potion/theme/proto/assets/js/jsrender.min.js +4 -0
- data/lib/jekyll-potion/theme/proto/assets/js/jsrender.min.js.map +1 -0
- data/lib/jekyll-potion/theme/proto/assets/js/main.js +237 -0
- data/lib/jekyll-potion/theme.rb +165 -0
- data/lib/jekyll-potion/util.rb +73 -0
- data/lib/jekyll-potion.rb +32 -0
- metadata +143 -0
@@ -0,0 +1,237 @@
|
|
1
|
+
$(function () {
|
2
|
+
class Page {
|
3
|
+
static HASH_REGEX = new RegExp('([^#]*)#([^#]*)')
|
4
|
+
|
5
|
+
constructor() {
|
6
|
+
this.main = $('main')
|
7
|
+
this.nav = $('nav')
|
8
|
+
|
9
|
+
this.is_hide_mobile_menu = true
|
10
|
+
|
11
|
+
this.modal_image_area = $('#modal_image_area > div.modal-wrapper')
|
12
|
+
this.modal_image = $('#modal_image')
|
13
|
+
|
14
|
+
this.modal_search_area = $('#modal_search_area > div.modal-wrapper')
|
15
|
+
this.search_input = $('#search_keyword')
|
16
|
+
this.search_contents = $('#search_contents')
|
17
|
+
|
18
|
+
this.keyupEventHandlers = []
|
19
|
+
|
20
|
+
this.navigation = $.navigation()
|
21
|
+
this.header = $.header()
|
22
|
+
this.search = $.search()
|
23
|
+
this.tabs = $.tabs()
|
24
|
+
this.code = $.code()
|
25
|
+
}
|
26
|
+
|
27
|
+
init() {
|
28
|
+
let context = this
|
29
|
+
$(document).keydown(e => {
|
30
|
+
this.keyupEventHandlers.forEach(handler => {
|
31
|
+
if (e.keyCode === handler.keyCode || e.which === handler.keyCode) {
|
32
|
+
if (handler.condition && handler.condition.call(context)) {
|
33
|
+
handler.accept.call(context, e)
|
34
|
+
} else {
|
35
|
+
handler.accept.call(context, e)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
})
|
39
|
+
})
|
40
|
+
|
41
|
+
Page.on(this, this.modal_image, 'load', () => this.modal_image_area.parent().removeClass('hide'))
|
42
|
+
Page.on(
|
43
|
+
this,
|
44
|
+
this.modal_image_area,
|
45
|
+
'click',
|
46
|
+
e => {
|
47
|
+
e.preventDefault()
|
48
|
+
if (e.currentTarget === this.modal_image_area[0]) {
|
49
|
+
this.modal_image_area.parent().addClass('hide')
|
50
|
+
}
|
51
|
+
}
|
52
|
+
)
|
53
|
+
|
54
|
+
Page.on(this, $('.show_search'), 'click', () => {
|
55
|
+
this.search_contents.children().remove()
|
56
|
+
this.modal_search_area.parent().removeClass('hide')
|
57
|
+
})
|
58
|
+
|
59
|
+
Page.on(this, this.modal_search_area.children(), 'click', e => e.stopPropagation())
|
60
|
+
Page.on(
|
61
|
+
this,
|
62
|
+
this.modal_search_area,
|
63
|
+
'click',
|
64
|
+
e => {
|
65
|
+
e.preventDefault()
|
66
|
+
if (e.currentTarget === this.modal_search_area[0]) {
|
67
|
+
this.search_contents.children().remove()
|
68
|
+
this.modal_search_area.parent().addClass('hide')
|
69
|
+
}
|
70
|
+
}
|
71
|
+
)
|
72
|
+
|
73
|
+
Page.on(this, this.search_input, 'keyup', e => {
|
74
|
+
if (e.keyCode === 13 || e.which === 13) {
|
75
|
+
this.search_keyword()
|
76
|
+
}
|
77
|
+
})
|
78
|
+
|
79
|
+
this.keyupEventHandlers.push({
|
80
|
+
'keyCode': 27,
|
81
|
+
'condition': () => !this.modal_search_area.parent().hasClass('hide'),
|
82
|
+
'accept': () => this.modal_search_area.parent().addClass('hide')
|
83
|
+
})
|
84
|
+
|
85
|
+
Page.on(this, $('[data-nav-link]'), 'click', this.updateMainContent)
|
86
|
+
|
87
|
+
Page.on(this, $(window), 'popstate', () => {
|
88
|
+
this.loadPage($(location).attr('pathname') + $(location).attr('hash'))
|
89
|
+
})
|
90
|
+
|
91
|
+
Page.on(this, $('.show_menu'), 'click', () => {
|
92
|
+
if (this.is_hide_mobile_menu) {
|
93
|
+
this.is_hide_mobile_menu = false
|
94
|
+
this.nav.addClass('show')
|
95
|
+
this.main.addClass('hide')
|
96
|
+
} else {
|
97
|
+
this.is_hide_mobile_menu = true
|
98
|
+
this.nav.removeClass('show')
|
99
|
+
this.main.removeClass('hide')
|
100
|
+
}
|
101
|
+
})
|
102
|
+
|
103
|
+
this.navigation.init($(location).attr('pathname'))
|
104
|
+
this.header.init()
|
105
|
+
this.tabs.init()
|
106
|
+
this.code.init()
|
107
|
+
|
108
|
+
this.updateMainImages()
|
109
|
+
this.updateMainLinks()
|
110
|
+
|
111
|
+
if ($(location).attr('hash')) {
|
112
|
+
Page.goHash($(location).attr('hash'))
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
updateMainImages() {
|
117
|
+
let expandableImages = $('img.img-internal:not(.img-inline):not([data-handled])')
|
118
|
+
|
119
|
+
Page.on(this, expandableImages, 'click', e => {
|
120
|
+
this.modal_image.attr('src', $(e.currentTarget).attr('src'))
|
121
|
+
})
|
122
|
+
|
123
|
+
expandableImages.attr('data-handled', true)
|
124
|
+
}
|
125
|
+
|
126
|
+
updateMainLinks() {
|
127
|
+
// #, /로 시작하는 내부링크의 경우 페이지내 전환을 위해 click 이벤트를 조작한다.
|
128
|
+
let absolute_links = $('a.a-internal[href]:not([data-nav-link]):not([data-handled])')
|
129
|
+
let only_hash_links = $('a.hash-internal[href]:not([data-nav-link]):not([data-handled])')
|
130
|
+
|
131
|
+
Page.on(this, absolute_links, 'click', this.updateMainContent)
|
132
|
+
Page.on(this, only_hash_links, 'click', this.updateHash)
|
133
|
+
|
134
|
+
absolute_links.attr('data-handled', true)
|
135
|
+
only_hash_links.attr('data-handled', true)
|
136
|
+
}
|
137
|
+
|
138
|
+
loadPage(pathname, callback) {
|
139
|
+
this.main.load(pathname + ' #container', (html, status) => {
|
140
|
+
if (status !== 'success') {
|
141
|
+
return
|
142
|
+
}
|
143
|
+
this.main.scrollTop(0)
|
144
|
+
let title = html.match('<title>(.*?)</title>')[1]
|
145
|
+
document.title = title
|
146
|
+
|
147
|
+
if (Page.hasHash(pathname)) {
|
148
|
+
Page.goHash(Page.getHash(pathname))
|
149
|
+
}
|
150
|
+
|
151
|
+
this.header.init()
|
152
|
+
this.tabs.init()
|
153
|
+
this.code.init()
|
154
|
+
|
155
|
+
this.updateMainImages()
|
156
|
+
this.updateMainLinks()
|
157
|
+
|
158
|
+
if (callback) {
|
159
|
+
callback.call(this, title)
|
160
|
+
}
|
161
|
+
})
|
162
|
+
}
|
163
|
+
|
164
|
+
updateMainContent(e) {
|
165
|
+
e.preventDefault()
|
166
|
+
|
167
|
+
let pathname = $(e.currentTarget).attr('href')
|
168
|
+
|
169
|
+
if (Page.matchPath($(location).attr('pathname'), pathname)) {
|
170
|
+
return
|
171
|
+
}
|
172
|
+
|
173
|
+
this.loadPage(pathname, title => {
|
174
|
+
if (typeof (history.pushState) !== 'undefined') {
|
175
|
+
history.pushState(null, title, pathname)
|
176
|
+
}
|
177
|
+
|
178
|
+
this.navigation.init($(location).attr('pathname'))
|
179
|
+
|
180
|
+
if (!this.is_hide_mobile_menu) {
|
181
|
+
this.is_hide_mobile_menu = true
|
182
|
+
this.nav.removeClass('show')
|
183
|
+
this.main.removeClass('hide')
|
184
|
+
}
|
185
|
+
})
|
186
|
+
}
|
187
|
+
|
188
|
+
updateHash(e) {
|
189
|
+
e.preventDefault()
|
190
|
+
|
191
|
+
let hash = $(e.currentTarget).attr('href')
|
192
|
+
|
193
|
+
Page.goHash(hash)
|
194
|
+
|
195
|
+
if (typeof (history.pushState) !== 'undefined') {
|
196
|
+
history.pushState(null, document.title, $(location).attr('pathname') + hash)
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
search_keyword() {
|
201
|
+
if (this.search_input.val().trim().length >= 2) {
|
202
|
+
this.search_contents.children().remove()
|
203
|
+
|
204
|
+
this.search.search(this.search_input.val(), this, results => {
|
205
|
+
this.search_contents.html($.templates('#search_contents_tmpl').render(results))
|
206
|
+
})
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
static matchPath(path, requestPath) {
|
211
|
+
return new RegExp(path + '(/|/?#([^/]*))?$').test(requestPath)
|
212
|
+
}
|
213
|
+
|
214
|
+
static hasHash(path) {
|
215
|
+
return Page.HASH_REGEX.test(path)
|
216
|
+
}
|
217
|
+
|
218
|
+
static getHash(path) {
|
219
|
+
return path.replace(Page.HASH_REGEX, '#$2')
|
220
|
+
}
|
221
|
+
|
222
|
+
static goHash(hash) {
|
223
|
+
let $hash = $(decodeURI(hash))
|
224
|
+
if ($hash.length) {
|
225
|
+
$hash[0].scrollIntoView()
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
static on(context, selector, eventType, func) {
|
230
|
+
selector.off(eventType)
|
231
|
+
selector.on(eventType, e => func.call(context, e))
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
let page = new Page()
|
236
|
+
page.init()
|
237
|
+
})
|
@@ -0,0 +1,165 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright 2022 SK TELECOM CO., LTD.
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
3
|
+
|
4
|
+
module Jekyll::Potion
|
5
|
+
class Theme < Jekyll::Theme
|
6
|
+
@@themes = {}
|
7
|
+
|
8
|
+
attr_reader :processors_config
|
9
|
+
attr_reader :tags_config
|
10
|
+
|
11
|
+
DEFAULT_THEME_CONFIG = {
|
12
|
+
:internal => false,
|
13
|
+
:path => "",
|
14
|
+
:layouts_dir => "_layouts",
|
15
|
+
:includes_dir => "_includes",
|
16
|
+
:default_layout => "default",
|
17
|
+
:assets => {
|
18
|
+
:target_root_path => "_assets",
|
19
|
+
:source_dir => "assets",
|
20
|
+
:priority_files => [],
|
21
|
+
:scss_source_dir => "_scss",
|
22
|
+
:scss_files => []
|
23
|
+
},
|
24
|
+
:templates_dir => "_templates",
|
25
|
+
:content_x_path => "main"
|
26
|
+
}.freeze
|
27
|
+
|
28
|
+
DEFAULT_THEME_RELATIVE_PATH = "/theme".freeze
|
29
|
+
EXTERNAL_THEME_RELATIVE_PATH = "./".freeze
|
30
|
+
|
31
|
+
DEFAULT_THEME = "proto".freeze
|
32
|
+
|
33
|
+
DEFAULT_THEMES = [
|
34
|
+
{
|
35
|
+
"proto" => {
|
36
|
+
"internal" => true,
|
37
|
+
"path" => "proto",
|
38
|
+
"assets" => {
|
39
|
+
"priority_files" => ["js/jsrender.min.js"],
|
40
|
+
"scss_files" => ["main.scss"]
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
].freeze
|
45
|
+
|
46
|
+
LIQUID_EXTENSION = ".liquid".freeze
|
47
|
+
|
48
|
+
def initialize(name, site, config)
|
49
|
+
@name = name
|
50
|
+
@site = site
|
51
|
+
@config = Util.extract(DEFAULT_THEME_CONFIG, config)
|
52
|
+
|
53
|
+
raise SyntaxError, "themes.path must not null" if @config[:path].nil? or @config[:path].empty?
|
54
|
+
|
55
|
+
if @config[:internal]
|
56
|
+
@config[:path] = File.join(@site[:potion_base_dir], DEFAULT_THEME_RELATIVE_PATH, @name)
|
57
|
+
end
|
58
|
+
|
59
|
+
@config[:layouts_dir] = File.join(@config[:path], @config[:layouts_dir])
|
60
|
+
@config[:includes_dir] = File.join(@config[:path], @config[:includes_dir])
|
61
|
+
@config[:assets][:source_dir] = File.join(@config[:path], @config[:assets][:source_dir])
|
62
|
+
@config[:assets][:scss_source_dir] = File.join(@config[:path], @config[:assets][:scss_source_dir])
|
63
|
+
@config[:templates_dir] = File.join(@config[:path], @config[:templates_dir])
|
64
|
+
|
65
|
+
@processors_config = ProcessorsConfig.new(config["processors"])
|
66
|
+
@tags_config = TagsConfig.new(config["tags"])
|
67
|
+
end
|
68
|
+
|
69
|
+
def root
|
70
|
+
if @config[:internal]
|
71
|
+
@config[:path]
|
72
|
+
else
|
73
|
+
EXTERNAL_THEME_RELATIVE_PATH
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def includes_path
|
78
|
+
@config[:includes_dir]
|
79
|
+
end
|
80
|
+
|
81
|
+
def layouts_path
|
82
|
+
@config[:layouts_dir]
|
83
|
+
end
|
84
|
+
|
85
|
+
def sass_path
|
86
|
+
@config[:layouts_dir]
|
87
|
+
end
|
88
|
+
|
89
|
+
def assets_path
|
90
|
+
end
|
91
|
+
|
92
|
+
def data_path
|
93
|
+
end
|
94
|
+
|
95
|
+
def [] (key)
|
96
|
+
@config[key]
|
97
|
+
end
|
98
|
+
|
99
|
+
def assets_static_file(base, dir, name, target = "")
|
100
|
+
if target.empty?
|
101
|
+
target = @config[:assets][:target_root_path]
|
102
|
+
else
|
103
|
+
target = File.join(@config[:assets][:target_root_path], target)
|
104
|
+
end
|
105
|
+
|
106
|
+
@site.static_file(base, dir, name, target)
|
107
|
+
end
|
108
|
+
|
109
|
+
def assets_potion_page(base, dir, name)
|
110
|
+
@site.potion_page(base, dir, name, @config[:assets][:target_root_path])
|
111
|
+
end
|
112
|
+
|
113
|
+
def assets_scss_potion_page(base, dir, file_name)
|
114
|
+
scss_file = assets_potion_page(base, dir, @site.replace_scss_ext(file_name))
|
115
|
+
scss_file.output = @site.scss_convert(@site.read_file(File.join(base, dir, file_name)))
|
116
|
+
scss_file
|
117
|
+
end
|
118
|
+
|
119
|
+
def assets_map_page(scss_file)
|
120
|
+
PotionSourceMapPage.new(scss_file, @config[:assets][:target_root_path])
|
121
|
+
end
|
122
|
+
|
123
|
+
def base_assets_url(*args)
|
124
|
+
File.join(File.join(@site.baseurl, @config[:assets][:target_root_path], *args))
|
125
|
+
end
|
126
|
+
|
127
|
+
def load_template(template_name, theme_path = "")
|
128
|
+
begin
|
129
|
+
theme_path = @config[:templates_dir] if theme_path.empty?
|
130
|
+
@site.load_template(File.join(theme_path, [template_name, LIQUID_EXTENSION].join))
|
131
|
+
rescue
|
132
|
+
load_template(template_name, @@themes[DEFAULT_THEME][:templates_dir]) unless theme_path == @@themes[DEFAULT_THEME][:templates_dir]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def render_template(template_name, context)
|
137
|
+
load_template(template_name).render(context)
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.initialize(site, config)
|
141
|
+
DEFAULT_THEMES.each { |default_theme|
|
142
|
+
@@themes[default_theme.keys[0]] = Theme.new(default_theme.keys[0], site, default_theme.values[0])
|
143
|
+
}
|
144
|
+
|
145
|
+
unless config.nil?
|
146
|
+
config.each { |theme|
|
147
|
+
raise SyntaxError, "theme config is not valid" unless theme.size == 1
|
148
|
+
@@themes[theme.keys[0]] = Theme.new(theme.keys[0], site, theme.values[0])
|
149
|
+
}
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.themes
|
154
|
+
@@themes
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.theme(theme_name)
|
158
|
+
if @@themes.has_key?(theme_name)
|
159
|
+
@@themes[theme_name]
|
160
|
+
else
|
161
|
+
@@themes[DEFAULT_THEME]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright 2022 SK TELECOM CO., LTD.
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
3
|
+
|
4
|
+
module Jekyll::Potion
|
5
|
+
class Util
|
6
|
+
# load_files(base, dir, &block)
|
7
|
+
#
|
8
|
+
# base, dir을 기준으로 조회되는 모든 파일의 base, dir, file_name 을 block method 으로 전달한다.
|
9
|
+
def self.load_files(base, dir = "", &block)
|
10
|
+
Dir.foreach(File.join(base, dir)) { |file_name|
|
11
|
+
next if file_name == "." or file_name == ".."
|
12
|
+
|
13
|
+
path = File.join(base, dir, file_name)
|
14
|
+
|
15
|
+
if File.directory?(path)
|
16
|
+
self.load_files(base, file_name, &block)
|
17
|
+
else
|
18
|
+
block.call(base, dir, file_name)
|
19
|
+
end
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.read_file(base, path)
|
24
|
+
File.read(File.join(base, path))
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.load_template(base, path)
|
28
|
+
Liquid::Template.parse(read_file(base, path))
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.jsonify(base, path)
|
32
|
+
JSON.parse(read_file(base, path))
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.extract(base, config, check_type = true, parent_key = "")
|
36
|
+
config = {} if config.nil?
|
37
|
+
|
38
|
+
raise SyntaxError, "config is not valid type #{base.class} <=> #{config.class}" unless base.is_a?(Hash) and config.is_a?(Hash)
|
39
|
+
|
40
|
+
extracted = {}
|
41
|
+
|
42
|
+
base.each { |key, value|
|
43
|
+
config_value = config[key] ||= config[key.to_s]
|
44
|
+
|
45
|
+
if config_value.nil?
|
46
|
+
extracted[key] = value
|
47
|
+
elsif (value.is_a?(TrueClass) or value.is_a?(FalseClass)) and (config_value.is_a?(TrueClass) or config_value.is_a?(FalseClass))
|
48
|
+
extracted[key] = config_value
|
49
|
+
else
|
50
|
+
raise SyntaxError, "#{parent_key}#{key} is not valid base[#{value.class}] <=> config[#{config_value.class}]" if check_type && value.class != config_value.class
|
51
|
+
|
52
|
+
if config_value.is_a?(Hash)
|
53
|
+
extracted[key] = self.extract(base[key], config_value, check_type, "#{parent_key}#{key}.")
|
54
|
+
else
|
55
|
+
extracted[key] = config_value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
}
|
59
|
+
|
60
|
+
extracted
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.string_key_hash(sym_key_hash)
|
64
|
+
sym_key_hash.map { |k, v|
|
65
|
+
if v.is_a?(Hash)
|
66
|
+
[k.to_s, string_key_hash(v)]
|
67
|
+
else
|
68
|
+
[k.to_s, v]
|
69
|
+
end
|
70
|
+
}.to_h
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright 2022 SK TELECOM CO., LTD.
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
3
|
+
|
4
|
+
require_relative "jekyll-potion/models/favicon"
|
5
|
+
require_relative "jekyll-potion/models/page-potion"
|
6
|
+
require_relative "jekyll-potion/models/potion-page"
|
7
|
+
require_relative "jekyll-potion/models/potion-static-file"
|
8
|
+
require_relative "jekyll-potion/models/potion-source-map-page"
|
9
|
+
|
10
|
+
require_relative "jekyll-potion/util"
|
11
|
+
require_relative "jekyll-potion/logger"
|
12
|
+
require_relative "jekyll-potion/processor"
|
13
|
+
require_relative "jekyll-potion/tag"
|
14
|
+
require_relative "jekyll-potion/site"
|
15
|
+
require_relative "jekyll-potion/theme"
|
16
|
+
require_relative "jekyll-potion/potion"
|
17
|
+
|
18
|
+
module Jekyll::Potion
|
19
|
+
potion_base_dir = File.join(File.dirname(__FILE__), "jekyll-potion")
|
20
|
+
Potion.load(potion_base_dir)
|
21
|
+
end
|
22
|
+
|
23
|
+
require_relative "jekyll-potion/tags/alerts"
|
24
|
+
require_relative "jekyll-potion/tags/api"
|
25
|
+
require_relative "jekyll-potion/tags/code"
|
26
|
+
require_relative "jekyll-potion/tags/empty"
|
27
|
+
require_relative "jekyll-potion/tags/file"
|
28
|
+
require_relative "jekyll-potion/tags/link"
|
29
|
+
require_relative "jekyll-potion/tags/logo"
|
30
|
+
require_relative "jekyll-potion/tags/navigation"
|
31
|
+
require_relative "jekyll-potion/tags/pagination"
|
32
|
+
require_relative "jekyll-potion/tags/tabs"
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-potion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SK TELECOM CO., LTD
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-22 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.2.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.13.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.13.6
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- changgun.kim@sk.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE
|
49
|
+
- jekyll-potion.gemspec
|
50
|
+
- lib/jekyll-potion.rb
|
51
|
+
- lib/jekyll-potion/logger.rb
|
52
|
+
- lib/jekyll-potion/models/favicon.rb
|
53
|
+
- lib/jekyll-potion/models/page-potion.rb
|
54
|
+
- lib/jekyll-potion/models/potion-page.rb
|
55
|
+
- lib/jekyll-potion/models/potion-source-map-page.rb
|
56
|
+
- lib/jekyll-potion/models/potion-static-file.rb
|
57
|
+
- lib/jekyll-potion/potion.rb
|
58
|
+
- lib/jekyll-potion/processor.rb
|
59
|
+
- lib/jekyll-potion/processor/base-template/code.js
|
60
|
+
- lib/jekyll-potion/processor/base-template/navigation.js
|
61
|
+
- lib/jekyll-potion/processor/base-template/tabs.js
|
62
|
+
- lib/jekyll-potion/processor/base/jquery-3.6.0.min.js
|
63
|
+
- lib/jekyll-potion/processor/header-template/header.js
|
64
|
+
- lib/jekyll-potion/processor/make-base-javascript-processor.rb
|
65
|
+
- lib/jekyll-potion/processor/make-date-processor.rb
|
66
|
+
- lib/jekyll-potion/processor/make-empty-content-processor.rb
|
67
|
+
- lib/jekyll-potion/processor/make-favicon-processor.rb
|
68
|
+
- lib/jekyll-potion/processor/make-front-matter-processor.rb
|
69
|
+
- lib/jekyll-potion/processor/make-header-link-processor.rb
|
70
|
+
- lib/jekyll-potion/processor/make-navigation-processor.rb
|
71
|
+
- lib/jekyll-potion/processor/make-og-tag-processor.rb
|
72
|
+
- lib/jekyll-potion/processor/make-search-index-processor.rb
|
73
|
+
- lib/jekyll-potion/processor/make-theme-processor.rb
|
74
|
+
- lib/jekyll-potion/processor/make-title-processor.rb
|
75
|
+
- lib/jekyll-potion/processor/rewrite-a-href-processor.rb
|
76
|
+
- lib/jekyll-potion/processor/rewrite-img-processor.rb
|
77
|
+
- lib/jekyll-potion/processor/search-template/search.js
|
78
|
+
- lib/jekyll-potion/site.rb
|
79
|
+
- lib/jekyll-potion/tag.rb
|
80
|
+
- lib/jekyll-potion/tags/alerts.rb
|
81
|
+
- lib/jekyll-potion/tags/api.rb
|
82
|
+
- lib/jekyll-potion/tags/code.rb
|
83
|
+
- lib/jekyll-potion/tags/empty.rb
|
84
|
+
- lib/jekyll-potion/tags/file.rb
|
85
|
+
- lib/jekyll-potion/tags/link.rb
|
86
|
+
- lib/jekyll-potion/tags/logo.rb
|
87
|
+
- lib/jekyll-potion/tags/navigation.rb
|
88
|
+
- lib/jekyll-potion/tags/pagination.rb
|
89
|
+
- lib/jekyll-potion/tags/tabs.rb
|
90
|
+
- lib/jekyll-potion/theme.rb
|
91
|
+
- lib/jekyll-potion/theme/proto/_includes/container.html
|
92
|
+
- lib/jekyll-potion/theme/proto/_includes/head.html
|
93
|
+
- lib/jekyll-potion/theme/proto/_includes/header.html
|
94
|
+
- lib/jekyll-potion/theme/proto/_includes/image.html
|
95
|
+
- lib/jekyll-potion/theme/proto/_includes/nav.html
|
96
|
+
- lib/jekyll-potion/theme/proto/_includes/search.html
|
97
|
+
- lib/jekyll-potion/theme/proto/_layouts/default.html
|
98
|
+
- lib/jekyll-potion/theme/proto/_layouts/error.html
|
99
|
+
- lib/jekyll-potion/theme/proto/_templates/alerts.liquid
|
100
|
+
- lib/jekyll-potion/theme/proto/_templates/api.liquid
|
101
|
+
- lib/jekyll-potion/theme/proto/_templates/api=description.liquid
|
102
|
+
- lib/jekyll-potion/theme/proto/_templates/api=parameter.liquid
|
103
|
+
- lib/jekyll-potion/theme/proto/_templates/api=response.liquid
|
104
|
+
- lib/jekyll-potion/theme/proto/_templates/code.liquid
|
105
|
+
- lib/jekyll-potion/theme/proto/_templates/empty.liquid
|
106
|
+
- lib/jekyll-potion/theme/proto/_templates/file.liquid
|
107
|
+
- lib/jekyll-potion/theme/proto/_templates/link.liquid
|
108
|
+
- lib/jekyll-potion/theme/proto/_templates/logo.liquid
|
109
|
+
- lib/jekyll-potion/theme/proto/_templates/navigation-page.liquid
|
110
|
+
- lib/jekyll-potion/theme/proto/_templates/navigation.liquid
|
111
|
+
- lib/jekyll-potion/theme/proto/_templates/pagination.liquid
|
112
|
+
- lib/jekyll-potion/theme/proto/_templates/tabs.liquid
|
113
|
+
- lib/jekyll-potion/theme/proto/_templates/tabs=content.liquid
|
114
|
+
- lib/jekyll-potion/theme/proto/assets/css/main.scss
|
115
|
+
- lib/jekyll-potion/theme/proto/assets/css/syntax.css
|
116
|
+
- lib/jekyll-potion/theme/proto/assets/js/jsrender.min.js
|
117
|
+
- lib/jekyll-potion/theme/proto/assets/js/jsrender.min.js.map
|
118
|
+
- lib/jekyll-potion/theme/proto/assets/js/main.js
|
119
|
+
- lib/jekyll-potion/util.rb
|
120
|
+
homepage: https://github.com/nugudevelopers/jekyll-potion
|
121
|
+
licenses:
|
122
|
+
- Apache-2.0
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 2.6.0
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubygems_version: 3.2.33
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: Jekyll's Potion
|
143
|
+
test_files: []
|