middleman-presentation-helpers 0.0.7 → 0.1.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -2
- data/.rubocop.yml +45 -4
- data/README.md +23 -2
- data/Rakefile +6 -2
- data/features/image_gallery.feature +3 -4
- data/features/metadata.feature +40 -0
- data/features/step_definitions.rb +0 -1
- data/features/support/aruba.rb +1 -1
- data/features/support/ci.rb +1 -1
- data/features/support/env.rb +1 -1
- data/lib/middleman-presentation-helpers.rb +24 -0
- data/lib/middleman-presentation-helpers/helpers/image.rb +20 -0
- data/lib/{middleman-presentation → middleman-presentation-helpers}/helpers/image_gallery.rb +9 -7
- data/lib/middleman-presentation-helpers/helpers/metadata.rb +29 -0
- data/lib/{middleman-presentation → middleman-presentation-helpers}/helpers/slides.rb +6 -4
- data/lib/middleman-presentation-helpers/plugins/footer_plugin.rb +17 -0
- data/lib/middleman-presentation-helpers/plugins/highlight_plugin.rb +23 -0
- data/lib/middleman-presentation-helpers/plugins/image_gallery_plugin.rb +25 -0
- data/lib/middleman-presentation-helpers/plugins/images_plugin.rb +19 -0
- data/lib/{middleman-presentation/helpers/plugins/footer_plugin.rb → middleman-presentation-helpers/plugins/jquery_plugin.rb} +4 -5
- data/lib/middleman-presentation-helpers/plugins/metadata_plugin.rb +13 -0
- data/lib/{middleman-presentation/helpers/plugins/diagram_plugin.rb → middleman-presentation-helpers/plugins/normalize_plugin.rb} +4 -5
- data/lib/middleman-presentation-helpers/plugins/print_plugin.rb +17 -0
- data/lib/middleman-presentation-helpers/plugins/slides_plugin.rb +33 -0
- data/lib/{middleman-presentation/helpers → middleman-presentation-helpers}/version.rb +1 -1
- data/lib/middleman-presentation-plugin.rb +1 -0
- data/middleman-presentation-helpers.gemspec +5 -5
- data/vendor/assets/{javascripts → middleman-presentation-helpers/footer}/footer.js +4 -2
- data/vendor/assets/middleman-presentation-helpers/footer/footer.scss +3 -0
- data/vendor/assets/{stylesheets → middleman-presentation-helpers/image_gallery}/image_gallery.scss +0 -0
- data/vendor/assets/{stylesheets → middleman-presentation-helpers/images}/images.scss +0 -0
- data/vendor/assets/middleman-presentation-helpers/print/pdf.scss +200 -0
- metadata +29 -24
- data/.travis.yml +0 -8
- data/Gemfile +0 -50
- data/Gemfile.lock +0 -382
- data/config/rubocop/exclude.yml +0 -25
- data/config/rubocop/include.yml +0 -142
- data/lib/middleman-presentation/helpers.rb +0 -14
- data/lib/middleman-presentation/helpers/plugins/common_plugin.rb +0 -22
- data/lib/middleman-presentation/helpers/plugins/image_gallery_plugin.rb +0 -35
- data/lib/middleman-presentation/helpers/plugins/slides_plugin.rb +0 -43
- data/vendor/assets/stylesheets/footer.scss +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fb635fa3238435651cdd97bd3362c32244f06a3
|
4
|
+
data.tar.gz: 4ed2069d1a150026b69674303f4e6b719dec23e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ba948607297dd6b971a80f7ca5822e5d292fa67e1aa24e19570e7728f355128cfd30fabb221f482085877cc6aeeb1fdc1dc69692da0f3c01b9ed36038f411bd
|
7
|
+
data.tar.gz: 54446cd01e1baec08ccd4df9daf10f03b684abf0ff956abccba1ee87e1ab57424732eccebffa0dc7c21f18167c2526023afd316b3090a2a50c36def915f336c4
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,4 +1,45 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'tmp/**/*'
|
4
|
+
|
5
|
+
# Configuration parameters: AllowURI.
|
6
|
+
Metrics/LineLength:
|
7
|
+
Max: 225
|
8
|
+
|
9
|
+
# Configuration parameters: CountKeywordArgs.
|
10
|
+
Metrics/ParameterLists:
|
11
|
+
Max: 6
|
12
|
+
|
13
|
+
# Configuration parameters: Exclude.
|
14
|
+
Style/FileName:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
# Configuration parameters: CountComments.
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Max: 118
|
20
|
+
|
21
|
+
# Configuration parameters: CountComments.
|
22
|
+
Metrics/ClassLength:
|
23
|
+
Max: 160
|
24
|
+
# Exclude:
|
25
|
+
# - lib/middleman-presentation-core/cli/create_presentation.rb
|
26
|
+
|
27
|
+
Metrics/CyclomaticComplexity:
|
28
|
+
Max: 9
|
29
|
+
# Exclude:
|
30
|
+
# - lib/middleman-presentation-core/file_extensions.rb
|
31
|
+
|
32
|
+
#Metrics/PerceivedComplexity:
|
33
|
+
# Exclude:
|
34
|
+
# - lib/middleman-presentation-core/cli/create_slide.rb
|
35
|
+
# - lib/middleman-presentation-core/frontend_component.rb
|
36
|
+
# - lib/middleman-presentation-core/assets_manager.rb
|
37
|
+
# - lib/middleman-presentation-core/file_extensions.rb
|
38
|
+
# - lib/middleman-presentation-core/commands/slide.rb
|
39
|
+
|
40
|
+
# Configuration parameters: MaxSlashes.
|
41
|
+
Style/RegexpLiteral:
|
42
|
+
MaxSlashes: 0
|
43
|
+
|
44
|
+
Metrics/AbcSize:
|
45
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Middleman::Presentation::Helpers
|
2
2
|
|
3
|
-
|
3
|
+
This gem contains helpers for
|
4
|
+
[`middleman-presentation`](https://github.com/maxmeyer/middleman-presentation):
|
5
|
+
|
6
|
+
* Image gallery
|
7
|
+
* Images
|
8
|
+
* Some methods which could be core or helpers
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -20,7 +25,23 @@ Or install it yourself as:
|
|
20
25
|
|
21
26
|
## Usage
|
22
27
|
|
23
|
-
|
28
|
+
### Image gallery
|
29
|
+
|
30
|
+
If you want to create an image gallery in your slides you can use the
|
31
|
+
`image_gallery`-helper. It just needs an id for the gallery and a list of images.
|
32
|
+
|
33
|
+
```eruby
|
34
|
+
<%= image_gallery ['img/image1.png', 'img/image2.png'], id: 'my-gallery' %>
|
35
|
+
```
|
36
|
+
|
37
|
+
### Images
|
38
|
+
|
39
|
+
If you want to create an image in your slides and want it to have a fancy style, you can use the
|
40
|
+
`image`-helper. Just needs the name of the image.
|
41
|
+
|
42
|
+
```eruby
|
43
|
+
<%= image 'img/image1.png' %>
|
44
|
+
```
|
24
45
|
|
25
46
|
## Contributing
|
26
47
|
|
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'active_support/all'
|
|
6
6
|
require 'open3'
|
7
7
|
|
8
8
|
def software
|
9
|
-
gemspec.name
|
9
|
+
gemspec.name.sub(/mp-/, 'middleman-presentation-')
|
10
10
|
end
|
11
11
|
|
12
12
|
def module_name
|
@@ -14,7 +14,7 @@ def module_name
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def require_name
|
17
|
-
|
17
|
+
software
|
18
18
|
end
|
19
19
|
|
20
20
|
def gemspec
|
@@ -121,6 +121,10 @@ namespace :test do
|
|
121
121
|
sh 'bundle exec cucumber -p all'
|
122
122
|
end
|
123
123
|
|
124
|
+
task :parallel_cucumber do
|
125
|
+
sh 'bundle exec parallel_cucumber features -o "-p all" --serialize-stdout'
|
126
|
+
end
|
127
|
+
|
124
128
|
desc 'Run mutant'
|
125
129
|
task :mutant do
|
126
130
|
sh 'mutant --include lib --require middleman-presentation --use rspec "Middleman::Presentation*"'
|
@@ -5,17 +5,16 @@ Feature: Image Gallery
|
|
5
5
|
In order to spent as less time as possible on it
|
6
6
|
|
7
7
|
Background:
|
8
|
-
Given I
|
8
|
+
Given I use presentation fixture "image_gallery" with title "My Presentation"
|
9
9
|
And an image "image01.png" at "images/image01.png"
|
10
10
|
And an image "image02.png" at "images/image02.png"
|
11
11
|
|
12
|
-
@wip
|
13
12
|
Scenario: Images only
|
14
13
|
Given a slide named "01.html.erb" with:
|
15
14
|
"""
|
16
15
|
<section>
|
17
16
|
<h1>Image Gallery</h1>
|
18
|
-
<%= image_gallery %W{images/image01.png images/image02.png},
|
17
|
+
<%= image_gallery %W{images/image01.png images/image02.png}, id: 'test-gallery' %>
|
19
18
|
</section>
|
20
19
|
"""
|
21
20
|
And the Server is running
|
@@ -45,7 +44,7 @@ Feature: Image Gallery
|
|
45
44
|
"""
|
46
45
|
<section>
|
47
46
|
<h1>Image Gallery</h1>
|
48
|
-
<%= image_gallery({'images/image01.png' => 'Title 1', 'images/image02.png' => 'Title 2'},
|
47
|
+
<%= image_gallery({'images/image01.png' => 'Title 1', 'images/image02.png' => 'Title 2'}, id: 'test-gallery') %>
|
49
48
|
</section>
|
50
49
|
"""
|
51
50
|
And the Server is running
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: Add meta data fields
|
2
|
+
|
3
|
+
As a creator of a presentation
|
4
|
+
I want to use meta data from configuration
|
5
|
+
In order to display them on the slides
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use presentation fixture "simple1" with title "My Presentation"
|
9
|
+
|
10
|
+
Scenario: Generate meta data
|
11
|
+
Given a presentation config file for middleman-presentation with:
|
12
|
+
"""
|
13
|
+
author: 'Max'
|
14
|
+
"""
|
15
|
+
And a slide named "01.html.erb" with:
|
16
|
+
"""
|
17
|
+
<section>
|
18
|
+
<%= metadata_markup([:author], [:author]) %>
|
19
|
+
</section>
|
20
|
+
"""
|
21
|
+
When the Server is running
|
22
|
+
And I go to "/"
|
23
|
+
Then I should see:
|
24
|
+
"""
|
25
|
+
Max
|
26
|
+
"""
|
27
|
+
|
28
|
+
Scenario: Unknown field
|
29
|
+
Given a slide named "01.html.erb" with:
|
30
|
+
"""
|
31
|
+
<section>
|
32
|
+
<%= metadata_markup([:author], []) %>
|
33
|
+
</section>
|
34
|
+
"""
|
35
|
+
When the Server is running
|
36
|
+
And I go to "/"
|
37
|
+
Then I should see:
|
38
|
+
"""
|
39
|
+
You entered an unknown metadata field "author".
|
40
|
+
"""
|
data/features/support/aruba.rb
CHANGED
data/features/support/ci.rb
CHANGED
data/features/support/env.rb
CHANGED
@@ -8,7 +8,7 @@ SimpleCov.start
|
|
8
8
|
# middleman
|
9
9
|
require 'middleman-core'
|
10
10
|
require 'middleman-core/step_definitions'
|
11
|
-
require 'middleman-presentation/step_definitions'
|
11
|
+
require 'middleman-presentation-core/step_definitions'
|
12
12
|
|
13
13
|
# Pull in all of the gems including those in the `test` group
|
14
14
|
require 'bundler'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'middleman-presentation-helpers/version'
|
2
|
+
|
3
|
+
require 'middleman-presentation-helpers/helpers/image_gallery'
|
4
|
+
require 'middleman-presentation-helpers/helpers/image'
|
5
|
+
require 'middleman-presentation-helpers/helpers/slides'
|
6
|
+
require 'middleman-presentation-helpers/helpers/metadata'
|
7
|
+
|
8
|
+
require 'middleman-presentation-helpers/plugins/jquery_plugin'
|
9
|
+
require 'middleman-presentation-helpers/plugins/normalize_plugin'
|
10
|
+
require 'middleman-presentation-helpers/plugins/highlight_plugin'
|
11
|
+
require 'middleman-presentation-helpers/plugins/slides_plugin'
|
12
|
+
require 'middleman-presentation-helpers/plugins/images_plugin'
|
13
|
+
require 'middleman-presentation-helpers/plugins/image_gallery_plugin'
|
14
|
+
require 'middleman-presentation-helpers/plugins/metadata_plugin'
|
15
|
+
require 'middleman-presentation-helpers/plugins/footer_plugin'
|
16
|
+
require 'middleman-presentation-helpers/plugins/print_plugin'
|
17
|
+
|
18
|
+
module Middleman
|
19
|
+
module Presentation
|
20
|
+
# Helpers plugin
|
21
|
+
module Helpers
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'middleman-presentation-helpers/helpers/image_gallery.rb'
|
3
|
+
|
4
|
+
module Middleman
|
5
|
+
module Presentation
|
6
|
+
# Helper module
|
7
|
+
module Helpers
|
8
|
+
# Images helpers
|
9
|
+
module Image
|
10
|
+
# Create entry for single image
|
11
|
+
#
|
12
|
+
# @param [String] image
|
13
|
+
# The path to the image, e.g. 'img/image1.png'
|
14
|
+
def image(image)
|
15
|
+
ImageGallery.image_gallery Array(image), id: SecureRandom.hex
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module Middleman
|
3
2
|
module Presentation
|
4
3
|
# Helper module
|
@@ -6,20 +5,23 @@ module Middleman
|
|
6
5
|
# Images helpers
|
7
6
|
module ImageGallery
|
8
7
|
# Create image gallery
|
9
|
-
|
8
|
+
#
|
9
|
+
# @param [Array] images
|
10
|
+
# An array of image paths, e.g. `img/image.png`
|
11
|
+
#
|
12
|
+
# @param [String] id
|
13
|
+
# A unique id for your image gallery - unique within your presentation
|
14
|
+
def image_gallery(images, id:)
|
10
15
|
template = File.read(File.expand_path('../../../../templates/image_gallery.erb', __FILE__)).chomp
|
11
16
|
|
12
17
|
images.each_with_object([]) do |(image, title), memo|
|
13
18
|
engine = Erubis::Eruby.new(template)
|
14
19
|
|
15
|
-
memo << engine.result(image_path: image, image_gallery_id:
|
20
|
+
memo << engine.result(image_path: image, image_gallery_id: id, title: title)
|
16
21
|
end.join("\n")
|
17
22
|
end
|
18
23
|
|
19
|
-
|
20
|
-
def image(image)
|
21
|
-
image_gallery Array(image), image_gallery_id: SecureRandom.hex
|
22
|
-
end
|
24
|
+
module_function :image_gallery
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
module Helpers
|
5
|
+
# Meta daa helper
|
6
|
+
module Metadata
|
7
|
+
def metadata_markup(requested_fields, allowed_fields)
|
8
|
+
requested_fields = Array(requested_fields).map(&:to_sym)
|
9
|
+
allowed_fields = Array(allowed_fields).map(&:to_sym)
|
10
|
+
unknown_fields = requested_fields - allowed_fields
|
11
|
+
|
12
|
+
fail ArgumentError, Middleman::Presentation.t('errors.unknown_metadata_fields', fields: unknown_fields.to_list, count: unknown_fields.size) unless unknown_fields.blank?
|
13
|
+
|
14
|
+
Erubis::Eruby.new(template).result(fields: requested_fields).chomp
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def template
|
20
|
+
<<-EOS.strip_heredoc
|
21
|
+
<%- fields.each do |f| -%>
|
22
|
+
<span class="mp-meta-<%= f %>"><%= Middleman::Presentation.config.public_send f %></span>
|
23
|
+
<%- end -%>
|
24
|
+
EOS
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -7,17 +7,19 @@ module Middleman
|
|
7
7
|
module Slides
|
8
8
|
# Yield slides
|
9
9
|
def yield_slides
|
10
|
-
|
10
|
+
environment = Middleman::Presentation::MiddlemanEnvironment.new
|
11
|
+
|
12
|
+
list = SlideList.new(Dir.glob(File.join(environment.slides_path, '**', '*')), slide_builder: ExistingSlide, base_path: environment.sources_path) do |l|
|
11
13
|
l.transform_with Transformers::FileKeeper.new
|
12
14
|
l.transform_with Transformers::RemoveDuplicateSlides.new raise_error: true
|
13
|
-
l.transform_with Transformers::IgnoreSlides.new ignore_file: File.join(
|
15
|
+
l.transform_with Transformers::IgnoreSlides.new ignore_file: File.join(environment.root_path, Middleman::Presentation.config.slides_ignore_file)
|
14
16
|
l.transform_with Transformers::SortSlides.new
|
15
|
-
l.transform_with Transformers::GroupSlides.new template: Erubis::Eruby.new(GroupTemplate.new(working_directory:
|
17
|
+
l.transform_with Transformers::GroupSlides.new template: Erubis::Eruby.new(GroupTemplate.new(working_directory: environment.root_path).content)
|
16
18
|
end
|
17
19
|
|
18
20
|
list.all.map do |element|
|
19
21
|
begin
|
20
|
-
element.render { |path|
|
22
|
+
element.render { |path| render_template(path, {}, layout: nil).chomp }
|
21
23
|
rescue StandardError => e
|
22
24
|
message = []
|
23
25
|
message << "Rendering slide \"#{element.partial_path}\" failed with"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
# Helpers plugin
|
5
|
+
module Helpers
|
6
|
+
# Slides plugin
|
7
|
+
module SlidesPlugin
|
8
|
+
extend PluginApi
|
9
|
+
|
10
|
+
add_assets(
|
11
|
+
path: File.expand_path('../../../../vendor/assets', __FILE__),
|
12
|
+
importable_files: %w(footer.js footer.scss)
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
# Helpers plugin
|
5
|
+
module Helpers
|
6
|
+
# Highlight plugin
|
7
|
+
module HighlightPlugin
|
8
|
+
extend PluginApi
|
9
|
+
|
10
|
+
loadable_files = [
|
11
|
+
/.*\.js$/
|
12
|
+
]
|
13
|
+
|
14
|
+
add_component(
|
15
|
+
name: :'highlightjs',
|
16
|
+
version: 'latest',
|
17
|
+
importable_files: %w(zenburn.css),
|
18
|
+
loadable_files: loadable_files
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Middleman
|
3
|
+
module Presentation
|
4
|
+
# Helpers plugin
|
5
|
+
module Helpers
|
6
|
+
# Image Gallery plugin
|
7
|
+
class ImageGalleryPlugin < Plugin
|
8
|
+
extend PluginApi
|
9
|
+
|
10
|
+
add_assets(
|
11
|
+
path: File.expand_path('../../../../vendor/assets', __FILE__),
|
12
|
+
importable_files: %w(image_gallery.scss)
|
13
|
+
)
|
14
|
+
|
15
|
+
add_component(
|
16
|
+
name: :lightbox2,
|
17
|
+
github: 'dg-vrnetze/revealjs-lightbox2',
|
18
|
+
importable_files: %w(js/lightbox.js)
|
19
|
+
)
|
20
|
+
|
21
|
+
add_helpers Middleman::Presentation::Helpers::ImageGallery
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|