middleman-presentation-core 0.16.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rdebugrc +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +52 -0
- data/.simplecov +25 -0
- data/.yardopts +5 -0
- data/Guardfile +13 -0
- data/LICENSE.software +21 -0
- data/Rakefile +200 -0
- data/config/license_finder.yml +13 -0
- data/cucumber.yml +2 -0
- data/doc/licenses/dependencies.csv +55 -0
- data/doc/licenses/dependencies.db +0 -0
- data/doc/licenses/dependencies.html +1415 -0
- data/doc/licenses/dependencies.md +603 -0
- data/doc/licenses/dependencies_detailed.csv +190 -0
- data/doc/yard/.keep +0 -0
- data/features/build_presentation.feature +62 -0
- data/features/code_highlighting.feature +43 -0
- data/features/components.feature +29 -0
- data/features/create_plugin-cli.feature +11 -0
- data/features/create_presentation-cli.feature +349 -0
- data/features/create_slide-cli.feature +188 -0
- data/features/create_slides-templates-cli.feature +114 -0
- data/features/create_theme-cli.feature +58 -0
- data/features/default_slides.feature +58 -0
- data/features/edit_slide-cli.feature +121 -0
- data/features/export_presentation-cli.feature +23 -0
- data/features/grouping_slides.feature +150 -0
- data/features/ignore_slides.feature +103 -0
- data/features/init_application-cli.feature +59 -0
- data/features/init_predefined_slides.feature +9 -0
- data/features/language_detection.feature +0 -0
- data/features/list_assets-cli.feature +13 -0
- data/features/list_components-cli.feature +13 -0
- data/features/list_helpers-cli.feature +13 -0
- data/features/list_plugins-cli.feature +13 -0
- data/features/list_styles-cli.feature +17 -0
- data/features/plugins.feature +63 -0
- data/features/presentation.feature +57 -0
- data/features/rename_slide-cli.feature +176 -0
- data/features/render_slides.feature +76 -0
- data/features/show_config-cli.feature +25 -0
- data/features/show_footer.feature +14 -0
- data/features/show_slide_number.feature +31 -0
- data/features/show_support_information-cli.feature +12 -0
- data/features/support/aruba.rb +18 -0
- data/features/support/ci.rb +3 -0
- data/features/support/env.rb +25 -0
- data/features/support/fixtures.rb +21 -0
- data/features/support/hash.rb +2 -0
- data/features/support/reporting.rb +2 -0
- data/features/version_number.feature +15 -0
- data/fixtures/middleman-presentation-simple_plugin/Rakefile +1 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-plugin.rb +0 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/helpers.rb +13 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/plugin.rb +34 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin/version.rb +8 -0
- data/fixtures/middleman-presentation-simple_plugin/lib/middleman-presentation-simple_plugin.rb +11 -0
- data/fixtures/middleman-presentation-simple_plugin/middleman-presentation-simple_plugin.gemspec +22 -0
- data/fixtures/middleman-presentation-simple_plugin/vendor/assets/stylesheets/test_simple.scss +3 -0
- data/lib/middleman-presentation-core/application_config.rb +198 -0
- data/lib/middleman-presentation-core/asset.rb +103 -0
- data/lib/middleman-presentation-core/asset_component.rb +34 -0
- data/lib/middleman-presentation-core/asset_list.rb +84 -0
- data/lib/middleman-presentation-core/asset_store.rb +73 -0
- data/lib/middleman-presentation-core/assets_loader.rb +95 -0
- data/lib/middleman-presentation-core/assets_manager.rb +73 -0
- data/lib/middleman-presentation-core/cache.rb +49 -0
- data/lib/middleman-presentation-core/cli/base.rb +30 -0
- data/lib/middleman-presentation-core/cli/base_group.rb +11 -0
- data/lib/middleman-presentation-core/cli/build.rb +13 -0
- data/lib/middleman-presentation-core/cli/build_presentation.rb +57 -0
- data/lib/middleman-presentation-core/cli/change.rb +13 -0
- data/lib/middleman-presentation-core/cli/change_slide.rb +82 -0
- data/lib/middleman-presentation-core/cli/create.rb +16 -0
- data/lib/middleman-presentation-core/cli/create_plugin.rb +62 -0
- data/lib/middleman-presentation-core/cli/create_presentation.rb +300 -0
- data/lib/middleman-presentation-core/cli/create_slide.rb +52 -0
- data/lib/middleman-presentation-core/cli/create_theme.rb +81 -0
- data/lib/middleman-presentation-core/cli/edit.rb +13 -0
- data/lib/middleman-presentation-core/cli/edit_slide.rb +49 -0
- data/lib/middleman-presentation-core/cli/export.rb +11 -0
- data/lib/middleman-presentation-core/cli/export_presentation.rb +55 -0
- data/lib/middleman-presentation-core/cli/init.rb +12 -0
- data/lib/middleman-presentation-core/cli/init_application.rb +48 -0
- data/lib/middleman-presentation-core/cli/init_predefined_slides.rb +31 -0
- data/lib/middleman-presentation-core/cli/list.rb +66 -0
- data/lib/middleman-presentation-core/cli/reset_thor.rb +18 -0
- data/lib/middleman-presentation-core/cli/runner.rb +47 -0
- data/lib/middleman-presentation-core/cli/serve.rb +13 -0
- data/lib/middleman-presentation-core/cli/serve_presentation.rb +30 -0
- data/lib/middleman-presentation-core/cli/shared.rb +51 -0
- data/lib/middleman-presentation-core/cli/show.rb +70 -0
- data/lib/middleman-presentation-core/comparable_slide.rb +69 -0
- data/lib/middleman-presentation-core/component.rb +86 -0
- data/lib/middleman-presentation-core/components_manager.rb +96 -0
- data/lib/middleman-presentation-core/configuration_file.rb +15 -0
- data/lib/middleman-presentation-core/css_class_extracter.rb +41 -0
- data/lib/middleman-presentation-core/custom_template.rb +15 -0
- data/lib/middleman-presentation-core/erb_template.rb +15 -0
- data/lib/middleman-presentation-core/errors.rb +10 -0
- data/lib/middleman-presentation-core/existing_slide.rb +92 -0
- data/lib/middleman-presentation-core/frontend_component.rb +75 -0
- data/lib/middleman-presentation-core/group_template.rb +15 -0
- data/lib/middleman-presentation-core/helpers_manager.rb +37 -0
- data/lib/middleman-presentation-core/ignore_file.rb +52 -0
- data/lib/middleman-presentation-core/liquid_template.rb +15 -0
- data/lib/middleman-presentation-core/list.rb +7 -0
- data/lib/middleman-presentation-core/locale_configurator.rb +84 -0
- data/lib/middleman-presentation-core/logger.rb +8 -0
- data/lib/middleman-presentation-core/main.rb +55 -0
- data/lib/middleman-presentation-core/markdown_template.rb +15 -0
- data/lib/middleman-presentation-core/middleman_environment.rb +108 -0
- data/lib/middleman-presentation-core/middleman_extension.rb +12 -0
- data/lib/middleman-presentation-core/middleman_step_definitions.rb +131 -0
- data/lib/middleman-presentation-core/new_slide.rb +140 -0
- data/lib/middleman-presentation-core/overwrite_sass.rb +22 -0
- data/lib/middleman-presentation-core/plugin.rb +8 -0
- data/lib/middleman-presentation-core/plugin_api.rb +65 -0
- data/lib/middleman-presentation-core/plugins_manager.rb +7 -0
- data/lib/middleman-presentation-core/predefined_slide_templates_directory.rb +15 -0
- data/lib/middleman-presentation-core/presentation_helper.rb +69 -0
- data/lib/middleman-presentation-core/register_extension.rb +4 -0
- data/lib/middleman-presentation-core/roles/comparable_by_name.rb +24 -0
- data/lib/middleman-presentation-core/slide_group.rb +33 -0
- data/lib/middleman-presentation-core/slide_list.rb +52 -0
- data/lib/middleman-presentation-core/slide_name.rb +61 -0
- data/lib/middleman-presentation-core/start.rb +68 -0
- data/lib/middleman-presentation-core/step_definitions.rb +238 -0
- data/lib/middleman-presentation-core/syntax_highlighter.rb +42 -0
- data/lib/middleman-presentation-core/test_helpers.rb +22 -0
- data/lib/middleman-presentation-core/transformers/file_keeper.rb +13 -0
- data/lib/middleman-presentation-core/transformers/group_slides.rb +34 -0
- data/lib/middleman-presentation-core/transformers/ignore_slides.rb +28 -0
- data/lib/middleman-presentation-core/transformers/remove_duplicate_slides.rb +32 -0
- data/lib/middleman-presentation-core/transformers/sort_slides.rb +13 -0
- data/lib/middleman-presentation-core/utils.rb +40 -0
- data/lib/middleman-presentation-core/version.rb +8 -0
- data/lib/middleman-presentation-core.rb +127 -0
- data/locales/de.yml +233 -0
- data/locales/en.yml +236 -0
- data/middleman-presentation-core.gemspec +40 -0
- data/source/slides/01.html.liquid +0 -0
- data/spec/asset_component_spec.rb +13 -0
- data/spec/asset_list_spec.rb +50 -0
- data/spec/asset_spec.rb +45 -0
- data/spec/asset_store_spec.rb +61 -0
- data/spec/assets_manager_spec.rb +111 -0
- data/spec/components_manager_spec.rb +142 -0
- data/spec/css_class_extracter_spec.rb +28 -0
- data/spec/existing_slide_spec.rb +177 -0
- data/spec/frontend_component_spec.rb +94 -0
- data/spec/helpers_manager_spec.rb +90 -0
- data/spec/ignore_file_spec.rb +75 -0
- data/spec/new_slide_spec.rb +155 -0
- data/spec/presentation_helper_spec.rb +137 -0
- data/spec/shared_examples/.keep +0 -0
- data/spec/slide_group_spec.rb +54 -0
- data/spec/slide_list_spec.rb +125 -0
- data/spec/slide_name_spec.rb +53 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/support/aruba.rb +53 -0
- data/spec/support/ci.rb +20 -0
- data/spec/support/environment.rb +18 -0
- data/spec/support/filesystem.rb +22 -0
- data/spec/support/locale.rb +2 -0
- data/spec/support/reporting.rb +2 -0
- data/spec/support/rspec.rb +9 -0
- data/spec/support/string.rb +2 -0
- data/spec/transformers/file_keeper_spec.rb +24 -0
- data/spec/transformers/group_slides_spec.rb +44 -0
- data/spec/transformers/ignore_slides_spec.rb +64 -0
- data/spec/transformers/remove_duplicate_slides_spec.rb +120 -0
- data/spec/transformers/sort_slides_spec.rb +17 -0
- data/spec/utils_spec.rb +14 -0
- data/templates/.bowerrc.tt +4 -0
- data/templates/.gitignore +5 -0
- data/templates/Gemfile.tt +32 -0
- data/templates/LICENSE.presentation +1 -0
- data/templates/Rakefile +59 -0
- data/templates/bower.json.tt +8 -0
- data/templates/bundler_config.tt +6 -0
- data/templates/config.rb.tt +2 -0
- data/templates/config.yaml.tt +17 -0
- data/templates/gitignore.tt +14 -0
- data/templates/plugin/%plugin_name%.gemspec.tt +24 -0
- data/templates/plugin/.gitignore +13 -0
- data/templates/plugin/Gemfile.tt +4 -0
- data/templates/plugin/LICENSE.txt.tt +22 -0
- data/templates/plugin/README.md.tt +31 -0
- data/templates/plugin/Rakefile +1 -0
- data/templates/plugin/lib/%plugin_name%/version.rb.tt +8 -0
- data/templates/plugin/lib/%plugin_name%.rb.tt +10 -0
- data/templates/predefined_slides.d/00_00.html.erb.tt +26 -0
- data/templates/predefined_slides.d/00_01.html.md.tt +6 -0
- data/templates/predefined_slides.d/999980.html.erb.tt +4 -0
- data/templates/predefined_slides.d/999981.html.erb.tt +27 -0
- data/templates/predefined_slides.d/999982.html.erb.tt +4 -0
- data/templates/presentation_theme/bower.json.tt +20 -0
- data/templates/presentation_theme/images/.keep +0 -0
- data/templates/presentation_theme/javascripts/%theme_name%.js.tt +0 -0
- data/templates/presentation_theme/stylesheets/%theme_name%.scss.tt +9 -0
- data/templates/presentation_theme/stylesheets/_fonts.scss.tt +0 -0
- data/templates/presentation_theme/stylesheets/_images.scss.tt +5 -0
- data/templates/presentation_theme/stylesheets/_theme.scss.tt +251 -0
- data/templates/rackup.config.erb +16 -0
- data/templates/script/bootstrap +5 -0
- data/templates/script/build +3 -0
- data/templates/script/export +3 -0
- data/templates/script/presentation +3 -0
- data/templates/script/slide +3 -0
- data/templates/script/start +43 -0
- data/templates/slides/custom.md.tt +3 -0
- data/templates/slides/erb.tt +5 -0
- data/templates/slides/group.tt +3 -0
- data/templates/slides/liquid.tt +5 -0
- data/templates/slides/markdown.tt +3 -0
- data/templates/source/index.html.erb +1 -0
- data/templates/source/javascripts/application.js.tt +3 -0
- data/templates/source/layout.erb +133 -0
- data/templates/source/stylesheets/application.scss.tt +3 -0
- metadata +574 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# Create theme
|
6
|
+
class CreateTheme < BaseGroup
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc Middleman::Presentation.t('views.themes.create.title')
|
10
|
+
|
11
|
+
class_option :prefix, default: Middleman::Presentation.config.theme_prefix, desc: Middleman::Presentation.t('views.themes.create.options.prefix')
|
12
|
+
class_option :stylesheets_directory, default: Middleman::Presentation.config.create_stylesheets_directory, desc: Middleman::Presentation.t('views.themes.create.options.stylesheets_directory')
|
13
|
+
class_option :javascripts_directory, default: Middleman::Presentation.config.create_javascripts_directory, desc: Middleman::Presentation.t('views.themes.create.options.javascripts_directory')
|
14
|
+
class_option :images_directory, default: Middleman::Presentation.config.create_images_directory, desc: Middleman::Presentation.t('views.themes.create.options.images_directory')
|
15
|
+
class_option :author, default: Middleman::Presentation.config.author, desc: Middleman::Presentation.t('views.themes.create.options.author')
|
16
|
+
class_option :email, desc: Middleman::Presentation.t('views.themes.create.options.email')
|
17
|
+
class_option :homepage, desc: Middleman::Presentation.t('views.themes.create.options.homepage')
|
18
|
+
class_option :version, default: '0.0.1', required: true, desc: Middleman::Presentation.t('views.themes.create.options.version')
|
19
|
+
class_option :year, default: Time.now.strftime('%Y'), desc: Middleman::Presentation.t('views.themes.create.options.year')
|
20
|
+
class_option :license, default: 'MIT', required: true, desc: Middleman::Presentation.t('views.themes.create.options.license')
|
21
|
+
class_option :initialize_git, type: :boolean, default: Middleman::Presentation.config.initialize_git, desc: Middleman::Presentation.t('views.themes.create.options.initialize_git')
|
22
|
+
class_option :clean_css, type: :boolean, default: false, desc: Middleman::Presentation.t('views.themes.create.options.clean_css')
|
23
|
+
|
24
|
+
argument :name, desc: Middleman::Presentation.t('views.themes.create.arguments.name')
|
25
|
+
|
26
|
+
def initialize_generator
|
27
|
+
enable_debug_mode
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_path_to_source_paths
|
31
|
+
source_paths << File.expand_path('../../../../templates', __FILE__)
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_theme_name
|
35
|
+
new_name = []
|
36
|
+
new_name << options[:prefix] unless options[:prefix].blank?
|
37
|
+
new_name << name
|
38
|
+
|
39
|
+
@theme_name = new_name.join('-')
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_variables_for_templates
|
43
|
+
@author = options[:author]
|
44
|
+
@year = options[:year]
|
45
|
+
@license = options[:license]
|
46
|
+
@email = options[:email]
|
47
|
+
@version = options[:version]
|
48
|
+
@clean_css = options[:clean_css]
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_theme_directory
|
52
|
+
empty_directory theme_name
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_bower_config_file
|
56
|
+
template 'presentation_theme/bower.json.tt', File.join(theme_name, 'bower.json')
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_asset_directories
|
60
|
+
directory('presentation_theme/javascripts', File.join(theme_name, 'javascripts')) if options[:javascripts_directory]
|
61
|
+
directory('presentation_theme/stylesheets', File.join(theme_name, 'stylesheets')) if options[:stylesheets_directory]
|
62
|
+
directory('presentation_theme/images', File.join(theme_name, 'images')) if options[:images_directory]
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize_git
|
66
|
+
return unless options[:initialize_git]
|
67
|
+
|
68
|
+
Dir.chdir(theme_name) do
|
69
|
+
run 'git init'
|
70
|
+
run 'git add -A .'
|
71
|
+
run 'git commit -m Init'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
no_commands do
|
76
|
+
attr_reader :theme_name
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
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 Edit < Base
|
7
|
+
register(EditSlide, 'slide', 'slide NAME(S)', Middleman::Presentation.t('views.slides.edit.title'))
|
8
|
+
|
9
|
+
default_command :slide
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# Create slide
|
6
|
+
class EditSlide < BaseGroup
|
7
|
+
class_option :editor_command, default: Middleman::Presentation.config.editor_command, desc: Middleman::Presentation.t('views.application.options.editor_command')
|
8
|
+
class_option :regex, type: :boolean, default: Middleman::Presentation.config.use_regex, desc: Middleman::Presentation.t('views.application.options.regex')
|
9
|
+
|
10
|
+
argument :names, default: [], required: false, type: :array, desc: Middleman::Presentation.t('views.slides.edit.arguments.names')
|
11
|
+
|
12
|
+
def make_middleman_environment_available
|
13
|
+
@environment = MiddlemanEnvironment.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def edit_slide
|
17
|
+
enable_debug_mode
|
18
|
+
|
19
|
+
existing_slides = SlideList.new(
|
20
|
+
Dir.glob(File.join(@environment.slides_path, '**', '*')),
|
21
|
+
slide_builder: ExistingSlide,
|
22
|
+
base_path: @environment.sources_path
|
23
|
+
) do |l|
|
24
|
+
l.transform_with Transformers::FileKeeper.new
|
25
|
+
end
|
26
|
+
|
27
|
+
found_slides = existing_slides.select do |s|
|
28
|
+
if names.blank?
|
29
|
+
true
|
30
|
+
else
|
31
|
+
if options[:regex]
|
32
|
+
names.any? { |n| s.base_name =~ /#{n}/ }
|
33
|
+
else
|
34
|
+
names.any? { |n| s.base_name == n }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if found_slides.blank?
|
40
|
+
Middleman::Presentation.logger.warn Middleman::Presentation.t('errors.slide_not_found', patterns: names.to_list)
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
open_in_editor found_slides.sort.map(&:path)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# This class provides an 'export presentation' command for the middleman CLI.
|
6
|
+
class ExportPresentation < BaseGroup
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
class_option :output_file, desc: Middleman::Presentation.t('views.presentations.export.options.output_file')
|
10
|
+
class_option :prefix, desc: Middleman::Presentation.t('views.presentations.export.options.prefix')
|
11
|
+
|
12
|
+
desc Middleman::Presentation.t('views.presentation.export.title')
|
13
|
+
|
14
|
+
def initialize_generator
|
15
|
+
enable_debug_mode
|
16
|
+
end
|
17
|
+
|
18
|
+
def make_middleman_environment_available
|
19
|
+
@environment = MiddlemanEnvironment.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def extract_data
|
23
|
+
@title = Middleman::Presentation.config.title
|
24
|
+
@date = Middleman::Presentation.config.date.to_s
|
25
|
+
@source_directory = @environment.build_path
|
26
|
+
@output_file = File.expand_path(
|
27
|
+
options.fetch('output_file', (@date.to_s + '-' + @title).characterize + '.zip')
|
28
|
+
)
|
29
|
+
|
30
|
+
fail Middleman::Presentation.t('errors.zip_filename_error', name: File.basename(@output_file)) unless @output_file.end_with? '.zip'
|
31
|
+
|
32
|
+
@prefix = options.fetch('prefix', (@date.to_s + '-' + @title.to_s).characterize + '/')
|
33
|
+
@images_directory = @environment.images_directory
|
34
|
+
@stylesheets_directory = @environment.stylesheets_directory
|
35
|
+
@javascripts_directory = @environment.scripts_directory
|
36
|
+
@fonts_directory = @environment.fonts_directory
|
37
|
+
end
|
38
|
+
|
39
|
+
def build_presentation
|
40
|
+
invoke 'middleman:presentation:cli:build:presentation'
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_archive
|
44
|
+
Middleman::Presentation.logger.info Middleman::Presentation.t(
|
45
|
+
'views.presentation.export.headline',
|
46
|
+
title: @title,
|
47
|
+
file: @output_file
|
48
|
+
)
|
49
|
+
|
50
|
+
Middleman::Presentation::Utils.zip(@source_directory, @output_file, prefix: @prefix)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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 Init < Base
|
7
|
+
register(InitApplication, 'application', 'application', Middleman::Presentation.t('views.applications.init.title'))
|
8
|
+
register(InitPredefinedSlides, 'predefined_slides', 'predefined_slides', Middleman::Presentation.t('views.predefined_slides.init.title'))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# This class provides an 'init presentation' command for the middleman CLI.
|
6
|
+
class InitApplication < BaseGroup
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
class_option :configuration_file, default: Middleman::Presentation.config.preferred_configuration_file, desc: Middleman::Presentation.t('views.applications.create.options.configuration_file')
|
10
|
+
class_option :force, type: :boolean, desc: Middleman::Presentation.t('views.applications.create.options.force')
|
11
|
+
class_option :local, type: :boolean, desc: Middleman::Presentation.t('views.applications.create.options.local')
|
12
|
+
|
13
|
+
def initialize_generator
|
14
|
+
enable_debug_mode
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_to_source_path
|
18
|
+
source_paths << File.expand_path('../../../../templates', __FILE__)
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_variables_for_templates
|
22
|
+
@version = Middleman::Presentation::VERSION
|
23
|
+
@config = Middleman::Presentation.config
|
24
|
+
end
|
25
|
+
|
26
|
+
def write_new_configuration
|
27
|
+
file = if options[:local]
|
28
|
+
File.join(MiddlemanEnvironment.new.root_path, '.middleman-presentation.yaml')
|
29
|
+
else
|
30
|
+
options[:configuration_file]
|
31
|
+
end
|
32
|
+
|
33
|
+
FileUtils.cp file, "#{file}.bkp" if File.exist?(file) && options[:force]
|
34
|
+
|
35
|
+
if options[:local]
|
36
|
+
create_file(
|
37
|
+
file,
|
38
|
+
Middleman::Presentation.config.to_yaml(keys: Middleman::Presentation.config.exportable_options, remove_blank: true),
|
39
|
+
force: options[:force]
|
40
|
+
)
|
41
|
+
else
|
42
|
+
template 'config.yaml.tt', file, force: options[:force]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# This class provides an 'create presentation' command for the middleman CLI.
|
6
|
+
class InitPredefinedSlides < BaseGroup
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
class_option :directory, default: PredefinedSlideTemplateDirectory.new.preferred_template_directory, desc: Middleman::Presentation.t('views.predefined_slides.create.options.directory')
|
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 set_variables
|
20
|
+
@source = File.expand_path('../../../../templates', __FILE__)
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_templates
|
24
|
+
PredefinedSlideTemplateDirectory.new(working_directory: @source).template_files.each do |file|
|
25
|
+
copy_file file, File.join(options[:directory], File.basename(file))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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 List < Base
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc 'plugins', Middleman::Presentation.t('views.plugins.list.title')
|
10
|
+
def plugins
|
11
|
+
enable_debug_mode
|
12
|
+
load_runtime_assets
|
13
|
+
|
14
|
+
puts Middleman::Presentation.t('views.plugins.list.headline').underline(character: Middleman::Presentation.underline_character)
|
15
|
+
puts Middleman::Presentation.plugins_manager.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'helpers', Middleman::Presentation.t('views.helpers.list.title')
|
19
|
+
def helpers
|
20
|
+
enable_debug_mode
|
21
|
+
load_runtime_assets
|
22
|
+
|
23
|
+
puts Middleman::Presentation.t('views.helpers.list.headline').underline(character: Middleman::Presentation.underline_character)
|
24
|
+
puts Middleman::Presentation.helpers_manager.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'assets', Middleman::Presentation.t('views.assets.list.title')
|
28
|
+
def assets
|
29
|
+
enable_debug_mode
|
30
|
+
load_runtime_assets
|
31
|
+
|
32
|
+
puts Middleman::Presentation.t('views.assets.list.headline').underline(character: Middleman::Presentation.underline_character)
|
33
|
+
puts Middleman::Presentation.assets_manager.to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'components', Middleman::Presentation.t('views.components.list.title')
|
37
|
+
def components
|
38
|
+
enable_debug_mode
|
39
|
+
load_runtime_assets
|
40
|
+
|
41
|
+
puts Middleman::Presentation.t('views.components.list.headline').underline(character: Middleman::Presentation.underline_character)
|
42
|
+
puts Middleman::Presentation.components_manager.to_s
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'styles', Middleman::Presentation.t('views.styles.list.title')
|
46
|
+
def styles
|
47
|
+
enable_debug_mode
|
48
|
+
load_runtime_assets
|
49
|
+
|
50
|
+
css_classes = Middleman::Presentation::CssClassExtracter.new.extract Middleman::Presentation.stylable_files, ignore: %w(slides reveal)
|
51
|
+
|
52
|
+
puts Middleman::Presentation.t('views.styles.list.headline').underline(character: Middleman::Presentation.underline_character)
|
53
|
+
css_classes.each { |klass| puts format ' %20s: %s', klass.name, klass.files.to_list }
|
54
|
+
puts
|
55
|
+
end
|
56
|
+
|
57
|
+
no_commands do
|
58
|
+
# Overwrite for assets_loader
|
59
|
+
def bower_path
|
60
|
+
MiddlemanEnvironment.new(strict: false).bower_path
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Restore original behaviour of thor
|
2
|
+
# rubocop:disable Style/ClassAndModuleChildren
|
3
|
+
class ::Thor
|
4
|
+
# rubocop:enable Style/ClassAndModuleChildren
|
5
|
+
module Actions
|
6
|
+
# Create file helper class
|
7
|
+
class CreateFile
|
8
|
+
def on_conflict_behavior(&block)
|
9
|
+
if identical?
|
10
|
+
say_status :identical, :blue
|
11
|
+
else
|
12
|
+
options = base.options.merge(config)
|
13
|
+
force_or_skip_or_conflict(options[:force], options[:skip], &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# Run command
|
6
|
+
class Runner < Base
|
7
|
+
class_option :debug_mode, default: Middleman::Presentation.config.debug_mode, type: :boolean, desc: Middleman::Presentation.t('views.application.options.debug_mode')
|
8
|
+
class_option :bower_directory, default: Middleman::Presentation.config.bower_directory, desc: Middleman::Presentation.t('views.application.options.bower_directory')
|
9
|
+
|
10
|
+
map '-v' => :version
|
11
|
+
map '--version' => :version
|
12
|
+
|
13
|
+
desc 'init', Middleman::Presentation.t('views.runners.init.title')
|
14
|
+
subcommand 'init', Init
|
15
|
+
|
16
|
+
desc 'show', Middleman::Presentation.t('views.runners.show.title')
|
17
|
+
subcommand 'show', Show
|
18
|
+
|
19
|
+
desc 'create', Middleman::Presentation.t('views.runners.create.title')
|
20
|
+
subcommand 'create', Create
|
21
|
+
|
22
|
+
desc 'list', Middleman::Presentation.t('views.runners.list.title')
|
23
|
+
subcommand 'list', List
|
24
|
+
|
25
|
+
desc 'export', Middleman::Presentation.t('views.runners.export.title')
|
26
|
+
subcommand 'export', Export
|
27
|
+
|
28
|
+
desc 'build', Middleman::Presentation.t('views.runners.build.title')
|
29
|
+
subcommand 'build', Build
|
30
|
+
|
31
|
+
desc 'serve', Middleman::Presentation.t('views.runners.build.title')
|
32
|
+
subcommand 'serve', Serve
|
33
|
+
|
34
|
+
desc 'change', Middleman::Presentation.t('views.runners.change.title')
|
35
|
+
subcommand 'change', Change
|
36
|
+
|
37
|
+
desc 'edit', Middleman::Presentation.t('views.runners.edit.title')
|
38
|
+
subcommand 'edit', Edit
|
39
|
+
|
40
|
+
desc 'version', 'version', hide: true
|
41
|
+
def version
|
42
|
+
invoke 'middleman:presentation:cli:show:version'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# Build presentation
|
6
|
+
class Serve < Base
|
7
|
+
register ServePresentation, 'presentation', 'presentation', 'Serve presentation'
|
8
|
+
|
9
|
+
default_command :presentation
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
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 ServePresentation < BaseGroup
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc Middleman::Presentation.t('views.presentation.serve.title')
|
10
|
+
|
11
|
+
def initialize_generator
|
12
|
+
enable_debug_mode
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_presentation
|
16
|
+
Middleman::Presentation.logger.info Middleman::Presentation.t(
|
17
|
+
'views.presentation.serve.headline',
|
18
|
+
title: Middleman::Presentation.config.title
|
19
|
+
)
|
20
|
+
|
21
|
+
cmd = []
|
22
|
+
cmd << 'middleman server'
|
23
|
+
cmd << '--verbose' if options[:debug_mode]
|
24
|
+
|
25
|
+
run(cmd.join(' '))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Cli
|
5
|
+
# Bundle shared methods for all cli classes
|
6
|
+
module Shared
|
7
|
+
def self.included(base)
|
8
|
+
base.extend ClassMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
# Enable debug mode
|
12
|
+
def enable_debug_mode
|
13
|
+
Middleman::Presentation.enable_debug_mode if options[:debug_mode] == true
|
14
|
+
end
|
15
|
+
|
16
|
+
# Create bower directory
|
17
|
+
def bower_path
|
18
|
+
MiddlemanEnvironment.new.bower_path
|
19
|
+
end
|
20
|
+
|
21
|
+
# Create assets loader base on bower directory
|
22
|
+
def assets_loader
|
23
|
+
return @assets_loader if @assets_loader
|
24
|
+
|
25
|
+
@assets_loader = Middleman::Presentation::AssetsLoader.new(bower_directory: bower_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
def open_in_editor(paths)
|
29
|
+
editor = []
|
30
|
+
|
31
|
+
begin
|
32
|
+
editor << Erubis::Eruby.new(options[:editor_command]).result(Middleman::Presentation.config.to_h)
|
33
|
+
rescue NameError => e
|
34
|
+
$stderr.puts Middleman::Presentation.t('errors.missing_data_attribute', message: e.message)
|
35
|
+
end
|
36
|
+
editor.concat paths
|
37
|
+
|
38
|
+
Middleman::Presentation.logger.warn Middleman::Presentation.t('infos.open_slide_in_editor', editor: editor.first)
|
39
|
+
system(editor.join(' '))
|
40
|
+
end
|
41
|
+
|
42
|
+
# The class methods
|
43
|
+
module ClassMethods
|
44
|
+
def self.exit_on_failure?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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 Show < Base
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
desc 'support_information', Middleman::Presentation.t('views.support_informations.show.title')
|
10
|
+
def support_information
|
11
|
+
enable_debug_mode
|
12
|
+
load_runtime_assets
|
13
|
+
|
14
|
+
puts FeduxOrgStdlib::SupportInformation.new(
|
15
|
+
headlines: {
|
16
|
+
rubygems_information: Middleman::Presentation.t('views.support_informations.show.headline.rubygems_information'),
|
17
|
+
system_information: Middleman::Presentation.t('views.support_informations.show.headline.system_information'),
|
18
|
+
installed_rubygems: Middleman::Presentation.t('views.support_informations.show.headline.installed_rubygems')
|
19
|
+
},
|
20
|
+
underline_character: Middleman::Presentation.underline_character
|
21
|
+
).to_s
|
22
|
+
puts
|
23
|
+
|
24
|
+
puts Middleman::Presentation.t('views.plugins.list.headline').underline(character: Middleman::Presentation.underline_character)
|
25
|
+
puts Middleman::Presentation.plugins_manager.to_s
|
26
|
+
puts
|
27
|
+
|
28
|
+
puts Middleman::Presentation.t('views.helpers.list.headline').underline(character: Middleman::Presentation.underline_character)
|
29
|
+
puts Middleman::Presentation.helpers_manager.to_s
|
30
|
+
puts
|
31
|
+
|
32
|
+
puts Middleman::Presentation.t('views.assets.list.headline').underline(character: Middleman::Presentation.underline_character)
|
33
|
+
puts Middleman::Presentation.assets_manager.to_s
|
34
|
+
puts
|
35
|
+
|
36
|
+
puts Middleman::Presentation.t('views.components.list.headline').underline(character: Middleman::Presentation.underline_character)
|
37
|
+
puts Middleman::Presentation.components_manager.to_s
|
38
|
+
puts
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'version', Middleman::Presentation.t('views.versions.show.title')
|
42
|
+
def version
|
43
|
+
puts Middleman::Presentation::VERSION
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'config', Middleman::Presentation.t('views.configs.show.title')
|
47
|
+
option :defaults, type: :boolean, desc: Middleman::Presentation.t('views.configs.show.options.defaults')
|
48
|
+
def config
|
49
|
+
enable_debug_mode
|
50
|
+
|
51
|
+
if options[:defaults]
|
52
|
+
puts Middleman::Presentation.config.defaults.to_s
|
53
|
+
else
|
54
|
+
files = Middleman::Presentation.config.files
|
55
|
+
puts Middleman::Presentation.t('views.configs.show.used_config_files', files: files.to_list, count: files.size)
|
56
|
+
puts
|
57
|
+
puts Middleman::Presentation.config.to_s
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
no_commands do
|
62
|
+
# Overwrite for assets_loader
|
63
|
+
def bower_path
|
64
|
+
MiddlemanEnvironment.new(strict: false).bower_path
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
# All methods needed to compare slides
|
5
|
+
module ComparableSlide
|
6
|
+
include Comparable
|
7
|
+
|
8
|
+
# Needs to be implemented to make the other methods work
|
9
|
+
def path
|
10
|
+
fail MethodNotImplemented
|
11
|
+
end
|
12
|
+
|
13
|
+
# Needs to be implemented to make the other methods work
|
14
|
+
def base_name
|
15
|
+
fail MethodNotImplemented
|
16
|
+
end
|
17
|
+
|
18
|
+
# Needs to be implemented to make the other methods work
|
19
|
+
def group
|
20
|
+
fail MethodNotImplemented
|
21
|
+
end
|
22
|
+
|
23
|
+
# @private
|
24
|
+
def <=>(other)
|
25
|
+
path <=> other.path
|
26
|
+
end
|
27
|
+
|
28
|
+
# @private
|
29
|
+
def eql?(other)
|
30
|
+
path.eql? other.path
|
31
|
+
end
|
32
|
+
|
33
|
+
# Is slide similar to another slide
|
34
|
+
def similar?(other)
|
35
|
+
return true if eql? other
|
36
|
+
|
37
|
+
base_name?(other.base_name) && group?(other.group)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @private
|
41
|
+
def hash
|
42
|
+
path.hash
|
43
|
+
end
|
44
|
+
|
45
|
+
# Checks if slide is in group
|
46
|
+
def group?(g)
|
47
|
+
group == g
|
48
|
+
end
|
49
|
+
|
50
|
+
# Check if string/regex matches path
|
51
|
+
def match?(string_or_regex)
|
52
|
+
regex = if string_or_regex.is_a? String
|
53
|
+
Regexp.new(string_or_regex)
|
54
|
+
else
|
55
|
+
string_or_regex
|
56
|
+
end
|
57
|
+
|
58
|
+
# rubocop:disable Style/CaseEquality
|
59
|
+
regex === relative_path.to_s
|
60
|
+
# rubocop:enable Style/CaseEquality
|
61
|
+
end
|
62
|
+
|
63
|
+
# Check if basename is equal
|
64
|
+
def base_name?(b)
|
65
|
+
base_name == b
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|