bridgetown-core 0.14.1 → 0.15.0

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +3 -1
  3. data/bin/bridgetown +9 -23
  4. data/bridgetown-core.gemspec +3 -1
  5. data/lib/bridgetown-core.rb +9 -2
  6. data/lib/bridgetown-core/commands/apply.rb +73 -0
  7. data/lib/bridgetown-core/commands/base.rb +45 -0
  8. data/lib/bridgetown-core/commands/build.rb +91 -86
  9. data/lib/bridgetown-core/commands/clean.rb +30 -29
  10. data/lib/bridgetown-core/commands/concerns/actions.rb +128 -0
  11. data/lib/bridgetown-core/commands/concerns/build_options.rb +76 -0
  12. data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +18 -0
  13. data/lib/bridgetown-core/commands/concerns/summarizable.rb +13 -0
  14. data/lib/bridgetown-core/commands/console.rb +57 -39
  15. data/lib/bridgetown-core/commands/doctor.rb +126 -126
  16. data/lib/bridgetown-core/commands/new.rb +120 -155
  17. data/lib/bridgetown-core/commands/plugins.rb +167 -130
  18. data/lib/bridgetown-core/commands/registrations.rb +16 -0
  19. data/lib/bridgetown-core/commands/serve.rb +219 -215
  20. data/lib/bridgetown-core/concerns/convertible.rb +1 -4
  21. data/lib/bridgetown-core/concerns/site/renderable.rb +1 -2
  22. data/lib/bridgetown-core/drops/document_drop.rb +9 -1
  23. data/lib/bridgetown-core/drops/page_drop.rb +1 -1
  24. data/lib/bridgetown-core/excerpt.rb +4 -1
  25. data/lib/bridgetown-core/generators/prototype_generator.rb +2 -0
  26. data/lib/bridgetown-core/liquid_renderer.rb +1 -0
  27. data/lib/bridgetown-core/liquid_renderer/file.rb +1 -4
  28. data/lib/bridgetown-core/liquid_renderer/file_system.rb +3 -1
  29. data/lib/bridgetown-core/page.rb +3 -18
  30. data/lib/bridgetown-core/plugin_manager.rb +31 -17
  31. data/lib/bridgetown-core/renderer.rb +31 -18
  32. data/lib/bridgetown-core/tags/include.rb +14 -0
  33. data/lib/bridgetown-core/tags/render_content.rb +39 -16
  34. data/lib/bridgetown-core/tags/with.rb +15 -0
  35. data/lib/bridgetown-core/utils.rb +44 -0
  36. data/lib/bridgetown-core/version.rb +2 -2
  37. data/lib/bridgetown-core/watcher.rb +17 -10
  38. data/lib/site_template/Gemfile.erb +19 -0
  39. data/lib/site_template/bridgetown.config.yml +5 -3
  40. data/lib/site_template/package.json +1 -0
  41. data/lib/site_template/src/_components/footer.liquid +3 -0
  42. data/lib/site_template/src/_components/head.liquid +9 -0
  43. data/lib/site_template/src/{_includes/navbar.html → _components/navbar.liquid} +0 -0
  44. data/lib/site_template/src/_layouts/default.html +3 -3
  45. data/lib/site_template/start.js +1 -1
  46. data/lib/site_template/webpack.config.js +3 -3
  47. metadata +53 -19
  48. data/lib/bridgetown-core/command.rb +0 -112
  49. data/lib/bridgetown-core/commands/help.rb +0 -34
  50. data/lib/site_template/src/_components/.keep +0 -0
  51. data/lib/site_template/src/_includes/footer.html +0 -3
  52. 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 < Command
6
- class << self
7
- def init_with_program(prog)
8
- prog.command(:clean) do |c|
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
- add_build_options(c)
10
+ Registrations.register do
11
+ register(Clean, "clean", "clean", Clean.summary)
12
+ end
14
13
 
