middleman-presentation-core 0.16.0.alpha

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 (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,55 @@
1
+ # encoding: utf-8
2
+ # Main
3
+ module Middleman
4
+ # Presentation extension
5
+ module Presentation
6
+ @logger = Logger.new
7
+ @config = ApplicationConfig.new(merge_files: true)
8
+ @helpers_manager = HelpersManager.new
9
+ @assets_manager = AssetsManager.new
10
+ @components_manager = ComponentsManager.new
11
+ @plugins_manager = PluginsManager.new(creator: Plugin)
12
+ @locale_configurator = LocaleConfigurator.new(path: File.expand_path('../../../locales', __FILE__), default_locale: @config.cli_language)
13
+ @debug_mode = false
14
+
15
+ class << self
16
+ attr_reader :config, :logger, :plugins_manager, :components_manager, :helpers_manager, :assets_manager, :locale_configurator
17
+
18
+ private
19
+
20
+ attr_accessor :debug_mode
21
+
22
+ public
23
+
24
+ def t(*args, &block)
25
+ locale_configurator.t(*args, &block)
26
+ end
27
+
28
+ def underline_character
29
+ '#'
30
+ end
31
+
32
+ def debug_mode_enabled?
33
+ debug_mode == true
34
+ end
35
+
36
+ def enable_debug_mode
37
+ self.debug_mode = true
38
+ Middleman::Presentation.config.debugging_libraries.each { |l| require l }
39
+ end
40
+
41
+ def stylable_files
42
+ paths = []
43
+
44
+ paths << '../../../templates/slides/*.tt'
45
+ paths << '../../../templates/predefined_slides.d/*.tt'
46
+
47
+ paths.concat ['../../../templates/source/'].product(%w(layout.erb index.html.erb)).map(&:join)
48
+
49
+ Rake::FileList.new(
50
+ paths.map { |f| File.expand_path(f, __FILE__) }
51
+ )
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Markdown template to create new slides
5
+ class MarkdownTemplate < FeduxOrgStdlib::FileTemplate
6
+ def application_name
7
+ 'middleman-presentation'
8
+ end
9
+
10
+ def fallback_template_directory
11
+ File.expand_path('../../../templates/slides', __FILE__)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,108 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Abstraction for middleman environment
5
+ class MiddlemanEnvironment
6
+ private
7
+
8
+ attr_reader :strict, :application_config
9
+
10
+ public
11
+
12
+ def initialize(strict: true)
13
+ @strict = strict
14
+ @application_config = Middleman::Presentation.config
15
+ end
16
+
17
+ def root_path
18
+ @root_path ||= ConfigurationFile.new.directory
19
+ rescue Errno::ENOENT
20
+ raise Errno::ENOENT, Middleman::Presentation.t('errors.extension_not_activated') if strict
21
+
22
+ @root_path = Dir.getwd
23
+ end
24
+
25
+ def build_directory
26
+ application_config.build_directory
27
+ end
28
+
29
+ def build_path
30
+ File.join(sources_path, application_config.build_directory)
31
+ end
32
+
33
+ def stylesheets_directory
34
+ application_config.stylesheets_directory
35
+ end
36
+
37
+ def stylesheets_path
38
+ File.join(sources_path, application_config.stylesheets_directory)
39
+ end
40
+
41
+ def scripts_directory
42
+ application_config.scripts_directory
43
+ end
44
+
45
+ def scripts_path
46
+ File.join(sources_path, application_config.scripts_directory)
47
+ end
48
+
49
+ def images_directory
50
+ application_config.images_directory
51
+ end
52
+
53
+ def images_path
54
+ File.join(sources_path, application_config.images_directory)
55
+ end
56
+
57
+ def fonts_directory
58
+ application_config.fonts_directory
59
+ end
60
+
61
+ def fonts_path
62
+ File.join(sources_path, application_config.fonts_directory)
63
+ end
64
+
65
+ def sources_directory
66
+ application_config.sources_directory
67
+ end
68
+
69
+ def sources_path
70
+ File.join(root_path, application_config.sources_directory)
71
+ end
72
+
73
+ def slides_directory
74
+ File.join(application_config.sources_directory, application_config.slides_directory)
75
+ end
76
+
77
+ def slides_path
78
+ File.join(root_path, application_config.sources_directory, application_config.slides_directory)
79
+ end
80
+
81
+ def bower_directory
82
+ application_config.bower_directory
83
+ end
84
+
85
+ def bower_path
86
+ File.join(root_path, application_config.bower_directory)
87
+ end
88
+
89
+ private
90
+
91
+ def configuration_file
92
+ @configuration_file ||= ConfigurationFile.new
93
+ end
94
+
95
+ def server_instance
96
+ @server_instance ||= proc { ::Middleman::Application.server.inst }.call
97
+
98
+ fail Thor::Error, Middleman::Presentation.t('errors.extension_not_activated') unless @server_instance.extensions.key? :presentation
99
+
100
+ @server_instance
101
+ end
102
+
103
+ def presentation_instance
104
+ @presentation_instance ||= server_instance.extensions[:presentation]
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Presentation extension
5
+ class MiddlemanExtension < Extension
6
+ end
7
+ end
8
+ end
9
+
10
+ ::Middleman::Extensions.register(:presentation) do
11
+ ::Middleman::Presentation::MiddlemanExtension
12
+ end
@@ -0,0 +1,131 @@
1
+ # encoding: UTF-8
2
+ require 'rack/test'
3
+
4
+ Given /^a clean server$/ do
5
+ @initialize_commands = []
6
+ end
7
+
8
+ Given /^"([^\"]*)" feature is "([^\"]*)"$/ do |feature, state|
9
+ @initialize_commands ||= []
10
+
11
+ if state == 'enabled'
12
+ @initialize_commands << lambda { activate(feature.to_sym) }
13
+ end
14
+ end
15
+
16
+ Given /^"([^\"]*)" feature is "enabled" with "([^\"]*)"$/ do |feature, options_str|
17
+ @initialize_commands ||= []
18
+
19
+ options = eval("{#{options_str}}")
20
+
21
+ @initialize_commands << lambda { activate(feature.to_sym, options) }
22
+ end
23
+
24
+ Given /^"([^\"]*)" is set to "([^\"]*)"$/ do |variable, value|
25
+ @initialize_commands ||= []
26
+ @initialize_commands << lambda { set(variable.to_sym, value) }
27
+ end
28
+
29
+ Given /^current environment is "([^\"]*)"$/ do |env|
30
+ @current_env = env.to_sym
31
+ end
32
+
33
+ Given /^the Server is running$/ do
34
+ root_dir = File.expand_path(current_dir)
35
+ in_current_dir do
36
+
37
+ if File.exist?(File.join(root_dir, 'source'))
38
+ ENV['MM_SOURCE'] = 'source'
39
+ else
40
+ ENV['MM_SOURCE'] = ''
41
+ end
42
+
43
+ ENV['MM_ROOT'] = root_dir
44
+
45
+ initialize_commands = @initialize_commands || []
46
+ initialize_commands.unshift lambda {
47
+ set :environment, @current_env || :development
48
+ set :show_exceptions, false
49
+ }
50
+
51
+ in_current_dir do
52
+ @server_inst = Middleman::Application.server.inst do
53
+ initialize_commands.each do |p|
54
+ instance_exec(&p)
55
+ end
56
+ end
57
+ end
58
+
59
+ app_rack = @server_inst.class.to_rack_app
60
+ @browser = ::Rack::Test::Session.new(::Rack::MockSession.new(app_rack))
61
+ end
62
+ end
63
+
64
+ Given /^the Server is running at "([^\"]*)"$/ do |app_path|
65
+ step %(a fixture app "#{app_path}")
66
+ step %(the Server is running)
67
+ end
68
+
69
+ Given /^a template named "([^\"]*)" with:$/ do |name, string|
70
+ step %(a file named "source/#{name}" with:), string
71
+ end
72
+
73
+ When /^I go to "([^\"]*)"$/ do |url|
74
+ in_current_dir do
75
+ @browser.get(URI.escape(url))
76
+ end
77
+ end
78
+
79
+ Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
80
+ in_current_dir do
81
+ expect { @browser.get(URI.escape(url)) }.to_not raise_exception
82
+ end
83
+ end
84
+
85
+ Then /^the content type should be "([^\"]*)"$/ do |expected|
86
+ in_current_dir do
87
+ expect(@browser.last_response.content_type).to start_with(expected)
88
+ end
89
+ end
90
+
91
+ Then /^I should see "([^\"]*)"$/ do |expected|
92
+ in_current_dir do
93
+ expect(@browser.last_response.body).to include(expected)
94
+ end
95
+ end
96
+
97
+ Then /^I should see '([^\']*)'$/ do |expected|
98
+ in_current_dir do
99
+ expect(@browser.last_response.body).to include(expected)
100
+ end
101
+ end
102
+
103
+ Then /^I should see:$/ do |expected|
104
+ in_current_dir do
105
+ expect(@browser.last_response.body).to include(expected)
106
+ end
107
+ end
108
+
109
+ Then /^I should not see "([^\"]*)"$/ do |expected|
110
+ in_current_dir do
111
+ expect(@browser.last_response.body).to_not include(expected)
112
+ end
113
+ end
114
+
115
+ Then /^I should not see:$/ do |expected|
116
+ in_current_dir do
117
+ expect(@browser.last_response.body).to_not include(expected.chomp)
118
+ end
119
+ end
120
+
121
+ Then /^the status code should be "([^\"]*)"$/ do |expected|
122
+ in_current_dir do
123
+ expect(@browser.last_response.status).to eq expected.to_i
124
+ end
125
+ end
126
+
127
+ Then /^I should see "([^\"]*)" lines$/ do |lines|
128
+ in_current_dir do
129
+ expect(@browser.last_response.body.chomp.split($INPUT_RECORD_SEPARATOR).length).to eq(lines.to_i)
130
+ end
131
+ end
@@ -0,0 +1,140 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # A slide
5
+ class NewSlide
6
+ include ComparableSlide
7
+
8
+ private
9
+
10
+ attr_reader :input, :name, :base_path, :slide_directory_path
11
+
12
+ public
13
+
14
+ def initialize(input, base_path:)
15
+ @input = input.split(/:/)
16
+ @name = extract_name
17
+ @slide_directory_path = Pathname.new(base_path)
18
+ @base_path = @slide_directory_path.dirname
19
+ end
20
+
21
+ # Return string representation of self
22
+ def to_s
23
+ path.to_s
24
+ end
25
+
26
+ def path
27
+ p = []
28
+ p << Pathname.new(group) unless group.blank?
29
+ p << file_name
30
+
31
+ # rubocop:disable Style/EachWithObject
32
+ p.reduce(slide_directory_path) do |a, e|
33
+ # rubocop:enable Style/EachWithObject
34
+ a += e
35
+
36
+ a
37
+ end
38
+ end
39
+
40
+ def group
41
+ @group ||= extract_group
42
+ end
43
+
44
+ # Return basename of slide
45
+ def base_name
46
+ File.basename(name).scan(/^([^.]+)(?:\..+)?/).flatten.first
47
+ end
48
+
49
+ def file_name
50
+ path = if type? :erb
51
+ Pathname.new "#{base_name}.html.erb"
52
+ elsif type? :md
53
+ Pathname.new "#{base_name}.html.md"
54
+ elsif type? :liquid
55
+ Pathname.new "#{base_name}.html.liquid"
56
+ else
57
+ Pathname.new("#{base_name}.html#{template.proposed_extname}")
58
+ end
59
+
60
+ Pathname.new(path)
61
+ end
62
+
63
+ # Write slide content to file
64
+ def write(**data)
65
+ FileUtils.mkdir_p path.dirname
66
+
67
+ File.open(path, 'wb') do |f|
68
+ f.write(content(**data))
69
+ end
70
+ end
71
+
72
+ # Does the slide exist
73
+ def exist?
74
+ path.exist?
75
+ end
76
+
77
+ # Generate slide content
78
+ #
79
+ # It either uses previously set content or generates content by using a
80
+ # predefined template
81
+ def content(**data)
82
+ Erubis::Eruby.new(template.content).result(data)
83
+ end
84
+
85
+ # Relative path of slide
86
+ def relative_path
87
+ path.relative_path_from(base_path)
88
+ end
89
+
90
+ private
91
+
92
+ def template
93
+ if type? :erb
94
+ ErbTemplate.new(working_directory: base_path.dirname)
95
+ elsif type? :md
96
+ MarkdownTemplate.new(working_directory: base_path.dirname)
97
+ elsif type? :liquid
98
+ LiquidTemplate.new(working_directory: base_path.dirname)
99
+ else
100
+ CustomTemplate.new(working_directory: base_path.dirname)
101
+ end
102
+ end
103
+
104
+ # Check type of slide
105
+ def type?(t)
106
+ type == t
107
+ end
108
+
109
+ # Determine type of slide
110
+ def type
111
+ return :erb if extname? '.erb'
112
+ return :md if extname? '.md', '.markdown', '.mkd'
113
+ return :liquid if extname? '.l', '.liquid'
114
+
115
+ :custom
116
+ end
117
+
118
+ # Return file extension
119
+ def extname
120
+ File.extname(name)
121
+ end
122
+
123
+ # Check if slide has given extensions
124
+ def extname?(*extensions)
125
+ extensions.any? { |e| extname == e }
126
+ end
127
+
128
+ def extract_name
129
+ input.last
130
+ end
131
+
132
+ # Extract group from name
133
+ def extract_group
134
+ return nil if input.size < 2 # no group given
135
+
136
+ input.first.to_s
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,22 @@
1
+ # Fixes bug in middleman
2
+ module Middleman
3
+ # Renderers
4
+ module Renderers
5
+ # Sass
6
+ module Sass
7
+ # Template
8
+ class SassPlusCSSFilenameTemplate < ::Tilt::SassTemplate
9
+ def evaluate(context, _)
10
+ @context ||= context
11
+ @engine = ::Sass::Engine.new(data, sass_options)
12
+
13
+ begin
14
+ @engine.render
15
+ rescue ::Sass::SyntaxError => e
16
+ ::Sass::SyntaxError.exception_to_css(e)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Plugin
5
+ class Plugin < FeduxOrgStdlib::GemPlugins::Plugin
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,65 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Plugin Api
5
+ module PluginApi
6
+ # Require some other plugin
7
+ #
8
+ # @param [String, Array] names
9
+ # The name of the plugin which should be loaded. It also supports
10
+ # multiple arguments or an array of plugin names.
11
+ #
12
+ # @example String
13
+ #
14
+ # require_plugin 'name1'
15
+ #
16
+ # @example Multiple Arguments
17
+ #
18
+ # require_plugin 'name1', 'name2'
19
+ #
20
+ # @example Arrays
21
+ #
22
+ # require_plugin ['name1', 'name2']
23
+ #
24
+ def require_plugin(*names)
25
+ application.plugins_manager.activate_plugin(names)
26
+ end
27
+
28
+ # Add frontend component
29
+ #
30
+ # @param [Hash] component
31
+ # The component which should be added
32
+ def add_component(component)
33
+ Middleman::Presentation.components_manager.add FrontendComponent.new(**component)
34
+ end
35
+
36
+ # Add helpers
37
+ #
38
+ # @example Add helpers via modules
39
+ #
40
+ # add_helpers MyModule1, MyModule2
41
+ #
42
+ # @example Add helpers via code block
43
+ #
44
+ # add_helpers do
45
+ # def my_helper1
46
+ # 'my_helper1'
47
+ # end
48
+ # end
49
+ def add_helpers(*m, &block)
50
+ Middleman::Presentation.helpers_manager.add(*m, &block)
51
+ end
52
+
53
+ # Add assets which should be imported
54
+ #
55
+ # @param [String] path
56
+ # Directory where assets are stored
57
+ # def add_assets(path, output_paths: {}, importable_files: [], loadable_files: [], ignorable_files: [])
58
+ def add_assets(component)
59
+ Middleman::Presentation.components_manager.add AssetComponent.new(**component)
60
+ end
61
+
62
+ module_function :add_component, :add_helpers, :add_assets
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ class PluginsManager < FeduxOrgStdlib::GemPlugins::PluginManager
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Predefined slide templates directory
5
+ class PredefinedSlideTemplateDirectory < FeduxOrgStdlib::TemplateDirectory
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
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Container for helper methods which can be used in presentation slides
5
+ class PresentationHelper
6
+ include Comparable
7
+
8
+ private
9
+
10
+ attr_reader :helper_container
11
+
12
+ public
13
+
14
+ def initialize(helper_container)
15
+ fail TypeError, Middleman::Presentation.t('errors.invalid_helper_module') if !helper_container.is_a?(Module) && !helper_container.is_a?(Proc)
16
+
17
+ @helper_container = helper_container
18
+ end
19
+
20
+ # Return self as module
21
+ def to_module
22
+ if helper_container.is_a? Proc
23
+ mod = Module.new
24
+ mod.module_eval(&helper_container)
25
+
26
+ mod
27
+ else
28
+ helper_container
29
+ end
30
+ end
31
+
32
+ # Return name for container
33
+ def name
34
+ if helper_container.respond_to?(:name) && !helper_container.name.blank?
35
+ helper_container.name
36
+ else
37
+ '<Anonymous>'
38
+ end
39
+ end
40
+
41
+ # Type of helper
42
+ def type
43
+ if helper_container.is_a? Module
44
+ :MODULE
45
+ else
46
+ :PROC
47
+ end
48
+ end
49
+
50
+ # Return all available methods
51
+ def available_methods
52
+ instance_methods = to_module.instance_methods - Module.methods
53
+ klass_methods = (to_module.methods - Module.methods).map { |m| "self.#{m}" }
54
+
55
+ instance_methods + klass_methods
56
+ end
57
+
58
+ # Parse an array
59
+ def self.parse(*modules)
60
+ modules.flatten.map { |m| new(m) }
61
+ end
62
+
63
+ # @private
64
+ def <=>(other)
65
+ name <=> other.name
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+ ::Middleman::Extensions.register(:presentation) do
3
+ ::Middleman::Presentation::PresentationExtension
4
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ # Included if class can be compared by name
5
+ module ComparableByName
6
+ include Comparable
7
+
8
+ # @private
9
+ def hash
10
+ name.hash
11
+ end
12
+
13
+ # @private
14
+ def eql?(other)
15
+ name.eql? other.name
16
+ end
17
+
18
+ # @private
19
+ def <=>(other)
20
+ name <=> other.name
21
+ end
22
+ end
23
+ end
24
+ end