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.
- 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,198 @@
|
|
|
1
|
+
# encoding, utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# Configuration for presentation extension
|
|
5
|
+
class ApplicationConfig < FeduxOrgStdlib::AppConfig
|
|
6
|
+
option :title, nil
|
|
7
|
+
option :subtitle, nil
|
|
8
|
+
option :project_id, nil
|
|
9
|
+
option :version, nil
|
|
10
|
+
|
|
11
|
+
option :date, Time.now.strftime('%Y-%m-%d %H:%M:%S')
|
|
12
|
+
option :speaker, process_environment.fetch('USER')
|
|
13
|
+
option :license, 'CC BY 4.0'
|
|
14
|
+
option :bower_directory, 'vendor/assets/components'
|
|
15
|
+
option :author, `git config user.name`.strip.blank? ? process_environment.fetch('USER') : `git config user.name`.strip
|
|
16
|
+
option :email, `git config user.email`.strip.blank? ? 'noemail@example.org' : `git config user.email`.strip
|
|
17
|
+
option :description, nil
|
|
18
|
+
option :homepage, nil
|
|
19
|
+
option :company, nil
|
|
20
|
+
option :location, nil
|
|
21
|
+
option :audience, nil
|
|
22
|
+
option :phone_number, nil
|
|
23
|
+
option :email_address, nil
|
|
24
|
+
option :github_url, nil
|
|
25
|
+
|
|
26
|
+
option :theme, name: 'middleman-presentation-theme-default',
|
|
27
|
+
github: 'maxmeyer/middleman-presentation-theme-default',
|
|
28
|
+
importable_files: [
|
|
29
|
+
%r{stylesheets/middleman-presentation-theme-default.scss$}
|
|
30
|
+
],
|
|
31
|
+
loadable_files: [
|
|
32
|
+
/.*\.png$/
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
option :plugin_prefix, 'middleman-presentation'
|
|
36
|
+
|
|
37
|
+
option :components, []
|
|
38
|
+
|
|
39
|
+
option :width, 960
|
|
40
|
+
option :height, 700
|
|
41
|
+
option :margin, 0.1
|
|
42
|
+
option :min_scale, 0.2
|
|
43
|
+
option :max_scale, 1.0
|
|
44
|
+
option :activate_center, true
|
|
45
|
+
option :activate_controls, true
|
|
46
|
+
option :activate_embedded, false
|
|
47
|
+
option :activate_fragments, true
|
|
48
|
+
option :activate_history, true
|
|
49
|
+
option :activate_keyboard, true
|
|
50
|
+
option :activate_loop, false
|
|
51
|
+
option :activate_mouse_wheel, true
|
|
52
|
+
option :activate_overview, true
|
|
53
|
+
option :activate_progress, true
|
|
54
|
+
option :activate_rtl, false
|
|
55
|
+
option :activate_slide_number, true
|
|
56
|
+
option :activate_touch, true
|
|
57
|
+
option :auto_slide, 0
|
|
58
|
+
option :auto_slide_stoppable, true
|
|
59
|
+
option :default_background_transition, 'default'
|
|
60
|
+
option :default_transition_speed, 'default'
|
|
61
|
+
option :default_transition_type, 'linear'
|
|
62
|
+
option :hide_address_bar, true
|
|
63
|
+
option :parallax_background_image, ''
|
|
64
|
+
option :parallax_background_size, ''
|
|
65
|
+
option :preview_links, false
|
|
66
|
+
option :view_distance, 3
|
|
67
|
+
|
|
68
|
+
option :install_assets, true
|
|
69
|
+
option :initialize_git, true
|
|
70
|
+
option :check_for_bower, true
|
|
71
|
+
option :clear_source, true
|
|
72
|
+
option :create_predefined_slides, true
|
|
73
|
+
option :presentation_language, nil
|
|
74
|
+
option :cli_language, nil
|
|
75
|
+
option :default_version_number, 'v0.0.1'
|
|
76
|
+
|
|
77
|
+
option :plugins, []
|
|
78
|
+
|
|
79
|
+
option :slides_directory, 'slides'
|
|
80
|
+
option :slides_ignore_file, '.slidesignore'
|
|
81
|
+
|
|
82
|
+
option :create_stylesheets_directory, true
|
|
83
|
+
option :create_javascripts_directory, true
|
|
84
|
+
option :create_images_directory, true
|
|
85
|
+
option :theme_prefix, 'middleman-presentation-theme'
|
|
86
|
+
|
|
87
|
+
option :edit_created_slide, false
|
|
88
|
+
option :edit_changed_slide, false
|
|
89
|
+
option :editor_command, FeduxOrgStdlib::Editor.new.path
|
|
90
|
+
option :error_on_duplicates, true
|
|
91
|
+
|
|
92
|
+
option :force_create_presentation, false
|
|
93
|
+
option :debug_mode, false
|
|
94
|
+
option :exportable_options, %w(
|
|
95
|
+
activate_center
|
|
96
|
+
activate_controls
|
|
97
|
+
activate_embedded
|
|
98
|
+
activate_fragments
|
|
99
|
+
activate_history
|
|
100
|
+
activate_keyboard
|
|
101
|
+
activate_loop
|
|
102
|
+
activate_mouse_wheel
|
|
103
|
+
activate_overview
|
|
104
|
+
activate_progress
|
|
105
|
+
activate_rtl
|
|
106
|
+
activate_slide_number
|
|
107
|
+
activate_touch
|
|
108
|
+
activeate_history
|
|
109
|
+
audience
|
|
110
|
+
author
|
|
111
|
+
auto_slide
|
|
112
|
+
auto_slide_stoppable
|
|
113
|
+
bower_directory
|
|
114
|
+
company
|
|
115
|
+
date
|
|
116
|
+
default_background_transition
|
|
117
|
+
default_transition_speed
|
|
118
|
+
default_transition_type
|
|
119
|
+
description
|
|
120
|
+
email_address
|
|
121
|
+
github_url
|
|
122
|
+
height
|
|
123
|
+
hide_address_bar
|
|
124
|
+
homepage
|
|
125
|
+
license
|
|
126
|
+
location
|
|
127
|
+
margin
|
|
128
|
+
max_scale
|
|
129
|
+
min_scale
|
|
130
|
+
parallax_background_image
|
|
131
|
+
parallax_background_size
|
|
132
|
+
phone_number
|
|
133
|
+
preview_links
|
|
134
|
+
project_id
|
|
135
|
+
speaker
|
|
136
|
+
subtitle
|
|
137
|
+
title
|
|
138
|
+
version
|
|
139
|
+
view_distance
|
|
140
|
+
width
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
option :loadable_assets_for_installed_components, [
|
|
144
|
+
/\.png$/,
|
|
145
|
+
/\.gif$/,
|
|
146
|
+
/\.jpg$/,
|
|
147
|
+
/\.jpeg$/,
|
|
148
|
+
/\.svg$/,
|
|
149
|
+
/\.webp$/,
|
|
150
|
+
/\.eot$/,
|
|
151
|
+
/\.otf$/,
|
|
152
|
+
/\.svc$/,
|
|
153
|
+
/\.woff$/,
|
|
154
|
+
/\.ttf$/
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
option :sources_directory, 'source'
|
|
158
|
+
option :images_directory, 'images'
|
|
159
|
+
option :scripts_directory, 'javascripts'
|
|
160
|
+
option :stylesheets_directory, 'stylesheets'
|
|
161
|
+
option :fonts_directory, 'fonts'
|
|
162
|
+
option :build_directory, 'build'
|
|
163
|
+
|
|
164
|
+
option :minify_assets, false
|
|
165
|
+
|
|
166
|
+
option :runtime_environment, ENV['MP_ENV'].to_s.to_sym
|
|
167
|
+
option :use_regex, false
|
|
168
|
+
|
|
169
|
+
option :debugging_libraries, %w(pry byebug)
|
|
170
|
+
|
|
171
|
+
def preferred_configuration_file
|
|
172
|
+
::File.expand_path(::File.join('~', '.config', _application_name, _config_file))
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
private
|
|
176
|
+
|
|
177
|
+
def _application_name
|
|
178
|
+
'middleman-presentation'
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def _config_name
|
|
182
|
+
'application'
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def _allowed_config_file_paths
|
|
186
|
+
[
|
|
187
|
+
::File.expand_path(::File.join(ConfigurationFile.new(raise_error: false).directory.to_s, format('.%s%s', _application_name, _config_file_suffix))),
|
|
188
|
+
::File.expand_path(::File.join(ConfigurationFile.new(raise_error: false).directory.to_s, format('%s%s', _application_name, _config_file_suffix))),
|
|
189
|
+
::File.expand_path(::File.join('~', '.config', _application_name, _config_file)),
|
|
190
|
+
::File.expand_path(::File.join('~', format('.%s', _application_name), _config_file)),
|
|
191
|
+
::File.expand_path(::File.join('~', format('.%s%s', _application_name, _config_file_suffix))),
|
|
192
|
+
::File.expand_path(::File.join('~', format('.%src', _application_name))),
|
|
193
|
+
::File.expand_path(::File.join('/etc', _application_name, _config_file))
|
|
194
|
+
]
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# External asset
|
|
5
|
+
#
|
|
6
|
+
# It represents a single asset - an image, a stylesheets, a font etc. An
|
|
7
|
+
# assets will be placed in a default directory by `middleman-sprockes`. To
|
|
8
|
+
# change the default directory one needs to tell the `Asset`-class that on
|
|
9
|
+
# initialization.
|
|
10
|
+
class Asset
|
|
11
|
+
include Comparable
|
|
12
|
+
include FeduxOrgStdlib::Roles::Typable
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
attr_reader :importable, :loadable
|
|
17
|
+
|
|
18
|
+
public
|
|
19
|
+
|
|
20
|
+
attr_reader :source_path, :destination_path, :relative_source_path
|
|
21
|
+
attr_writer :importable, :loadable
|
|
22
|
+
|
|
23
|
+
# Create instance
|
|
24
|
+
#
|
|
25
|
+
# @param [String] source_path
|
|
26
|
+
# The source path for the asset
|
|
27
|
+
#
|
|
28
|
+
# @param [String] destination_path
|
|
29
|
+
# The directory where the asset should be placed when building the
|
|
30
|
+
# static version of the web application
|
|
31
|
+
def initialize(source_path:, relative_source_path:, destination_path:, importable: false, loadable: false)
|
|
32
|
+
@source_path = Pathname.new(source_path)
|
|
33
|
+
@relative_source_path = Pathname.new(relative_source_path)
|
|
34
|
+
@importable = importable
|
|
35
|
+
@loadable = loadable
|
|
36
|
+
|
|
37
|
+
self.destination_path = destination_path
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def import_path
|
|
41
|
+
relative_source_path.dirname + relative_source_path.basename('.*')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def load_path
|
|
45
|
+
relative_source_path
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def destination_path=(value)
|
|
49
|
+
@destination_path = value.blank? ? nil : Pathname.new(value)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Destination path resolver
|
|
53
|
+
def destination_path_resolver
|
|
54
|
+
return proc { |_| destination_path } if destination_path
|
|
55
|
+
|
|
56
|
+
proc {}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @private
|
|
60
|
+
def hash
|
|
61
|
+
source_path.hash
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# @private
|
|
65
|
+
def eql?(other)
|
|
66
|
+
source_path.eql? other.source_path
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# @private
|
|
70
|
+
def <=>(other)
|
|
71
|
+
source_path <=> other.source_path
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Is this asset importable?
|
|
75
|
+
#
|
|
76
|
+
# If it is importable, one can use it in `application.js` or
|
|
77
|
+
# `application.scss`.
|
|
78
|
+
#
|
|
79
|
+
# @return [true, false]
|
|
80
|
+
# The result of check
|
|
81
|
+
def importable?
|
|
82
|
+
importable == true
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Is this asset loadable?
|
|
86
|
+
#
|
|
87
|
+
# If it is importable, it will be placed in build directory by sprockets.
|
|
88
|
+
#
|
|
89
|
+
# @return [true, false]
|
|
90
|
+
# The result of check
|
|
91
|
+
def loadable?
|
|
92
|
+
loadable == true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Merge data from other asset
|
|
96
|
+
def merge!(other)
|
|
97
|
+
self.importable = true if other.importable?
|
|
98
|
+
self.loadable = true if other.loadable?
|
|
99
|
+
self.destination_path = other.destination_path if destination_path.blank?
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# A asset component
|
|
5
|
+
#
|
|
6
|
+
# It represents a asset component. A asset component can contain
|
|
7
|
+
# JavaScript-files, stylesheets, images, fonts, ... . A asset component
|
|
8
|
+
# knows where to get a the files from in filesystem, which version of the
|
|
9
|
+
# component is required and which JavaScript-files and stylesheets should
|
|
10
|
+
# be includes in "javascripts/application.js" and
|
|
11
|
+
# "stylesheets"application.scss".
|
|
12
|
+
class AssetComponent < Component
|
|
13
|
+
attr_reader :path, :base_path
|
|
14
|
+
|
|
15
|
+
# An asset component
|
|
16
|
+
#
|
|
17
|
+
# @see [Component] For all other params
|
|
18
|
+
#
|
|
19
|
+
# @param [String] path
|
|
20
|
+
# The directory where all assets files can be found which belong to this component
|
|
21
|
+
def initialize(path:, base_path: path, name: path, **args)
|
|
22
|
+
super(**args)
|
|
23
|
+
|
|
24
|
+
@path = Pathname.new(path)
|
|
25
|
+
@name = name
|
|
26
|
+
@base_path = Pathname.new(base_path)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def root_directory; end
|
|
30
|
+
|
|
31
|
+
def root_directory=(*); end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# List of assets
|
|
5
|
+
#
|
|
6
|
+
# The class takes a list of components and generates a list of assets from
|
|
7
|
+
# this. It also includes `Enumerable`
|
|
8
|
+
class AssetList
|
|
9
|
+
include Enumerable
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
attr_reader :directory, :creator, :store, :components
|
|
14
|
+
|
|
15
|
+
public
|
|
16
|
+
|
|
17
|
+
def initialize(components, creator: Asset, store: AssetStore.new)
|
|
18
|
+
@components = components
|
|
19
|
+
@store = store
|
|
20
|
+
@creator = creator
|
|
21
|
+
|
|
22
|
+
read_in_assets
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Iternate over each component and execute block
|
|
26
|
+
#
|
|
27
|
+
# @yield
|
|
28
|
+
# Block which is executed for each component
|
|
29
|
+
def each(&block)
|
|
30
|
+
to_a.each(&block)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def to_a
|
|
36
|
+
store.assets
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def read_in_assets
|
|
40
|
+
components.each do |c|
|
|
41
|
+
add_assets(
|
|
42
|
+
c.path,
|
|
43
|
+
base_path: c.base_path,
|
|
44
|
+
output_paths: c.output_paths,
|
|
45
|
+
loadable_files: c.loadable_files,
|
|
46
|
+
importable_files: c.importable_files,
|
|
47
|
+
ignorable_files: c.ignorable_files
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def add_assets(search_path, base_path:, output_paths:, loadable_files:, importable_files:, ignorable_files:)
|
|
53
|
+
search_path = File.join(File.expand_path(search_path), '**', '*')
|
|
54
|
+
|
|
55
|
+
Dir.glob(search_path).sort.each do |p|
|
|
56
|
+
next unless File.file? p
|
|
57
|
+
|
|
58
|
+
# rubocop:disable Style/CaseEquality
|
|
59
|
+
next if !ignorable_files.blank? && Array(ignorable_files).any? { |f| Regexp.new(f) === p }
|
|
60
|
+
# rubocop:enable Style/CaseEquality
|
|
61
|
+
|
|
62
|
+
# assets will be find multiple times: vendor/ will find assets in vendor/assets as well
|
|
63
|
+
new_path = File.join(*Pathname.new(p).relative_path_from(Pathname.new(base_path)).each_filename.to_a)
|
|
64
|
+
next if new_path.to_s.start_with?('assets')
|
|
65
|
+
|
|
66
|
+
# rubocop:disable Style/CaseEquality
|
|
67
|
+
output_path = output_paths.find(proc { [] }) { |pattern, _| pattern === p }.last
|
|
68
|
+
# rubocop:enable Style/CaseEquality
|
|
69
|
+
|
|
70
|
+
asset = creator.new(source_path: p, relative_source_path: new_path, destination_path: output_path)
|
|
71
|
+
|
|
72
|
+
# rubocop:disable Style/CaseEquality
|
|
73
|
+
asset.loadable = true if loadable_files.any? { |regexp| regexp === p }
|
|
74
|
+
asset.importable = true if importable_files.any? { |regexp| regexp === p }
|
|
75
|
+
# rubocop:enable Style/CaseEquality
|
|
76
|
+
|
|
77
|
+
store.add asset
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
store
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# Store which stores assets
|
|
5
|
+
#
|
|
6
|
+
# @example Add asset
|
|
7
|
+
#
|
|
8
|
+
# store = AssetStore.new
|
|
9
|
+
# store.add <asset>
|
|
10
|
+
class AssetStore
|
|
11
|
+
include Enumerable
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
attr_reader :store
|
|
16
|
+
|
|
17
|
+
public
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
@store = []
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Add asset
|
|
24
|
+
def add(asset)
|
|
25
|
+
if (existing_asset = @store.find { |a| a.source_path == asset.source_path })
|
|
26
|
+
existing_asset.merge! asset
|
|
27
|
+
else
|
|
28
|
+
store << asset
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Merge list
|
|
33
|
+
#
|
|
34
|
+
# @param [#each] list_or_store
|
|
35
|
+
# The list to merge
|
|
36
|
+
def merge(list_or_store)
|
|
37
|
+
list_or_store.each { |a| add a }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# All uniq assets
|
|
41
|
+
def assets
|
|
42
|
+
store.uniq
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Iterate over assets
|
|
46
|
+
def each(&block)
|
|
47
|
+
assets.each(&block)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Find all assets matching criteria
|
|
51
|
+
#
|
|
52
|
+
# @param [String] source_path (optional)
|
|
53
|
+
# Source path to be used
|
|
54
|
+
#
|
|
55
|
+
# @yield
|
|
56
|
+
# Search criteria
|
|
57
|
+
def find_all(source_path: nil, &block)
|
|
58
|
+
if block_given?
|
|
59
|
+
store.select(&block)
|
|
60
|
+
else
|
|
61
|
+
store.select { |a| a.source_path == source_path }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Find asset matching criteria
|
|
66
|
+
#
|
|
67
|
+
# @see #find_all
|
|
68
|
+
def find(**args, &block)
|
|
69
|
+
find_all(**args, &block).first
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# Loads all default helpers, plugins, components
|
|
5
|
+
class AssetsLoader
|
|
6
|
+
private
|
|
7
|
+
|
|
8
|
+
attr_reader :application, :bower_directory
|
|
9
|
+
|
|
10
|
+
public
|
|
11
|
+
|
|
12
|
+
def initialize(bower_directory:)
|
|
13
|
+
@application = Middleman::Presentation
|
|
14
|
+
@bower_directory = bower_directory
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def load_for_bower_update
|
|
18
|
+
set_bower_directory
|
|
19
|
+
|
|
20
|
+
activate_core_plugins
|
|
21
|
+
activate_user_plugins
|
|
22
|
+
|
|
23
|
+
add_components_required_in_config_file
|
|
24
|
+
add_theme_component
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def load_for_asset_aggregators
|
|
28
|
+
set_bower_directory
|
|
29
|
+
|
|
30
|
+
activate_core_plugins
|
|
31
|
+
activate_user_plugins
|
|
32
|
+
|
|
33
|
+
add_components_required_in_config_file
|
|
34
|
+
add_theme_component
|
|
35
|
+
|
|
36
|
+
add_assets_from_components
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def load_at_presentation_runtime
|
|
40
|
+
set_bower_directory
|
|
41
|
+
|
|
42
|
+
add_assets_from_bower_directory
|
|
43
|
+
|
|
44
|
+
activate_core_plugins
|
|
45
|
+
activate_user_plugins
|
|
46
|
+
|
|
47
|
+
add_components_required_in_config_file
|
|
48
|
+
add_theme_component
|
|
49
|
+
|
|
50
|
+
add_assets_from_components
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def set_bower_directory
|
|
56
|
+
application.components_manager.bower_directory = bower_directory if bower_directory
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def activate_core_plugins
|
|
60
|
+
application.plugins_manager.activate_plugin('middleman-presentation-helpers')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def activate_user_plugins
|
|
64
|
+
application.plugins_manager.activate_plugin(*application.config.plugins)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def add_components_required_in_config_file
|
|
68
|
+
return if application.config.components.blank?
|
|
69
|
+
|
|
70
|
+
application.config.components.each do |c|
|
|
71
|
+
application.components_manager.add FrontendComponent.new(**c)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def add_theme_component
|
|
76
|
+
return if application.config.theme.blank?
|
|
77
|
+
|
|
78
|
+
application.components_manager.add FrontendComponent.new(**application.config.theme)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def add_assets_from_bower_directory
|
|
82
|
+
application.components_manager.add AssetComponent.new(path: bower_directory, loadable_files: Middleman::Presentation.config.loadable_assets_for_installed_components)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Load default components
|
|
86
|
+
def add_assets_from_components
|
|
87
|
+
components_list = Middleman::Presentation::AssetList.new(
|
|
88
|
+
application.components_manager.available_components
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
application.assets_manager.load_from_list components_list
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# Manager for assets
|
|
5
|
+
#
|
|
6
|
+
# It knows about all assets. This information is used when adding assets to
|
|
7
|
+
# `sprockets`. It gets its information normally from through `plugins` or
|
|
8
|
+
# through reading the bower components directory in filesystem.
|
|
9
|
+
class AssetsManager
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
attr_reader :store
|
|
13
|
+
|
|
14
|
+
public
|
|
15
|
+
|
|
16
|
+
def initialize(
|
|
17
|
+
store: AssetStore.new
|
|
18
|
+
)
|
|
19
|
+
@store = store
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Add asset
|
|
23
|
+
def add(asset)
|
|
24
|
+
store.add asset
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Return assets
|
|
28
|
+
def know?(asset)
|
|
29
|
+
store.include? asset
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Show assets which should be imported
|
|
33
|
+
def to_s
|
|
34
|
+
data = store.assets.sort.reduce([]) do |a, e|
|
|
35
|
+
a << {
|
|
36
|
+
source_path: e.relative_source_path,
|
|
37
|
+
destination_path: e.destination_path,
|
|
38
|
+
loadable: e.loadable?,
|
|
39
|
+
importable: e.importable?
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
List.new(data).to_s(fields: [:source_path, :destination_path, :loadable, :importable])
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Iterate over each loadable asset
|
|
47
|
+
def each_loadable_asset(&block)
|
|
48
|
+
store.select { |a| a.valid? && a.loadable? }.each(&block)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Iterate over each importable asset
|
|
52
|
+
def each_importable_stylesheet(&block)
|
|
53
|
+
each_importable_asset.select(&:stylesheet?).each(&block)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Iterate over each importable asset
|
|
57
|
+
def each_importable_javascript(&block)
|
|
58
|
+
each_importable_asset.select(&:script?).each(&block)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Load assets from list
|
|
62
|
+
def load_from_list(*lists)
|
|
63
|
+
lists.flatten.each { |l| store.merge l }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def each_importable_asset(&_block)
|
|
69
|
+
store.select { |a| a.valid? && a.importable? }
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
module Middleman
|
|
3
|
+
module Presentation
|
|
4
|
+
# Cache for objects
|
|
5
|
+
#
|
|
6
|
+
# It can be used to run 'block' on `#map` only if new objects have been
|
|
7
|
+
# added.
|
|
8
|
+
class Cache
|
|
9
|
+
include Enumerable
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
attr_reader :store
|
|
14
|
+
attr_accessor :clean
|
|
15
|
+
|
|
16
|
+
public
|
|
17
|
+
|
|
18
|
+
def initialize(store: [])
|
|
19
|
+
@store = store
|
|
20
|
+
@clean = true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def add(obj)
|
|
24
|
+
store << obj
|
|
25
|
+
self.clean = false
|
|
26
|
+
|
|
27
|
+
self
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def mark_dirty
|
|
31
|
+
self.clean = false
|
|
32
|
+
|
|
33
|
+
self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def each(&block)
|
|
37
|
+
return if clean
|
|
38
|
+
|
|
39
|
+
self.clean = true
|
|
40
|
+
|
|
41
|
+
store.each(&block)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def to_a
|
|
45
|
+
store.to_a
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|