middleman-presentation-core 0.16.0.beta → 0.16.0.rc1

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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -2
  3. data/doc/licenses/dependencies.db +0 -0
  4. data/features/build_presentation.feature +49 -8
  5. data/features/create_presentation-cli.feature +35 -75
  6. data/features/init_application-cli.feature +7 -1
  7. data/features/init_predefined_slides.feature +1 -1
  8. data/features/predefined_slides.feature +79 -0
  9. data/lib/middleman-presentation-core.rb +3 -0
  10. data/lib/middleman-presentation-core/application_config.rb +13 -2
  11. data/lib/middleman-presentation-core/build_readme_template.rb +15 -0
  12. data/lib/middleman-presentation-core/cli/build_presentation.rb +30 -0
  13. data/lib/middleman-presentation-core/cli/create_presentation.rb +38 -14
  14. data/lib/middleman-presentation-core/cli/export.rb +2 -0
  15. data/lib/middleman-presentation-core/cli/init.rb +2 -0
  16. data/lib/middleman-presentation-core/cli/init_application.rb +5 -1
  17. data/lib/middleman-presentation-core/cli/runner.rb +4 -0
  18. data/lib/middleman-presentation-core/cli/serve_presentation.rb +3 -0
  19. data/lib/middleman-presentation-core/cli/shared.rb +0 -3
  20. data/lib/middleman-presentation-core/frontend_component.rb +0 -2
  21. data/lib/middleman-presentation-core/middleman_environment.rb +1 -1
  22. data/lib/middleman-presentation-core/presentation_license_template.rb +15 -0
  23. data/lib/middleman-presentation-core/step_definitions.rb +14 -1
  24. data/lib/middleman-presentation-core/utils.rb +0 -1
  25. data/lib/middleman-presentation-core/version.rb +1 -1
  26. data/locales/de.yml +4 -0
  27. data/locales/en.yml +4 -0
  28. data/middleman-presentation-core.gemspec +2 -2
  29. data/spec/components_manager_spec.rb +0 -1
  30. data/spec/existing_slide_spec.rb +0 -1
  31. data/spec/new_slide_spec.rb +0 -1
  32. data/spec/presentation_helper_spec.rb +0 -1
  33. data/spec/slide_list_spec.rb +0 -1
  34. data/templates/Gemfile.tt +2 -2
  35. data/templates/Rakefile +0 -1
  36. data/templates/build_readme.md.tt +80 -0
  37. data/templates/gitignore.tt +4 -0
  38. data/templates/{LICENSE.presentation → presentation_license.md.tt} +0 -0
  39. data/templates/script/bootstrap +0 -1
  40. data/templates/script/build +1 -2
  41. data/templates/script/export +1 -2
  42. data/templates/script/start +2 -43
  43. data/utils/server/server.darwin.amd64 +0 -0
  44. data/utils/server/server.linux.amd64 +0 -0
  45. data/utils/server/server.windows.amd64.exe +0 -0
  46. metadata +13 -9
  47. data/lib/middleman-presentation-core/middleman_step_definitions.rb +0 -131
  48. data/templates/config.yaml.tt +0 -17
  49. data/templates/script/presentation +0 -3
  50. data/templates/script/slide +0 -3
@@ -8,6 +8,8 @@ module Middleman
8
8
 
9
9
  desc Middleman::Presentation.t('views.presentation.build.title')
10
10
 
11
+ class_option :add_static_servers, type: :boolean, default: Middleman::Presentation.config.add_static_servers, desc: Middleman::Presentation.t('views.presentation.build.options.add_static_servers')
12
+
11
13
  def initialize_generator
12
14
  enable_debug_mode
13
15
  end
@@ -31,6 +33,16 @@ module Middleman
31
33
  @javascripts_directory = @environment.scripts_directory
32
34
  @fonts_directory = @environment.fonts_directory
33
35
  @rackup_config_file = File.join @environment.build_directory, 'config.ru'
