bunto 3.2.1 → 3.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +21 -4
  3. data/LICENSE +1 -1
  4. data/README.markdown +20 -25
  5. data/exe/bunto +1 -1
  6. data/lib/bunto.rb +10 -4
  7. data/lib/bunto/collection.rb +11 -4
  8. data/lib/bunto/commands/build.rb +17 -2
  9. data/lib/bunto/commands/doctor.rb +1 -1
  10. data/lib/bunto/commands/new.rb +35 -5
  11. data/lib/bunto/commands/new_theme.rb +4 -2
  12. data/lib/bunto/commands/serve.rb +45 -15
  13. data/lib/bunto/commands/serve/servlet.rb +1 -1
  14. data/lib/bunto/configuration.rb +9 -7
  15. data/lib/bunto/converters/markdown/kramdown_parser.rb +2 -2
  16. data/lib/bunto/converters/markdown/redcarpet_parser.rb +1 -1
  17. data/lib/bunto/convertible.rb +21 -82
  18. data/lib/bunto/desktop.ini +1 -1
  19. data/lib/bunto/document.rb +118 -81
  20. data/lib/bunto/drops/bunto_drop.rb +1 -1
  21. data/lib/bunto/drops/static_file_drop.rb +11 -0
  22. data/lib/bunto/drops/url_drop.rb +5 -0
  23. data/lib/bunto/entry_filter.rb +9 -10
  24. data/lib/bunto/excerpt.rb +2 -3
  25. data/lib/bunto/external.rb +1 -1
  26. data/lib/bunto/filters.rb +10 -32
  27. data/lib/bunto/filters/grouping_filters.rb +63 -0
  28. data/lib/bunto/filters/url_filters.rb +40 -0
  29. data/lib/bunto/frontmatter_defaults.rb +1 -1
  30. data/lib/bunto/hooks.rb +9 -9
  31. data/lib/bunto/log_adapter.rb +1 -1
  32. data/lib/bunto/page.rb +8 -4
  33. data/lib/bunto/plugin.rb +1 -1
  34. data/lib/bunto/reader.rb +2 -1
  35. data/lib/bunto/readers/data_reader.rb +9 -10
  36. data/lib/bunto/readers/post_reader.rb +1 -1
  37. data/lib/bunto/readers/theme_assets_reader.rb +47 -0
  38. data/lib/bunto/regenerator.rb +1 -1
  39. data/lib/bunto/related_posts.rb +3 -9
  40. data/lib/bunto/renderer.rb +26 -6
  41. data/lib/bunto/site.rb +12 -7
  42. data/lib/bunto/static_file.rb +20 -9
  43. data/lib/bunto/tags/highlight.rb +3 -3
  44. data/lib/bunto/tags/include.rb +9 -5
  45. data/lib/bunto/tags/link.rb +4 -2
  46. data/lib/bunto/tags/post_url.rb +4 -2
  47. data/lib/bunto/theme.rb +8 -4
  48. data/lib/bunto/theme_builder.rb +2 -2
  49. data/lib/bunto/url.rb +31 -8
  50. data/lib/bunto/utils.rb +16 -2
  51. data/lib/bunto/utils/ansi.rb +1 -1
  52. data/lib/bunto/utils/exec.rb +25 -0
  53. data/lib/bunto/utils/platforms.rb +52 -2
  54. data/lib/bunto/utils/win_tz.rb +73 -0
  55. data/lib/bunto/version.rb +1 -1
  56. data/lib/site_template/_config.yml +8 -3
  57. data/lib/site_template/_posts/0000-00-00-welcome-to-bunto.markdown.erb +4 -4
  58. data/lib/site_template/about.md +1 -1
  59. data/lib/site_template/index.md +6 -0
  60. data/lib/theme_template/LICENSE.txt.erb +1 -1
  61. data/lib/theme_template/README.md.erb +4 -4
  62. data/lib/theme_template/gitignore.erb +1 -0
  63. data/lib/theme_template/theme.gemspec.erb +3 -2
  64. metadata +55 -40
  65. data/lib/site_template/css/main.scss +0 -39
  66. data/lib/site_template/feed.xml +0 -30
  67. data/lib/site_template/index.html +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b6a72b2c296e0ff7b771f3c59f5323253e692a4