15
- c.action do |_, options|
16
- Bridgetown::Commands::Clean.process(options)
17
- end
18
- end
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
- def process(options)
22
- options = configuration_from_options(options)
23
- destination = options["destination"]
24
- metadata_file = File.join(options["source"], ".bridgetown-metadata")
25
- cache_dir = File.join(options["source"], options["cache_dir"])
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
- remove(destination, checker_func: :directory?)
28
- remove(metadata_file, checker_func: :file?)
29
- remove(cache_dir, checker_func: :directory?)
30
- end
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
- def remove(filename, checker_func: :file?)
33
- if File.public_send(checker_func, filename)
34
- Bridgetown.logger.info "Cleaner:", "Removing #{filename}..."
35
- FileUtils.rm_rf(filename)
36
- else
37
- Bridgetown.logger.info "Cleaner:", "Nothing to do for #{filename}."
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,128 @@
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
+ GITHUB_REGEX = %r!https://github\.com!.freeze
12
+ GITHUB_TREE_REGEX = %r!#{GITHUB_REGEX}/.*/.*/tree/.*/?!.freeze
13
+ GITHUB_BLOB_REGEX = %r!#{GITHUB_REGEX}/.*/.*/blob/!.freeze
14
+
15
+ def create_builder(filename, data = nil)
16
+ say_status :create_builder, filename
17
+ data ||= yield if block_given?
18
+
19
+ site_builder = File.join("plugins", "site_builder.rb")
20
+ unless File.exist?(site_builder)
21
+ create_file("plugins/site_builder.rb", verbose: true) do
22
+ <<~RUBY
23
+ class SiteBuilder < Bridgetown::Builder
24
+ end
25
+ RUBY
26
+ end
27
+ end
28
+
29
+ create_file("plugins/builders/#{filename}", data, verbose: false)
30
+ end
31
+
32
+ def javascript_import(data = nil, filename: "index.js")
33
+ data ||= yield if block_given?
34
+ data += "\n" unless data.chars.last == "\n"
35
+
36
+ say_status :javascript_import, filename
37
+
38
+ js_index = File.join("frontend", "javascript", filename)
39
+ if File.exist?(js_index)
40
+ index_file = File.read(js_index)
41
+
42
+ last_import = ""
43
+ index_file.each_line do |line|
44
+ line.start_with?("import ") ? last_import = line : break
45
+ end
46
+
47
+ if last_import == ""
48
+ # add to top of file
49
+ prepend_file js_index, data, verbose: false
50
+ else
51
+ # inject after the last import line
52
+ inject_into_file js_index, data, after: last_import, verbose: false, force: false
53
+ end
54
+ else
55
+ create_file(js_index, data, verbose: false)
56
+ end
57
+ end
58
+
59
+ def add_bridgetown_plugin(gemname, version: nil)
60
+ version = " -v \"#{version}\"" if version
61
+ run "bundle add #{gemname}#{version} -g bridgetown_plugins"
62
+ rescue SystemExit
63
+ say_status :run, "Gem not added due to bundler error", :red
64
+ end
65
+
66
+ def add_yarn_for_gem(gemname)
67
+ say_status :add_yarn, gemname
68
+
69
+ Bundler.reset!
70
+ available_gems = Bundler.setup Bridgetown::PluginManager::PLUGINS_GROUP
71
+ Bridgetown::PluginManager.install_yarn_dependencies(
72
+ available_gems.requested_specs, gemname
73
+ )
74
+ rescue SystemExit
75
+ say_status :add_yarn, "Package not added due to yarn error", :red
76
+ end
77
+
78
+ def apply_from_url(url)
79
+ apply transform_automation_url(url.dup)
80
+ end
81
+
82
+ private
83
+
84
+ def determine_remote_filename(arg)
85
+ if arg.end_with?(".rb")
86
+ arg.split("/").yield_self do |segments|
87
+ arg.sub!(%r!/#{segments.last}$!, "")
88
+ segments.last
89
+ end
90
+ else
91
+ "bridgetown.automation.rb"
92
+ end
93
+ end
94
+
95
+ # TODO: option to download and confirm remote automation?
96
+ # rubocop:disable Metrics/MethodLength
97
+ def transform_automation_url(arg)
98
+ return arg unless arg.start_with?("http")
99
+
100
+ remote_file = determine_remote_filename(arg)
101
+ github_match = GITHUB_REGEX.match(arg)
102
+
103
+ arg = if arg.start_with?("https://gist.github.com")
104
+ arg.sub(
105
+ "https://gist.github.com", "https://gist.githubusercontent.com"
106
+ ) + "/raw"
107
+ elsif github_match
108
+ new_url = arg.sub(GITHUB_REGEX, "https://raw.githubusercontent.com")
109
+ github_tree_match = GITHUB_TREE_REGEX.match(arg)
110
+ github_blob_match = GITHUB_BLOB_REGEX.match(arg)
111
+
112
+ if github_tree_match
113
+ new_url.sub("/tree/", "/")
114
+ elsif github_blob_match
115
+ new_url.sub("/blob/", "/")
116
+ else
117
+ "#{new_url}/master"
118
+ end
119
+ else
120
+ arg
121
+ end
122
+
123
+ "#{arg}/#{remote_file}"
124
+ end
125
+ # rubocop:enable Metrics/MethodLength
126
+ end
127
+ end
128
+ 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
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Commands
5
+ module Summarizable
6
+ def summary(description = nil)
7
+ return @desc.split("\n").last.strip unless description
8
+
9
+ desc "Description:\n #{description}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,56 +1,74 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "irb"
4
-
5
3
  module Bridgetown
6
4
  module Commands
7
- class Console < Command
8
- class << self
9
- def init_with_program(prog)
10
- prog.command(:console) do |c|
11
- c.syntax "console"
12
- c.description "Invoke an IRB console with the site loaded"
13
- c.alias :c
14
-
15
- add_build_options(c)
16
-
17
- c.action do |_, options|
18
- Bridgetown::Commands::Console.process(options)
19
- end
20
- end
21
- end
5
+ class Console < Thor::Group
6
+ extend Summarizable
7
+ include ConfigurationOverridable
8
+
9
+ Registrations.register do
10
+ register(Console, "console", "console", Console.summary)
11
+ end
12
+
13
+ def self.banner
14
+ "bridgetown console [options]"
15
+ end
16
+ summary "Invoke an IRB console with the site loaded"
17
+
18
+ class_option :config,
19
+ type: :array,
20
+ banner: "FILE1 FILE2",
21
+ desc: "Custom configuration file(s)"
22
+ class_option :"bypass-ap",
23
+ type: :boolean,
24
+ desc: "Don't load AwesomePrint when IRB opens"
25
+ class_option :blank,
26
+ type: :boolean,
27
+ desc: "Skip reading content and running generators before opening console"
28
+
29
+ def console
30
+ require "irb"
31
+ require "awesome_print" unless options[:"bypass-ap"]
32
+
33
+ Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
34
+ " (codename \"#{Bridgetown::CODE_NAME.yellow}\")" \
35
+ " console…"
36
+ Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
37
+ site = Bridgetown::Site.new(configuration_with_overrides(options))
22
38
 
23
- # TODO: is there a way to add a unit test for this command?
24
- # rubocop:disable Style/GlobalVars, Metrics/AbcSize, Metrics/MethodLength
25
- def process(options)
26
- Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
27
- " (codename \"#{Bridgetown::CODE_NAME.yellow}\")" \
28
- " console…"
29
- Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
30
- site = Bridgetown::Site.new(configuration_from_options(options))
39
+ unless options[:blank]
31
40
  site.reset
41
+ Bridgetown.logger.info "Reading files..."
32
42
  site.read
43
+ Bridgetown.logger.info "", "done!"
44
+ Bridgetown.logger.info "Running generators..."
33
45
  site.generate
46
+ Bridgetown.logger.info "", "done!"
47
+ end
34
48
 
35
- $BRIDGETOWN_SITE = site
36
- IRB.setup(nil)
37
- workspace = IRB::WorkSpace.new
38
- irb = IRB::Irb.new(workspace)
39
- IRB.conf[:MAIN_CONTEXT] = irb.context
40
- eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
41
- Bridgetown.logger.info "Console:", "Now loaded as " + "site".cyan + " variable."
49
+ $BRIDGETOWN_SITE = site
50
+ IRB.setup(nil)
51
+ workspace = IRB::WorkSpace.new
52
+ irb = IRB::Irb.new(workspace)
53
+ IRB.conf[:MAIN_CONTEXT] = irb.context
54
+ eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
55
+ Bridgetown.logger.info "Console:", "Now loaded as " + "site".cyan + " variable."
42
56
 
43
- trap("SIGINT") do
44
- irb.signal_handle
45
- end
57
+ trap("SIGINT") do
58
+ irb.signal_handle
59
+ end
46
60
 
47
- begin
48
- catch(:IRB_EXIT) do
49
- irb.eval_input
61
+ begin
62
+ catch(:IRB_EXIT) do
63
+ unless options[:"bypass-ap"]
64
+ AwesomePrint.defaults = {
65
+ indent: 2,
66
+ }
67
+ AwesomePrint.irb!
50
68
  end
69
+ irb.eval_input
51
70
  end
52
71
  end
53
- # rubocop:enable Style/GlobalVars, Metrics/AbcSize, Metrics/MethodLength
54
72
  end
55
73
  end
56
74
  end
@@ -2,160 +2,160 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Commands
5
- class Doctor < Command
6
- class << self
7
- def init_with_program(prog)
8
- prog.command(:doctor) do |c|
9
- c.syntax "doctor"
10
- c.description "Search site and print specific deprecation warnings"
11
-
12
- add_build_options(c)
13
-
14
- c.action do |_, options|
15
- Bridgetown::Commands::Doctor.process(options)
16
- end
17
- end
18
- end
5
+ class Doctor < Thor::Group
6
+ extend BuildOptions
7
+ extend Summarizable
8
+ include ConfigurationOverridable
19
9
 
20
- def process(options)
21
- site = Bridgetown::Site.new(configuration_from_options(options))
22
- site.reset
23
- site.read
24
- site.generate
10
+ Registrations.register do
11
+ register(Doctor, "doctor", "doctor", Doctor.summary)
12
+ end
25
13
 
26
- if healthy?(site)
27
- Bridgetown.logger.info "Your test results", "are in. Everything looks fine."
28
- else
29
- abort
30
- end
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
31
29
  end
30
+ end
32
31
 
33
- def healthy?(site)
34
- [
35
- fsnotify_buggy?(site),
36
- !conflicting_urls(site),
37
- !urls_only_differ_by_case(site),
38
- proper_site_url?(site),
39
- properly_gathered_posts?(site),
40
- ].all?
41
- end
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
42
43
 
43
- def properly_gathered_posts?(site)
44
- return true if site.config["collections_dir"].empty?
44
+ def properly_gathered_posts?(site)
45
+ return true if site.config["collections_dir"].empty?
45
46
 
46
- posts_at_root = site.in_source_dir("_posts")
47
- return true unless File.directory?(posts_at_root)
47
+ posts_at_root = site.in_source_dir("_posts")
48
+ return true unless File.directory?(posts_at_root)
48
49
 
49
- Bridgetown.logger.warn "Warning:",
50
- "Detected '_posts' directory outside custom `collections_dir`!"
51
- Bridgetown.logger.warn "",
52
- "Please move '#{posts_at_root}' into the custom directory at " \
53
- "'#{site.in_source_dir(site.config["collections_dir"])}'"
54
- false
55
- end
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
56
57
 
57
- def conflicting_urls(site)
58
- conflicting_urls = false
59
- urls = {}
60
- urls = collect_urls(urls, site.pages, site.dest)
61
- urls = collect_urls(urls, site.posts.docs, site.dest)
62
- urls.each do |url, paths|
63
- next unless paths.size > 1
64
-
65
- conflicting_urls = true
66
- Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
67
- " for the following pages: #{paths.join(", ")}"
68
- end
69
- 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(", ")}"
70
69
  end
