middleman-presentation-core 0.16.0.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +7 -0
  2. data/.rdebugrc +7 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +52 -0
  5. data/.simplecov +25 -0
  6. data/.yardopts +5 -0
  7. data/Guardfile +13 -0
  8. data/LICENSE.software +21 -0
  9. data/Rakefile +200 -0
  10. data/config/license_finder.yml +13 -0
  11. data/cucumber.yml +2 -0
  12. data/doc/licenses/dependencies.csv +55 -0
  13. data/doc/licenses/dependencies.db +0 -0
  14. data/doc/licenses/dependencies.html +1415 -0
  15. data/doc/licenses/dependencies.md +603 -0
  16. data/doc/licenses/dependencies_detailed.csv +190 -0
  17. data/doc/yard/.keep +0 -0
  18. data/features/build_presentation.feature +62 -0
  19. data/features/code_highlighting.feature +43 -0
  20. data/features/components.feature +29 -0
  21. data/features/create_plugin-cli.feature +11 -0
  22. data/features/create_presentation-cli.feature +349 -0
  23. data/features/create_slide-cli.feature +188 -0
  24. data/features/create_slides-templates-cli.feature +114 -0
  25. data/features/create_theme-cli.feature +58 -0
  26. data/features/default_slides.feature +58 -0
  27. data/features/edit_slide-cli.feature +121 -0
  28. data/features/export_presentation-cli.feature +23 -0
  29. data/features/grouping_slides.feature +150 -0
  30. data/features/ignore_slides.feature +103 -0
  31. data/features/init_application-cli.feature +59 -0
  32. data/features/init_predefined_slides.feature +9 -0
  33. data/features/language_detection.feature +0 -0
  34. data/features/list_assets-cli.feature +13 -0
  35. data/features/list_components-cli.feature +13 -0
  36. data/features/list_helpers-cli.feature +13 -0
  37. data/features/list_plugins-cli.feature +13 -0
  38. data/features/list_styles-cli.feature +17 -0
  39. data/features/plugins.feature +63 -0
  40. data/features/presentation.feature +57 -0
  41. data/features/rename_slide-cli.feature +176 -0
  42. data/features/render_slides.feature +76 -0
  43. data/features/show_config-cli.feature +25 -0
  44. data/features/show_footer.feature +14 -0
  45. data/features/show_slide_number.feature +31 -0
  46. data/features/show_support_information-cli.feature +12 -0
  47. data/features/support/aruba.rb +18 -0
  48. data/features/support/ci.rb +3 -0
  49. data/features/support/env.rb +25 -0
  50. data/features/support/fixtures.rb +21 -0
  51. data/features/support/hash.rb +2 -0
  52. data/features/support/reporting.rb +2 -0
  53. data/features/version_number.feature +15 -0
  54. data/fixtures/middleman-presentation-simple_plugin/Rakefile +1 -0
  55. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-plugin.rb +0 -0
  56. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/helpers.rb +13 -0
  57. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/plugin.rb +34 -0
  58. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/version.rb +8 -0
  59. data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin.rb +11 -0
  60. data/fixtures/middleman-presentation-simple_plugin/middleman-presentation-simple_plugin.gemspec +22 -0
  61. data/fixtures/middleman-presentation-simple_plugin/vendor/assets/stylesheets/test_simple.scss +3 -0
  62. data/lib/middleman-presentation-core/application_config.rb +198 -0
  63. data/lib/middleman-presentation-core/asset.rb +103 -0
  64. data/lib/middleman-presentation-core/asset_component.rb +34 -0
  65. data/lib/middleman-presentation-core/asset_list.rb +84 -0
  66. data/lib/middleman-presentation-core/asset_store.rb +73 -0
  67. data/lib/middleman-presentation-core/assets_loader.rb +95 -0
  68. data/lib/middleman-presentation-core/assets_manager.rb +73 -0
  69. data/lib/middleman-presentation-core/cache.rb +49 -0
  70. data/lib/middleman-presentation-core/cli/base.rb +30 -0
  71. data/lib/middleman-presentation-core/cli/base_group.rb +11 -0
  72. data/lib/middleman-presentation-core/cli/build.rb +13 -0
  73. data/lib/middleman-presentation-core/cli/build_presentation.rb +57 -0
  74. data/lib/middleman-presentation-core/cli/change.rb +13 -0
  75. data/lib/middleman-presentation-core/cli/change_slide.rb +82 -0
  76. data/lib/middleman-presentation-core/cli/create.rb +16 -0
  77. data/lib/middleman-presentation-core/cli/create_plugin.rb +62 -0
  78. data/lib/middleman-presentation-core/cli/create_presentation.rb +300 -0
  79. data/lib/middleman-presentation-core/cli/create_slide.rb +52 -0
  80. data/lib/middleman-presentation-core/cli/create_theme.rb +81 -0
  81. data/lib/middleman-presentation-core/cli/edit.rb +13 -0
  82. data/lib/middleman-presentation-core/cli/edit_slide.rb +49 -0
  83. data/lib/middleman-presentation-core/cli/export.rb +11 -0
  84. data/lib/middleman-presentation-core/cli/export_presentation.rb +55 -0
  85. data/lib/middleman-presentation-core/cli/init.rb +12 -0
  86. data/lib/middleman-presentation-core/cli/init_application.rb +48 -0
  87. data/lib/middleman-presentation-core/cli/init_predefined_slides.rb +31 -0
  88. data/lib/middleman-presentation-core/cli/list.rb +66 -0
  89. data/lib/middleman-presentation-core/cli/reset_thor.rb +18 -0
  90. data/lib/middleman-presentation-core/cli/runner.rb +47 -0
  91. data/lib/middleman-presentation-core/cli/serve.rb +13 -0
  92. data/lib/middleman-presentation-core/cli/serve_presentation.rb +30 -0
  93. data/lib/middleman-presentation-core/cli/shared.rb +51 -0
  94. data/lib/middleman-presentation-core/cli/show.rb +70 -0
  95. data/lib/middleman-presentation-core/comparable_slide.rb +69 -0
  96. data/lib/middleman-presentation-core/component.rb +86 -0
  97. data/lib/middleman-presentation-core/components_manager.rb +96 -0
  98. data/lib/middleman-presentation-core/configuration_file.rb +15 -0
  99. data/lib/middleman-presentation-core/css_class_extracter.rb +41 -0
  100. data/lib/middleman-presentation-core/custom_template.rb +15 -0
  101. data/lib/middleman-presentation-core/erb_template.rb +15 -0
  102. data/lib/middleman-presentation-core/errors.rb +10 -0
  103. data/lib/middleman-presentation-core/existing_slide.rb +92 -0
  104. data/lib/middleman-presentation-core/frontend_component.rb +75 -0
  105. data/lib/middleman-presentation-core/group_template.rb +15 -0
  106. data/lib/middleman-presentation-core/helpers_manager.rb +37 -0
  107. data/lib/middleman-presentation-core/ignore_file.rb +52 -0
  108. data/lib/middleman-presentation-core/liquid_template.rb +15 -0
  109. data/lib/middleman-presentation-core/list.rb +7 -0
  110. data/lib/middleman-presentation-core/locale_configurator.rb +84 -0
  111. data/lib/middleman-presentation-core/logger.rb +8 -0
  112. data/lib/middleman-presentation-core/main.rb +55 -0
  113. data/lib/middleman-presentation-core/markdown_template.rb +15 -0
  114. data/lib/middleman-presentation-core/middleman_environment.rb +108 -0
  115. data/lib/middleman-presentation-core/middleman_extension.rb +12 -0
  116. data/lib/middleman-presentation-core/middleman_step_definitions.rb +131 -0
  117. data/lib/middleman-presentation-core/new_slide.rb +140 -0
  118. data/lib/middleman-presentation-core/overwrite_sass.rb +22 -0
  119. data/lib/middleman-presentation-core/plugin.rb +8 -0
  120. data/lib/middleman-presentation-core/plugin_api.rb +65 -0
  121. data/lib/middleman-presentation-core/plugins_manager.rb +7 -0
  122. data/lib/middleman-presentation-core/predefined_slide_templates_directory.rb +15 -0
  123. data/lib/middleman-presentation-core/presentation_helper.rb +69 -0
  124. data/lib/middleman-presentation-core/register_extension.rb +4 -0
  125. data/lib/middleman-presentation-core/roles/comparable_by_name.rb +24 -0
  126. data/lib/middleman-presentation-core/slide_group.rb +33 -0
  127. data/lib/middleman-presentation-core/slide_list.rb +52 -0
  128. data/lib/middleman-presentation-core/slide_name.rb +61 -0
  129. data/lib/middleman-presentation-core/start.rb +68 -0
  130. data/lib/middleman-presentation-core/step_definitions.rb +238 -0
  131. data/lib/middleman-presentation-core/syntax_highlighter.rb +42 -0
  132. data/lib/middleman-presentation-core/test_helpers.rb +22 -0
  133. data/lib/middleman-presentation-core/transformers/file_keeper.rb +13 -0
  134. data/lib/middleman-presentation-core/transformers/group_slides.rb +34 -0
  135. data/lib/middleman-presentation-core/transformers/ignore_slides.rb +28 -0
  136. data/lib/middleman-presentation-core/transformers/remove_duplicate_slides.rb +32 -0
  137. data/lib/middleman-presentation-core/transformers/sort_slides.rb +13 -0
  138. data/lib/middleman-presentation-core/utils.rb +40 -0
  139. data/lib/middleman-presentation-core/version.rb +8 -0
  140. data/lib/middleman-presentation-core.rb +127 -0
  141. data/locales/de.yml +233 -0
  142. data/locales/en.yml +236 -0
  143. data/middleman-presentation-core.gemspec +40 -0
  144. data/source/slides/01.html.liquid +0 -0
  145. data/spec/asset_component_spec.rb +13 -0
  146. data/spec/asset_list_spec.rb +50 -0
  147. data/spec/asset_spec.rb +45 -0
  148. data/spec/asset_store_spec.rb +61 -0
  149. data/spec/assets_manager_spec.rb +111 -0
  150. data/spec/components_manager_spec.rb +142 -0
  151. data/spec/css_class_extracter_spec.rb +28 -0
  152. data/spec/existing_slide_spec.rb +177 -0
  153. data/spec/frontend_component_spec.rb +94 -0
  154. data/spec/helpers_manager_spec.rb +90 -0
  155. data/spec/ignore_file_spec.rb +75 -0
  156. data/spec/new_slide_spec.rb +155 -0
  157. data/spec/presentation_helper_spec.rb +137 -0
  158. data/spec/shared_examples/.keep +0 -0
  159. data/spec/slide_group_spec.rb +54 -0
  160. data/spec/slide_list_spec.rb +125 -0
  161. data/spec/slide_name_spec.rb +53 -0
  162. data/spec/spec_helper.rb +19 -0
  163. data/spec/support/aruba.rb +53 -0
  164. data/spec/support/ci.rb +20 -0
  165. data/spec/support/environment.rb +18 -0
  166. data/spec/support/filesystem.rb +22 -0
  167. data/spec/support/locale.rb +2 -0
  168. data/spec/support/reporting.rb +2 -0
  169. data/spec/support/rspec.rb +9 -0
  170. data/spec/support/string.rb +2 -0
  171. data/spec/transformers/file_keeper_spec.rb +24 -0
  172. data/spec/transformers/group_slides_spec.rb +44 -0
  173. data/spec/transformers/ignore_slides_spec.rb +64 -0
  174. data/spec/transformers/remove_duplicate_slides_spec.rb +120 -0
  175. data/spec/transformers/sort_slides_spec.rb +17 -0
  176. data/spec/utils_spec.rb +14 -0
  177. data/templates/.bowerrc.tt +4 -0
  178. data/templates/.gitignore +5 -0
  179. data/templates/Gemfile.tt +32 -0
  180. data/templates/LICENSE.presentation +1 -0
  181. data/templates/Rakefile +59 -0
  182. data/templates/bower.json.tt +8 -0
  183. data/templates/bundler_config.tt +6 -0
  184. data/templates/config.rb.tt +2 -0
  185. data/templates/config.yaml.tt +17 -0
  186. data/templates/gitignore.tt +14 -0
  187. data/templates/plugin/%plugin_name%.gemspec.tt +24 -0
  188. data/templates/plugin/.gitignore +13 -0
  189. data/templates/plugin/Gemfile.tt +4 -0
  190. data/templates/plugin/LICENSE.txt.tt +22 -0
  191. data/templates/plugin/README.md.tt +31 -0
  192. data/templates/plugin/Rakefile +1 -0
  193. data/templates/plugin/lib/%plugin_name%/version.rb.tt +8 -0
  194. data/templates/plugin/lib/%plugin_name%.rb.tt +10 -0
  195. data/templates/predefined_slides.d/00_00.html.erb.tt +26 -0
  196. data/templates/predefined_slides.d/00_01.html.md.tt +6 -0
  197. data/templates/predefined_slides.d/999980.html.erb.tt +4 -0
  198. data/templates/predefined_slides.d/999981.html.erb.tt +27 -0
  199. data/templates/predefined_slides.d/999982.html.erb.tt +4 -0
  200. data/templates/presentation_theme/bower.json.tt +20 -0
  201. data/templates/presentation_theme/images/.keep +0 -0
  202. data/templates/presentation_theme/javascripts/%theme_name%.js.tt +0 -0
  203. data/templates/presentation_theme/stylesheets/%theme_name%.scss.tt +9 -0
  204. data/templates/presentation_theme/stylesheets/_fonts.scss.tt +0 -0
  205. data/templates/presentation_theme/stylesheets/_images.scss.tt +5 -0
  206. data/templates/presentation_theme/stylesheets/_theme.scss.tt +251 -0
  207. data/templates/rackup.config.erb +16 -0
  208. data/templates/script/bootstrap +5 -0
  209. data/templates/script/build +3 -0
  210. data/templates/script/export +3 -0
  211. data/templates/script/presentation +3 -0
  212. data/templates/script/slide +3 -0
  213. data/templates/script/start +43 -0
  214. data/templates/slides/custom.md.tt +3 -0
  215. data/templates/slides/erb.tt +5 -0
  216. data/templates/slides/group.tt +3 -0
  217. data/templates/slides/liquid.tt +5 -0
  218. data/templates/slides/markdown.tt +3 -0
  219. data/templates/source/index.html.erb +1 -0
  220. data/templates/source/javascripts/application.js.tt +3 -0
  221. data/templates/source/layout.erb +133 -0
  222. data/templates/source/stylesheets/application.scss.tt +3 -0
  223. metadata +574 -0
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # A group of slides
5
+ class SlideGroup
6
+ private
7
+
8
+ attr_reader :template
9
+
10
+ public
11
+
12
+ attr_reader :name, :slides
13
+
14
+ def initialize(name:, slides:, template:)
15
+ @name = name
16
+ @slides = slides
17
+ @template = template
18
+ end
19
+
20
+ # Combine paths of all slides
21
+ def partial_path
22
+ slides.map(&:partial_path).to_list
23
+ end
24
+
25
+ # Call block for each slide
26
+ def render(&block)
27
+ slides_content = slides.each_with_object([]) { |e, a| a << e.render(&block) }.join("\n")
28
+
29
+ template.result(slides: slides_content)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # List of slides
5
+ class SlideList
6
+ include Enumerable
7
+
8
+ private
9
+
10
+ attr_accessor :transformers, :slides
11
+
12
+ public
13
+
14
+ def initialize(names, slide_builder:, **args, &block)
15
+ @slides = Array(names).map { |n| slide_builder.new(n, **args) }
16
+ @transformers = []
17
+
18
+ block.call(self) if block_given?
19
+
20
+ @slides = transformers.reduce(@slides) { |a, e| e.transform(a) }
21
+ end
22
+
23
+ def transform_with(transformer)
24
+ transformers << transformer
25
+ end
26
+
27
+ def all
28
+ slides.dup
29
+ end
30
+
31
+ def each(&block)
32
+ slides.each(&block)
33
+ end
34
+
35
+ def each_new(&block)
36
+ all.keep_if { |s| s.respond_to?(:exist?) && !s.exist? }.each(&block)
37
+ end
38
+
39
+ def each_existing(&block)
40
+ all.keep_if { |s| s.respond_to?(:exist?) && s.exist? }.each(&block)
41
+ end
42
+
43
+ def existing_slides
44
+ all.keep_if { |s| s.respond_to?(:exist?) && s.exist? }
45
+ end
46
+
47
+ def to_a
48
+ all
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Determine slide name base on old slide
5
+ class SlideName
6
+ private
7
+
8
+ attr_reader :old_slide, :base_name, :type
9
+
10
+ public
11
+
12
+ # Create new instance
13
+ #
14
+ # @param [ExistingSlide] old_slide
15
+ # The old slide which should be used
16
+ #
17
+ # @param [String] base_name
18
+ # The requested new base of the file name
19
+ #
20
+ # @param [String] type
21
+ # The requested new type for the slide name
22
+ def initialize(old_slide, base_name:, type:)
23
+ @old_slide = old_slide
24
+ @base_name = base_name
25
+ @type = type
26
+ end
27
+
28
+ # Return the string version of slide name
29
+ def to_s
30
+ return determine_base_name + guess_type if base_name.blank? && type.blank?
31
+
32
+ determine_base_name + determine_type
33
+ end
34
+
35
+ private
36
+
37
+ def guess_type
38
+ case File.extname(old_slide.ext_name)
39
+ when '.md'
40
+ '.erb'
41
+ when '.erb'
42
+ '.md'
43
+ else
44
+ '.md'
45
+ end
46
+ end
47
+
48
+ def determine_base_name
49
+ return base_name if base_name
50
+
51
+ old_slide.base_name
52
+ end
53
+
54
+ def determine_type
55
+ return type.gsub(/^\./, '').prepend('.') if type
56
+
57
+ File.extname(old_slide.ext_name)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+ # Main
3
+ module Middleman
4
+ # Presentation extension
5
+ module Presentation
6
+ class << self
7
+ def start(environment)
8
+ environment.instance_eval do
9
+ activate :sprockets unless respond_to? :sprockets
10
+
11
+ # For testing only otherwise config = Middleman::Pre...::Config.new
12
+ # is run before the new home is set and the config file is created
13
+ # and there is not used.
14
+ Middleman::Presentation.config.redetect if ENV['MP_ENV'] == 'test'
15
+
16
+ set :js_dir, Middleman::Presentation.config.scripts_directory
17
+ set :images_dir, Middleman::Presentation.config.images_directory
18
+ set :build_dir, Middleman::Presentation.config.build_directory
19
+ set :css_dir, Middleman::Presentation.config.stylesheets_directory
20
+ set :source_dir, Middleman::Presentation.config.sources_directory
21
+
22
+ Middleman::Presentation::AssetsLoader.new(bower_directory: MiddlemanEnvironment.new.bower_path).load_at_presentation_runtime
23
+
24
+ helpers Middleman::Presentation.helpers_manager.available_helpers
25
+
26
+ set :markdown_engine, :kramdown
27
+ set :markdown,
28
+ parse_block_html: true,
29
+ tables: true,
30
+ syntax_highlighter: 'middleman_presentation',
31
+ syntax_highlighter_opts: {
32
+ code_block_class: 'mp-code-block',
33
+ inline_code_class: 'mp-code-inline'
34
+ },
35
+ smart_quotes: true
36
+
37
+ # ignore slides so that a user doesn't need to prepend slide names
38
+ # with an underscore
39
+ ignore 'slides/*'
40
+
41
+ # all fetchable components reside in the bower directory. Their
42
+ # assets are required with "component_name/path/to/asset.scss".
43
+ # Therefore it's suffice enough to add the bower directory only.
44
+ sprockets.append_path Pathname.new(File.join(root, Middleman::Presentation::MiddlemanEnvironment.new.bower_directory))
45
+
46
+ # all non fetchable components can be hidden in rubygems and
47
+ # therefor the full path to that components needs to be added
48
+ Middleman::Presentation.components_manager.each_nonfetchable_component do |c|
49
+ next if sprockets.appended_paths.include? c.path
50
+
51
+ sprockets.append_path c.path
52
+ end
53
+
54
+ Middleman::Presentation.assets_manager.each_loadable_asset do |a|
55
+ sprockets.import_asset a.load_path, &a.destination_path_resolver
56
+ end
57
+
58
+ configure :build do
59
+ if Middleman::Presentation.config.minify_assets
60
+ activate :minify_css
61
+ activate :minify_javascript
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,238 @@
1
+ # encoding: utf-8
2
+ Before do
3
+ @aruba_timeout_seconds = 120
4
+ ENV['MM_ENV'] = 'development'
5
+ ENV['MP_ENV'] = 'test'
6
+
7
+ step 'a mocked home directory'
8
+ step 'I configure bundler for fast testing'
9
+ step 'git is configured with username "User" and email-address "email@example.com"'
10
+ step 'I set the language for the shell to "en_GB.UTF-8"'
11
+ end
12
+
13
+ Given(/I configure bundler for fast testing/) do
14
+ config = []
15
+ config << "BUNDLE_PATH: #{ENV['BUNDLE_PATH']}" if ENV.key? 'BUNDLE_PATH'
16
+
17
+ config_file = File.join ENV['HOME'], '.bundle', 'config'
18
+
19
+ FileUtils.mkdir_p File.dirname(config_file)
20
+ File.write config_file, config.join("\n")
21
+ end
22
+
23
+ # Clean environment
24
+ Around do |_, block|
25
+ old_env = ENV.to_h
26
+
27
+ block.call
28
+
29
+ ENV.replace old_env
30
+ end
31
+
32
+ When(/^I start debugging/) do
33
+ # rubocop:disable Lint/Debugger
34
+ require 'pry'
35
+ binding.pry
36
+ # rubocop:enable Lint/Debugger
37
+
38
+ ''
39
+ end
40
+
41
+ Given(/^I use presentation fixture "([^"]+)" with title "([^"]+)"(?: and date "([^"]+)")?$/) do |name, title, date|
42
+ directory = []
43
+ directory << name
44
+ directory << ('-' + title)
45
+ directory << ('-' + date) if date
46
+
47
+ directory = directory.join.characterize
48
+
49
+ command = []
50
+ command << "middleman-presentation create presentation #{temporary_fixture_path(directory)}"
51
+ command << "--title #{Shellwords.escape(title)}"
52
+ command << "--date #{Shellwords.escape(date)}" if date
53
+
54
+ system(command.join(' ')) unless temporary_fixture_exist?(directory)
55
+
56
+ FileUtils.cp_r temporary_fixture_path(directory), absolute_path(name)
57
+ step %(I cd to "#{name}")
58
+ end
59
+
60
+ Given(/^I set the language for the shell to "([^"]+)"$/) do |language|
61
+ set_env 'LANG', language
62
+ end
63
+
64
+ Given(/only the executables of gems "([^"]+)" can be found in PATH/) do |gems|
65
+ dirs = []
66
+
67
+ dirs.concat gems.split(/,\s?/).map(&:strip).each_with_object([]) { |e, a| a << Gem::Specification.find_by_name(e).bin_dir }
68
+
69
+ if ci?
70
+ dirs << "/home/travis/.rvm/rubies/ruby-#{RUBY_VERSION}/bin"
71
+ dirs << "/home/travis/.rvm/rubies/ruby-#{Gem.ruby_api_version}/bin" unless Gem.ruby_api_version == RUBY_VERSION
72
+ end
73
+
74
+ dirs << '/usr/bin'
75
+
76
+ set_env 'PATH', dirs.join(':')
77
+ end
78
+
79
+ Given(/^I create a new presentation with title "([^"]+)"(?: for speaker "([^"]+)")?(?: on "([^"]+)")?$/) do |title, speaker, date|
80
+ options = {}
81
+ options[:title] = title
82
+ options[:speaker] = speaker if speaker
83
+ options[:date] = date if date
84
+
85
+ step %(I successfully run `middleman-presentation create presentation presentation1 #{options.to_options.join(' ')}`)
86
+ step 'I cd to "presentation1"'
87
+ end
88
+
89
+ Given(/^I prepend "([^"]+)" to environment variable "([^"]+)"$/) do |value, variable|
90
+ set_env variable, value + ENV[variable]
91
+ end
92
+
93
+ Given(/^a slide named "(.*?)" with:$/) do |name, string|
94
+ step %(a file named "source/slides/#{name}" with:), string
95
+ end
96
+
97
+ Given(/^a project template named "(.*?)" with:$/) do |name, string|
98
+ step %(a file named "templates/#{name}" with:), string
99
+ end
100
+
101
+ Given(/^a user template named "(.*?)" with:$/) do |name, string|
102
+ step %(a file named "~/.config/middleman-presentation/templates/#{name}" with:), string
103
+ end
104
+
105
+ Given(/^a presentation theme named "(.*?)" does not exist$/) do |name|
106
+ step %(I remove the directory "middleman-presentation-theme-#{name}")
107
+ end
108
+
109
+ Given(/^a file named "(.*?)" does not exist$/) do |name|
110
+ FileUtils.rm_rf absolute_path(name)
111
+ end
112
+
113
+ Given(/^a directory named "(.*?)" does not exist$/) do |name|
114
+ step %(I remove the directory "#{name}")
115
+ end
116
+
117
+ Given(/^a plugin named "(.*?)" does not exist$/) do |name|
118
+ step %(I remove the directory "#{name}")
119
+ end
120
+
121
+ Then(%r{^a plugin named "(.*?)" should exist( with default files/directories created)?$}) do |name, default_files|
122
+ step %(a directory named "#{name}" should exist)
123
+
124
+ if default_files
125
+ %W(
126
+ #{name}/#{name}.gemspec
127
+ #{name}/lib/#{name}.rb
128
+ #{name}/lib/#{name}/version.rb
129
+ #{name}/Gemfile
130
+ #{name}/LICENSE.txt
131
+ #{name}/README.md
132
+ #{name}/Rakefile
133
+ #{name}/.gitignore
134
+ ).each do |file|
135
+ step %(a file named "#{file}" should exist)
136
+ end
137
+
138
+ %W(
139
+ #{name}/lib
140
+ #{name}/lib/#{name}
141
+ ).each do |file|
142
+ step %(a directory named "#{file}" should exist)
143
+ end
144
+ end
145
+ end
146
+
147
+ Given(/^git is configured with username "(.*?)" and email-address "(.*?)"$/) do |name, email|
148
+ step %(I successfully run `git config --global user.email "#{email}"`)
149
+ step %(I successfully run `git config --global user.name "#{name}"`)
150
+ end
151
+
152
+ Given(/^a user config file for middleman\-presentation with:$/) do |string|
153
+ step 'a file named "~/.config/middleman-presentation/application.yaml" with:', string
154
+ end
155
+
156
+ Given(/^a presentation config file for middleman\-presentation with:$/) do |string|
157
+ step 'a file named ".middleman-presentation.yaml" with:', string
158
+ end
159
+
160
+ Then(/^the user config file for middleman\-presentation should contain:$/) do |string|
161
+ step 'the file "~/.config/middleman-presentation/application.yaml" should contain:', string
162
+ end
163
+
164
+ Then(/^the presentation config file for middleman\-presentation should contain:$/) do |string|
165
+ step 'the file ".middleman-presentation.yaml" should contain:', string
166
+ end
167
+
168
+ Then(%r{^a presentation theme named "(.*?)" should exist( with default files/directories created)?$}) do |name, default_files|
169
+ name = "middleman-presentation-theme-#{name}"
170
+
171
+ step %(a directory named "#{name}" should exist)
172
+
173
+ if default_files
174
+ step %(a directory named "#{name}/stylesheets" should exist)
175
+ step %(a directory named "#{name}/javascripts" should exist)
176
+ end
177
+ end
178
+
179
+ Then(/^I go to "([^"]*)" and see the following error message:$/) do |url, message|
180
+ message = capture :stderr do
181
+ # rubocop:disable Lint/HandleExceptions:
182
+ begin
183
+ @browser.get(URI.escape(url))
184
+ rescue StandardError
185
+ end
186
+ # rubocop:enable Lint/HandleExceptions:
187
+ end
188
+
189
+ expect(message).to include message
190
+ end
191
+
192
+ Then(/^a directory named "(.*?)" is a git repository$/) do |name|
193
+ step %(a directory named "#{name}/.git" should exist)
194
+ end
195
+
196
+ Given(/^a slide named "(.*?)" does not exist$/) do |name|
197
+ FileUtils.rm_rf absolute_path('source', 'slides', name)
198
+ end
199
+
200
+ Then(/^a slide named "(.*?)" should exist$/) do |name|
201
+ step %(a file named "source/slides/#{name}" should exist)
202
+ end
203
+
204
+ Then(/^a slide named "(.*?)" should exist with:$/) do |name, string|
205
+ step %(the file "source/slides/#{name}" should contain:), string
206
+ end
207
+
208
+ When(/^I successfully run `([^`]+)` in clean environment$/) do |command|
209
+ Bundler.with_clean_env do
210
+ step %(I successfully run `#{command}`)
211
+ end
212
+ end
213
+
214
+ Given(/^I add a stylesheet asset named "(.*?)" to the presentation$/) do |asset|
215
+ import_string = "@import '#{asset}';"
216
+
217
+ step 'I append to "source/stylesheets/application.scss" with:', import_string
218
+ end
219
+
220
+ When(/^I successfully run `([^`]+)` in debug mode$/) do |cmd|
221
+ step "I run `#{cmd}` in debug mode"
222
+ end
223
+
224
+ When(/^I run `([^`]+)` in debug mode$/) do |cmd|
225
+ in_current_dir do
226
+ # rubocop:disable Lint/Debugger
227
+ require 'pry'
228
+ binding.pry
229
+ # rubocop:enable Lint/Debugger
230
+ system(cmd)
231
+ end
232
+ end
233
+
234
+ Then(/^the size of "(.*?)" should be much smaller than from "(.*?)"$/) do |file1, file2|
235
+ in_current_dir do
236
+ expect(File.size(file1)).to be < File.size(file2)
237
+ end
238
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+ require 'kramdown'
3
+
4
+ # External
5
+ module Kramdown
6
+ # External
7
+ module Converter
8
+ # External
9
+ module SyntaxHighlighter
10
+ # Middleman Presentation Converter
11
+ module MiddlemanPresentation
12
+ def self.call(converter, text, lang, type, _unused_opts)
13
+ opts = converter.options[:syntax_highlighter_opts].dup
14
+ text = ERB::Util.html_escape(text)
15
+
16
+ case type
17
+ when :span
18
+ %(<code class=\"#{opts[:inline_code_class]}\">#{text}</code>)
19
+ when :block
20
+ %(<pre class=\"#{opts[:code_block_class]}\"><code class=\"#{opts[:language_prefix]}#{lang}\">#{text}</code></pre>)
21
+ else
22
+ %(<pre class=\"#{opts[:code_block_class]}\"><code class=\"#{opts[:language_prefix]}#{lang}\">#{text}</code></pre>)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ # External
31
+ module Kramdown
32
+ # External
33
+ module Converter
34
+ klass = ::Kramdown::Converter::SyntaxHighlighter::MiddlemanPresentation
35
+ kn_down = :middleman_presentation
36
+
37
+ add_syntax_highlighter(kn_down) do |converter, text, lang, type, opts|
38
+ add_syntax_highlighter(kn_down, klass)
39
+ syntax_highlighter(kn_down).call(converter, text, lang, type, opts)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Test helpers
5
+ module TestHelpers
6
+ # Helpers for tests
7
+ def ci?
8
+ ENV.key?('CI') || ENV.key?('TRAVIS')
9
+ end
10
+
11
+ def temporary_fixture_path(name)
12
+ File.expand_path("../../../tmp/fixtures/#{name}", __FILE__)
13
+ end
14
+
15
+ def temporary_fixture_exist?(name)
16
+ File.exist? File.expand_path("../../../tmp/fixtures/#{name}", __FILE__)
17
+ end
18
+
19
+ module_function :temporary_fixture_path
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Transformers
5
+ # Keep slide if it is a file
6
+ class FileKeeper
7
+ def transform(slides)
8
+ slides.keep_if { |slide| File.file? slide.path }
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Transformers
5
+ # Group slides together
6
+ class GroupSlides
7
+ private
8
+
9
+ attr_reader :template
10
+
11
+ public
12
+
13
+ def initialize(template:)
14
+ @template = template
15
+ end
16
+
17
+ def transform(slides)
18
+ groups = Set.new
19
+
20
+ new_slides = slides.map do |slide|
21
+ if slide.group && groups.none? { |g| g.name == slide.group }
22
+ slide = group = SlideGroup.new name: slide.group, slides: slides.select { |s| s.group? slide.group }, template: template
23
+ groups << group
24
+ end
25
+
26
+ slide
27
+ end
28
+
29
+ new_slides - groups.map(&:slides).flatten
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Transformers
5
+ # Ignore slides in list: delete them from list
6
+ class IgnoreSlides
7
+ private
8
+
9
+ attr_reader :ignore_file
10
+
11
+ public
12
+
13
+ def initialize(ignore_file:, ignore_file_builder: IgnoreFile)
14
+ @ignore_file = ignore_file_builder.new(ignore_file)
15
+
16
+ invalid_ignore_file = Pathname.new(ignore_file).dirname + Pathname.new('.slideignore')
17
+
18
+ message = "Invalid ignore file \"#{invalid_ignore_file}\" detected. I'm going to ignore it. Please use the correct one \"#{ignore_file}\"."
19
+ Middleman::Presentation.logger.warn message if invalid_ignore_file.exist?
20
+ end
21
+
22
+ def transform(slides)
23
+ slides.delete_if { |slide| ignore_file.ignore? slide }
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Transformers
5
+ # Remove duplicates slides from list
6
+ class RemoveDuplicateSlides
7
+ private
8
+
9
+ attr_reader :additional_slides, :raise_error
10
+
11
+ public
12
+
13
+ def initialize(additional_slides: [], raise_error: false)
14
+ @additional_slides = additional_slides
15
+ @raise_error = raise_error
16
+ end
17
+
18
+ def transform(slides)
19
+ temp_slides = (Array(slides) + Array(additional_slides)).uniq
20
+
21
+ duplicate_slides = temp_slides.each_with_object([]) do |e, a|
22
+ a << slides.select { |s| e.similar?(s) && !e.eql?(s) }
23
+ end.flatten
24
+
25
+ fail ArgumentError, Middleman::Presentation.t('errors.duplicate_slide_names', slide_names: duplicate_slides.map(&:file_name).to_list) if !duplicate_slides.blank? && raise_error
26
+
27
+ slides - duplicate_slides
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Transformers
5
+ # Sort slides
6
+ class SortSlides
7
+ def transform(slides)
8
+ slides.sort
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Utils module
5
+ module Utils
6
+ # Create zip archive from directory
7
+ #
8
+ # @param [String] source_directory
9
+ # The source directory
10
+ #
11
+ # @param [String] destination_file
12
+ # The zip file which should be created
13
+ #
14
+ # @param [String] prefix
15
+ # A prefix for the zip file, e.g. dir1/dir2/ => dir1/dir2/zip_file.
16
+ # Please mind the trailing '/'.
17
+ def zip(source_directory, destination_file, prefix: nil)
18
+ Zip.setup do |c|
19
+ c.on_exists_proc = true
20
+ c.continue_on_exists_proc = true
21
+ c.unicode_names = true
22
+ c.default_compression = Zlib::BEST_COMPRESSION
23
+ end
24
+
25
+ Zip::File.open(destination_file, Zip::File::CREATE) do |file|
26
+ Dir.glob(File.join(source_directory, '**', '*')).each do |filename|
27
+
28
+ path = ''
29
+ path << prefix if prefix
30
+ path << Pathname.new(filename).relative_path_from(Pathname.new(source_directory)).to_s
31
+
32
+ file.add(path, filename)
33
+ end
34
+ end
35
+ end
36
+
37
+ module_function :zip
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Middleman
3
+ module Middleman
4
+ # Presentation
5
+ module Presentation
6
+ VERSION = '0.16.0.alpha'
7
+ end
8
+ end