36
+ @readme_file = File.join @environment.build_directory, 'README.md'
37
+
38
+ @title = Middleman::Presentation.config.title
39
+ @subtitle = Middleman::Presentation.config.subtitle
40
+ @author = Middleman::Presentation.config.author
41
+ @speaker = Middleman::Presentation.config.speaker
42
+ @date = Middleman::Presentation.config.date
43
+ @license_file = Dir.glob(File.join(@environment.root_path, 'LICENSE.*')).first
44
+
45
+ @add_static_servers = options[:add_static_servers]
34
46
  end
35
47
 
36
48
  def build_presentation
@@ -51,6 +63,24 @@ module Middleman
51
63
  def add_rackup_file
52
64
  template 'rackup.config.erb', @rackup_config_file
53
65
  end
66
+
67
+ def add_server_executables
68
+ return unless @add_static_servers
69
+
70
+ pattern = File.expand_path('../../../../utils/server/*', __FILE__)
71
+ Dir.glob(pattern).each { |f| FileUtils.cp f, @environment.build_path }
72
+ end
73
+
74
+ def add_readme
75
+ template_file = BuildReadmeTemplate.new
76
+ template template_file.file, File.join(@environment.build_directory, "README#{template_file.proposed_extname}"), force: options[:force]
77
+ end
78
+
79
+ def add_license
80
+ return if @license_file.blank?
81
+
82
+ copy_file @license_file, File.join(@environment.build_directory, File.basename(@license_file))
83
+ end
54
84
  end
55
85
  end
56
86
  end
@@ -6,6 +6,10 @@ module Middleman
6
6
  class CreatePresentation < BaseGroup
7
7
  include Thor::Actions
8
8
 
9
+ def self.exit_on_failure?
10
+ true
11
+ end
12
+
9
13
  class_option :speaker, required: true, default: Middleman::Presentation.config.speaker, desc: Middleman::Presentation.t('views.presentations.create.options.speaker')
10
14
  class_option :title, required: true, desc: Middleman::Presentation.t('views.presentations.create.options.title')
11
15
  class_option :date, required: true, default: Time.now.strftime('%d.%m.%Y'), desc: Middleman::Presentation.t('views.presentations.create.options.date')
@@ -70,6 +74,8 @@ module Middleman
70
74
  class_option :stylesheets_directory, default: Middleman::Presentation.config.stylesheets_directory, desc: Middleman::Presentation.t('views.presentations.create.options.stylesheets_directory')
71
75
  class_option :fonts_directory, default: Middleman::Presentation.config.fonts_directory, desc: Middleman::Presentation.t('views.presentations.create.options.fonts_directory')
72
76
  class_option :build_directory, default: Middleman::Presentation.config.build_directory, desc: Middleman::Presentation.t('views.presentations.create.options.build_directory')
77
+ class_option :network_port, default: Middleman::Presentation.config.network_port, desc: Middleman::Presentation.t('views.presentations.create.options.network_port')
78
+ class_option :network_interface, default: Middleman::Presentation.config.network_interface, desc: Middleman::Presentation.t('views.presentations.create.options.network_interface')
73
79
 
74
80
  argument :directory, default: Dir.getwd, desc: Middleman::Presentation.t('views.presentations.create.arguments.directory')
75
81
 
@@ -154,6 +160,9 @@ module Middleman
154
160
  Middleman::Presentation.config.stylesheets_directory = options[:stylesheets_directory]
155
161
  Middleman::Presentation.config.fonts_directory = options[:fonts_directory]
156
162
  Middleman::Presentation.config.build_directory = options[:build_directory]
163
+
164
+ Middleman::Presentation.config.network_port = options[:network_port]
165
+ Middleman::Presentation.config.network_interface = options[:network_interface]
157
166
  end
158
167
 
159
168
  def create_root_directory
@@ -174,10 +183,11 @@ module Middleman
174
183
 
175
184
  def create_gemfile
176
185
  @rubygem_path = File.expand_path('../../../../../', __FILE__)
186
+ @library_version = Middleman::Presentation::VERSION
177
187
  template 'Gemfile.tt', File.join(middleman_environment.root_path, 'Gemfile'), force: options[:force]