70
+ conflicting_urls
71
+ end
71
72
 
72
- def fsnotify_buggy?(_site)
73
- return true unless Utils::Platforms.osx?
74
-
75
- if Dir.pwd != `pwd`.strip
76
- Bridgetown.logger.error " " + <<-STR.strip.gsub(%r!\n\s+!, "\n ")
77
- We have detected that there might be trouble using fsevent on your
78
- operating system, you can read https://github.com/thibaudgg/rb-fsevent/wiki/no-fsevents-fired-(OSX-bug)
79
- for possible work arounds or you can work around it immediately
80
- with `--force-polling`.
81
- STR
73
+ def fsnotify_buggy?(_site)
74
+ return true unless Utils::Platforms.osx?
82
75
 
83
- false
84
- end
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
85
83
 
86
- true
84
+ false
87
85
  end
88
86
 
89
- def urls_only_differ_by_case(site)
90
- urls_only_differ_by_case = false
91
- urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
92
- urls.each_value do |real_urls|
93
- next unless real_urls.uniq.size > 1
87
+ true
88
+ end
94
89
 
95
- urls_only_differ_by_case = true
96
- Bridgetown.logger.warn "Warning:", "The following URLs only differ" \
97
- " by case. On a case-insensitive file system one of the URLs" \
98
- " will be overwritten by the other: #{real_urls.join(", ")}"
99
- end
100
- urls_only_differ_by_case
101
- 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
102
95
 
