j1-template 2022.0.12 → 2022.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/themes/j1/adapter/js/advertising.js +65 -44
- data/assets/themes/j1/adapter/js/algolia.js +9 -9
- data/assets/themes/j1/adapter/js/analytics.js +46 -24
- data/assets/themes/j1/adapter/js/asciidoctor.js +9 -9
- data/assets/themes/j1/adapter/js/attic.js +9 -1
- data/assets/themes/j1/adapter/js/bmd.js +9 -10
- data/assets/themes/j1/adapter/js/carousel.js +9 -9
- data/assets/themes/j1/adapter/js/clipboard.js +9 -9
- data/assets/themes/j1/adapter/js/comments.js +31 -10
- data/assets/themes/j1/adapter/js/cookieConsent.js +73 -80
- data/assets/themes/j1/adapter/js/fab.js +10 -10
- data/assets/themes/j1/adapter/js/framer.js +59 -58
- data/assets/themes/j1/adapter/js/j1.js +166 -103
- data/assets/themes/j1/adapter/js/justifiedGallery.js +11 -10
- data/assets/themes/j1/adapter/js/justifiedGalleryCustomizer.js +9 -9
- data/assets/themes/j1/adapter/js/lightbox.js +11 -4
- data/assets/themes/j1/adapter/js/logger.js +10 -3
- data/assets/themes/j1/adapter/js/mmenu.js +9 -9
- data/assets/themes/j1/adapter/js/navigator.js +9 -9
- data/assets/themes/j1/adapter/js/quicksearch.js +9 -9
- data/assets/themes/j1/adapter/js/rouge.js +9 -9
- data/assets/themes/j1/adapter/js/rtable.js +9 -9
- data/assets/themes/j1/adapter/js/rtextResizer.js +9 -9
- data/assets/themes/j1/adapter/js/scroller.js +12 -7
- data/assets/themes/j1/adapter/js/themer.js +11 -2
- data/assets/themes/j1/adapter/js/toccer.js +9 -9
- data/assets/themes/j1/adapter/js/translator.js +13 -16
- data/assets/themes/j1/core/css/vendor.css +6 -1
- data/assets/themes/j1/core/css/vendor.min.css +1 -1
- data/assets/themes/j1/core/js/template.js +4 -3
- data/assets/themes/j1/core/js/template.min.js +1 -1
- data/assets/themes/j1/core/js/template.min.js.map +1 -1
- data/assets/themes/j1/modules/advertising/js/google/adInitializer.js +14 -4
- data/exe/j1 +31 -11
- data/lib/j1/commands/generate.rb +37 -36
- data/lib/j1/commands/help.rb +35 -0
- data/lib/j1/commands/patch.rb +81 -0
- data/lib/j1/commands/reset.rb +36 -0
- data/lib/j1/commands/setup.rb +126 -0
- data/lib/j1/commands/site.rb +27 -0
- data/lib/j1/external.rb +1 -1
- data/lib/j1/utils/exec_until_trap.rb +28 -0
- data/lib/j1/utils.rb +31 -0
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/layouts/home.ads.yml +262 -0
- data/lib/starter_web/_data/layouts/home.no-ads.yml +262 -0
- data/lib/starter_web/_data/layouts/home.yml +1 -1
- data/lib/starter_web/_data/modules/advertising.yml +1 -12
- data/lib/starter_web/_data/modules/analytics.yml +1 -1
- data/lib/starter_web/_data/modules/cookies.yml +5 -2
- data/lib/starter_web/_data/modules/defaults/advertising.yml +7 -8
- data/lib/starter_web/_data/modules/defaults/comments.yml +4 -4
- data/lib/starter_web/_data/modules/defaults/cookies.yml +106 -36
- data/lib/starter_web/_data/modules/defaults/themer.yml +3 -2
- data/lib/starter_web/_data/modules/themer.yml +2 -1
- data/lib/starter_web/_includes/attributes.asciidoc +1 -1
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/collections/posts/public/featured/_posts/0000-00-00-welcome-to-j1.adoc.erb +1 -1
- data/lib/starter_web/collections/posts/public/featured/_posts/2021-01-01-about-cookies.adoc +1 -1
- data/lib/starter_web/collections/posts/public/featured/_posts/2021-01-01-about-cookies.ads.asciidoc +1 -1
- data/lib/starter_web/collections/posts/public/featured/_posts/2021-01-01-about-cookies.comments.asciidoc +1 -1
- data/lib/starter_web/collections/posts/public/featured/_posts/2021-02-01-site-generators.adoc +1 -1
- data/lib/starter_web/collections/posts/public/featured/_posts/2021-03-03-about-j1.adoc +1 -1
- data/lib/starter_web/collections/posts/public/series/_posts/2020-01-01-post-wiki-series.adoc +1 -1
- data/lib/starter_web/collections/posts/public/series/_posts/2020-01-02-post-wiki-series.adoc +1 -1
- data/lib/starter_web/collections/posts/public/series/_posts/2020-01-03-post-wiki-series.adoc +1 -1
- data/lib/starter_web/index.html +0 -3
- data/lib/starter_web/package.json +5 -1
- data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/000_intro.adoc +1 -1
- data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/100_converter.adoc +1 -1
- data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/200_themes.adoc +1 -1
- data/lib/starter_web/pages/public/asciidoc_skeletons/documentation/documentation.adoc +1 -4
- data/lib/starter_web/pages/public/asciidoc_skeletons/multi-document/multi.adoc +1 -4
- data/lib/starter_web/pages/public/asciidoc_skeletons/simple-document/simple.adoc +1 -4
- data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +7 -7
- data/lib/starter_web/pages/public/manuals/dropdown-help.adoc +23 -2
- data/lib/starter_web/pages/public/previewer/preview_bootstrap_theme.adoc +100 -166
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +11 -3
@@ -80,13 +80,23 @@ $(document).ready(function() {
|
|
80
80
|
// [INFO ] [j1.adapter.advertising ] [ detected advertising provider: {{advertising_provider}}} ]
|
81
81
|
// [INFO ] [j1.adapter.advertising ] [ advertising detected as: {{advertising}} ]
|
82
82
|
{% if advertising %}
|
83
|
-
var logger
|
84
|
-
var ads_found
|
85
|
-
var cookie_names
|
86
|
-
var user_consent
|
83
|
+
var logger = log4javascript.getLogger('j1.core.advertising.google');
|
84
|
+
var ads_found = document.getElementsByClassName('adsbygoogle').length;
|
85
|
+
var cookie_names = j1.getCookieNames();
|
86
|
+
var user_consent = j1.readCookie(cookie_names.user_consent);
|
87
|
+
var providerID = '{{advertising_options.google.publisherID}}';
|
88
|
+
var validProviderID = (providerID.includes('your')) ? false : true;
|
89
|
+
var advertisingProvider = 'Google Adsense';
|
87
90
|
|
88
91
|
var dependencies_met_page_ready = setInterval (function (options) {
|
89
92
|
if (j1.getState() === 'finished') {
|
93
|
+
|
94
|
+
if (!validProviderID) {
|
95
|
+
logger.warn('\n' + 'disabled provider: ' + advertisingProvider);
|
96
|
+
clearInterval(dependencies_met_page_ready);
|
97
|
+
return false;
|
98
|
+
}
|
99
|
+
|
90
100
|
if (user_consent.personalization) {
|
91
101
|
if (ads_found) {
|
92
102
|
logger.info('\n' + 'initialize all ads in page: #' + ads_found);
|
data/exe/j1
CHANGED
@@ -11,17 +11,37 @@ Mercenary.program(:j1) do |p|
|
|
11
11
|
p.description 'J1 Template is a gem-based Template made for Jekyll'
|
12
12
|
p.syntax 'j1 <subcommand> [options]'
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
# available options for all subcommands
|
15
|
+
#
|
16
|
+
# p.option 'force', '--force'
|
17
|
+
# p.option 'skip-bundle', '--skip-bundle'
|
18
|
+
# p.option 'skip-patches', '--skip-patches'
|
19
|
+
# p.option 'system', '--system'
|
20
|
+
|
21
|
+
# J1::External.require_if_present(J1::External.blessed_gems) do |g, ver_constraint|
|
22
|
+
# cmd = g.split("-").last
|
23
|
+
# p.command(cmd.to_sym) do |c|
|
24
|
+
# c.syntax cmd
|
25
|
+
# c.action do
|
26
|
+
# J1.logger.abort_with "You must install the '#{g}' gem" \
|
27
|
+
# " version #{ver_constraint} to use the 'jekyll #{cmd}' command."
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
J1::Command.subclasses.each { |c| c.init_with_program(p) }
|
33
|
+
|
34
|
+
p.action do |args, _|
|
35
|
+
if args.empty?
|
36
|
+
J1.logger.error "A subcommand is required."
|
37
|
+
puts p
|
38
|
+
abort
|
39
|
+
else
|
40
|
+
subcommand = args.first
|
41
|
+
unless p.has_command? subcommand
|
42
|
+
J1.logger.abort_with "fatal: 'j1 #{args.first}' failed." \
|
43
|
+
" No subcommand '#{args.first}' available."
|
44
|
+
end
|
23
45
|
end
|
24
46
|
end
|
25
|
-
|
26
|
-
p.default_command(:generate)
|
27
47
|
end
|
data/lib/j1/commands/generate.rb
CHANGED
@@ -1,36 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'erb'
|
2
|
-
require 'rbconfig'
|
3
|
-
require 'fileutils'
|
4
4
|
|
5
5
|
module J1
|
6
6
|
module Commands
|
7
7
|
class Generate < Command
|
8
8
|
class << self
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# end
|
23
|
-
|
24
|
-
def is_windows?
|
25
|
-
RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
|
10
|
+
def init_with_program(prog)
|
11
|
+
prog.command(:generate) do |c|
|
12
|
+
c.description 'Generates a J1 project scaffold in PATH'
|
13
|
+
c.syntax 'generate PATH'
|
14
|
+
c.option 'force', '--force', 'Force a site to be created even the PATH already exists'
|
15
|
+
c.option 'skip-bundle', '--skip-bundle', 'Skip bundle install'
|
16
|
+
c.option 'skip-patches', '--skip-patches', 'Skip install any PATCHES build-in with J1'
|
17
|
+
c.option 'system', '--system', 'Run "bundle install" for the Ruby SYSTEM gem folder'
|
18
|
+
c.action do |args, options|
|
19
|
+
J1::Commands::Generate.process(args, options)
|
20
|
+
end
|
21
|
+
end
|
26
22
|
end
|
27
23
|
|
28
24
|
def process(args, options = {})
|
29
|
-
raise ArgumentError, 'You must specify a path.' if args.empty?
|
25
|
+
raise ArgumentError, 'GENERATE: You must specify a path.' if args.empty?
|
26
|
+
|
30
27
|
new_blog_path = File.expand_path(args.join(' '), Dir.pwd)
|
31
28
|
FileUtils.mkdir_p new_blog_path
|
32
29
|
if preserve_source_location?(new_blog_path, options)
|
33
|
-
J1.logger.abort_with 'Conflict:', "#{new_blog_path} exists and is not empty."
|
30
|
+
J1.logger.abort_with 'GENERATE: Conflict:', "#{new_blog_path} exists and is not empty."
|
34
31
|
end
|
35
32
|
|
36
33
|
if options['blank']
|
@@ -61,6 +58,10 @@ module J1
|
|
61
58
|
|
62
59
|
private
|
63
60
|
|
61
|
+
def is_windows?
|
62
|
+
RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
|
63
|
+
end
|
64
|
+
|
64
65
|
def create_site(new_blog_path)
|
65
66
|
create_sample_files new_blog_path
|
66
67
|
|
@@ -92,33 +93,33 @@ module J1
|
|
92
93
|
def after_install(path, options = {})
|
93
94
|
unless options['skip-bundle']
|
94
95
|
bundle_install(path, options)
|
95
|
-
|
96
|
-
|
96
|
+
if options['skip-patches']
|
97
|
+
J1.logger.info "GENERATE: Install build-in patches skipped ..."
|
97
98
|
else
|
98
|
-
|
99
|
+
patch_install(options)
|
99
100
|
end
|
100
101
|
end
|
101
|
-
|
102
|
-
J1.logger.info "Generated Jekyll site installed in folder #{path}"
|
102
|
+
if options['force']
|
103
|
+
J1.logger.info "GENERATE: Generated Jekyll site force installed in folder #{path}"
|
103
104
|
else
|
104
|
-
J1.logger.info "Generated Jekyll site
|
105
|
+
J1.logger.info "GENERATE: Generated Jekyll site installed in folder #{path}"
|
105
106
|
end
|
106
|
-
J1.logger.info 'Installation (bundle) of RubyGems skipped' if options['skip-bundle']
|
107
|
+
J1.logger.info 'GENERATE: Installation (bundle) of RubyGems skipped' if options['skip-bundle']
|
107
108
|
end
|
108
109
|
|
109
110
|
def bundle_install(path, options)
|
110
111
|
J1::External.require_with_graceful_fail 'bundler'
|
111
|
-
J1.logger.info "Running bundle install in #{path} ..."
|
112
|
+
J1.logger.info "GENERATE: Running bundle install in #{path} ..."
|
112
113
|
Dir.chdir(path) do
|
113
114
|
if options['system']
|
114
|
-
J1.logger.info "Install bundle in Ruby gem SYSTEM folder ..."
|
115
|
+
J1.logger.info "GENERATE: Install bundle in Ruby gem SYSTEM folder ..."
|
115
116
|
else
|
116
|
-
J1.logger.info "Install bundle in USER gem folder ~/.gem ..."
|
117
|
+
J1.logger.info "GENERATE: Install bundle in USER gem folder ~/.gem ..."
|
117
118
|
process, output = J1::Utils::Exec.run('bundle', 'config', 'set', '--local', 'path', '~/.gem')
|
118
119
|
end
|
119
120
|
process, output = J1::Utils::Exec.run('bundle', 'install')
|
120
121
|
output.to_s.each_line do |line|
|
121
|
-
J1.logger.info('
|
122
|
+
J1.logger.info('BUNDLE:', line.strip) unless line.to_s.empty?
|
122
123
|
end
|
123
124
|
raise SystemExit unless process.success?
|
124
125
|
end
|
@@ -142,12 +143,12 @@ module J1
|
|
142
143
|
system_path = result[1]
|
143
144
|
|
144
145
|
if options['system']
|
145
|
-
J1.logger.info "Install patches in SYSTEM folder ..."
|
146
|
-
J1.logger.info "Install patches on path #{system_path} ..."
|
146
|
+
J1.logger.info "GENERATE: Install patches in SYSTEM folder ..."
|
147
|
+
J1.logger.info "GENERATE: Install patches on path #{system_path} ..."
|
147
148
|
dest = system_path + '/gems/' + patch_gem_eventmachine + '/lib'
|
148
149
|
else
|
149
|
-
J1.logger.info "Install patches in USER gem folder ~/.gem ..."
|
150
|
-
J1.logger.info "Install patches on path #{user_path} ..."
|
150
|
+
J1.logger.info "GENERATE: Install patches in USER gem folder ~/.gem ..."
|
151
|
+
J1.logger.info "GENERATE: Install patches on path #{user_path} ..."
|
151
152
|
dest = user_path + '/gems/' + patch_gem_eventmachine + '/lib'
|
152
153
|
end
|
153
154
|
src = patch_eventmachine_source_path
|
@@ -163,7 +164,7 @@ module J1
|
|
163
164
|
if Dir.exist?(dest)
|
164
165
|
FileUtils.cp(src, dest)
|
165
166
|
else
|
166
|
-
J1.logger.info "Skipped install patches for execjs-2.7.0 ..."
|
167
|
+
J1.logger.info "GENERATE: Skipped install patches for execjs-2.7.0 ..."
|
167
168
|
end
|
168
169
|
end
|
169
170
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module J1
|
4
|
+
module Commands
|
5
|
+
class Help < Command
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def init_with_program(prog)
|
9
|
+
prog.command(:help) do |c|
|
10
|
+
c.syntax "help [subcommand]"
|
11
|
+
c.description "Show the help message, optionally for a given subcommand"
|
12
|
+
|
13
|
+
c.action do |args, _|
|
14
|
+
cmd = (args.first || "").to_sym
|
15
|
+
if args.empty?
|
16
|
+
J1.logger.info prog.to_s
|
17
|
+
elsif prog.has_command? cmd
|
18
|
+
J1.logger.info prog.commands[cmd].to_s
|
19
|
+
else
|
20
|
+
invalid_command(prog, cmd)
|
21
|
+
abort
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def invalid_command(prog, cmd)
|
28
|
+
J1.logger.error "Error:",
|
29
|
+
"Hmm... we don't know what the '#{cmd}' command is."
|
30
|
+
J1.logger.info "Valid commands:", prog.commands.keys.join(", ")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module J1
|
4
|
+
module Commands
|
5
|
+
class Patch < Command
|
6
|
+
#noinspection MissingYardParamTag
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def init_with_program(prog)
|
10
|
+
prog.command(:patch) do |c|
|
11
|
+
c.description 'Install patches available for J1 projects'
|
12
|
+
c.syntax 'patch'
|
13
|
+
c.option 'force', '--force', 'Force to install patches even already exists'
|
14
|
+
c.option 'system', '--system', 'Install patches on the Ruby SYSTEM gem folder'
|
15
|
+
c.action do |args, options|
|
16
|
+
J1::Commands::Patch.process(args, options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def process(args, options = {})
|
22
|
+
patch_install(options)
|
23
|
+
@args = args
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def is_windows?
|
29
|
+
#noinspection RubyResolve
|
30
|
+
RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
|
31
|
+
end
|
32
|
+
|
33
|
+
def patch_install(options)
|
34
|
+
if is_windows?
|
35
|
+
major, minor = RUBY_VERSION.split('.')
|
36
|
+
lib_version = major + '.' + minor
|
37
|
+
curr_path = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
38
|
+
patch_gem_eventmachine = 'eventmachine-1.2.7-x64-mingw32'
|
39
|
+
patch_gem_execjs = 'execjs-2.7.0'
|
40
|
+
patch_eventmachine_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_eventmachine + '/lib/' + lib_version
|
41
|
+
patch_execjs_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_execjs + '/lib/execjs/external_runtime.rb'
|
42
|
+
|
43
|
+
process, output = J1::Utils::Exec.run('gem', 'env', 'gempath')
|
44
|
+
raise SystemExit unless process.success?
|
45
|
+
|
46
|
+
result = output.split(';')
|
47
|
+
user_path = result[0]
|
48
|
+
system_path = result[1]
|
49
|
+
|
50
|
+
if options['system']
|
51
|
+
J1.logger.info "PATCH: Install patches in SYSTEM folder ..."
|
52
|
+
J1.logger.info "PATCH: Install patches on path #{system_path} ..."
|
53
|
+
dest = system_path + '/gems/' + patch_gem_eventmachine + '/lib'
|
54
|
+
else
|
55
|
+
J1.logger.info "PATCH: Install patches in USER gem folder ~/.gem ..."
|
56
|
+
J1.logger.info "PATCH: Install patches on path #{user_path} ..."
|
57
|
+
dest = user_path + '/gems/' + patch_gem_eventmachine + '/lib'
|
58
|
+
end
|
59
|
+
src = patch_eventmachine_source_path
|
60
|
+
FileUtils.cp_r(src, dest)
|
61
|
+
|
62
|
+
if lib_version === '2.7'
|
63
|
+
if options['system']
|
64
|
+
dest = system_path + '/gems/' + patch_gem_execjs + '/lib/execjs'
|
65
|
+
else
|
66
|
+
dest = user_path + '/gems/' + patch_gem_execjs + '/lib/execjs'
|
67
|
+
end
|
68
|
+
src = patch_execjs_source_path
|
69
|
+
if Dir.exist?(dest)
|
70
|
+
FileUtils.cp(src, dest)
|
71
|
+
else
|
72
|
+
J1.logger.info "PATCH: Skipped install patches for execjs-2.7.0 ..."
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module J1
|
4
|
+
module Commands
|
5
|
+
class Reset < Command
|
6
|
+
#noinspection MissingYardParamTag
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def init_with_program(prog)
|
10
|
+
prog.command(:reset) do |c|
|
11
|
+
c.description 'Reset a J1 project to factory state'
|
12
|
+
c.syntax 'reset'
|
13
|
+
c.action do |args, options|
|
14
|
+
J1::Commands::Reset.process(args, options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def process(args, options = {})
|
20
|
+
J1.logger.info "RESET: Reset the project to factory state ..."
|
21
|
+
J1.logger.info "RESET: Be patient, this will take a while ..."
|
22
|
+
process, output = J1::Utils::Exec.run('npm', 'run', 'reset')
|
23
|
+
output.to_s.each_line do |line|
|
24
|
+
J1.logger.info('RESET:', line.strip) unless line.to_s.empty?
|
25
|
+
end
|
26
|
+
if process.success?
|
27
|
+
J1.logger.info "RESET: The project reset finished successfully."
|
28
|
+
else
|
29
|
+
raise SystemExit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module J1
|
4
|
+
module Commands
|
5
|
+
class Setup < Command
|
6
|
+
#noinspection MissingYardParamTag
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def init_with_program(prog)
|
10
|
+
prog.command(:setup) do |c|
|
11
|
+
c.description 'Initialize a J1 project for first use'
|
12
|
+
c.syntax 'setup'
|
13
|
+
c.option 'force', '--force', ' Force to install patches even already exists'
|
14
|
+
c.option 'system', '--system', ' Install patches on the Ruby SYSTEM gem folder'
|
15
|
+
c.option 'skip-patches', '--skip-patches', 'Skip install any PATCHES build-in with J1'
|
16
|
+
c.action do |args, options|
|
17
|
+
J1::Commands::Setup.process(args, options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def process(args, options = {})
|
23
|
+
@args = args
|
24
|
+
path = File.expand_path(Dir.getwd)
|
25
|
+
if is_project?
|
26
|
+
bundle_install(path, options)
|
27
|
+
if options['skip-patches']
|
28
|
+
J1.logger.info "SETUP: Install build-in patches skipped ..."
|
29
|
+
else
|
30
|
+
patch_install(options)
|
31
|
+
end
|
32
|
+
J1.logger.info "SETUP: Initialize the project ..."
|
33
|
+
J1.logger.info "SETUP: Be patient, this will take a while ..."
|
34
|
+
process, output = J1::Utils::Exec.run('npm', 'run', 'setup')
|
35
|
+
output.to_s.each_line do |line|
|
36
|
+
J1.logger.info('SETUP:', line.strip) unless line.to_s.empty?
|
37
|
+
end
|
38
|
+
if process.success?
|
39
|
+
J1.logger.info "SETUP: Initializing the project finished successfully."
|
40
|
+
J1.logger.info "SETUP: To open your site, run: j1 site"
|
41
|
+
else
|
42
|
+
raise SystemExit
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def is_project?
|
50
|
+
path = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
51
|
+
J1.logger.info "Check consistency of the project ..."
|
52
|
+
return true
|
53
|
+
end
|
54
|
+
|
55
|
+
def is_windows?
|
56
|
+
#noinspection RubyResolve
|
57
|
+
RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
|
58
|
+
end
|
59
|
+
|
60
|
+
def bundle_install(path, options)
|
61
|
+
J1::External.require_with_graceful_fail 'bundler'
|
62
|
+
J1.logger.info "Running bundle install in #{path} ..."
|
63
|
+
Dir.chdir(path) do
|
64
|
+
if options['system']
|
65
|
+
J1.logger.info "Install bundle in Ruby gem SYSTEM folder ..."
|
66
|
+
else
|
67
|
+
J1.logger.info "Install bundle in USER gem folder ~/.gem ..."
|
68
|
+
process, output = J1::Utils::Exec.run('bundle', 'config', 'set', '--local', 'path', '~/.gem')
|
69
|
+
end
|
70
|
+
process, output = J1::Utils::Exec.run('bundle', 'install')
|
71
|
+
output.to_s.each_line do |line|
|
72
|
+
J1.logger.info('Bundler:', line.strip) unless line.to_s.empty?
|
73
|
+
end
|
74
|
+
raise SystemExit unless process.success?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def patch_install(options)
|
79
|
+
if is_windows?
|
80
|
+
major, minor = RUBY_VERSION.split('.')
|
81
|
+
lib_version = major + '.' + minor
|
82
|
+
curr_path = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
83
|
+
patch_gem_eventmachine = 'eventmachine-1.2.7-x64-mingw32'
|
84
|
+
patch_gem_execjs = 'execjs-2.7.0'
|
85
|
+
patch_eventmachine_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_eventmachine + '/lib/' + lib_version
|
86
|
+
patch_execjs_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_execjs + '/lib/execjs/external_runtime.rb'
|
87
|
+
|
88
|
+
process, output = J1::Utils::Exec.run('gem', 'env', 'gempath')
|
89
|
+
raise SystemExit unless process.success?
|
90
|
+
|
91
|
+
result = output.split(';')
|
92
|
+
user_path = result[0]
|
93
|
+
system_path = result[1]
|
94
|
+
|
95
|
+
if options['system']
|
96
|
+
J1.logger.info "Install patches in SYSTEM folder ..."
|
97
|
+
J1.logger.info "Install patches on path #{system_path} ..."
|
98
|
+
dest = system_path + '/gems/' + patch_gem_eventmachine + '/lib'
|
99
|
+
else
|
100
|
+
J1.logger.info "Install patches in USER gem folder ~/.gem ..."
|
101
|
+
J1.logger.info "Install patches on path #{user_path} ..."
|
102
|
+
dest = user_path + '/gems/' + patch_gem_eventmachine + '/lib'
|
103
|
+
end
|
104
|
+
src = patch_eventmachine_source_path
|
105
|
+
FileUtils.cp_r(src, dest)
|
106
|
+
|
107
|
+
if lib_version === '2.7'
|
108
|
+
if options['system']
|
109
|
+
dest = system_path + '/gems/' + patch_gem_execjs + '/lib/execjs'
|
110
|
+
else
|
111
|
+
dest = user_path + '/gems/' + patch_gem_execjs + '/lib/execjs'
|
112
|
+
end
|
113
|
+
src = patch_execjs_source_path
|
114
|
+
if Dir.exist?(dest)
|
115
|
+
FileUtils.cp(src, dest)
|
116
|
+
else
|
117
|
+
J1.logger.info "Skipped install patches for execjs-2.7.0 ..."
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module J1
|
4
|
+
module Commands
|
5
|
+
class Site < Command
|
6
|
+
#noinspection MissingYardParamTag
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def init_with_program(prog)
|
10
|
+
prog.command(:site) do |c|
|
11
|
+
c.description 'Run the website of a J1 project'
|
12
|
+
c.syntax 'site'
|
13
|
+
c.action do |args, options|
|
14
|
+
J1::Commands::Site.process(args, options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def process(args, options = {})
|
20
|
+
J1.logger.info "SITE: Starting up your site ..."
|
21
|
+
J1::Utils::ExecUntilTrap.run('SITE','npm', 'run', 'j1-site')
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/j1/external.rb
CHANGED
@@ -50,7 +50,7 @@ The full error message from Ruby is: '#{e.message}'
|
|
50
50
|
|
51
51
|
If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
|
52
52
|
MSG
|
53
|
-
raise
|
53
|
+
raise J1::Errors::MissingDependencyException, name
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
module J1
|
4
|
+
module Utils
|
5
|
+
module ExecUntilTrap
|
6
|
+
extend self
|
7
|
+
|
8
|
+
# Runs a program in a sub-shell and exits on Ctrl+C.
|
9
|
+
#
|
10
|
+
# title - Trailing line title for the output on stdout
|
11
|
+
# *args - a list of strings containing the program name and (followed by) arguments
|
12
|
+
#
|
13
|
+
def run(title, *args)
|
14
|
+
Open3.popen3(*args) do |stdin, stdout, stderr|
|
15
|
+
trap('INT') {
|
16
|
+
puts "#{title}: Received Ctrl-C to stop"
|
17
|
+
raise SystemExit
|
18
|
+
}
|
19
|
+
stdout.each_line do |line|
|
20
|
+
puts "#{title}: #{line}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
[stdin, stdout, stderr].each(&:close)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/j1/utils.rb
CHANGED
@@ -1,11 +1,42 @@
|
|
1
|
+
require "singleton"
|
2
|
+
|
1
3
|
module J1
|
2
4
|
module Utils
|
3
5
|
extend self
|
4
6
|
autoload :Ansi, "j1/utils/ansi"
|
5
7
|
autoload :Exec, "j1/utils/exec"
|
8
|
+
autoload :ExecUntilTrap, "j1/utils/exec_until_trap"
|
6
9
|
autoload :Platforms, "j1/utils/platforms"
|
7
10
|
autoload :WinTZ, "j1/utils/win_tz"
|
8
11
|
|
12
|
+
class GracefulQuit
|
13
|
+
include Singleton
|
14
|
+
|
15
|
+
attr_accessor :breaker
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
self.breaker = false
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.enable
|
22
|
+
trap('INT') {
|
23
|
+
yield if block_given?
|
24
|
+
self.instance.breaker = true
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.check(message = "Quitting")
|
29
|
+
if self.instance.breaker
|
30
|
+
yield if block_given?
|
31
|
+
puts message
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
9
40
|
# Constants for use in #slugify
|
10
41
|
SLUGIFY_MODES = %w(raw default pretty ascii).freeze
|
11
42
|
SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
|
data/lib/j1/version.rb
CHANGED
data/lib/starter_web/Gemfile
CHANGED
@@ -53,7 +53,7 @@ gem 'jekyll', '~> 4.2'
|
|
53
53
|
|
54
54
|
# Theme Rubies, default: J1 Template (NOT used for the development system)
|
55
55
|
#
|
56
|
-
gem 'j1-template', '~> 2022.0.
|
56
|
+
gem 'j1-template', '~> 2022.0.16'
|
57
57
|
|
58
58
|
# ------------------------------------------------------------------------------
|
59
59
|
# PRODUCTION: Gem needed for the Jekyll and J1 prod environment
|
data/lib/starter_web/_config.yml
CHANGED
@@ -53,7 +53,7 @@ environment: development
|
|
53
53
|
# ------------------------------------------------------------------------------
|
54
54
|
# Sets the build version of J1 Template Gem
|
55
55
|
#
|
56
|
-
version: 2022.0.
|
56
|
+
version: 2022.0.16
|
57
57
|
|
58
58
|
# version
|
59
59
|
# ------------------------------------------------------------------------------
|