178
188
  end
179
189
 
180
- def create_config_file
190
+ def create_presentation_config_file
181
191
  create_file(
182
192
  File.join(middleman_environment.root_path, '.middleman-presentation.yaml'),
183
193
  Middleman::Presentation.config.to_yaml(keys: Middleman::Presentation.config.exportable_options, remove_blank: true),
@@ -185,6 +195,14 @@ module Middleman
185
195
  )
186
196
  end
187
197
 
198
+ def create_local_config_file
199
+ create_file(
200
+ File.join(middleman_environment.root_path, '.middleman-presentation.local.yaml'),
201
+ Middleman::Presentation.config.to_yaml(keys: Middleman::Presentation.config.local_options, remove_blank: true),
202
+ force: options[:force]
203
+ )
204
+ end
205
+
188
206
  def create_bower_configuration_files
189
207
  assets_loader.load_for_bower_update
190
208
 
@@ -218,22 +236,26 @@ module Middleman
218
236
  return unless options[:create_predefined_slides]
219
237
 
220
238
  PredefinedSlideTemplateDirectory.new(working_directory: middleman_environment.root_path).template_files.each do |file|
221
- template file,
222
- File.join(
223
- middleman_environment.sources_path,
224
- Middleman::Presentation.config.slides_directory,
225
- File.basename(file, '.tt')
226
- ),
227
- force: options[:force]
239
+ template(
240
+ file,
241
+ File.join(
242
+ middleman_environment.sources_path,
243
+ Middleman::Presentation.config.slides_directory,
244
+ File.basename(file, '.tt')
245
+ ),
246
+ force: options[:force]
247
+ )
228
248
  end
229
249
  end
230
250
 
231
251
  def create_default_license_file_to_presentation
232
- copy_file 'LICENSE.presentation', File.join(middleman_environment.root_path, 'LICENSE.presentation'), force: options[:force]
252
+ license_template = PresentationLicenseTemplate.new
253
+
254
+ template license_template.file, File.join(middleman_environment.root_path, "LICENSE#{license_template.proposed_extname}"), force: options[:force]
233
255
  end
234
256
 
235
257
  def create_helper_scripts
236
- %w(start bootstrap slide presentation build export).each do |s|
258
+ %w(start bootstrap build export).each do |s|
237
259
  copy_file File.join('script', s), File.join(middleman_environment.root_path, 'script', s), force: options[:force]
238
260
  chmod File.join(middleman_environment.root_path, 'script', s), 0755, force: options[:force]
239
261
  end
@@ -243,16 +265,18 @@ module Middleman
243
265
  inside directory do
244
266
  fail Thor::Error, Middleman::Presentation.t('errors.bower_command_not_found', path: ENV['PATH']) if options[:check_for_bower] && File.which('bower').blank?
245
267
 
246
- result = run('bower update', capture: true) if options[:install_assets] == true
247
- fail Thor::Error, Middleman::Presentation.t('errors.bower_command_failed', result: result) unless $CHILD_STATUS.exitstatus == 0
268
+ system('bower update') || \
269
+ fail(Thor::Error, Middleman::Presentation.t('errors.bower_command_failed', result: '')) \
270
+ if options[:install_assets] == true
248
271
  end
249
272
  end
250
273
 
251
274
  def install_gems
252
275
  inside directory do
253
276
  Bundler.with_clean_env do
254
- result = run('bundle install', capture: true) if options[:install_assets] == true
255
- fail Thor::Error, Middleman::Presentation.t('errors.bundle_command_failed', result: result) unless $CHILD_STATUS.exitstatus == 0
277
+ system('bundle install') || \
278
+ fail(Thor::Error, Middleman::Presentation.t('errors.bundle_command_failed', result: '')) \
279
+ if options[:install_assets] == true
256
280
  end
257
281
  end
258
282
  end
@@ -5,6 +5,8 @@ module Middleman
5
5
  # Run command
6
6
  class Export < Base