4
- data.tar.gz: 74867fde8fc979a13b377bffdd737c9587eada07
3
+ metadata.gz: fc4d2fd1daf376ef5b227a641d9cfae478c88ccf
4
+ data.tar.gz: 3a52c08ff2176c9e6ccc01dd1a7e40da4cf73bfb
5
5
  SHA512:
6
- metadata.gz: 139c2359381a93813449163d1858c9a1647dfa3ea11d60d6681e57a1915c641c57ac0b1406762e2ab55afa0bb5082be60aa139ab6414578eabb0db1bc5264329
7
- data.tar.gz: a2bc45dc264572fe426cfd5cf1d2cd12342c12e2ae162a5a93b8cde1c9e2ce2480cbd7b2634fc707da10876313dc1f09ebecdf93b7495ee76463311a595a8bd6
6
+ metadata.gz: bc89a21c76795154d7bf53188ea374fa5afdc70d63b4fd900fa063f8d9d49edeea41c18f186dcb2075afbb92241efc2735c723120c3e25b3bfa2b6ecfb7b855f
7
+ data.tar.gz: 82ef4cb32b2be7bd8f9c93083f57b3f50b5340c581c2b3bbd4fa31444d3861a625bea8ebf3d01ca90f9af18e60f34a7e0d922cd8dd28c520ed6b068273c5f9b9
@@ -4,10 +4,9 @@ AllCops:
4
4
  Include:
5
5
  - lib/**/*.rb
6
6
  Exclude:
7
- - lib/bunto/convertible.rb
8
- - lib/bunto/document.rb
9
7
  - lib/bunto/renderer.rb
10
8
  - bin/**/*
9
+ - exe/**/*
11
10
  - benchmark/**/*
12
11
  - script/**/*
13
12
  - vendor/**/*
@@ -18,17 +17,25 @@ Lint/UnreachableCode:
18
17
  Lint/UselessAccessModifier:
19
18
  Enabled: false
20
19
  Metrics/AbcSize:
21
- Max: 20
20
+ Max: 21
21
+ Metrics/BlockLength:
22
+ Exclude:
23
+ - test/**/*.rb
24
+ - lib/bunto/configuration.rb
25
+ - rake/*.rake
26
+ - bunto.gemspec
22
27
  Metrics/ClassLength:
23
28
  Exclude:
24
29
  - !ruby/regexp /features\/.*.rb$/
25
30
  - !ruby/regexp /test\/.*.rb$/
26
31
  Max: 300
27
32
  Metrics/CyclomaticComplexity:
28
- Max: 8
33
+ Max: 9
29
34
  Metrics/LineLength:
30
35
  Exclude:
31
36
  - !ruby/regexp /features\/.*.rb/
37
+ - Rakefile
38
+ - rake/*.rake
32
39
  Max: 90
33
40
  Severity: warning
34
41
  Metrics/MethodLength:
@@ -41,6 +48,14 @@ Metrics/ParameterLists:
41
48
  Max: 4
42
49
  Metrics/PerceivedComplexity:
43
50
  Max: 8
51
+ Security/MarshalLoad:
52
+ Exclude:
53
+ - !ruby/regexp /test\/.*.rb$/
54
+ - lib/bunto/regenerator.rb
55
+ Security/YAMLLoad:
56
+ Exclude:
57
+ - !ruby/regexp /features\/.*.rb/
58
+ - !ruby/regexp /test\/.*.rb$/
44
59
  Style/Alias:
45
60
  Enabled: false
46
61
  Style/AlignArray:
@@ -124,5 +139,7 @@ Style/StringLiterals:
124
139
  EnforcedStyle: double_quotes
125
140
  Style/StringLiteralsInInterpolation:
126
141
  EnforcedStyle: double_quotes
142
+ Style/TrailingCommaInLiteral:
143
+ EnforcedStyleForMultiline: consistent_comma
127
144
  Style/UnneededCapitalW:
128
145
  Enabled: false
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-present Suriyaa Kudo
3
+ Copyright (c) 2014-present Suriyaa Kudo and Bunto contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -11,6 +11,7 @@
11
11
  <th>CodeShip</th>
12
12
  <th>RubyGems</th>
13
13
  <th>Gemnasium</th>
14
+ <th>CLA</th>
14
15
  </tr>
15
16
  </thead>
16
17
  <tbody>
@@ -33,32 +34,32 @@
33
34
  <td align="center">
34
35
  <a href="https://gemnasium.com/bunto/bunto"><img src="https://gemnasium.com/bunto/bunto.svg" alt="Dependency Status"></a>
35
36
  </td>
37
+ <td align="center">
38
+ <a href="https://gist.github.com/f76d4854fb196820325ee8a5072a5722"><img src="https://cla-assistant.io/readme/badge/bunto/bunto" alt="CLA assistant"></a>
39
+ </td>
36
40
  </tr>
37
41
  </tbody>
38
42
  </table>
39
43
 
40
44
  By Suriyaa Kudo, Tom Preston-Werner, Parker Moore and many [awesome contributors](https://github.com/bunto/bunto/graphs/contributors)!
41
45
 
42
- Bunto is a Web Application Framework and can be used as a static site generator perfect for personal, project, or organization sites. Think of it like a file-based CMS, without all the complexity. Bunto takes your content, renders HTML and CSS templates, and spits out a complete, static website ready to be served by Apache, hostSE, Nginx or another web server. Bunto is the engine behind [GitHub Pages](https://pages.github.com), which you can use to host sites right from your GitHub repositories.
46
+ Bunto is a Web Application Framework and can be used as a simple, blog-aware, static site generator perfect for personal, project, or organization sites. Think of it like a file-based CMS, without all the complexity. Bunto takes your content, renders Markdown and Liquid templates, and spits out a complete, static website ready to be served by Apache, Nginx or another web server. Bunto is the engine behind [GitHub Pages](https://pages.github.com), which you can use to host sites right from your GitHub repositories.
43
47
 
44
48
  ## Philosophy
45
49
 
46
- Bunto does what you tell it to do — no more, no less. It doesn't try to outsmart users by making bold assumptions, nor does it burden them with needless complexity and configuration. Put simply, Bunto gets out of your way and allows you to concentrate on what truly matters: your content.
50
+ Bunto does what you tell it to do — no more, no less. It doesn't try to outsmart users by making bold assumptions, nor does it burden them with needless complexity and configuration. Put simply, Bunto gets out of your way and allows you to concentrate on what truly matters: your content.
47
51
 
48
- ## Getting Started
52
+ ## Having trouble with OS X El Capitan?
49
53
 
50
- Bunto will work on most systems out-of-the-box. You need only to install [RubyGems](https://rubygems.org/pages/download) on your system.
51
- After that run in your command line program this command:
54
+ See: https://buntowaf.tk/docs/troubleshooting/#bunto-amp-mac-os-x-1011
52
55
 
53
- ``` bash
54
- gem install bunto
55
- ```
56
+ ## Getting Started
56
57
 
57
- * [Install](https://bunto.github.io/docs/installation/) the gem
58
- * Read up about its [Usage](https://bunto.github.io/docs/usage/) and [Configuration](https://bunto.github.io/docs/configuration/)
58
+ * [Install](https://buntowaf.tk/docs/installation/) the gem
59
+ * Read up about its [Usage](https://buntowaf.tk/docs/usage/) and [Configuration](https://buntowaf.tk/docs/configuration/)
59
60
  * Take a gander at some existing [Sites](https://wiki.github.com/bunto/bunto/sites)
60
- * [Fork](https://github.com/bunto/bunto/fork) and [Contribute](https://bunto.github.io/docs/contributing/) your own modifications
61
- * Have questions? Check out our official forum community [Bunto Talk](https://bunto.github.io/talk/) or [`#bunto` on irc.freenode.net](https://botbot.me/freenode/bunto/)
61
+ * [Fork](https://github.com/bunto/bunto/fork) and [Contribute](https://buntowaf.tk/docs/contributing/) your own modifications
62
+ * Have questions? Check out our official forum community [Bunto Talk](https://talk.buntowaf.tk/) or [`#bunto` on irc.freenode.net](https://botbot.me/freenode/bunto/)
62
63
 
63
64
  ## Code of Conduct
64
65
 
@@ -69,22 +70,16 @@ conduct.
69
70
  Please adhere to this code of conduct in any interactions you have in the
70
71
  Bunto community. It is strictly enforced on all official Bunto
71
72
  repositories, websites, and resources. If you encounter someone violating
72
- these terms, please let a maintainer ([@SuriyaaKudoIsc](https://github.com/SuriyaaKudoIsc)) know
73
- and we will address it as soon as possible.
73
+ these terms, please let a maintainer ([@parkr](https://github.com/parkr), [@envygeeks](https://github.com/envygeeks), [@mattr-](https://github.com/mattr-), or [@alfredxing](https://github.com/alfredxing)) know and we will address it as soon as possible.
74
74
 
75
75
  ## Diving In
76
76
 
77
- * [Migrate](https://bunto-import.tk/docs/home/) from your previous system
78
- * Learn how the [YAML Front Matter](https://bunto.github.io/docs/frontmatter/) works
79
- * Put information on your site with [Variables](https://bunto.github.io/docs/variables/)
80
- * Customize the [Permalinks](https://bunto.github.io/docs/permalinks/) your posts are generated with
81
- * Use the built-in [Liquid Extensions](https://bunto.github.io/docs/templates/) to make your life easier
82
- * Use custom [Plugins](https://bunto.github.io/docs/plugins/) to generate content specific to your site
83
-
84
- ## Have a problem? Come chat with us!
85
- [![Join the chat at https://gitter.im/bunto/bunto](https://badges.gitter.im/bunto/bunto.svg)](https://gitter.im/bunto/bunto?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
86
- [![IRC - #bunto on freenode WebChat](https://img.shields.io/badge/freenode-bunto-yellowgreen.svg?style=flat)](http://webchat.freenode.net/?channels=bunto)
87
- [<img src="https://upload.wikimedia.org/wikipedia/commons/0/06/Facebook.svg" width="60">](https://www.facebook.com/groups/BuntoWAF)
77
+ * [Migrate](http://import.buntowaf.tk/docs/home/) from your previous system
78
+ * Learn how the [YAML Front Matter](https://buntowaf.tk/docs/frontmatter/) works
79
+ * Put information on your site with [Variables](https://buntowaf.tk/docs/variables/)
80
+ * Customize the [Permalinks](https://buntowaf.tk/docs/permalinks/) your posts are generated with
81
+ * Use the built-in [Liquid Extensions](https://buntowaf.tk/docs/templates/) to make your life easier
82
+ * Use custom [Plugins](https://buntowaf.tk/docs/plugins/) to generate content specific to your site
88
83
 
89
84
  ## License
90
85
 
data/exe/bunto CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  STDOUT.sync = true
3
3
 
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w(.. lib)))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
5
 
6
6
  require "bunto"
7
7
  require "mercenary"
@@ -41,7 +41,6 @@ module Bunto
41
41
  autoload :Convertible, "bunto/convertible"
42
42
  autoload :Deprecator, "bunto/deprecator"
43
43
  autoload :Document, "bunto/document"
44
- autoload :Draft, "bunto/draft"
45
44
  autoload :EntryFilter, "bunto/entry_filter"
46
45
  autoload :Errors, "bunto/errors"
47
46
  autoload :Excerpt, "bunto/excerpt"
@@ -55,6 +54,7 @@ module Bunto
55
54
  autoload :PostReader, "bunto/readers/post_reader"
56
55
  autoload :PageReader, "bunto/readers/page_reader"
57
56
  autoload :StaticFileReader, "bunto/readers/static_file_reader"
57
+ autoload :ThemeAssetsReader, "bunto/readers/theme_assets_reader"
58
58
  autoload :LogAdapter, "bunto/log_adapter"
59
59
  autoload :Page, "bunto/page"
60
60
  autoload :PluginManager, "bunto/plugin_manager"
@@ -119,7 +119,11 @@ module Bunto
119
119
  # Returns nothing
120
120
  # rubocop:disable Style/AccessorMethodName
121
121
  def set_timezone(timezone)
122
- ENV["TZ"] = timezone
122
+ ENV["TZ"] = if Utils::Platforms.really_windows?
123
+ Utils::WinTZ.calculate(timezone)
124
+ else
125
+ timezone
126
+ end
123
127
  end
124
128
  # rubocop:enable Style/AccessorMethodName
125
129
 
@@ -160,11 +164,13 @@ module Bunto
160
164
 
161
165
  questionable_path.insert(0, "/") if questionable_path.start_with?("~")
162
166
  clean_path = File.expand_path(questionable_path, "/")
163
- clean_path.sub!(%r!\A\w:/!, "/")
164
167
 
165
- if clean_path.start_with?(base_directory.sub(%r!\A\w:/!, "/"))
168
+ return clean_path if clean_path.eql?(base_directory)
169
+
170
+ if clean_path.start_with?(base_directory.sub(%r!\z!, "/"))
166
171
  clean_path
167
172
  else
173
+ clean_path.sub!(%r!\A\w:/!, "/")
168
174
  File.join(base_directory, clean_path)
169
175
  end
170
176
  end
@@ -32,8 +32,8 @@ module Bunto
32
32
  # Override of method_missing to check in @data for the key.
33
33
  def method_missing(method, *args, &blck)
34
34
  if docs.respond_to?(method.to_sym)
35
- Bunto.logger.warn "Deprecation:", "#{label}.#{method} should be changed to" \
36
- "#{label}.docs.#{method}."
35
+ Bunto.logger.warn "Deprecation:",
36
+ "#{label}.#{method} should be changed to #{label}.docs.#{method}."
37
37
  Bunto.logger.warn "", "Called by #{caller.first}."
38
38
  docs.public_send(method.to_sym, *args, &blck)
39
39
  else
@@ -197,6 +197,7 @@ module Bunto
197
197
  end
198
198
 
199
199
  private
200
+
200
201
  def read_document(full_path)
201
202
  doc = Bunto::Document.new(full_path, :site => site, :collection => self)
202
203
  doc.read
@@ -208,14 +209,20 @@ module Bunto
208
209
  end
209
210
 
210
211
  private
212
+
211
213
  def read_static_file(file_path, full_path)
212
214
  relative_dir = Bunto.sanitized_path(
213
215
  relative_directory,
214
216
  File.dirname(file_path)
215
217
  ).chomp("/.")
216
218
 
217
- files << StaticFile.new(site, site.source, relative_dir,
218
- File.basename(full_path), self)
219
+ files << StaticFile.new(
220
+ site,
221
+ site.source,
222
+ relative_dir,
223
+ File.basename(full_path),
224
+ self
225
+ )
219
226
  end
220
227
  end
221
228
  end
@@ -71,12 +71,27 @@ module Bunto
71
71
  #
72
72
  # Returns nothing.
73
73
  def watch(site, options)
74
+ # Warn Windows users that they might need to upgrade.
75
+ if Utils::Platforms.bash_on_windows?
76
+ Bunto.logger.warn "",
77
+ "Auto-regeneration may not work on some Windows versions."
78
+ Bunto.logger.warn "",
79
+ "Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
80
+ Bunto.logger.warn "",
81
+ "If it does not work, please upgrade Bash on Windows or "\
82
+ "run Bunto with --no-watch."
83
+ end
84
+
74
85
  External.require_with_graceful_fail "bunto-watch"
75
86
  watch_method = Bunto::Watcher.method(:watch)
76
87
  if watch_method.parameters.size == 1
77
- watch_method.call(options)
88
+ watch_method.call(
89
+ options
90
+ )
78
91
  else
79
- watch_method.call(options, site)
92
+ watch_method.call(
93
+ options, site
94
+ )
80
95
  end
81
96
  end
82
97
  end # end of class << self
@@ -35,7 +35,7 @@ module Bunto
35
35
  fsnotify_buggy?(site),
36
36
  !deprecated_relative_permalinks(site),
37
37
  !conflicting_urls(site),
38
- !urls_only_differ_by_case(site)
38
+ !urls_only_differ_by_case(site),
39
39
  ].all?
40
40
  end
41
41
 
@@ -11,6 +11,7 @@ module Bunto
11
11
 
12
12
  c.option "force", "--force", "Force creation even if PATH already exists"
13
13
  c.option "blank", "--blank", "Creates scaffolding but with empty files"
14
+ c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'"
14
15
 
15
16
  c.action do |args, options|
16
17
  Bunto::Commands::New.process(args, options)
@@ -34,7 +35,7 @@ module Bunto
34
35
  create_site new_blog_path
35
36
  end
36
37
 
37
- Bunto.logger.info "New bunto site installed in #{new_blog_path}."
38
+ after_install(new_blog_path, options)
38
39
  end
39
40
 
40
41
  def create_blank_site(path)
@@ -73,16 +74,20 @@ ruby RUBY_VERSION
73
74
  gem "bunto", "#{Bunto::VERSION}"
74
75
 
75
76
  # This is the default theme for new Bunto sites. You may change this to anything you like.
76
- gem "minima"
77
+ gem "minima", "~> 2.0"
77
78
 
78
79
  # If you want to use GitHub Pages, remove the "gem "bunto"" above and
79
80
  # uncomment the line below. To upgrade, run `bundle update github-pages`.
80
81
  # gem "github-pages", group: :bunto_plugins
81
82
 
82
83
  # If you have any plugins, put them here!
83
- # group :bunto_plugins do
84
- # gem "bunto-github-metadata", "~> 1.0"
85
- # end
84
+ group :bunto_plugins do
85
+ gem "bunto-feed", "~> 0.6"
86
+ end
87
+
88
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
89
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
90
+
86
91
  RUBY
87
92
  end
88
93
 
@@ -114,6 +119,31 @@ RUBY
114
119
  def scaffold_path
115
120
  "_posts/0000-00-00-welcome-to-bunto.markdown.erb"
116
121
  end
122
+
123
+ # After a new blog has been created, print a success notification and
124
+ # then automatically execute bundle install from within the new blog dir
125
+ # unless the user opts to generate a blank blog or skip 'bundle install'.
126
+
127
+ def after_install(path, options = {})
128
+ unless options["blank"] || options["skip-bundle"]
129
+ bundle_install path
130
+ end
131
+
132
+ Bunto.logger.info "New bunto site installed in #{path.cyan}."
133
+ Bunto.logger.info "Bundle install skipped." if options["skip-bundle"]
134
+ end
135
+
136
+ def bundle_install(path)
137
+ Bunto::External.require_with_graceful_fail "bundler"
138
+ Bunto.logger.info "Running bundle install in #{path.cyan}..."
139
+ Dir.chdir(path) do
140
+ process, output = Bunto::Utils::Exec.run("bundle", "install")
141
+ output.to_s.each_line do |line|
142
+ Bunto.logger.info("Bundler:".green, line.strip) unless line.to_s.empty?
143
+ end
144
+ raise SystemExit unless process.success?
145
+ end
146
+ end
117
147
  end
118
148
  end
119
149
  end
@@ -16,6 +16,7 @@ class Bunto::Commands::NewTheme < Bunto::Command
16
16
  end
17
17
  end
18
18
 
19
+ # rubocop:disable Metrics/AbcSize
19
20
  def process(args, opts)
20
21
  if !args || args.empty?
21
22
  raise Bunto::Errors::InvalidThemeName, "You must specify a theme name."
@@ -28,9 +29,10 @@ class Bunto::Commands::NewTheme < Bunto::Command
28
29
  end
29
30
 
30
31
  theme.create!
31
- Bunto.logger.info "Your new Bunto theme, #{theme.name}," \
32
- " is ready for you in #{theme.path}!"
32
+ Bunto.logger.info "Your new Bunto theme, #{theme.name.cyan}," \
33
+ " is ready for you in #{theme.path.to_s.cyan}!"
33
34
  Bunto.logger.info "For help getting started, read #{theme.path}/README.md."
34
35
  end
36
+ # rubocop:enable Metrics/AbcSize
35
37
  end
36
38
  end
@@ -10,9 +10,9 @@ module Bunto
10
10
  "ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."],
11
11
  "port" => ["-P", "--port [PORT]", "Port to listen on"],
12
12
  "show_dir_listing" => ["--show-dir-listing",
13
- "Show a directory listing instead of loading your index file."],
13
+ "Show a directory listing instead of loading your index file.",],
14
14
  "skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
15
- "Skips the initial site build which occurs before the server is started."]
15
+ "Skips the initial site build which occurs before the server is started.",],
16
16
  }.freeze
17
17
 
18
18
  #
@@ -33,6 +33,7 @@ module Bunto
33
33
  opts["serving"] = true
34
34
  opts["watch" ] = true unless opts.key?("watch")
35
35
  config = opts["config"]
36
+ opts["url"] = default_url(opts) if Bunto.env == "development"
36
37
  Build.process(opts)
37
38
  opts["config"] = config
38
39
  Serve.process(opts)
@@ -47,11 +48,7 @@ module Bunto
47
48
  destination = opts["destination"]
48
49
  setup(destination)
49
50
 
50
- server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
51
- server.mount(opts["baseurl"], Servlet, destination, file_handler_opts)
52
- Bunto.logger.info "Server address:", server_address(server, opts)
53
- launch_browser server, opts if opts["open_url"]
54
- boot_or_detach server, opts
51
+ start_up_webrick(opts, destination)
55
52
  end
56
53
 
57
54
  # Do a base pre-setup of WEBRick so that everything is in place
@@ -91,7 +88,7 @@ module Bunto
91
88
  index.rhtml
92
89
  index.cgi
93
90
  index.xml
94
- )
91
+ ),
95
92
  }
96
93
 
97
94
  opts[:DirectoryIndex] = [] if opts[:BuntoOptions]["show_dir_listing"]
@@ -101,6 +98,17 @@ module Bunto
101
98
  opts
102
99
  end
103
100
 
101
+ #
102
+
103
+ private
104
+ def start_up_webrick(opts, destination)
105
+ server = WEBrick::HTTPServer.new(webrick_opts(opts)).tap { |o| o.unmount("") }
106
+ server.mount(opts["baseurl"].to_s, Servlet, destination, file_handler_opts)
107
+ Bunto.logger.info "Server address:", server_address(server, opts)
108
+ launch_browser server, opts if opts["open_url"]
109
+ boot_or_detach server, opts
110
+ end
111
+
104
112
  # Recreate NondisclosureName under utf-8 circumstance
105
113
 
106
114
  private
@@ -108,25 +116,47 @@ module Bunto
108
116
  WEBrick::Config::FileHandler.merge({
109
117
  :FancyIndexing => true,
110
118
  :NondisclosureName => [
111
- ".ht*", "~*"
112
- ]
119
+ ".ht*", "~*",
120
+ ],
113
121
  })
114
122
  end
115
123
 
116
124
  #
117
125
 
118
126
  private
119
- def server_address(server, opts)
127
+ def server_address(server, options = {})
128
+ format_url(
129
+ server.config[:SSLEnable],
130
+ server.config[:BindAddress],
131
+ server.config[:Port],
132
+ options["baseurl"]
133
+ )
134
+ end
135
+
136
+ private
137
+ def format_url(ssl_enabled, address, port, baseurl = nil)
120
138
  format("%{prefix}://%{address}:%{port}%{baseurl}", {
121
- :prefix => server.config[:SSLEnable] ? "https" : "http",
122
- :baseurl => opts["baseurl"] ? "#{opts["baseurl"]}/" : "",
123
- :address => server.config[:BindAddress],
124
- :port => server.config[:Port]
139
+ :prefix => ssl_enabled ? "https" : "http",
140
+ :address => address,
141
+ :port => port,
142
+ :baseurl => baseurl ? "#{baseurl}/" : "",
125
143
  })
126
144
  end
127
145
 
128
146
  #
129
147
 
148
+ private
149
+ def default_url(opts)
150
+ config = configuration_from_options(opts)
151
+ format_url(
152
+ config["ssl_cert"] && config["ssl_key"],
153
+ config["host"] == "127.0.0.1" ? "localhost" : config["host"],
154
+ config["port"]
155
+ )
156
+ end
157
+
158
+ #
159
+
130
160
  private
131
161
  def launch_browser(server, opts)
132
162
  address = server_address(server, opts)