middleman-presentation 0.15.8 → 0.16.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +31 -4
- data/Rakefile +8 -3
- data/bin/middleman-presentation +9 -1
- data/bin/mp +9 -1
- data/lib/middleman-presentation.rb +1 -71
- data/middleman-presentation.gemspec +7 -20
- metadata +14 -357
- data/.gitignore +0 -33
- data/.rdebugrc +0 -7
- data/.rspec +0 -5
- data/.simplecov +0 -8
- data/.travis.yml +0 -8
- data/.yardopts +0 -5
- data/CONTRIBUTING.md +0 -44
- data/Gemfile +0 -49
- data/Gemfile.lock +0 -328
- data/Guardfile +0 -13
- data/LICENSE.software +0 -21
- data/README.md +0 -608
- data/RELEASE_NOTES.md +0 -36
- data/config/license_finder.yml +0 -13
- data/config/rubocop/exclude.yml +0 -25
- data/config/rubocop/include.yml +0 -142
- data/cucumber.yml +0 -2
- data/doc/licenses/dependencies.csv +0 -55
- data/doc/licenses/dependencies.db +0 -0
- data/doc/licenses/dependencies.html +0 -1415
- data/doc/licenses/dependencies.md +0 -603
- data/doc/licenses/dependencies_detailed.csv +0 -190
- data/features/create_presentation-cli.feature +0 -312
- data/features/create_theme-cli.feature +0 -62
- data/features/grouping_slides.feature +0 -116
- data/features/ignore_slides.feature +0 -86
- data/features/image_gallery.feature +0 -58
- data/features/init_application-cli.feature +0 -91
- data/features/init_predefined_slides.feature +0 -13
- data/features/presentation.feature +0 -113
- data/features/show_config-cli.feature +0 -27
- data/features/show_style-cli.feature +0 -21
- data/features/show_support_information-cli.feature +0 -12
- data/features/slide-cli.feature +0 -311
- data/features/step_definitions.rb +0 -135
- data/features/support/ci.rb +0 -3
- data/features/support/env.rb +0 -19
- data/features/support/reporting.rb +0 -2
- data/features/version_number.feature +0 -18
- data/fixtures/images/image01.png +0 -0
- data/fixtures/images/image02.png +0 -0
- data/lib/middleman-presentation/cli/create.rb +0 -14
- data/lib/middleman-presentation/cli/create_presentation.rb +0 -308
- data/lib/middleman-presentation/cli/create_theme.rb +0 -77
- data/lib/middleman-presentation/cli/init.rb +0 -34
- data/lib/middleman-presentation/cli/reset_thor.rb +0 -18
- data/lib/middleman-presentation/cli/runner.rb +0 -18
- data/lib/middleman-presentation/cli/show.rb +0 -37
- data/lib/middleman-presentation/commands/presentation.rb +0 -23
- data/lib/middleman-presentation/commands/slide.rb +0 -86
- data/lib/middleman-presentation/commands/style.rb +0 -29
- data/lib/middleman-presentation/comparable_slide.rb +0 -69
- data/lib/middleman-presentation/css_class_extracter.rb +0 -41
- data/lib/middleman-presentation/custom_template.rb +0 -11
- data/lib/middleman-presentation/erb_template.rb +0 -11
- data/lib/middleman-presentation/existing_slide.rb +0 -133
- data/lib/middleman-presentation/extension.rb +0 -12
- data/lib/middleman-presentation/file_extensions.rb +0 -60
- data/lib/middleman-presentation/frontend_component.rb +0 -82
- data/lib/middleman-presentation/group_template.rb +0 -11
- data/lib/middleman-presentation/helpers.rb +0 -11
- data/lib/middleman-presentation/helpers/images.rb +0 -38
- data/lib/middleman-presentation/helpers/slides.rb +0 -31
- data/lib/middleman-presentation/helpers/tests.rb +0 -13
- data/lib/middleman-presentation/ignore_file.rb +0 -52
- data/lib/middleman-presentation/liquid_template.rb +0 -11
- data/lib/middleman-presentation/logger.rb +0 -8
- data/lib/middleman-presentation/main.rb +0 -40
- data/lib/middleman-presentation/markdown_template.rb +0 -11
- data/lib/middleman-presentation/new_slide.rb +0 -145
- data/lib/middleman-presentation/predefined_slide_templates_directory.rb +0 -11
- data/lib/middleman-presentation/presentation_config.rb +0 -48
- data/lib/middleman-presentation/slide_group.rb +0 -38
- data/lib/middleman-presentation/slide_list.rb +0 -46
- data/lib/middleman-presentation/transformers/file_keeper.rb +0 -13
- data/lib/middleman-presentation/transformers/group_slides.rb +0 -34
- data/lib/middleman-presentation/transformers/ignore_slides.rb +0 -28
- data/lib/middleman-presentation/transformers/remove_duplicate_slides.rb +0 -32
- data/lib/middleman-presentation/transformers/sort_slides.rb +0 -13
- data/lib/middleman-presentation/version.rb +0 -8
- data/locales/de.yml +0 -9
- data/locales/en.yml +0 -18
- data/script/bootstrap +0 -11
- data/script/ci +0 -3
- data/spec/css_class_extracter_spec.rb +0 -28
- data/spec/existing_slide_spec.rb +0 -158
- data/spec/frontend_resource_spec.rb +0 -87
- data/spec/ignore_file_spec.rb +0 -74
- data/spec/new_slide_spec.rb +0 -136
- data/spec/shared_examples/.keep +0 -0
- data/spec/slide_group_spec.rb +0 -69
- data/spec/slide_list_spec.rb +0 -90
- data/spec/spec_helper.rb +0 -19
- data/spec/support/ci.rb +0 -20
- data/spec/support/environment.rb +0 -18
- data/spec/support/filesystem.rb +0 -22
- data/spec/support/reporting.rb +0 -2
- data/spec/support/rspec.rb +0 -9
- data/spec/support/string.rb +0 -2
- data/spec/transformers/file_keeper_spec.rb +0 -23
- data/spec/transformers/group_slides_spec.rb +0 -44
- data/spec/transformers/ignore_slides_spec.rb +0 -64
- data/spec/transformers/remove_duplicate_slides_spec.rb +0 -120
- data/spec/transformers/sort_slides_spec.rb +0 -17
- data/templates/.bowerrc.tt +0 -4
- data/templates/.gitignore +0 -5
- data/templates/LICENSE.presentation +0 -1
- data/templates/Rakefile +0 -59
- data/templates/bower.json.tt +0 -8
- data/templates/config.yaml.tt +0 -41
- data/templates/data/config.yml.tt +0 -9
- data/templates/data/metadata.yml.tt +0 -77
- data/templates/predefined_slides.d/00.html.erb.tt +0 -23
- data/templates/predefined_slides.d/999980.html.erb.tt +0 -4
- data/templates/predefined_slides.d/999981.html.erb.tt +0 -21
- data/templates/predefined_slides.d/999982.html.erb.tt +0 -3
- data/templates/presentation_theme/bower.json.tt +0 -20
- 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 +0 -9
- data/templates/presentation_theme/stylesheets/_fonts.scss.tt +0 -0
- data/templates/presentation_theme/stylesheets/_images.scss.tt +0 -5
- data/templates/presentation_theme/stylesheets/_theme.scss.tt +0 -251
- data/templates/script/bootstrap +0 -5
- data/templates/script/build +0 -3
- data/templates/script/export +0 -34
- data/templates/script/presentation +0 -3
- data/templates/script/slide +0 -3
- data/templates/script/start +0 -43
- data/templates/slides/custom.md.tt +0 -3
- data/templates/slides/erb.tt +0 -5
- data/templates/slides/group.tt +0 -3
- data/templates/slides/liquid.tt +0 -5
- data/templates/slides/markdown.tt +0 -3
- data/templates/source/index.html.erb +0 -1
- data/templates/source/javascripts/application.js.tt +0 -3
- data/templates/source/layout.erb +0 -89
- data/templates/source/stylesheets/application.scss.tt +0 -3
@@ -1,12 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# Presentation extension
|
5
|
-
class PresentationExtension < Extension
|
6
|
-
option :slides_directory, Middleman::Presentation.config.slides_directory, 'Directory to look for slides'
|
7
|
-
option :slides_ignore_file, Middleman::Presentation.config.slides_ignore_file, 'File with patterns to (un)ignore slides in output'
|
8
|
-
|
9
|
-
helpers Middleman::Presentation::Helpers
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rbconfig'
|
3
|
-
require 'win32/file' if File::ALT_SEPARATOR
|
4
|
-
|
5
|
-
# File class
|
6
|
-
class File
|
7
|
-
if File::ALT_SEPARATOR
|
8
|
-
MSWINDOWS = true
|
9
|
-
if ENV['PATHEXT']
|
10
|
-
WIN32EXTS = ('.{' + ENV['PATHEXT'].tr(';', ',').tr('.', '') + '}').downcase
|
11
|
-
else
|
12
|
-
WIN32EXTS = '.{exe,com,bat}'
|
13
|
-
end
|
14
|
-
else
|
15
|
-
MSWINDOWS = false
|
16
|
-
end
|
17
|
-
|
18
|
-
class << self
|
19
|
-
def which(program, path = ENV['PATH'])
|
20
|
-
fail ArgumentError, 'path cannot be empty' if path.nil? || path.empty?
|
21
|
-
|
22
|
-
# Bail out early if an absolute path is provided.
|
23
|
-
if program =~ %r{^/|^[a-z]:[/]}i
|
24
|
-
program += WIN32EXTS if MSWINDOWS && File.extname(program).empty?
|
25
|
-
found = Dir[program].first
|
26
|
-
if found && File.executable?(found) && !File.directory?(found)
|
27
|
-
return found
|
28
|
-
else
|
29
|
-
return nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Iterate over each path glob the dir + program.
|
34
|
-
path.split(File::PATH_SEPARATOR).each do |dir|
|
35
|
-
dir = File.expand_path(dir)
|
36
|
-
|
37
|
-
next unless File.exist?(dir) # In case of bogus second argument
|
38
|
-
file = File.join(dir, program)
|
39
|
-
|
40
|
-
# Dir[] doesn't handle backslashes properly, so convert them. Also, if
|
41
|
-
# the program name doesn't have an extension, try them all.
|
42
|
-
if MSWINDOWS
|
43
|
-
file = file.tr('\\', '/')
|
44
|
-
file += WIN32EXTS if File.extname(program).empty?
|
45
|
-
end
|
46
|
-
|
47
|
-
found = Dir[file].first
|
48
|
-
|
49
|
-
next if !found || !File.executable?(found) || File.directory?(found)
|
50
|
-
|
51
|
-
# Convert all forward slashes to backslashes if supported
|
52
|
-
found.tr!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR
|
53
|
-
|
54
|
-
return found
|
55
|
-
end
|
56
|
-
|
57
|
-
nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# A frontend component
|
5
|
-
class FrontendComponent
|
6
|
-
attr_reader :name
|
7
|
-
|
8
|
-
class << self
|
9
|
-
# Parse line
|
10
|
-
#
|
11
|
-
# @param [Array, String] hashes
|
12
|
-
# Options read from config file
|
13
|
-
def parse(*hashes)
|
14
|
-
hashes.flatten.map { |h| new(**h) }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Create new frontend component
|
19
|
-
#
|
20
|
-
# @param [String] resource_locator
|
21
|
-
# The locator to look for the resource, e.g. http://example.org/test or latest
|
22
|
-
#
|
23
|
-
# @param [String] name (nil)
|
24
|
-
# Alternative name for the resource, otherwise the base name of the resource_locator's path is used: http://example.org/test => test
|
25
|
-
#
|
26
|
-
# @param [String] github
|
27
|
-
# Name of github repository, e.g. <account>/<repository>
|
28
|
-
def initialize(resource_locator: nil, version: nil, name: nil, github: nil, javascripts: [], stylesheets: [])
|
29
|
-
@resource_locator = if version
|
30
|
-
Class.new do
|
31
|
-
attr_reader :to_s
|
32
|
-
|
33
|
-
def initialize(value)
|
34
|
-
@to_s = value
|
35
|
-
end
|
36
|
-
end.new(version)
|
37
|
-
elsif github
|
38
|
-
Addressable::URI.heuristic_parse format('https://github.com/%s.git', github)
|
39
|
-
elsif resource_locator =~ /\A#{URI.regexp}\z/
|
40
|
-
Addressable::URI.heuristic_parse resource_locator
|
41
|
-
else
|
42
|
-
nil
|
43
|
-
end
|
44
|
-
|
45
|
-
fail ArgumentError, JSON.dump(message: I18n.t('errors.undefined_arguments', arguments: %w(resource_locator github version).to_list)) if @resource_locator.blank?
|
46
|
-
|
47
|
-
@name = if version
|
48
|
-
name
|
49
|
-
elsif name.blank?
|
50
|
-
File.basename(@resource_locator.path)
|
51
|
-
else
|
52
|
-
name
|
53
|
-
end
|
54
|
-
|
55
|
-
fail ArgumentError, JSON.dump(message: I18n.t('errors.argument_error', argument: :name, value: @name)) if @name.blank?
|
56
|
-
|
57
|
-
@javascripts = Array(javascripts)
|
58
|
-
@stylesheets = Array(stylesheets)
|
59
|
-
end
|
60
|
-
|
61
|
-
# Return resource locator
|
62
|
-
#
|
63
|
-
# @return [String]
|
64
|
-
# The resource locator
|
65
|
-
def resource_locator
|
66
|
-
@resource_locator.to_s
|
67
|
-
end
|
68
|
-
|
69
|
-
# @!attribute [r] javascripts
|
70
|
-
# Return the paths to javascripts prepended with "name/"
|
71
|
-
def javascripts
|
72
|
-
@javascripts.map { |j| format '%s/%s', name, j }
|
73
|
-
end
|
74
|
-
|
75
|
-
# @!attribute [r] stylesheets
|
76
|
-
# Return the paths to stylesheets prepended with "name/"
|
77
|
-
def stylesheets
|
78
|
-
@stylesheets.map { |s| format '%s/%s', name, s }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# Template for a group of slides
|
5
|
-
class GroupTemplate < FeduxOrgStdlib::FileTemplate
|
6
|
-
def fallback_template_directory
|
7
|
-
File.expand_path('../../../templates/slides', __FILE__)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# Helper module
|
5
|
-
module Helpers
|
6
|
-
# Create image gallery
|
7
|
-
def image_gallery(images, image_gallery_id:)
|
8
|
-
template = <<-EOS.strip_heredoc.chomp
|
9
|
-
<a href="<%= image_path %>" data-lightbox="<%= image_gallery_id %>">
|
10
|
-
<img src="<%= image_path %>"<% if title %> alt="<%= title %>"<% end %> class="mp-preview-image">
|
11
|
-
</a>
|
12
|
-
EOS
|
13
|
-
|
14
|
-
images.each_with_object([]) do |(image, title), memo|
|
15
|
-
engine = Erubis::Eruby.new(template)
|
16
|
-
memo << engine.result(image_path: image, image_gallery_id: image_gallery_id, title: title)
|
17
|
-
end.join("\n")
|
18
|
-
end
|
19
|
-
|
20
|
-
# Create entry for single image
|
21
|
-
def image(image)
|
22
|
-
image_gallery Array(image), image_gallery_id: SecureRandom.hex
|
23
|
-
end
|
24
|
-
|
25
|
-
# Find asset for substring
|
26
|
-
def find_asset(substring)
|
27
|
-
# sprockets.each_logical_path.find { |f| f.to_s.include? substring }
|
28
|
-
result = sprockets.each_file.find { |f| f.to_s.include? substring }
|
29
|
-
|
30
|
-
if result.blank?
|
31
|
-
I18n.t('errors.asset_not_found', asset: substring)
|
32
|
-
else
|
33
|
-
result.relative_path_from(Pathname.new(source_dir)).to_s
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# Helper module
|
5
|
-
module Helpers
|
6
|
-
# Yield slides
|
7
|
-
def yield_slides
|
8
|
-
list = SlideList.new(Dir.glob(File.join(source_dir, extensions[:presentation].options.slides_directory, '**', '*')), slide_builder: ExistingSlide, base_path: source_dir) do |l|
|
9
|
-
l.transform_with Transformers::FileKeeper.new
|
10
|
-
l.transform_with Transformers::RemoveDuplicateSlides.new raise_error: true
|
11
|
-
l.transform_with Transformers::IgnoreSlides.new ignore_file: File.join(root, extensions[:presentation].options.slides_ignore_file)
|
12
|
-
l.transform_with Transformers::SortSlides.new
|
13
|
-
l.transform_with Transformers::GroupSlides.new template: Erubis::Eruby.new(GroupTemplate.new(working_directory: root).content)
|
14
|
-
end
|
15
|
-
|
16
|
-
list.all.map do |element|
|
17
|
-
begin
|
18
|
-
element.render { |path| partial(path).chomp }
|
19
|
-
rescue StandardError => e
|
20
|
-
message = []
|
21
|
-
message << "Rendering slide \"#{element.partial_path}\" failed with"
|
22
|
-
message << e.class.to_s + ': ' + e.message
|
23
|
-
message << e.backtrace.join("\n")
|
24
|
-
|
25
|
-
raise e.class, message.join("\n\n")
|
26
|
-
end
|
27
|
-
end.join("\n")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# The ignore file uses to ignore slides
|
5
|
-
#
|
6
|
-
# @see [Transformers::IgnoreSlides]
|
7
|
-
class IgnoreFile
|
8
|
-
private
|
9
|
-
|
10
|
-
attr_reader :unignore, :ignore, :path
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
attr_writer :unignore, :ignore
|
15
|
-
|
16
|
-
public
|
17
|
-
|
18
|
-
def initialize(path)
|
19
|
-
@unignore = @ignore = /^!$/
|
20
|
-
@path = path
|
21
|
-
|
22
|
-
parse_file(path) if File.exist? path
|
23
|
-
end
|
24
|
-
|
25
|
-
def ignore?(slide)
|
26
|
-
return false unless File.exist? path
|
27
|
-
|
28
|
-
slide.match?(ignore) && !slide.match?(unignore)
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def parse_file(path)
|
34
|
-
File.readlines(path).each do |l|
|
35
|
-
next if l =~ /^#/
|
36
|
-
l = l.chomp.sub(/\s*#.*/, '')
|
37
|
-
|
38
|
-
if l =~ /^!/
|
39
|
-
self.unignore = Regexp.union(
|
40
|
-
unignore,
|
41
|
-
Regexp.new(
|
42
|
-
l.sub(/^!/, '')
|
43
|
-
)
|
44
|
-
)
|
45
|
-
else
|
46
|
-
self.ignore = Regexp.union(ignore, Regexp.new(l))
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# Liquid template for creating slides
|
5
|
-
class LiquidTemplate < FeduxOrgStdlib::FileTemplate
|
6
|
-
def fallback_template_directory
|
7
|
-
File.expand_path('../../../templates/slides', __FILE__)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# Main
|
3
|
-
module Middleman
|
4
|
-
# Presentation extension
|
5
|
-
module Presentation
|
6
|
-
@config = PresentationConfig.new
|
7
|
-
@logger = Logger.new
|
8
|
-
|
9
|
-
class << self
|
10
|
-
attr_reader :config, :logger
|
11
|
-
|
12
|
-
def root_path
|
13
|
-
File.expand_path '../../../', __FILE__
|
14
|
-
end
|
15
|
-
|
16
|
-
def stylable_files
|
17
|
-
paths = []
|
18
|
-
|
19
|
-
paths << '../../../templates/slides/*.tt'
|
20
|
-
paths << '../../../templates/predefined_slides.d/*.tt'
|
21
|
-
|
22
|
-
paths.concat ['../../../templates/source/'].product(%w(layout.erb index.html.erb)).map(&:join)
|
23
|
-
|
24
|
-
Rake::FileList.new(
|
25
|
-
paths.map { |f| File.expand_path(f, __FILE__) }
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def configure_i18n
|
30
|
-
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
|
31
|
-
I18n.load_path = Dir[::File.join(Middleman::Presentation.root_path, 'locales', '*.yml')]
|
32
|
-
I18n.backend.load_translations
|
33
|
-
I18n.available_locales = [:en, :de]
|
34
|
-
I18n.enforce_available_locales = false
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
Middleman::Presentation.configure_i18n
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# Markdown template to create new slides
|
5
|
-
class MarkdownTemplate < FeduxOrgStdlib::FileTemplate
|
6
|
-
def fallback_template_directory
|
7
|
-
File.expand_path('../../../templates/slides', __FILE__)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,145 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Middleman
|
3
|
-
module Presentation
|
4
|
-
# A slide
|
5
|
-
class NewSlide
|
6
|
-
include ComparableSlide
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
attr_reader :input, :name, :base_path, :slide_directory_path
|
11
|
-
|
12
|
-
public
|
13
|
-
|
14
|
-
def initialize(input, base_path:)
|
15
|
-
@input = input.split(/:/)
|
16
|
-
@name = extract_name
|
17
|
-
@slide_directory_path = Pathname.new(base_path)
|
18
|
-
@base_path = @slide_directory_path.dirname
|
19
|
-
end
|
20
|
-
|
21
|
-
# Return string representation of self
|
22
|
-
def to_s
|
23
|
-
path.to_s
|
24
|
-
end
|
25
|
-
|
26
|
-
def path
|
27
|
-
p = []
|
28
|
-
p << Pathname.new(group) unless group.blank?
|
29
|
-
p << file_name
|
30
|
-
|
31
|
-
# rubocop:disable Style/EachWithObject
|
32
|
-
p.reduce(slide_directory_path) do |a, e|
|
33
|
-
# rubocop:enable Style/EachWithObject
|
34
|
-
a += e
|
35
|
-
|
36
|
-
a
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def group
|
41
|
-
@group ||= extract_group
|
42
|
-
end
|
43
|
-
|
44
|
-
# Return basename of slide
|
45
|
-
def base_name
|
46
|
-
File.basename(name).scan(/^([^.]+)(?:\..+)?/).flatten.first
|
47
|
-
end
|
48
|
-
|
49
|
-
def file_name
|
50
|
-
path = if type? :erb
|
51
|
-
Pathname.new "#{base_name}.html.erb"
|
52
|
-
elsif type? :md
|
53
|
-
Pathname.new "#{base_name}.html.md"
|
54
|
-
elsif type? :liquid
|
55
|
-
Pathname.new "#{base_name}.html.liquid"
|
56
|
-
else
|
57
|
-
Pathname.new("#{base_name}.html#{template.proposed_extname}")
|
58
|
-
end
|
59
|
-
|
60
|
-
Pathname.new(path)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Is group?
|
64
|
-
def group_object?
|
65
|
-
false
|
66
|
-
end
|
67
|
-
|
68
|
-
# Write slide content to file
|
69
|
-
def write(**data)
|
70
|
-
FileUtils.mkdir_p path.dirname
|
71
|
-
|
72
|
-
File.open(path, 'wb') do |f|
|
73
|
-
f.write(content(**data))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# Does the slide exist
|
78
|
-
def exist?
|
79
|
-
path.exist?
|
80
|
-
end
|
81
|
-
|
82
|
-
# Generate slide content
|
83
|
-
#
|
84
|
-
# It either uses previously set content or generates content by using a
|
85
|
-
# predefined template
|
86
|
-
def content(**data)
|
87
|
-
Erubis::Eruby.new(template.content).result(data)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Relative path of slide
|
91
|
-
def relative_path
|
92
|
-
path.relative_path_from(base_path)
|
93
|
-
end
|
94
|
-
|
95
|
-
private
|
96
|
-
|
97
|
-
def template
|
98
|
-
if type? :erb
|
99
|
-
ErbTemplate.new(working_directory: base_path.dirname)
|
100
|
-
elsif type? :md
|
101
|
-
MarkdownTemplate.new(working_directory: base_path.dirname)
|
102
|
-
elsif type? :liquid
|
103
|
-
LiquidTemplate.new(working_directory: base_path.dirname)
|
104
|
-
else
|
105
|
-
CustomTemplate.new(working_directory: base_path.dirname)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
# Check type of slide
|
110
|
-
def type?(t)
|
111
|
-
type == t
|
112
|
-
end
|
113
|
-
|
114
|
-
# Determine type of slide
|
115
|
-
def type
|
116
|
-
return :erb if extname? '.erb'
|
117
|
-
return :md if extname? '.md', '.markdown', '.mkd'
|
118
|
-
return :liquid if extname? '.l', '.liquid'
|
119
|
-
|
120
|
-
:custom
|
121
|
-
end
|
122
|
-
|
123
|
-
# Return file extension
|
124
|
-
def extname
|
125
|
-
File.extname(name)
|
126
|
-
end
|
127
|
-
|
128
|
-
# Check if slide has given extensions
|
129
|
-
def extname?(*extensions)
|
130
|
-
extensions.any? { |e| extname == e }
|
131
|
-
end
|
132
|
-
|
133
|
-
def extract_name
|
134
|
-
input.last
|
135
|
-
end
|
136
|
-
|
137
|
-
# Extract group from name
|
138
|
-
def extract_group
|
139
|
-
return nil if input.size < 2 # no group given
|
140
|
-
|
141
|
-
input.first.to_s
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|