103
- def proper_site_url?(site)
104
- url = site.config["url"]
105
- [
106
- url_exists?(url),
107
- url_valid?(url),
108
- url_absolute(url),
109
- ].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(", ")}"
110
100
  end
101
+ urls_only_differ_by_case
102
+ end
111
103
 
112
- private
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
113
112
 
114
- def collect_urls(urls, things, destination)
115
- things.each do |thing|
116
- dest = thing.destination(destination)
117
- if urls[dest]
118
- urls[dest] << thing.path
119
- else
120
- urls[dest] = [thing.path]
121
- end
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]
122
122
  end
123
- urls
124
123
  end
124
+ urls
125
+ end
125
126
 
126
- def case_insensitive_urls(things, destination)
127
- things.each_with_object({}) do |thing, memo|
128
- dest = thing.destination(destination)
129
- (memo[dest.downcase] ||= []) << dest
130
- 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
131
131
  end
132
+ end
132
133
 
133
- def url_exists?(url)
134
- return true unless url.nil? || url.empty?
134
+ def url_exists?(url)
135
+ return true unless url.nil? || url.empty?
135
136
 
136
- Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, "\
137
- "you may encounter problems with some plugins."
138
- false
139
- end
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
140
141
 
141
- def url_valid?(url)
142
- Addressable::URI.parse(url)
143
- true
144
- # Addressable::URI#parse only raises a TypeError
145
- # https://git.io/vFfbx
146
- rescue TypeError
147
- Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, "\
148
- "check the value of `url` in your config file."
149
- false
150
- end
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
151
152
 
152
- def url_absolute(url)
153
- return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
153
+ def url_absolute(url)
154
+ return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
154
155
 
155
- Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
156
- "check the value of `url` in your config file."
157
- false
158
- 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
159
159
  end
160
160
  end
161
161
  end