jektify 1.0.6 → 1.0.8
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 +4 -4
- data/.bundle/config +3 -0
- data/.github/workflows/ruby.yml +12 -23
- data/.gitignore +10 -28
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +198 -0
- data/LICENSE +1 -1
- data/README.md +9 -34
- data/_config.yml +315 -0
- data/assets/vendor/jektify/js/jektify.min.js +1 -1
- data/assets/vendor/jektify/sass/_jektify.scss +5 -19
- data/bin/setup +3 -0
- data/bin/tests +9 -79
- data/example/.bundle/config +3 -0
- data/example/.gitignore +5 -0
- data/example/Gemfile +11 -0
- data/example/Gemfile.lock +181 -0
- data/example/_config.yml +43 -0
- data/example/_includes/head.html +6 -0
- data/example/_layouts/default.html +22 -0
- data/example/_layouts/home.html +36 -0
- data/example/_layouts/post.html +27 -0
- data/example/_posts/2025-09-19-welcome-to-jektify.markdown +12 -0
- data/example/_sass/_reset.scss +24 -0
- data/example/_sass/main.scss +2 -0
- data/example/assets/jquery.min.js +2 -0
- data/example/assets/style.scss +4 -0
- data/example/index.markdown +3 -0
- data/gulpfile.js +11 -17
- data/jektify.gemspec +6 -6
- data/lib/jektify/engine.rb +24 -26
- data/lib/jektify/main.rb +62 -81
- data/lib/jektify/render.rb +50 -76
- data/lib/jektify/version.rb +1 -1
- data/package-lock.json +2057 -0
- data/src/js/jektify.js +30 -6
- metadata +37 -36
- data/.travis.yml +0 -12
data/lib/jektify/main.rb
CHANGED
|
@@ -1,128 +1,109 @@
|
|
|
1
|
-
# Required libs
|
|
2
1
|
require "jekyll"
|
|
3
2
|
require "yaml"
|
|
4
|
-
require "benchmark"
|
|
5
3
|
require "find"
|
|
6
4
|
require "fileutils"
|
|
7
|
-
require "
|
|
8
|
-
|
|
5
|
+
require "liquid"
|
|
9
6
|
|
|
10
7
|
module Jektify
|
|
11
|
-
|
|
12
|
-
# Instance class
|
|
13
|
-
ENGINE = Engine.new
|
|
14
|
-
RENDER = Render.new
|
|
15
|
-
|
|
16
|
-
# Variables global
|
|
17
8
|
APP_NAME = "jektify"
|
|
18
|
-
YML_LOAD = ENGINE.yml_config('_config.yml')
|
|
19
|
-
APP_ROOT_CONFIG = YML_LOAD["#{APP_NAME}"]
|
|
20
|
-
|
|
21
9
|
|
|
22
10
|
class Generator < Jekyll::Generator
|
|
11
|
+
safe true
|
|
12
|
+
priority :normal
|
|
23
13
|
|
|
24
14
|
def generate(site)
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
engine = Engine.new
|
|
16
|
+
render_obj = Render.new
|
|
17
|
+
config = engine.yml_config('_config.yml')[APP_NAME]
|
|
18
|
+
|
|
19
|
+
# Verifica se a configuração existe
|
|
20
|
+
engine.yml_verify(config)
|
|
27
21
|
|
|
28
22
|
@site = site
|
|
29
23
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
# Configura Sass para Jekyll
|
|
25
|
+
engine.configure_sass_for_jekyll(site)
|
|
26
|
+
|
|
27
|
+
# Copia arquivos estáticos caso toggle esteja habilitado
|
|
28
|
+
if config["enable"] == true
|
|
29
|
+
@site.static_files.concat static_files(engine) if config["toggle"].nil? || config["toggle"]["enable"] == true
|
|
33
30
|
end
|
|
34
|
-
ENGINE.copy_sass_manual(APP_ROOT_CONFIG)
|
|
35
31
|
end
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
#
|
|
40
|
-
def static_files
|
|
41
|
-
source = File.dirname(
|
|
42
|
-
asset_files.map do |file|
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
# Lista arquivos estáticos (exceto Sass)
|
|
36
|
+
def static_files(engine)
|
|
37
|
+
source = File.dirname(engine.assets_path)
|
|
38
|
+
asset_files(engine).map do |file|
|
|
43
39
|
dir = File.dirname(file)
|
|
44
40
|
file_name = File.basename(file)
|
|
45
|
-
Jekyll::StaticFile.new
|
|
41
|
+
Jekyll::StaticFile.new(@site, source, dir, file_name)
|
|
46
42
|
end
|
|
47
43
|
end
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Find.find(ENGINE.assets_path).each do |path|
|
|
45
|
+
def asset_files(engine)
|
|
46
|
+
files = []
|
|
47
|
+
Find.find(engine.assets_path).each do |path|
|
|
53
48
|
next if File.directory?(path)
|
|
54
|
-
next if path.include?(
|
|
55
|
-
|
|
49
|
+
next if path.include?(engine.stylesheets_sass_path)
|
|
50
|
+
files << path.sub(engine.assets_path, 'assets')
|
|
56
51
|
end
|
|
57
|
-
|
|
52
|
+
files
|
|
58
53
|
end
|
|
54
|
+
end
|
|
59
55
|
|
|
60
|
-
end # Generator
|
|
61
|
-
|
|
62
|
-
# class load SASS
|
|
63
|
-
class << self
|
|
64
|
-
|
|
65
|
-
def loadSass
|
|
66
|
-
ENGINE.configure_sass(ENGINE)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
end # self
|
|
70
|
-
|
|
71
|
-
# Implement Jektify in Page
|
|
72
56
|
class Main < Liquid::Tag
|
|
73
|
-
|
|
74
57
|
def initialize(tag_name, input, tokens)
|
|
75
58
|
super
|
|
76
|
-
# Name tag in liquid
|
|
77
|
-
# @tag_name = tag_name # DEPRECATED
|
|
78
59
|
@input = input
|
|
79
60
|
end
|
|
80
61
|
|
|
81
62
|
def render(context)
|
|
82
|
-
|
|
83
|
-
|
|
63
|
+
engine = Engine.new
|
|
64
|
+
render_obj = Render.new
|
|
65
|
+
config = engine.yml_config('_config.yml')[APP_NAME]
|
|
84
66
|
|
|
85
|
-
#
|
|
67
|
+
# Split do input e configurações do Spotify
|
|
68
|
+
input_split = engine.split_params(@input)
|
|
86
69
|
spotify_user = input_split[0].strip
|
|
87
70
|
spotify_embed_category = input_split[1].strip
|
|
88
71
|
spotify_id = input_split[2].strip
|
|
89
72
|
spotify_embed_theme = input_split[3].strip
|
|
73
|
+
spotify_embed_theme = spotify_embed_theme == "light" ? "white" : spotify_embed_theme
|
|
90
74
|
|
|
91
|
-
|
|
92
|
-
|
|
75
|
+
engine.error_different_string(
|
|
76
|
+
spotify_embed_theme,
|
|
77
|
+
"dark",
|
|
78
|
+
"white",
|
|
79
|
+
"[x] Error: Parameter incorrect in {% spotify [user]/[type]/[id]/[theme] %}."
|
|
80
|
+
)
|
|
93
81
|
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
player_color = spotify_embed_theme == "dark" ? "0" : "1"
|
|
83
|
+
spotify_embed_url = "https://open.spotify.com/embed/#{spotify_embed_category}/#{spotify_id}?theme=#{player_color}"
|
|
96
84
|
|
|
97
|
-
#
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
# Checks a series of error values in the settings of Jektify in _config.yml
|
|
104
|
-
ENGINE.error_different_true_false(APP_ROOT_CONFIG["enable"], "[x] Error: The property 'spotify => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["enable"].nil?
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
ENGINE.error_different_true_false(APP_ROOT_CONFIG["open"], "[x] Error: The property 'spotify => open' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["open"].nil?
|
|
108
|
-
|
|
109
|
-
ENGINE.error_different_true_false(APP_ROOT_CONFIG["title"]["enable"], "[x] Error: The property 'spotify => title => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["title"].nil?
|
|
110
|
-
|
|
111
|
-
ENGINE.error_different_true_false(APP_ROOT_CONFIG["description"]["enable"], "[x] Error: The property 'spotify => description => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["description"].nil?
|
|
112
|
-
|
|
113
|
-
ENGINE.error_different_true_false(APP_ROOT_CONFIG["toggle"]["enable"], "[x] Error: The property 'spotify => toggle => enable' in file '_config.yml' does not exist or its value is incorrect. Use: [ true | false ]") unless APP_ROOT_CONFIG["toggle"].nil?
|
|
85
|
+
# Validações das configs
|
|
86
|
+
%w[enable open].each do |key|
|
|
87
|
+
engine.error_different_true_false(config[key], "[x] Error: The property 'spotify => #{key}' in '_config.yml' is missing or invalid.") unless config[key].nil?
|
|
88
|
+
end
|
|
114
89
|
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
if config["title"]
|
|
91
|
+
engine.error_different_true_false(config["title"]["enable"], "[x] Error: The property 'spotify => title => enable' in '_config.yml' is missing or invalid.") unless config["title"].nil?
|
|
92
|
+
end
|
|
117
93
|
|
|
118
|
-
|
|
94
|
+
if config["description"]
|
|
95
|
+
engine.error_different_true_false(config["description"]["enable"], "[x] Error: The property 'spotify => description => enable' in '_config.yml' is missing or invalid.") unless config["description"].nil?
|
|
96
|
+
end
|
|
119
97
|
|
|
120
|
-
|
|
98
|
+
if config["toggle"]
|
|
99
|
+
engine.error_different_true_false(config["toggle"]["enable"], "[x] Error: The property 'spotify => toggle => enable' in '_config.yml' is missing or invalid.") unless config["toggle"].nil?
|
|
100
|
+
end
|
|
121
101
|
|
|
122
|
-
|
|
123
|
-
|
|
102
|
+
# Renderiza o player
|
|
103
|
+
render_obj.rendering(APP_NAME, config, spotify_embed_category, spotify_embed_url, spotify_embed_theme)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
124
106
|
|
|
125
|
-
#
|
|
107
|
+
# Registra a tag Liquid
|
|
126
108
|
Liquid::Template.register_tag(APP_NAME, Jektify::Main)
|
|
127
|
-
|
|
128
|
-
end # module Jektify
|
|
109
|
+
end
|
data/lib/jektify/render.rb
CHANGED
|
@@ -1,85 +1,59 @@
|
|
|
1
1
|
module Jektify
|
|
2
|
-
|
|
3
2
|
class Render
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
jektify__toggle_button = "" if !app_root_config["toggle"].nil? && app_root_config["toggle"]["enable"] == false
|
|
35
|
-
|
|
36
|
-
# This is a feature for adding a Spotify user link. Version 3.0.1
|
|
37
|
-
# NOTe: If the user uses the previous version of the "_config.yml" file, there will be no conflict.
|
|
38
|
-
if app_root_config["spotify"].nil?
|
|
39
|
-
jektify__spotify_user = ""
|
|
40
|
-
else
|
|
41
|
-
jektify__spotify_user = "<div class=\"jektify__user\"><a href=\"https://open.spotify.com/user/#{app_root_config["spotify"]["user"]}\" target=\"_blank\" class=\"jektify__user-link jektify__user-link--#{spotify_embed_theme} jektify__user-link--custom\" title=\"#{app_root_config["spotify"]["text"]}\"><span class=\"jektify__user-text jektify__user-text--#{spotify_embed_theme} jektify__user-text--custom\">#{app_root_config["spotify"]["text"]}</span></a></div>" if !app_root_config["spotify"]["user"].nil? && !app_root_config["spotify"]["text"].nil?
|
|
3
|
+
$DATETIME = Time.now
|
|
4
|
+
|
|
5
|
+
def rendering(app_name, app_root_config, category, url, theme)
|
|
6
|
+
jektify_title = app_root_config.dig("title", "enable") ? "block" : "none"
|
|
7
|
+
jektify_description = app_root_config.dig("description", "enable") ? "block" : "none"
|
|
8
|
+
box_height = %w[album playlist artist].include?(category) ? 380 : 80
|
|
9
|
+
open_track = app_root_config["open"] ? "block" : "none"
|
|
10
|
+
button_action = app_root_config["open"] ? "jektify__button--open" : "jektify__button--closed"
|
|
11
|
+
|
|
12
|
+
toggle_button = if app_root_config.dig("toggle", "enable").nil? || app_root_config.dig("toggle", "enable")
|
|
13
|
+
"<span class=\"jektify__button jektify__button--#{theme} jektify__button--custom #{button_action}\">+</span>"
|
|
14
|
+
else
|
|
15
|
+
""
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
open_track = "block" if app_root_config.dig("toggle", "enable") == false
|
|
19
|
+
|
|
20
|
+
spotify_user_html = ""
|
|
21
|
+
if app_root_config["spotify"]
|
|
22
|
+
user = app_root_config["spotify"]["user"]
|
|
23
|
+
text = app_root_config["spotify"]["text"]
|
|
24
|
+
if user && text
|
|
25
|
+
spotify_user_html = <<~HTML
|
|
26
|
+
<div class="jektify__user">
|
|
27
|
+
<a href="https://open.spotify.com/user/#{user}" target="_blank" class="jektify__user-link jektify__user-link--#{theme} jektify__user-link--custom" title="#{text}">
|
|
28
|
+
<span class="jektify__user-text jektify__user-text--#{theme} jektify__user-text--custom">#{text}</span>
|
|
29
|
+
</a>
|
|
30
|
+
</div>
|
|
31
|
+
HTML
|
|
32
|
+
end
|
|
42
33
|
end
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
# Render template if enable == true
|
|
46
|
-
if app_root_config["enable"] == true
|
|
47
|
-
%(<dl class="jektify jektify--#{spotify_embed_theme} jektify--custom">
|
|
48
|
-
|
|
49
|
-
<dt class="jektify__header jektify__header--#{spotify_embed_theme} jektify__header--custom">
|
|
50
|
-
|
|
51
|
-
<a class="jektify__brand jektify__brand--#{spotify_embed_theme} jektify__brand--custom" href="https://#{app_name}.github.io" target="_blank">#{app_name}</a>
|
|
35
|
+
return unless app_root_config["enable"]
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
<<~HTML
|
|
38
|
+
<dl class="jektify jektify--#{theme} jektify--custom">
|
|
39
|
+
<dt class="jektify__header jektify__header--#{theme} jektify__header--custom">
|
|
40
|
+
<a class="jektify__brand jektify__brand--#{theme} jektify__brand--custom" href="https://#{app_name}.github.io" target="_blank">#{app_name}</a>
|
|
41
|
+
<i class="jektify__year jektify__year--#{theme} jektify__year--custom">© #{$DATETIME.year} </i>
|
|
42
|
+
#{toggle_button}
|
|
55
43
|
</dt>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
#{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
<div class="jektify__tracklist jektify__tracklist--#{spotify_embed_theme} jektify__tracklist--custom">
|
|
66
|
-
<iframe id="jektify__track"
|
|
67
|
-
class="jektify__track jektify__track--#{spotify_embed_theme}
|
|
68
|
-
jektify__track--custom"
|
|
69
|
-
src="#{spotify_embed_url}"
|
|
70
|
-
width="100%"
|
|
71
|
-
height="#{box_height}"
|
|
72
|
-
frameborder="0"
|
|
73
|
-
allowtransparency="true"
|
|
74
|
-
allow="encrypted-media">
|
|
44
|
+
<dd class="jektify__body jektify__body--#{theme} jektify__body--custom" style="display: #{open_track}">
|
|
45
|
+
#{spotify_user_html}
|
|
46
|
+
<h1 class="jektify__title jektify__title--#{theme} jektify__title--custom" style="display: #{jektify_title};">#{app_root_config.dig("title", "text")}</h1>
|
|
47
|
+
<p class="jektify__description jektify__description--#{theme} jektify__description--custom" style="display: #{jektify_description};">#{app_root_config.dig("description", "text")}</p>
|
|
48
|
+
<div class="jektify__tracklist jektify__tracklist--#{theme} jektify__tracklist--custom">
|
|
49
|
+
<iframe id="jektify__track" class="jektify__track jektify__track--#{theme} jektify__track--custom"
|
|
50
|
+
src="#{url}" width="100%" height="#{box_height}" frameborder="0"
|
|
51
|
+
allowtransparency="true" allow="encrypted-media">
|
|
75
52
|
</iframe>
|
|
76
53
|
</div>
|
|
77
54
|
</dd>
|
|
78
|
-
</dl>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end # class Render
|
|
84
|
-
|
|
85
|
-
end # module Jektify
|
|
55
|
+
</dl>
|
|
56
|
+
HTML
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|