bridgetown-core 0.13.0 → 0.15.0.beta3
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/Rakefile +3 -1
- data/bin/bridgetown +9 -48
- data/bridgetown-core.gemspec +6 -2
- data/lib/bridgetown-core.rb +13 -3
- data/lib/bridgetown-core/cleaner.rb +1 -0
- data/lib/bridgetown-core/commands/apply.rb +73 -0
- data/lib/bridgetown-core/commands/base.rb +45 -0
- data/lib/bridgetown-core/commands/build.rb +91 -86
- data/lib/bridgetown-core/commands/clean.rb +30 -29
- data/lib/bridgetown-core/commands/concerns/actions.rb +123 -0
- data/lib/bridgetown-core/commands/concerns/build_options.rb +76 -0
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +18 -0
- data/lib/bridgetown-core/commands/concerns/summarizable.rb +13 -0
- data/lib/bridgetown-core/commands/console.rb +46 -39
- data/lib/bridgetown-core/commands/doctor.rb +126 -127
- data/lib/bridgetown-core/commands/new.rb +120 -158
- data/lib/bridgetown-core/commands/plugins.rb +206 -0
- data/lib/bridgetown-core/commands/registrations.rb +16 -0
- data/lib/bridgetown-core/commands/serve.rb +214 -215
- data/lib/bridgetown-core/{convertible.rb → concerns/convertible.rb} +3 -6
- data/lib/bridgetown-core/concerns/site/configurable.rb +153 -0
- data/lib/bridgetown-core/concerns/site/content.rb +111 -0
- data/lib/bridgetown-core/concerns/site/extensible.rb +56 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +74 -0
- data/lib/bridgetown-core/concerns/site/renderable.rb +49 -0
- data/lib/bridgetown-core/concerns/site/writable.rb +31 -0
- data/lib/bridgetown-core/configuration.rb +2 -9
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +0 -3
- data/lib/bridgetown-core/document.rb +1 -1
- data/lib/bridgetown-core/drops/page_drop.rb +1 -1
- data/lib/bridgetown-core/drops/site_drop.rb +1 -1
- data/lib/bridgetown-core/excerpt.rb +4 -1
- data/lib/bridgetown-core/external.rb +17 -21
- data/lib/bridgetown-core/filters.rb +10 -0
- data/lib/bridgetown-core/generators/prototype_generator.rb +3 -1
- data/lib/bridgetown-core/hooks.rb +62 -62
- data/lib/bridgetown-core/layout.rb +10 -4
- data/lib/bridgetown-core/liquid_renderer.rb +1 -0
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -4
- data/lib/bridgetown-core/liquid_renderer/file_system.rb +3 -1
- data/lib/bridgetown-core/page.rb +11 -19
- data/lib/bridgetown-core/plugin.rb +2 -0
- data/lib/bridgetown-core/plugin_manager.rb +88 -21
- data/lib/bridgetown-core/reader.rb +5 -0
- data/lib/bridgetown-core/readers/data_reader.rb +5 -2
- data/lib/bridgetown-core/readers/layout_reader.rb +9 -2
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +48 -0
- data/lib/bridgetown-core/renderer.rb +38 -28
- data/lib/bridgetown-core/site.rb +20 -463
- data/lib/bridgetown-core/tags/include.rb +12 -0
- data/lib/bridgetown-core/tags/render_content.rb +29 -16
- data/lib/bridgetown-core/tags/with.rb +15 -0
- data/lib/bridgetown-core/utils.rb +45 -27
- data/lib/bridgetown-core/utils/ruby_exec.rb +1 -4
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/bridgetown-core/watcher.rb +21 -10
- data/lib/site_template/Gemfile.erb +19 -0
- data/lib/site_template/package.json +1 -0
- data/lib/site_template/plugins/{.keep → builders/.keep} +0 -0
- data/lib/site_template/plugins/site_builder.rb +4 -0
- data/lib/site_template/src/_components/footer.html +3 -0
- data/lib/site_template/src/_components/head.html +9 -0
- data/lib/site_template/src/{_includes → _components}/navbar.html +1 -0
- data/lib/site_template/src/_layouts/default.html +3 -3
- data/lib/site_template/src/posts.md +15 -0
- data/lib/site_template/start.js +1 -1
- data/lib/site_template/webpack.config.js +3 -3
- metadata +90 -18
- data/lib/bridgetown-core/command.rb +0 -106
- data/lib/bridgetown-core/commands/help.rb +0 -34
- data/lib/site_template/src/_components/.keep +0 -0
- data/lib/site_template/src/_includes/footer.html +0 -3
- data/lib/site_template/src/_includes/head.html +0 -9
@@ -2,40 +2,41 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
module Commands
|
5
|
-
class Clean <
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
c.syntax "clean [subcommand]"
|
10
|
-
c.description "Clean the site " \
|
11
|
-
"(removes site output and metadata file) without building."
|
5
|
+
class Clean < Thor::Group
|
6
|
+
extend BuildOptions
|
7
|
+
extend Summarizable
|
8
|
+
include ConfigurationOverridable
|
12
9
|
|
13
|
-
|
10
|
+
Registrations.register do
|
11
|
+
register(Clean, "clean", "clean", Clean.summary)
|
12
|
+
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
14
|
+
def self.banner
|
15
|
+
"bridgetown clean [options]"
|
16
|
+
end
|
17
|
+
summary "Clean the site (removes site output and metadata file) without building"
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
def clean
|
20
|
+
config = configuration_with_overrides(options)
|
21
|
+
destination = config["destination"]
|
22
|
+
metadata_file = File.join(config["root_dir"], ".bridgetown-metadata")
|
23
|
+
cache_dir = File.join(config["root_dir"], config["cache_dir"])
|
24
|
+
webpack_dir = File.join(config["root_dir"], ".bridgetown-webpack")
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
remove(destination, checker_func: :directory?)
|
27
|
+
remove(metadata_file, checker_func: :file?)
|
28
|
+
remove(cache_dir, checker_func: :directory?)
|
29
|
+
remove(webpack_dir, checker_func: :directory?)
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
34
|
+
def remove(filename, checker_func: :file?)
|
35
|
+
if File.public_send(checker_func, filename)
|
36
|
+
Bridgetown.logger.info "Cleaner:", "Removing #{filename}..."
|
37
|
+
FileUtils.rm_rf(filename)
|
38
|
+
else
|
39
|
+
Bridgetown.logger.info "Cleaner:", "Nothing to do for #{filename}."
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Mostly not used here, but may come in handy in new automations
|
4
|
+
require "active_support/core_ext/array/extract_options"
|
5
|
+
require "active_support/core_ext/string/strip"
|
6
|
+
require "active_support/core_ext/string/indent"
|
7
|
+
|
8
|
+
module Bridgetown
|
9
|
+
module Commands
|
10
|
+
module Actions
|
11
|
+
def create_builder(filename, data = nil)
|
12
|
+
say_status :create_builder, filename
|
13
|
+
data ||= yield if block_given?
|
14
|
+
|
15
|
+
site_builder = File.join("plugins", "site_builder.rb")
|
16
|
+
unless File.exist?(site_builder)
|
17
|
+
create_file("plugins/site_builder.rb", verbose: true) do
|
18
|
+
<<~RUBY
|
19
|
+
class SiteBuilder < Bridgetown::Builder
|
20
|
+
end
|
21
|
+
RUBY
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
create_file("plugins/builders/#{filename}", data, verbose: false)
|
26
|
+
end
|
27
|
+
|
28
|
+
def javascript_import(data = nil, filename: "index.js")
|
29
|
+
data ||= yield if block_given?
|
30
|
+
data += "\n" unless data.chars.last == "\n"
|
31
|
+
|
32
|
+
say_status :javascript_import, filename
|
33
|
+
|
34
|
+
js_index = File.join("frontend", "javascript", filename)
|
35
|
+
if File.exist?(js_index)
|
36
|
+
index_file = File.read(js_index)
|
37
|
+
|
38
|
+
last_import = ""
|
39
|
+
index_file.each_line do |line|
|
40
|
+
line.start_with?("import ") ? last_import = line : break
|
41
|
+
end
|
42
|
+
|
43
|
+
if last_import == ""
|
44
|
+
# add to top of file
|
45
|
+
prepend_file js_index, data, verbose: false
|
46
|
+
else
|
47
|
+
# inject after the last import line
|
48
|
+
inject_into_file js_index, data, after: last_import, verbose: false, force: false
|
49
|
+
end
|
50
|
+
else
|
51
|
+
create_file(js_index, data, verbose: false)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_bridgetown_plugin(gemname, version: nil)
|
56
|
+
version = " -v \"#{version}\"" if version
|
57
|
+
run "bundle add #{gemname}#{version} -g bridgetown_plugins"
|
58
|
+
rescue SystemExit
|
59
|
+
say_status :run, "Gem not added due to bundler error", :red
|
60
|
+
end
|
61
|
+
|
62
|
+
def add_yarn_for_gem(gemname)
|
63
|
+
say_status :add_yarn, gemname
|
64
|
+
|
65
|
+
Bundler.reset!
|
66
|
+
available_gems = Bundler.setup Bridgetown::PluginManager::PLUGINS_GROUP
|
67
|
+
Bridgetown::PluginManager.install_yarn_dependencies(
|
68
|
+
available_gems.requested_specs, gemname
|
69
|
+
)
|
70
|
+
rescue SystemExit
|
71
|
+
say_status :add_yarn, "Package not added due to yarn error", :red
|
72
|
+
end
|
73
|
+
|
74
|
+
def apply_from_url(url)
|
75
|
+
apply transform_automation_url(url.dup)
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def determine_remote_filename(arg)
|
81
|
+
if arg.end_with?(".rb")
|
82
|
+
arg.split("/").yield_self do |segments|
|
83
|
+
arg.sub!(%r!/#{segments.last}$!, "")
|
84
|
+
segments.last
|
85
|
+
end
|
86
|
+
else
|
87
|
+
"bridgetown.automation.rb"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# TODO: option to download and confirm remote automation?
|
92
|
+
def transform_automation_url(arg)
|
93
|
+
return arg unless arg.start_with?("http")
|
94
|
+
|
95
|
+
remote_file = determine_remote_filename(arg)
|
96
|
+
|
97
|
+
github_regex = %r!https://github\.com!
|
98
|
+
github_tree_regex = %r!#{github_regex}/.*/.*/tree/.*/?!
|
99
|
+
|
100
|
+
github_match = github_regex.match(arg)
|
101
|
+
github_tree_match = github_tree_regex.match(arg)
|
102
|
+
|
103
|
+
if arg.start_with?("https://gist.github.com")
|
104
|
+
return arg.sub(
|
105
|
+
"https://gist.github.com", "https://gist.githubusercontent.com"
|
106
|
+
) + "/raw/#{remote_file}"
|
107
|
+
elsif github_match
|
108
|
+
new_url = arg.sub(github_regex, "https://raw.githubusercontent.com")
|
109
|
+
|
110
|
+
if github_tree_match
|
111
|
+
new_url = new_url.sub("/tree/", "/")
|
112
|
+
else
|
113
|
+
new_url += "/master"
|
114
|
+
end
|
115
|
+
|
116
|
+
return "#{new_url}/#{remote_file}"
|
117
|
+
end
|
118
|
+
|
119
|
+
arg + "/#{remote_file}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Commands
|
5
|
+
module BuildOptions
|
6
|
+
def self.extended(klass)
|
7
|
+
klass.class_option :trace,
|
8
|
+
type: :boolean,
|
9
|
+
aliases: "-t",
|
10
|
+
desc: "Show the full backtrace when an error occurs during watch mode"
|
11
|
+
|
12
|
+
klass.class_option :config,
|
13
|
+
type: :array,
|
14
|
+
banner: "FILE1 FILE2",
|
15
|
+
desc: "Custom configuration file(s)"
|
16
|
+
klass.class_option :source,
|
17
|
+
aliases: "-s",
|
18
|
+
desc: "Source directory (defaults to src)"
|
19
|
+
klass.class_option :destination,
|
20
|
+
aliases: "-d",
|
21
|
+
desc: "Destination directory (defaults to output)"
|
22
|
+
klass.class_option :root_dir,
|
23
|
+
aliases: "-r",
|
24
|
+
desc: "The top-level root folder" \
|
25
|
+
" where config files are located"
|
26
|
+
klass.class_option :plugins_dir,
|
27
|
+
aliases: "-p",
|
28
|
+
type: :array,
|
29
|
+
banner: "DIR1 DIR2",
|
30
|
+
desc: "Plugins directory (defaults to plugins)"
|
31
|
+
klass.class_option :layouts_dir,
|
32
|
+
desc: "Layouts directory (defaults to src/_layouts)"
|
33
|
+
klass.class_option :future,
|
34
|
+
type: :boolean,
|
35
|
+
desc: "Publishes posts with a future date"
|
36
|
+
klass.class_option :limit_posts,
|
37
|
+
type: :numeric,
|
38
|
+
desc: "Limits the number of posts to parse and publish"
|
39
|
+
klass.class_option :baseurl,
|
40
|
+
aliases: "-b",
|
41
|
+
desc: "Serve the website from the given base URL"
|
42
|
+
klass.class_option :force_polling,
|
43
|
+
type: :boolean,
|
44
|
+
desc: "Force watch to use polling"
|
45
|
+
klass.class_option :lsi,
|
46
|
+
type: :boolean,
|
47
|
+
desc: "Use LSI for improved related posts"
|
48
|
+
klass.class_option :unpublished,
|
49
|
+
type: :boolean,
|
50
|
+
aliases: "-U",
|
51
|
+
desc: "Render posts that were marked as unpublished"
|
52
|
+
klass.class_option :disable_disk_cache,
|
53
|
+
type: :boolean,
|
54
|
+
desc: "Disable caching to disk"
|
55
|
+
klass.class_option :profile,
|
56
|
+
type: :boolean,
|
57
|
+
desc: "Generate a Liquid rendering profile"
|
58
|
+
klass.class_option :quiet,
|
59
|
+
aliases: "-q",
|
60
|
+
type: :boolean,
|
61
|
+
desc: "Silence output."
|
62
|
+
klass.class_option :verbose,
|
63
|
+
aliases: "-V",
|
64
|
+
type: :boolean,
|
65
|
+
desc: "Print verbose output."
|
66
|
+
klass.class_option :incremental,
|
67
|
+
aliases: "-I",
|
68
|
+
type: :boolean,
|
69
|
+
desc: "Enable incremental rebuild."
|
70
|
+
klass.class_option :strict_front_matter,
|
71
|
+
type: :boolean,
|
72
|
+
desc: "Fail if errors are present in front matter"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Commands
|
5
|
+
module ConfigurationOverridable
|
6
|
+
# Create a full Bridgetown configuration with the options passed in as overrides
|
7
|
+
#
|
8
|
+
# options - the configuration overrides
|
9
|
+
#
|
10
|
+
# Returns a full Bridgetown configuration
|
11
|
+
def configuration_with_overrides(options)
|
12
|
+
return options if options.is_a?(Bridgetown::Configuration)
|
13
|
+
|
14
|
+
Bridgetown.configuration(options)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -4,54 +4,61 @@ require "irb"
|
|
4
4
|
|
5
5
|
module Bridgetown
|
6
6
|
module Commands
|
7
|
-
class Console <
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Bridgetown::Commands::Console.process(options)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
7
|
+
class Console < Thor::Group
|
8
|
+
extend Summarizable
|
9
|
+
include ConfigurationOverridable
|
10
|
+
|
11
|
+
Registrations.register do
|
12
|
+
register(Console, "console", "console", Console.summary)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.banner
|
16
|
+
"bridgetown console [options]"
|
17
|
+
end
|
18
|
+
summary "Invoke an IRB console with the site loaded"
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
class_option :config,
|
21
|
+
type: :array,
|
22
|
+
banner: "FILE1 FILE2",
|
23
|
+
desc: "Custom configuration file(s)"
|
24
|
+
class_option :blank,
|
25
|
+
type: :boolean,
|
26
|
+
desc: "Skip reading content and running generators before opening console"
|
27
|
+
|
28
|
+
def console
|
29
|
+
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
30
|
+
" (codename \"#{Bridgetown::CODE_NAME.yellow}\")" \
|
31
|
+
" console…"
|
32
|
+
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
|
33
|
+
site = Bridgetown::Site.new(configuration_with_overrides(options))
|
34
|
+
|
35
|
+
unless options[:blank]
|
32
36
|
site.reset
|
37
|
+
Bridgetown.logger.info "Reading files..."
|
33
38
|
site.read
|
39
|
+
Bridgetown.logger.info "", "done!"
|
40
|
+
Bridgetown.logger.info "Running generators..."
|
34
41
|
site.generate
|
42
|
+
Bridgetown.logger.info "", "done!"
|
43
|
+
end
|
35
44
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
$BRIDGETOWN_SITE = site
|
46
|
+
IRB.setup(nil)
|
47
|
+
workspace = IRB::WorkSpace.new
|
48
|
+
irb = IRB::Irb.new(workspace)
|
49
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
50
|
+
eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
|
51
|
+
Bridgetown.logger.info "Console:", "Now loaded as " + "site".cyan + " variable."
|
43
52
|
|
44
|
-
|
45
|
-
|
46
|
-
|
53
|
+
trap("SIGINT") do
|
54
|
+
irb.signal_handle
|
55
|
+
end
|
47
56
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
57
|
+
begin
|
58
|
+
catch(:IRB_EXIT) do
|
59
|
+
irb.eval_input
|
52
60
|
end
|
53
61
|
end
|
54
|
-
# rubocop:enable Style/GlobalVars, Metrics/AbcSize, Metrics/MethodLength
|
55
62
|
end
|
56
63
|
end
|
57
64
|
end
|
@@ -2,161 +2,160 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
module Commands
|
5
|
-
class Doctor <
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
c.syntax "doctor"
|
10
|
-
c.description "Search site and print specific deprecation warnings"
|
11
|
-
|
12
|
-
c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
|
13
|
-
"Custom configuration file"
|
14
|
-
|
15
|
-
c.action do |_, options|
|
16
|
-
Bridgetown::Commands::Doctor.process(options)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
5
|
+
class Doctor < Thor::Group
|
6
|
+
extend BuildOptions
|
7
|
+
extend Summarizable
|
8
|
+
include ConfigurationOverridable
|
20
9
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
site.read
|
25
|
-
site.generate
|
10
|
+
Registrations.register do
|
11
|
+
register(Doctor, "doctor", "doctor", Doctor.summary)
|
12
|
+
end
|
26
13
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
14
|
+
def self.banner
|
15
|
+
"bridgetown doctor [options]"
|
16
|
+
end
|
17
|
+
summary "Search site and print specific deprecation warnings"
|
18
|
+
|
19
|
+
def doctor
|
20
|
+
site = Bridgetown::Site.new(configuration_with_overrides(options))
|
21
|
+
site.reset
|
22
|
+
site.read
|
23
|
+
site.generate
|
24
|
+
|
25
|
+
if healthy?(site)
|
26
|
+
Bridgetown.logger.info "Your test results", "are in. Everything looks fine."
|
27
|
+
else
|
28
|
+
abort
|
32
29
|
end
|
30
|
+
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
32
|
+
protected
|
33
|
+
|
34
|
+
def healthy?(site)
|
35
|
+
[
|
36
|
+
fsnotify_buggy?(site),
|
37
|
+
!conflicting_urls(site),
|
38
|
+
!urls_only_differ_by_case(site),
|
39
|
+
proper_site_url?(site),
|
40
|
+
properly_gathered_posts?(site),
|
41
|
+
].all?
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
def properly_gathered_posts?(site)
|
45
|
+
return true if site.config["collections_dir"].empty?
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
posts_at_root = site.in_source_dir("_posts")
|
48
|
+
return true unless File.directory?(posts_at_root)
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
Bridgetown.logger.warn "Warning:",
|
51
|
+
"Detected '_posts' directory outside custom `collections_dir`!"
|
52
|
+
Bridgetown.logger.warn "",
|
53
|
+
"Please move '#{posts_at_root}' into the custom directory at " \
|
54
|
+
"'#{site.in_source_dir(site.config["collections_dir"])}'"
|
55
|
+
false
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
70
|
-
conflicting_urls
|
58
|
+
def conflicting_urls(site)
|
59
|
+
conflicting_urls = false
|
60
|
+
urls = {}
|
61
|
+
urls = collect_urls(urls, site.pages, site.dest)
|
62
|
+
urls = collect_urls(urls, site.posts.docs, site.dest)
|
63
|
+
urls.each do |url, paths|
|
64
|
+
next unless paths.size > 1
|
65
|
+
|
66
|
+
conflicting_urls = true
|
67
|
+
Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
|
68
|
+
" for the following pages: #{paths.join(", ")}"
|
71
69
|
end
|
70
|
+
conflicting_urls
|
71
|
+
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if Dir.pwd != `pwd`.strip
|
77
|
-
Bridgetown.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
|
78
|
-
We have detected that there might be trouble using fsevent on your
|
79
|
-
operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
|
80
|
-
for possible work arounds or you can work around it immediately
|
81
|
-
with `--force-polling`.
|
82
|
-
STR
|
73
|
+
def fsnotify_buggy?(_site)
|
74
|
+
return true unless Utils::Platforms.osx?
|
83
75
|
|
84
|
-
|
85
|
-
|
76
|
+
if Dir.pwd != `pwd`.strip
|
77
|
+
Bridgetown.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
|
78
|
+
We have detected that there might be trouble using fsevent on your
|
79
|
+
operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
|
80
|
+
for possible work arounds or you can work around it immediately
|
81
|
+
with `--force-polling`.
|
82
|
+
STR
|
86
83
|
|
87
|
-
|
84
|
+
false
|
88
85
|
end
|
89
86
|
|
90
|
-
|
91
|
-
|
92
|
-
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
|
93
|
-
urls.each_value do |real_urls|
|
94
|
-
next unless real_urls.uniq.size > 1
|
87
|
+
true
|
88
|
+
end
|
95
89
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
urls_only_differ_by_case
|
102
|
-
end
|
90
|
+
def urls_only_differ_by_case(site)
|
91
|
+
urls_only_differ_by_case = false
|
92
|
+
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
|
93
|
+
urls.each_value do |real_urls|
|
94
|
+
next unless real_urls.uniq.size > 1
|
103
95
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
url_valid?(url),
|
109
|
-
url_absolute(url),
|
110
|
-
].all?
|
96
|
+
urls_only_differ_by_case = true
|
97
|
+
Bridgetown.logger.warn "Warning:", "The following URLs only differ" \
|
98
|
+
" by case. On a case-insensitive file system one of the URLs" \
|
99
|
+
" will be overwritten by the other: #{real_urls.join(", ")}"
|
111
100
|
end
|
101
|
+
urls_only_differ_by_case
|
102
|
+
end
|
112
103
|
|
113
|
-
|
104
|
+
def proper_site_url?(site)
|
105
|
+
url = site.config["url"]
|
106
|
+
[
|
107
|
+
url_exists?(url),
|
108
|
+
url_valid?(url),
|
109
|
+
url_absolute(url),
|
110
|
+
].all?
|
111
|
+
end
|
114
112
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
113
|
+
private
|
114
|
+
|
115
|
+
def collect_urls(urls, things, destination)
|
116
|
+
things.each do |thing|
|
117
|
+
dest = thing.destination(destination)
|
118
|
+
if urls[dest]
|
119
|
+
urls[dest] << thing.path
|
120
|
+
else
|
121
|
+
urls[dest] = [thing.path]
|
123
122
|
end
|
124
|
-
urls
|
125
123
|
end
|
124
|
+
urls
|
125
|
+
end
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
127
|
+
def case_insensitive_urls(things, destination)
|
128
|
+
things.each_with_object({}) do |thing, memo|
|
129
|
+
dest = thing.destination(destination)
|
130
|
+
(memo[dest.downcase] ||= []) << dest
|
132
131
|
end
|
132
|
+
end
|
133
133
|
|
134
|
-
|
135
|
-
|
134
|
+
def url_exists?(url)
|
135
|
+
return true unless url.nil? || url.empty?
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, "\
|
138
|
+
"you may encounter problems with some plugins."
|
139
|
+
false
|
140
|
+
end
|
141
141
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
142
|
+
def url_valid?(url)
|
143
|
+
Addressable::URI.parse(url)
|
144
|
+
true
|
145
|
+
# Addressable::URI#parse only raises a TypeError
|
146
|
+
# https://git.io/vFfbx
|
147
|
+
rescue TypeError
|
148
|
+
Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, "\
|
149
|
+
"check the value of `url` in your config file."
|
150
|
+
false
|
151
|
+
end
|
152
152
|
|
153
|
-
|
154
|
-
|
153
|
+
def url_absolute(url)
|
154
|
+
return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
end
|
156
|
+
Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
|
157
|
+
"check the value of `url` in your config file."
|
158
|
+
false
|
160
159
|
end
|
161
160
|
end
|
162
161
|
end
|