7
7
  register ExportPresentation, 'presentation', 'presentation', 'Export presentation'
8
+
9
+ default_command :presentation
8
10
  end
9
11
  end
10
12
  end
@@ -6,6 +6,8 @@ module Middleman
6
6
  class Init < Base
7
7
  register(InitApplication, 'application', 'application', Middleman::Presentation.t('views.applications.init.title'))
8
8
  register(InitPredefinedSlides, 'predefined_slides', 'predefined_slides', Middleman::Presentation.t('views.predefined_slides.init.title'))
9
+
10
+ default_command :application
9
11
  end
10
12
  end
11
13
  end
@@ -39,7 +39,11 @@ module Middleman
39
39
  force: options[:force]
40
40
  )
41
41
  else
42
- template 'config.yaml.tt', file, force: options[:force]
42
+ create_file(
43
+ file,
44
+ Middleman::Presentation.config.to_yaml(keys: Middleman::Presentation.config.known_options, remove_blank: false, prepend: '# '),
45
+ force: options[:force]
46
+ )
43
47
  end
44
48
  end
45
49
  end
@@ -4,6 +4,10 @@ module Middleman
4
4
  module Cli
5
5
  # Run command
6
6
  class Runner < Base
7
+ def self.exit_on_failure?
8
+ true
9
+ end
10
+
7
11
  class_option :debug_mode, default: Middleman::Presentation.config.debug_mode, type: :boolean, desc: Middleman::Presentation.t('views.application.options.debug_mode')
8
12
  class_option :bower_directory, default: Middleman::Presentation.config.bower_directory, desc: Middleman::Presentation.t('views.application.options.bower_directory')
9
13
 
@@ -8,6 +8,7 @@ module Middleman
8
8
 
9
9
  class_option :network_port, type: :numeric, default: Middleman::Presentation.config.network_port, desc: Middleman::Presentation.t('views.presentation.serve.options.network_port')
10
10
  class_option :network_interface, default: Middleman::Presentation.config.network_interface, desc: Middleman::Presentation.t('views.presentation.serve.options.network_interface')
11
+ class_option :open_in_browser, type: :boolean, default: Middleman::Presentation.config.open_in_browser, desc: Middleman::Presentation.t('views.presentation.serve.options.open_in_browser')
11
12
 
12
13
  def initialize_generator
13
14
  enable_debug_mode
@@ -19,6 +20,8 @@ module Middleman
19
20
  title: Middleman::Presentation.config.title
20
21
  )
21
22
 
23
+ Launchy.open(Addressable::URI.parse("http://#{options[:network_interface]}:#{options[:network_port]}")) if options[:open_in_browser]
24
+
22
25
  cmd = []
23
26
  cmd << 'middleman server'
24
27
  cmd << "-p #{options[:network_port]}"
@@ -41,9 +41,6 @@ module Middleman
41
41
 
42
42
  # The class methods
43
43
  module ClassMethods
44
- def self.exit_on_failure?
45
- true
46
- end
47
44
  end
48
45
  end
49
46
  end
@@ -32,8 +32,6 @@ module Middleman
32
32
  @to_s = value
33
33
  end
34
34
  end.new(version)
35
- else
36
- nil
37
35
  end
38
36
  fail ArgumentError, Middleman::Presentation.t('errors.undefined_arguments', arguments: %w(resource_locator github version).to_list) if @resource_locator.blank?
39
37
 
@@ -27,7 +27,7 @@ module Middleman
27
27
  end
28
28
 
29
29
  def build_path
30
- File.join(sources_path, application_config.build_directory)
30
+ File.join(root_path, application_config.build_directory)
31
31
  end
32
32
 
33
33
  def stylesheets_directory
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Markdown template to create new slides
5
+ class PresentationLicenseTemplate < FeduxOrgStdlib::FileTemplate
6
+ def application_name
7
+ 'middleman-presentation'
8
+ end
9
+
10
+ def fallback_template_directory
11
+ File.expand_path('../../../templates/', __FILE__)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -63,8 +63,17 @@ end
63
63
 
