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,30 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # Base cli class
6
+ class Base < Thor
7
+ include Shared
8
+
9
+ def self.subcommand_help(_cmd)
10
+ desc 'help [COMMAND]', Middleman::Presentation.t('views.application.help')
11
+
12
+ class_eval "
13
+ def help(command = nil, subcommand = true); super; end
14
+ "
15
+ end
16
+
17
+ desc 'help [COMMAND]', Middleman::Presentation.t('views.application.help')
18
+ def help(*args)
19
+ super
20
+ end
21
+
22
+ no_commands do
23
+ def load_runtime_assets
24
+ assets_loader.load_at_presentation_runtime
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # Base group cli class
6
+ class BaseGroup < Thor::Group
7
+ include Shared
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # Build presentation
6
+ class Build < Base
7
+ register BuildPresentation, 'presentation', 'presentation', 'Build presentation'
8
+
9
+ default_command :presentation
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # This class provides an 'build presentation' command for the middleman CLI.
6
+ class BuildPresentation < BaseGroup
7
+ include Thor::Actions
8
+
9
+ desc Middleman::Presentation.t('views.presentation.build.title')
10
+
11
+ def initialize_generator
12
+ enable_debug_mode
13
+ end
14
+
15
+ def add_to_source_path
16
+ source_paths << File.expand_path('../../../../templates', __FILE__)
17
+ end
18
+
19
+ def cleanup
20
+ # before server.inst to prevent having duplicate files
21
+ remove_dir 'build'
22
+ end
23
+
24
+ def make_middleman_environment_available
25
+ @environment = MiddlemanEnvironment.new
26
+ end
27
+
28
+ def extract_data
29
+ @images_directory = @environment.images_directory
30
+ @stylesheets_directory = @environment.stylesheets_directory
31
+ @javascripts_directory = @environment.scripts_directory
32
+ @fonts_directory = @environment.fonts_directory
33
+ @rackup_config_file = File.join @environment.build_directory, 'config.ru'
34
+ end
35
+
36
+ def build_presentation
37
+ Middleman::Presentation.logger.info Middleman::Presentation.t(
38
+ 'views.presentation.build.headline',
39
+ title: Middleman::Presentation.config.title
40
+ )
41
+
42
+ cmd = []
43
+ cmd << 'middleman build'
44
+ cmd << '--verbose' if options[:debug_mode]
45
+
46
+ system cmd.join(' ')
47
+
48
+ fail Thor::Error, Middleman::Presentation.t('errors.middleman_build_error', result: '') unless $CHILD_STATUS.exitstatus == 0
49
+ end
50
+
51
+ def add_rackup_file
52
+ template 'rackup.config.erb', @rackup_config_file
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # This class provides an 'presentation init' command for the middleman CLI.
6
+ class Change < Base
7
+ register(ChangeSlide, 'slide', 'slide NAME(S)', Middleman::Presentation.t('views.slides.change.title'))
8
+
9
+ default_command :slide
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # Create slide
6
+ class ChangeSlide < BaseGroup
7
+ class_option :edit, default: Middleman::Presentation.config.edit_changed_slide, desc: Middleman::Presentation.t('views.application.options.edit')
8
+ class_option :editor_command, default: Middleman::Presentation.config.editor_command, desc: Middleman::Presentation.t('views.application.options.editor_command')
9
+ class_option :error_on_duplicates, type: :boolean, default: Middleman::Presentation.config.error_on_duplicates, desc: Middleman::Presentation.t('views.slides.change.options.error_on_duplicates')
10
+ class_option :base_name, desc: Middleman::Presentation.t('views.slides.change.options.base_name')
11
+ class_option :type, desc: Middleman::Presentation.t('views.slides.change.options.type')
12
+ class_option :regex, type: :boolean, default: Middleman::Presentation.config.use_regex, desc: Middleman::Presentation.t('views.application.options.regex')
13
+
14
+ argument :names, required: false, default: [], type: :array, desc: Middleman::Presentation.t('views.slides.change.arguments.names')
15
+ def make_middleman_environment_available
16
+ @environment = MiddlemanEnvironment.new
17
+ end
18
+
19
+ def change_slide
20
+ enable_debug_mode
21
+
22
+ fail ArgumentError, Middleman::Presentation.t('errors.too_many_arguments', count: 1) if names.count > 1 && options.key?('base_name')
23
+
24
+ existing_slides = SlideList.new(
25
+ Dir.glob(File.join(@environment.slides_directory, '**', '*')),
26
+ slide_builder: ExistingSlide,
27
+ base_path: @environment.sources_directory
28
+ ) do |l|
29
+ l.transform_with Transformers::FileKeeper.new
30
+ end
31
+
32
+ found_slides = existing_slides.select do |s|
33
+ if names.blank?
34
+ true
35
+ else
36
+ if options[:regex]
37
+ names.any? { |n| s.base_name =~ /#{n}/ }
38
+ else
39
+ names.any? { |n| s.base_name == n }
40
+ end
41
+ end
42
+ end
43
+
44
+ if found_slides.blank?
45
+ Middleman::Presentation.logger.warn Middleman::Presentation.t('errors.slide_not_found', patterns: names.to_list)
46
+ return
47
+ end
48
+
49
+ move_jobs = found_slides.sort.map do |old_slide|
50
+ new_slide_file_name = SlideName.new(
51
+ old_slide,
52
+ base_name: options[:base_name],
53
+ type: options[:type]
54
+ )
55
+
56
+ new_slide = NewSlide.new(
57
+ File.join(@environment.slides_directory, new_slide_file_name.to_s),
58
+ base_path: @environment.slides_directory
59
+ )
60
+
61
+ OpenStruct.new(
62
+ source: old_slide,
63
+ destination: new_slide
64
+ )
65
+ end
66
+
67
+ move_jobs.each do |j|
68
+ if j.source == j.destination
69
+ $stderr.puts format('%-20s %-s -> %-s', 'ignore'.colorize(color: :yellow, mode: :bold), j.source.relative_path, j.destination.relative_path)
70
+ next
71
+ end
72
+
73
+ $stderr.puts format('%-20s %-s -> %-s', 'rename '.colorize(color: :green, mode: :bold), j.source.relative_path, j.destination.relative_path)
74
+ FileUtils.mv j.source.path, j.destination.path, force: true
75
+ end
76
+
77
+ invoke 'middleman:presentation:cli:edit_slide', move_jobs.map(&:destination).map(&:base_name), options.extract!('editor_command') if options['edit']
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # This class provides an 'presentation init' command for the middleman CLI.
6
+ class Create < Base
7
+ register(CreateTheme, 'theme', 'theme NAME', Middleman::Presentation.t('views.themes.create.title'))
8
+ register(CreatePresentation, 'presentation', 'presentation [DIR]', Middleman::Presentation.t('views.presentations.create.title'))
9
+ register(CreateSlide, 'slide', 'slide [DIR]', Middleman::Presentation.t('views.slides.create.title'))
10
+ register(CreatePlugin, 'plugin', 'plugin NAME', Middleman::Presentation.t('views.plugin.create.title'))
11
+
12
+ default_command :slide
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # Create plugin
6
+ class CreatePlugin < BaseGroup
7
+ include Thor::Actions
8
+
9
+ desc Middleman::Presentation.t('views.plugins.create.title')
10
+
11
+ class_option :author, default: Middleman::Presentation.config.author, desc: Middleman::Presentation.t('views.plugins.create.options.author')
12
+ class_option :email, default: Middleman::Presentation.config.email, desc: Middleman::Presentation.t('views.plugins.create.options.email')
13
+ class_option :homepage, default: Middleman::Presentation.config.homepage, desc: Middleman::Presentation.t('views.plugins.create.options.homepage')
14
+ class_option :year, default: Time.now.strftime('%Y'), desc: Middleman::Presentation.t('views.plugins.create.options.year')
15
+ class_option :initialize_git, type: :boolean, default: Middleman::Presentation.config.initialize_git, desc: Middleman::Presentation.t('views.plugins.create.options.initialize_git')
16
+
17
+ argument :name, desc: Middleman::Presentation.t('views.plugins.create.arguments.name')
18
+
19
+ def initialize_generator
20
+ enable_debug_mode
21
+ end
22
+
23
+ def add_path_to_source_paths
24
+ source_paths << File.expand_path('../../../../templates', __FILE__)
25
+ end
26
+
27
+ def build_plugin_name
28
+ new_name = []
29
+ new_name << name
30
+
31
+ @plugin_name = new_name.join('-')
32
+ end
33
+
34
+ def create_variables_for_templates
35
+ @plugin_path = File.expand_path(@plugin_name)
36
+ @plugin_class_name = @plugin_name.split(/-/).map(&:camelcase).join('::')
37
+ @author = options[:author]
38
+ @year = options[:year]
39
+ @email = options[:email]
40
+ end
41
+
42
+ def create_plugin
43
+ directory 'plugin', @plugin_name
44
+ end
45
+
46
+ def initialize_git
47
+ return unless options[:initialize_git]
48
+
49
+ Dir.chdir(@plugin_name) do
50
+ run 'git init'
51
+ run 'git add -A .'
52
+ run "git commit -m \"Initialized #{@plugin_name}\""
53
+ end
54
+ end
55
+
56
+ no_commands do
57
+ attr_reader :plugin_name
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,300 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # Initialize presentation
6
+ class CreatePresentation < BaseGroup
7
+ include Thor::Actions
8
+
9
+ class_option :speaker, required: true, default: Middleman::Presentation.config.speaker, desc: Middleman::Presentation.t('views.presentations.create.options.speaker')
10
+ class_option :title, required: true, desc: Middleman::Presentation.t('views.presentations.create.options.title')
11
+ class_option :date, required: true, default: Time.now.strftime('%d.%m.%Y'), desc: Middleman::Presentation.t('views.presentations.create.options.date')
12
+ class_option :license, required: true, default: Middleman::Presentation.config.license, desc: Middleman::Presentation.t('views.presentations.create.options.license')
13
+
14
+ class_option :author, default: Middleman::Presentation.config.author, desc: Middleman::Presentation.t('views.presentations.create.options.author')
15
+ class_option :description, desc: Middleman::Presentation.t('views.presentations.create.options.description')
16
+ class_option :subtitle, desc: Middleman::Presentation.t('views.presentations.create.options.subtitle')
17
+ class_option :homepage, default: Middleman::Presentation.config.homepage, desc: Middleman::Presentation.t('views.presentations.create.options.homepage')
18
+ class_option :company, default: Middleman::Presentation.config.company, desc: Middleman::Presentation.t('views.presentations.create.options.company')
19
+ class_option :location, default: Middleman::Presentation.config.location, desc: Middleman::Presentation.t('views.presentations.create.options.location')
20
+ class_option :audience, default: Middleman::Presentation.config.audience, desc: Middleman::Presentation.t('views.presentations.create.options.audience')
21
+
22
+ class_option :phone_number, default: Middleman::Presentation.config.phone_number, desc: Middleman::Presentation.t('views.presentations.create.options.phone_number')
23
+ class_option :email_address, default: Middleman::Presentation.config.email_address, desc: Middleman::Presentation.t('views.presentations.create.options.email_address')
24
+ class_option :github_url, default: Middleman::Presentation.config.github_url, desc: Middleman::Presentation.t('views.presentations.create.options.github_url')
25
+
26
+ class_option :width, default: Middleman::Presentation.config.width, desc: Middleman::Presentation.t('views.presentations.create.options.width')
27
+ class_option :height, default: Middleman::Presentation.config.height, desc: Middleman::Presentation.t('views.presentations.create.options.height')
28
+ class_option :margin, default: Middleman::Presentation.config.margin, desc: Middleman::Presentation.t('views.presentations.create.options.margin')
29
+ class_option :min_scale, default: Middleman::Presentation.config.min_scale, desc: Middleman::Presentation.t('views.presentations.create.options.min_scale')
30
+ class_option :max_scale, default: Middleman::Presentation.config.max_scale, desc: Middleman::Presentation.t('views.presentations.create.options.max_scale')
31
+ class_option :activate_center, type: :boolean, default: Middleman::Presentation.config.activate_center, desc: Middleman::Presentation.t('views.presentations.create.options.activate_center')
32
+ class_option :activate_controls, type: :boolean, default: Middleman::Presentation.config.activate_controls, desc: Middleman::Presentation.t('views.presentations.create.options.activate_controls')
33
+ class_option :activate_embedded, type: :boolean, default: Middleman::Presentation.config.activate_embedded, desc: Middleman::Presentation.t('views.presentations.create.options.activate_embedded')
34
+ class_option :activate_fragments, type: :boolean, default: Middleman::Presentation.config.activate_fragments, desc: Middleman::Presentation.t('views.presentations.create.options.activate_fragments')
35
+ class_option :activate_history, type: :boolean, default: Middleman::Presentation.config.activate_history, desc: Middleman::Presentation.t('views.presentations.create.options.activate_history')
36
+ class_option :activate_history, type: :boolean, default: Middleman::Presentation.config.activate_history, desc: Middleman::Presentation.t('views.presentations.create.options.activate_history')
37
+ class_option :activate_keyboard, type: :boolean, default: Middleman::Presentation.config.activate_keyboard, desc: Middleman::Presentation.t('views.presentations.create.options.activate_keyboard')
38
+ class_option :activate_loop, type: :boolean, default: Middleman::Presentation.config.activate_loop, desc: Middleman::Presentation.t('views.presentations.create.options.activate_loop')
39
+ class_option :activate_mouse_wheel, type: :boolean, default: Middleman::Presentation.config.activate_mouse_wheel, desc: Middleman::Presentation.t('views.presentations.create.options.activate_mouse_wheel')
40
+ class_option :activate_overview, type: :boolean, default: Middleman::Presentation.config.activate_overview, desc: Middleman::Presentation.t('views.presentations.create.options.activate_overview')
41
+ class_option :activate_progress, type: :boolean, default: Middleman::Presentation.config.activate_progress, desc: Middleman::Presentation.t('views.presentations.create.options.activate_progress')
42
+ class_option :activate_rtl, type: :boolean, default: Middleman::Presentation.config.activate_rtl, desc: Middleman::Presentation.t('views.presentations.create.options.activate_rtl')
43
+ class_option :activate_slide_number, type: :boolean, default: Middleman::Presentation.config.activate_slide_number, desc: Middleman::Presentation.t('views.presentations.create.options.activate_slide_number')
44
+ class_option :activate_touch, type: :boolean, default: Middleman::Presentation.config.activate_touch, desc: Middleman::Presentation.t('views.presentations.create.options.activate_touch')
45
+ class_option :auto_slide, type: :numeric, default: Middleman::Presentation.config.auto_slide, desc: Middleman::Presentation.t('views.presentations.create.options.auto_slide')
46
+ class_option :auto_slide_stoppable, type: :boolean, default: Middleman::Presentation.config.auto_slide_stoppable, desc: Middleman::Presentation.t('views.presentations.create.options.auto_slide_stoppable')
47
+ class_option :default_background_transition, default: Middleman::Presentation.config.default_background_transition, desc: Middleman::Presentation.t('views.presentations.create.options.default_background_transition')
48
+ class_option :default_transition_speed, default: Middleman::Presentation.config.default_transition_speed, desc: Middleman::Presentation.t('views.presentations.create.options.default_transition_speed')
49
+ class_option :default_transition_type, default: Middleman::Presentation.config.default_transition_type, desc: Middleman::Presentation.t('views.presentations.create.options.default_transition_type')
50
+ class_option :hide_address_bar, type: :boolean, default: Middleman::Presentation.config.hide_address_bar, desc: Middleman::Presentation.t('views.presentations.create.options.hide_address_bar')
51
+ class_option :parallax_background_image, default: Middleman::Presentation.config.parallax_background_image, desc: Middleman::Presentation.t('views.presentations.create.options.parallax_background_image')
52
+ class_option :parallax_background_size, default: Middleman::Presentation.config.parallax_background_size, desc: Middleman::Presentation.t('views.presentations.create.options.parallax_background_size')
53
+ class_option :preview_links, type: :boolean, default: Middleman::Presentation.config.preview_links, desc: Middleman::Presentation.t('views.presentations.create.options.preview_links')
54
+ class_option :view_distance, type: :numeric, default: Middleman::Presentation.config.view_distance, desc: Middleman::Presentation.t('views.presentations.create.options.view_distance')
55
+
56
+ class_option :install_assets, type: :boolean, default: Middleman::Presentation.config.install_assets, desc: Middleman::Presentation.t('views.presentations.create.options.install_assets')
57
+ class_option :initialize_git, type: :boolean, default: Middleman::Presentation.config.initialize_git, desc: Middleman::Presentation.t('views.presentations.create.options.initialize_git')
58
+ class_option :check_for_bower, type: :boolean, default: Middleman::Presentation.config.check_for_bower, desc: Middleman::Presentation.t('views.presentations.create.options.check_for_bower')
59
+
60
+ class_option :create_predefined_slides, type: :boolean, default: Middleman::Presentation.config.create_predefined_slides, desc: Middleman::Presentation.t('views.presentations.create.options.create_predefined_slides')
61
+
62
+ class_option :language, default: Middleman::Presentation.config.presentation_language, desc: Middleman::Presentation.t('views.presentations.create.options.language')
63
+ class_option :version, default: Middleman::Presentation.config.default_version_number, desc: Middleman::Presentation.t('views.presentations.create.options.version')
64
+ class_option :force, type: :boolean, default: Middleman::Presentation.config.force_create_presentation, desc: Middleman::Presentation.t('views.presentations.create.options.force')
65
+ class_option :runtime_environment, default: Middleman::Presentation.config.runtime_environment, desc: Middleman::Presentation.t('views.presentations.create.options.runtime_environment')
66
+
67
+ class_option :sources_directory, default: Middleman::Presentation.config.sources_directory, desc: Middleman::Presentation.t('views.presentations.create.options.sources_directory')
68
+ class_option :images_directory, default: Middleman::Presentation.config.images_directory, desc: Middleman::Presentation.t('views.presentations.create.options.images_directory')
69
+ class_option :scripts_directory, default: Middleman::Presentation.config.scripts_directory, desc: Middleman::Presentation.t('views.presentations.create.options.scripts_directory')
70
+ class_option :stylesheets_directory, default: Middleman::Presentation.config.stylesheets_directory, desc: Middleman::Presentation.t('views.presentations.create.options.stylesheets_directory')
71
+ class_option :fonts_directory, default: Middleman::Presentation.config.fonts_directory, desc: Middleman::Presentation.t('views.presentations.create.options.fonts_directory')
72
+ class_option :build_directory, default: Middleman::Presentation.config.build_directory, desc: Middleman::Presentation.t('views.presentations.create.options.build_directory')
73
+
74
+ argument :directory, default: Dir.getwd, desc: Middleman::Presentation.t('views.presentations.create.arguments.directory')
75
+
76
+ desc Middleman::Presentation.t('views.presentations.create.title')
77
+
78
+ def initialize_generator
79
+ enable_debug_mode
80
+ end
81
+
82
+ def add_to_sources_path
83
+ source_paths << File.expand_path('../../../../templates', __FILE__)
84
+ end
85
+
86
+ def expand_directory
87
+ @directory = File.expand_path(directory)
88
+ end
89
+
90
+ def set_language
91
+ @language = FeduxOrgStdlib::ShellLanguageDetector.new.detect(
92
+ allowed: Middleman::Presentation.locale_configurator.available_locales,
93
+ overwrite: options[:language]
94
+ ).language_code
95
+ end
96
+
97
+ def set_variables_for_templates
98
+ Middleman::Presentation.config.author = options[:author]
99
+ Middleman::Presentation.config.speaker = options[:speaker]
100
+ Middleman::Presentation.config.title = options[:title]
101
+ Middleman::Presentation.config.description = options[:description]
102
+ Middleman::Presentation.config.subtitle = options[:subtitle]
103
+ Middleman::Presentation.config.date = options[:date]
104
+ Middleman::Presentation.config.homepage = options[:homepage]
105
+ Middleman::Presentation.config.company = options[:company]
106
+ Middleman::Presentation.config.license = options[:license]
107
+ Middleman::Presentation.config.location = options[:location]
108
+ Middleman::Presentation.config.audience = options[:audience]
109
+
110
+ Middleman::Presentation.config.email_address = options[:email_address]
111
+ Middleman::Presentation.config.phone_number = options[:phone_number]
112
+ Middleman::Presentation.config.github_url = options[:github_url]
113
+
114
+ Middleman::Presentation.config.version = options[:version]
115
+ Middleman::Presentation.config.project_id = format '%s-%s', options[:title].characterize, SecureRandom.hex
116
+
117
+ Middleman::Presentation.config.width = options[:width]
118
+ Middleman::Presentation.config.height = options[:height]
119
+ Middleman::Presentation.config.margin = options[:margin]
120
+ Middleman::Presentation.config.min_scale = options[:min_scale]
121
+ Middleman::Presentation.config.max_scale = options[:max_scale]
122
+ Middleman::Presentation.config.activate_center = options[:activate_center]
123
+ Middleman::Presentation.config.activate_controls = options[:activate_controls]
124
+ Middleman::Presentation.config.activate_embedded = options[:activate_embedded]
125
+ Middleman::Presentation.config.activate_fragments = options[:activate_fragments]
126
+ Middleman::Presentation.config.activate_history = options[:activate_history]
127
+ Middleman::Presentation.config.activate_history = options[:activate_history]
128
+ Middleman::Presentation.config.activate_keyboard = options[:activate_keyboard]
129
+ Middleman::Presentation.config.activate_loop = options[:activate_loop]
130
+ Middleman::Presentation.config.activate_mouse_wheel = options[:activate_mouse_wheel]
131
+ Middleman::Presentation.config.activate_overview = options[:activate_overview]
132
+ Middleman::Presentation.config.activate_progress = options[:activate_progress]
133
+ Middleman::Presentation.config.activate_rtl = options[:activate_rtl]
134
+ Middleman::Presentation.config.activate_slide_number = options[:activate_slide_number]
135
+ Middleman::Presentation.config.activate_touch = options[:activate_touch]
136
+ Middleman::Presentation.config.auto_slide = options[:auto_slide]
137
+ Middleman::Presentation.config.auto_slide_stoppable = options[:auto_slide_stoppable]
138
+ Middleman::Presentation.config.default_background_transition = options[:default_background_transition]
139
+ Middleman::Presentation.config.default_transition_speed = options[:default_transition_speed]
140
+ Middleman::Presentation.config.default_transition_type = options[:default_transition_type]
141
+ Middleman::Presentation.config.hide_address_bar = options[:hide_address_bar]
142
+ Middleman::Presentation.config.parallax_background_image = options[:parallax_background_image]
143
+ Middleman::Presentation.config.parallax_background_size = options[:parallax_background_size]
144
+ Middleman::Presentation.config.preview_links = options[:preview_links]
145
+ Middleman::Presentation.config.view_distance = options[:view_distance]
146
+
147
+ Middleman::Presentation.config.bower_directory = options[:bower_directory]
148
+
149
+ Middleman::Presentation.config.runtime_environment = options[:runtime_environment]
150
+
151
+ Middleman::Presentation.config.sources_directory = options[:sources_directory]
152
+ Middleman::Presentation.config.images_directory = options[:images_directory]
153
+ Middleman::Presentation.config.scripts_directory = options[:scripts_directory]
154
+ Middleman::Presentation.config.stylesheets_directory = options[:stylesheets_directory]
155
+ Middleman::Presentation.config.fonts_directory = options[:fonts_directory]
156
+ Middleman::Presentation.config.build_directory = options[:build_directory]
157
+ end
158
+
159
+ def create_root_directory
160
+ empty_directory directory, force: options[:force]
161
+ end
162
+
163
+ def create_directories
164
+ [
165
+ # :sources_path, # implicit created
166
+ :images_path,
167
+ :scripts_path,
168
+ :stylesheets_path,
169
+ :fonts_path
170
+ ].each do |dir|
171
+ empty_directory middleman_environment.public_send(dir), force: options[:force]
172
+ end
173
+ end
174
+
175
+ def create_gemfile
176
+ @rubygem_path = File.expand_path('../../../../../', __FILE__)
177
+ template 'Gemfile.tt', File.join(middleman_environment.root_path, 'Gemfile'), force: options[:force]
178
+ end
179
+
180
+ def create_config_file
181
+ create_file(
182
+ File.join(middleman_environment.root_path, '.middleman-presentation.yaml'),
183
+ Middleman::Presentation.config.to_yaml(keys: Middleman::Presentation.config.exportable_options, remove_blank: true),
184
+ force: options[:force]
185
+ )
186
+ end
187
+
188
+ def create_bower_configuration_files
189
+ assets_loader.load_for_bower_update
190
+
191
+ @bower_directory = middleman_environment.bower_directory
192
+ template '.bowerrc.tt', File.join(middleman_environment.root_path, '.bowerrc'), force: options[:force]
193
+ template 'bower.json.tt', File.join(middleman_environment.root_path, 'bower.json'), force: options[:force]
194
+ end
195
+
196
+ def create_rake_file
197
+ template 'Rakefile', File.join(middleman_environment.root_path, 'Rakefile'), force: options[:force]
198
+ end
199
+
200
+ def create_slides_ignore_file
201
+ create_file File.join(middleman_environment.root_path, Middleman::Presentation.config.slides_ignore_file), "# empty\n", force: options[:force]
202
+ end
203
+
204
+ def add_configuration_for_middleman_presentation
205
+ template 'config.rb.tt', File.join(middleman_environment.root_path, 'config.rb'), force: options[:force]
206
+ end
207
+
208
+ def add_patterns_to_gitignore
209
+ template 'gitignore.tt', File.join(middleman_environment.root_path, '.gitignore'), force: options[:force]
210
+ end
211
+
212
+ def create_presentation_layout
213
+ template 'source/layout.erb', File.join(middleman_environment.sources_path, 'layout.erb'), force: options[:force]
214
+ copy_file 'source/index.html.erb', File.join(middleman_environment.sources_path, 'index.html.erb'), force: options[:force]
215
+ end
216
+
217
+ def create_default_slides
218
+ return unless options[:create_predefined_slides]
219
+
220
+ 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]
228
+ end
229
+ end
230
+
231
+ def create_default_license_file_to_presentation
232
+ copy_file 'LICENSE.presentation', File.join(middleman_environment.root_path, 'LICENSE.presentation'), force: options[:force]
233
+ end
234
+
235
+ def create_helper_scripts
236
+ %w(start bootstrap slide presentation build export).each do |s|
237
+ copy_file File.join('script', s), File.join(middleman_environment.root_path, 'script', s), force: options[:force]
238
+ chmod File.join(middleman_environment.root_path, 'script', s), 0755, force: options[:force]
239
+ end
240
+ end
241
+
242
+ def install_components
243
+ inside directory do
244
+ fail Thor::Error, Middleman::Presentation.t('errors.bower_command_not_found', path: ENV['PATH']) if options[:check_for_bower] && File.which('bower').blank?
245
+
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
248
+ end
249
+ end
250
+
251
+ def install_gems
252
+ inside directory do
253
+ 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
256
+ end
257
+ end
258
+ end
259
+
260
+ def create_application_asset_files
261
+ assets_loader.load_for_asset_aggregators
262
+
263
+ template 'source/stylesheets/application.scss.tt', File.join(middleman_environment.sources_path, 'stylesheets', 'application.scss'), force: options[:force]
264
+ template 'source/javascripts/application.js.tt', File.join(middleman_environment.sources_path, 'javascripts', 'application.js'), force: options[:force]
265
+ end
266
+
267
+ def initialize_git_directory
268
+ return unless options[:initialize_git]
269
+
270
+ inside directory do
271
+ run 'git init'
272
+ run 'git add -A .'
273
+ run 'git commit -m Init'
274
+ end
275
+ end
276
+
277
+ no_commands do
278
+ # Overwrite for assets_loader
279
+ def middleman_environment
280
+ return @middleman_environment if @middleman_environment
281
+
282
+ Dir.chdir directory do
283
+ @middleman_environment = MiddlemanEnvironment.new(strict: false)
284
+ @middleman_environment.root_path
285
+ end
286
+
287
+ @middleman_environment
288
+ end
289
+
290
+ def bower_path
291
+ return @bower_path if @bower_path
292
+
293
+ environment = MiddlemanEnvironment.new(strict: false)
294
+ @bower_path = File.join(directory, environment.bower_directory)
295
+ end
296
+ end
297
+ end
298
+ end
299
+ end
300
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+ module Middleman
3
+ module Presentation
4
+ module Cli
5
+ # Create slide
6
+ class CreateSlide < BaseGroup
7
+ class_option :edit, default: Middleman::Presentation.config.edit_created_slide, desc: Middleman::Presentation.t('views.application.options.edit')
8
+ class_option :editor_command, default: Middleman::Presentation.config.editor_command, desc: Middleman::Presentation.t('views.application.options.editor_command')
9
+ class_option :error_on_duplicates, type: :boolean, default: Middleman::Presentation.config.error_on_duplicates, desc: Middleman::Presentation.t('views.slides.create.options.error_on_duplicates')
10
+ class_option :title, desc: Middleman::Presentation.t('views.slides.create.options.title')
11
+
12
+ argument :names, type: :array, desc: Middleman::Presentation.t('views.slides.create.arguments.names')
13
+
14
+ def make_middleman_environment_available
15
+ @environment = MiddlemanEnvironment.new
16
+ end
17
+
18
+ def create_slide
19
+ enable_debug_mode
20
+
21
+ existing_slides = Middleman::Presentation::SlideList.new(
22
+ Dir.glob(File.join(@environment.slides_directory, '**', '*')),
23
+ slide_builder: Middleman::Presentation::ExistingSlide,
24
+ base_path: @environment.sources_directory
25
+ ) do |l|
26
+ l.transform_with Middleman::Presentation::Transformers::FileKeeper.new
27
+ end
28
+
29
+ slide_list = Middleman::Presentation::SlideList.new(
30
+ names,
31
+ slide_builder: Middleman::Presentation::NewSlide,
32
+ base_path: @environment.slides_directory
33
+ ) do |l|
34
+ l.transform_with Middleman::Presentation::Transformers::RemoveDuplicateSlides.new(additional_slides: existing_slides, raise_error: options[:error_on_duplicates])
35
+ l.transform_with Middleman::Presentation::Transformers::SortSlides.new
36
+ end
37
+
38
+ slide_list.each_existing do |slide|
39
+ $stderr.puts format('%-20s %-s', 'exist'.colorize(color: :blue, mode: :bold), slide.relative_path)
40
+ end
41
+
42
+ slide_list.each_new do |slide|
43
+ $stderr.puts format('%-20s %-s', 'create'.colorize(color: :green, mode: :bold), slide.relative_path)
44
+ slide.write(title: options[:title])
45
+ end
46
+
47
+ invoke 'middleman:presentation:cli:edit_slide', slide_list.map(&:base_name), options.extract!('editor_command') if options['edit']
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end