64
64
  Given(/only the executables of gems "([^"]+)" can be found in PATH/) do |gems|
65
65
  dirs = []
66
+ gem_names = gems.split(/,\s?/).map(&:strip)
66
67
 
67
- dirs.concat gems.split(/,\s?/).map(&:strip).each_with_object([]) { |e, a| a << Gem::Specification.find_by_name(e).bin_dir }
68
+ dirs.concat(
69
+ gem_names.each_with_object([]) do |e, a|
70
+ gem = Gem::Specification.each.find { |s| s.name == e }
71
+
72
+ fail if gem.blank?
73
+
74
+ a << gem.bin_dir
75
+ end
76
+ )
68
77
 
69
78
  if ci?
70
79
  dirs << "/home/travis/.rvm/rubies/ruby-#{RUBY_VERSION}/bin"
@@ -102,6 +111,10 @@ Given(/^a user template named "(.*?)" with:$/) do |name, string|
102
111
  step %(a file named "~/.config/middleman-presentation/templates/#{name}" with:), string
103
112
  end
104
113
 
114
+ Given(/^a user defined predefined slide named "(.*?)" with:$/) do |name, string|
115
+ step %(a file named "~/.config/middleman-presentation/predefined_slides.d/#{name}" with:), string
116
+ end
117
+
105
118
  Given(/^a presentation theme named "(.*?)" does not exist$/) do |name|
106
119
  step %(I remove the directory "middleman-presentation-theme-#{name}")
107
120
  end
@@ -24,7 +24,6 @@ module Middleman
24
24
 
25
25
  Zip::File.open(destination_file, Zip::File::CREATE) do |file|
26
26
  Dir.glob(File.join(source_directory, '**', '*')).each do |filename|
27
-
28
27
  path = ''
29
28
  path << prefix if prefix
30
29
  path << Pathname.new(filename).relative_path_from(Pathname.new(source_directory)).to_s
@@ -3,6 +3,6 @@
3
3
  module Middleman
4
4
  # Presentation
5
5
  module Presentation
6
- VERSION = '0.16.0.beta'
6
+ VERSION = '0.16.0.rc1'
7
7
  end
8
8
  end
data/locales/de.yml CHANGED
@@ -62,6 +62,8 @@ de:
62
62
  create:
63
63
  title: 'Erzeuge eine neue Präsentation in Verzeichnis DIR (standard: aktuelles Arbeitsverzeichnis)'
64
64
  options:
65
+ network_port: Netzwerk-Port, an dem der Server lauschen soll
66
+ network_interface: Netwerk-Schnittstelle, an der der Server lauschen soll
65
67
  runtime_environment: Laufzeit-Umgebung in der middleman-presentation läuft, z.B. "test"
66
68
  activate_center: 'Aktiviere "center" in reveal.js'
67
69
  activate_controls: 'Aktiviere "controls" in reveal.js'
@@ -215,11 +217,13 @@ de:
215
217
  options:
216
218
  network_port: Netzwerk-Port, an dem der Server lauschen soll
217
219
  network_interface: Netwerk-Schnittstelle, an der der Server lauschen soll
220
+ open_in_browser: Öffne Präsentation im Browser
218
221
  build:
219
222
  title: Präsentation generieren
220
223
  headline: Generiere die Präsentation "%{title}"
221
224
  options:
222
225
  title: 'Titel der Präsentation'
226
+ add_static_servers: 'Ergänze statische Webserver zu der generierten Präsentation'
223
227
  export:
224
228
  title: Präsentation exportieren
225
229
  headline: Exportiere die Präsentation "%{title}" nach "%{file}"
data/locales/en.yml CHANGED
@@ -62,6 +62,8 @@ en:
62
62
  create:
63
63
  title: 'Initialize a new presentation in DIR (default: $PWD)'
64
64
  options:
65
+ network_port: Networkport the server listens on
66
+ network_interface: Networkinterface the server listens on
65
67
  runtime_environment: Runtime environment in which middleman-presentation is running, e.g. "test"
66
68
  activate_center: 'Activate center in reveal.js'
67
69
  activate_controls: 'Activate controls in reveal.js'
@@ -215,11 +217,13 @@ en:
215
217
  options:
216
218
  network_port: Networkport the server listens on
217
219
  network_interface: Networkinterface the server listens on
220
+ open_in_browser: Open presentation in browser
218
221
  build:
219
222
  title: Build presentation
220
223
  headline: Build presentation "%{title}"
221
224
  options:
222
225
  title: 'Title of presentation'
226
+ add_static_servers: 'Add static webservers to built presentation'
223
227
  export:
224
228
  title: Export presentation
225
229
  headline: Export presentation "%{title}" to file "%{file}"
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = 'Presentation engine for Middleman'
13
13
 
14
14
  spec.license = 'MIT'
15
- spec.files = `git ls-files -z`.split("\x0")
15
+ spec.files = `git ls-files -z`.split("\x0") + Dir.glob('utils/server/*')
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
 
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'tzinfo', '>= 0.3.0'
26
26
  spec.add_dependency 'addressable', '~> 2.3.5'
27
27
  spec.add_dependency 'launchy', '~> 2.4.2'
28
- spec.add_dependency 'fedux_org-stdlib', '>= 0.10.1'
28
+ spec.add_dependency 'fedux_org-stdlib', '>= 0.11.1'
29
29
  spec.add_dependency 'rake'
30
30
  spec.add_dependency 'rubyzip', '~> 1.1.6'
31
31
  spec.add_dependency 'liquid'
@@ -138,5 +138,4 @@ RSpec.describe ComponentsManager do
138
138
  # rubocop:enable Style/TrailingWhitespace
139
139
  end
140
140
  end
141
-
142
141
  end
@@ -2,7 +2,6 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  RSpec.describe ExistingSlide do
5
-
6
5
  context '#file_name' do
7
6
  it 'extracts file name' do
8
7
  slide1 = ExistingSlide.new(absolute_path('source', 'slides', '01.html.md'))
@@ -2,7 +2,6 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  RSpec.describe NewSlide do
5
-
6
5
  context '#<=>' do
7
6
  it 'compares slides with same file name' do
8
7
  slide1 = NewSlide.new('01.md', base_path: absolute_path('source', 'slides'))
@@ -132,6 +132,5 @@ RSpec.describe PresentationHelper do
132
132
 
133
133
  expect(helper.available_methods).to eq [:helper1]
134
134
  end
135
-
136
135
  end
137
136
  end
@@ -2,7 +2,6 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  RSpec.describe SlideList do
5
-
6
5
  context '#initialize' do
7
6
  it 'requires a list of patterns' do
8
7
  slide = double('Middleman::Presentation::NewSlide')
data/templates/Gemfile.tt CHANGED
@@ -6,12 +6,12 @@ source 'https://rubygems.org'
6
6
  <% if Middleman::Presentation.config.runtime_environment == :test -%>
7
7
  # Make sure the paths are correct, otherwise you get
8
8
  # Bundler-errors a la `Path does not exist`
9
- gem 'middleman-presentation', path: '<%= File.join(@rubygem_path, 'middleman-presentation') %>'
9
+ gem 'middleman-presentation', '~> <%= @library_version %>', path: '<%= File.join(@rubygem_path, 'middleman-presentation') %>'
10
10
  gem 'middleman-presentation-core', path: '<%= File.join(@rubygem_path, 'middleman-presentation-core') %>'
11
11
  gem 'middleman-presentation-helpers', path: '<%= File.join(@rubygem_path, 'middleman-presentation-helpers') %>'
12
12
  gem 'middleman-presentation-simple_plugin', path: '<%= File.join(@rubygem_path, 'middleman-presentation-core/fixtures/middleman-presentation-simple_plugin') %>'
13
13
  <% else -%>
14
- gem 'middleman-presentation'
14
+ gem 'middleman-presentation', '~> <%= @library_version %>'
15
15
  <% end -%>
16
16
 
17
17
  # Choose one to make `execjs` happy