reveal-ck 0.1.4 → 0.1.5
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 +8 -8
- data/README.md +35 -0
- data/bin/reveal-ck +1 -4
- data/lib/reveal-ck.rb +9 -0
- data/lib/reveal-ck/presentation.rb +47 -0
- data/lib/reveal-ck/presentation_builder.rb +26 -14
- data/lib/reveal-ck/slide.rb +20 -0
- data/lib/reveal-ck/slides_html_builder.rb +30 -0
- data/lib/reveal-ck/template_finder.rb +35 -0
- data/lib/reveal-ck/template_processor.rb +1 -1
- data/lib/reveal-ck/version.rb +1 -1
- data/spec/data/slides_html_builder/slides.haml +3 -0
- data/spec/data/slides_html_builder/slides.rb +4 -0
- data/spec/data/slides_html_builder/slides.slim +2 -0
- data/spec/data/template_finder/automated/automated.slim +0 -0
- data/spec/data/template_finder/automated/common.haml +0 -0
- data/spec/data/template_finder/custom/common.haml +0 -0
- data/spec/data/template_finder/custom/custom.slim +0 -0
- data/spec/lib/reveal-ck/presentation_builder_spec.rb +36 -0
- data/spec/lib/reveal-ck/presentation_spec.rb +78 -0
- data/spec/lib/reveal-ck/slide_spec.rb +23 -0
- data/spec/lib/reveal-ck/slides_html_builder_spec.rb +102 -0
- data/spec/lib/reveal-ck/template_finder_spec.rb +78 -0
- data/spec/lib/reveal-ck_spec.rb +15 -0
- data/templates/code.slim +10 -0
- data/templates/image.slim +14 -0
- data/templates/quote.slim +11 -0
- data/templates/text.slim +9 -0
- data/templates/title.slim +23 -0
- metadata +36 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Mjg0NzYyNTNiNjY1NjZjZjE0MzBiYjQ2YjJlOGQ1YWE2ODRkYjNlMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzE0MDdlYzUwMjk3NmY1MzViOTI2NzJkZTY0N2Q1NmIwYTczZjNjOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDZjNGNkNTAxOGZmOGIzNjFjOWI2ZGEzYjE2YjcyZTMxNDQzMGQwNGNjNGM4
|
10
|
+
ZDM1ZDM3MGYzYTgwZGY0NjhhZjFhYzY2YzEwZDkyMTQ4NThmODgwMDQxNzI4
|
11
|
+
ZTY1ZmVmODYzOTQwZTc5OTFiMTVhMDEyOTZlZTdlMDM3YmE0YWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzYyY2MyYWQyNjcwYzFlMGIxMWY3NDYxOGU4MDQ3NjMyZDk4MWRkNjI4Yjg4
|
14
|
+
NmEzZDVjNTMzMzU5MTY4NzBmMTMxZjJjMWU0ODJiY2MyMTcyNzgwZTg1YzI0
|
15
|
+
NGU1NDgwMzE5MTQzZGZlZmM2ZjBjN2Q2YTNlYjEwM2I4ZWQ4MGU=
|
data/README.md
CHANGED
@@ -55,6 +55,41 @@ there's minimal markup.
|
|
55
55
|
In the end, [reveal.js][reveal-js], can make things pretty, but only
|
56
56
|
you can make a presentation that is worthwhile.
|
57
57
|
|
58
|
+
## One Last Thought: Slides in Ruby
|
59
|
+
|
60
|
+
Slim and Haml are decent, but the approach outlined so far means that
|
61
|
+
a user of reveal-ck needs to understand markup and conventions within
|
62
|
+
reveal.js. A templating language makes things less verbose, but it's
|
63
|
+
still a templating language.
|
64
|
+
|
65
|
+
If you'd like to go one step further, reveal-ck gives you the
|
66
|
+
opportunity to author slides in ruby. It comes with a small number of
|
67
|
+
pre-built templates that encapsulate reveal.js tag names, attributes,
|
68
|
+
and classes aside and provides classes that enable you to create
|
69
|
+
slides programmatically. See `examples/programmatic-slides.rb` for an
|
70
|
+
example.
|
71
|
+
|
72
|
+
What's more, once we've got programmatic support, it's not too much
|
73
|
+
harder to build a DSL. So, now you can create a file named `slides.rb`
|
74
|
+
(which replaces `slides.slim` or `slides.haml`) and write something
|
75
|
+
like this:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
slide 'title',
|
79
|
+
title: 'Here we go!',
|
80
|
+
author: 'Jed Northridge'
|
81
|
+
|
82
|
+
slide 'quote',
|
83
|
+
content: "when you don't create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create."
|
84
|
+
|
85
|
+
['3', '2', '1', 'Contact!'].each do |s|
|
86
|
+
slide 'text', content: s
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
You can now run `reveal-ck generate` with `slides.rb` and build slides
|
91
|
+
in ruby.
|
92
|
+
|
58
93
|
[jedcn-reveal-ck]: http://jedcn.com/posts/reveal-ck
|
59
94
|
[github-jedcn-reveal-ck-template]: http://github.com/jedcn/reveal-ck-template
|
60
95
|
[reveal-js]: http://lab.hakim.se/reveal-js
|
data/bin/reveal-ck
CHANGED
@@ -14,20 +14,17 @@ command :generate do |c|
|
|
14
14
|
|
15
15
|
require 'rake' # for FileList
|
16
16
|
|
17
|
-
revealjs_root = File.expand_path(File.join(File.dirname(__FILE__), '..', 'reveal.js'))
|
18
|
-
revealjs_files = FileList["#{revealjs_root}/**/*"]
|
19
|
-
|
20
17
|
image_files = FileList["images/**/*"]
|
21
18
|
|
22
19
|
output_dir = 'slides'
|
23
20
|
|
24
21
|
slides_file = 'slides.haml' if File.exists? 'slides.haml'
|
25
22
|
slides_file = 'slides.slim' if File.exists? 'slides.slim'
|
23
|
+
slides_file = 'slides.rb' if File.exists? 'slides.rb'
|
26
24
|
|
27
25
|
config = RevealCK::Config.new config_file: 'config.toml'
|
28
26
|
|
29
27
|
builder = RevealCK::PresentationBuilder.new({
|
30
|
-
revealjs_files: revealjs_files,
|
31
28
|
image_files: image_files,
|
32
29
|
output_dir: output_dir,
|
33
30
|
slides_file: slides_file,
|
data/lib/reveal-ck.rb
CHANGED
@@ -3,8 +3,17 @@ require_relative 'reveal-ck/config'
|
|
3
3
|
require_relative 'reveal-ck/file_string_replacer'
|
4
4
|
require_relative 'reveal-ck/file_slicer'
|
5
5
|
require_relative 'reveal-ck/file_splicer'
|
6
|
+
require_relative 'reveal-ck/template_finder'
|
6
7
|
require_relative 'reveal-ck/template_processor'
|
8
|
+
require_relative 'reveal-ck/slide'
|
9
|
+
require_relative 'reveal-ck/presentation'
|
7
10
|
require_relative 'reveal-ck/build_task'
|
8
11
|
require_relative 'reveal-ck/builder'
|
12
|
+
require_relative 'reveal-ck/slides_html_builder'
|
9
13
|
require_relative 'reveal-ck/slide_builder'
|
10
14
|
require_relative 'reveal-ck/presentation_builder'
|
15
|
+
|
16
|
+
module RevealCK
|
17
|
+
revealjs_root = File.expand_path(File.join(File.dirname(__FILE__), '..', 'reveal.js'))
|
18
|
+
REVEALJS_FILES = Dir.glob "#{revealjs_root}/**/*"
|
19
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module RevealCK
|
2
|
+
class Presentation
|
3
|
+
|
4
|
+
attr_accessor :theme, :title, :author
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@slides = []
|
8
|
+
@theme = 'default'
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_slide(slide)
|
12
|
+
@slides << slide
|
13
|
+
end
|
14
|
+
|
15
|
+
def content
|
16
|
+
s = ""
|
17
|
+
@slides.each do |slide|
|
18
|
+
s << slide.html
|
19
|
+
s << "\n\n"
|
20
|
+
end
|
21
|
+
s
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module RevealCK
|
28
|
+
class Presentation
|
29
|
+
|
30
|
+
def self.load(file)
|
31
|
+
presentation = Presentation.new
|
32
|
+
content = File.open(file).read
|
33
|
+
presentation.eval content
|
34
|
+
presentation
|
35
|
+
end
|
36
|
+
|
37
|
+
def eval(s)
|
38
|
+
instance_eval s
|
39
|
+
end
|
40
|
+
|
41
|
+
def slide(template, variables)
|
42
|
+
variables[:template] = template
|
43
|
+
add_slide(Slide.new(variables))
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -7,12 +7,14 @@ module RevealCK
|
|
7
7
|
#
|
8
8
|
class PresentationBuilder < Builder
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :image_files, :slides_file, :config
|
11
11
|
attr_reader :tasks
|
12
12
|
|
13
13
|
def initialize(args)
|
14
|
-
@
|
14
|
+
@image_files = args[:image_files]
|
15
15
|
@slides_file = args[:slides_file]
|
16
|
+
@presentation = args[:presentation]
|
17
|
+
raise 'either :slides_file or :presentation is required' unless @slides_file || @presentation
|
16
18
|
@output_dir = args[:output_dir]
|
17
19
|
@config = args[:config]
|
18
20
|
end
|
@@ -36,29 +38,39 @@ module RevealCK
|
|
36
38
|
FileUtils.mkdir_p output_dir, verbose: false
|
37
39
|
}
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
if @slides_file
|
42
|
+
add_task "Transforming #{slides_file} into #{output_dir('slides.html')}'}",
|
43
|
+
lambda {
|
44
|
+
builder = SlidesHtmlBuilder.new input_file: @slides_file
|
45
|
+
builder.write_to file: output_dir('slides.html')
|
46
|
+
}
|
47
|
+
else
|
48
|
+
add_task "Transforming Presentation into #{output_dir('slides.html')}'}",
|
49
|
+
lambda {
|
50
|
+
builder = SlidesHtmlBuilder.new presentation: @presentation
|
51
|
+
builder.write_to file: output_dir('slides.html')
|
52
|
+
}
|
53
|
+
end
|
44
54
|
|
45
55
|
add_task "Bundling up the revealjs stuff into #{output_dir}/",
|
46
56
|
lambda {
|
47
|
-
FileUtils.cp_r
|
57
|
+
FileUtils.cp_r RevealCK::REVEALJS_FILES, output_dir, verbose: false
|
48
58
|
}
|
49
59
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
60
|
+
if image_files
|
61
|
+
add_task "Copying in images into #{output_dir('images')}",
|
62
|
+
lambda {
|
63
|
+
FileUtils.mkdir_p output_dir('images'), verbose: false
|
64
|
+
FileUtils.cp_r image_files, output_dir('images'), verbose: false
|
65
|
+
}
|
66
|
+
end
|
55
67
|
|
56
68
|
add_task "Creating slides/index.html",
|
57
69
|
lambda {
|
58
70
|
slide_builder = SlideBuilder.new({
|
59
71
|
user_slides: output_dir('slides.html'),
|
60
72
|
reveal_slides: output_dir('index.html'),
|
61
|
-
config: config
|
73
|
+
config: @presentation || config
|
62
74
|
})
|
63
75
|
slide_builder.build!
|
64
76
|
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: A Slide produces HTML output to be included in a
|
4
|
+
# presentation. Presently, this output is based upon a template.
|
5
|
+
#
|
6
|
+
class Slide
|
7
|
+
|
8
|
+
def initialize(args)
|
9
|
+
template = args[:template] || raise(':template is required')
|
10
|
+
file = TemplateFinder.new.find template
|
11
|
+
@template = TemplateProcessor.open file
|
12
|
+
@variables = args
|
13
|
+
end
|
14
|
+
|
15
|
+
def html
|
16
|
+
@template.output({}, @variables)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RevealCK
|
2
|
+
class SlidesHtmlBuilder
|
3
|
+
|
4
|
+
def initialize(args)
|
5
|
+
@input_file = args[:input_file]
|
6
|
+
@presentation = args[:presentation]
|
7
|
+
raise 'either :input_file or :presentation are required' unless @input_file || @presentation
|
8
|
+
end
|
9
|
+
|
10
|
+
def render
|
11
|
+
if @input_file
|
12
|
+
if @input_file.end_with? '.rb'
|
13
|
+
presentation = RevealCK::Presentation.load @input_file
|
14
|
+
presentation.content
|
15
|
+
else
|
16
|
+
template = TemplateProcessor.open @input_file
|
17
|
+
template.output({}, {})
|
18
|
+
end
|
19
|
+
else
|
20
|
+
@presentation.content
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def write_to(args)
|
25
|
+
file = args[:file] || raise(':file is required')
|
26
|
+
File.open(file, 'w') { |f| f << render }
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RevealCK
|
2
|
+
#
|
3
|
+
# Public: This class is home to a simple algorithm for looking up
|
4
|
+
# files in a series of directories. Directory order matters, and the
|
5
|
+
# first match for the file will be returned. It'll raise if it can't
|
6
|
+
# find the file you've asked for.
|
7
|
+
#
|
8
|
+
class TemplateFinder
|
9
|
+
|
10
|
+
attr_reader :paths
|
11
|
+
|
12
|
+
def initialize(args={})
|
13
|
+
@paths = args[:paths] || default_paths
|
14
|
+
end
|
15
|
+
|
16
|
+
def default_paths
|
17
|
+
pwd = Dir.pwd
|
18
|
+
pwd_templates = File.join Dir.pwd, 'templates'
|
19
|
+
reveal_ck_templates =
|
20
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'templates'))
|
21
|
+
|
22
|
+
[pwd, pwd_templates, reveal_ck_templates]
|
23
|
+
end
|
24
|
+
|
25
|
+
def find(template_name)
|
26
|
+
paths.each do |path|
|
27
|
+
glob_pattern = "#{File.join(path, template_name)}*"
|
28
|
+
matching_templates = Dir.glob glob_pattern
|
29
|
+
return matching_templates[0] unless matching_templates.empty?
|
30
|
+
end
|
31
|
+
raise "Unable to find #{template_name} in #{paths}"
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/lib/reveal-ck/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
|
4
|
+
module RevealCK
|
5
|
+
describe PresentationBuilder do
|
6
|
+
|
7
|
+
let :presentation do
|
8
|
+
presentation = Presentation.new
|
9
|
+
presentation.title = "Presentation Title"
|
10
|
+
presentation.author = "Presentation Author"
|
11
|
+
|
12
|
+
presentation.add_slide(Slide.new({
|
13
|
+
template: 'title',
|
14
|
+
title: presentation.title,
|
15
|
+
author: presentation.author,
|
16
|
+
site: 'http://site.com',
|
17
|
+
twitter: 'twitter'
|
18
|
+
}))
|
19
|
+
presentation
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'can build reveal.js slides from a Presentation' do
|
23
|
+
|
24
|
+
tmp_dir = Dir.mktmpdir
|
25
|
+
|
26
|
+
presentation_builder = PresentationBuilder.new({
|
27
|
+
presentation: presentation,
|
28
|
+
output_dir: tmp_dir,
|
29
|
+
})
|
30
|
+
presentation_builder.build!
|
31
|
+
|
32
|
+
expect(File.exists? File.join(tmp_dir, "index.html")).to be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RevealCK
|
4
|
+
describe Presentation do
|
5
|
+
|
6
|
+
describe '#add_slide' do
|
7
|
+
|
8
|
+
it 'maintains a list of slides' do
|
9
|
+
presentation = Presentation.new
|
10
|
+
presentation.add_slide double('slide', html: "first")
|
11
|
+
presentation.add_slide double('slide', html: "second")
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#content' do
|
17
|
+
|
18
|
+
let :presentation do
|
19
|
+
presentation = Presentation.new
|
20
|
+
presentation.add_slide double('slide', html: "first")
|
21
|
+
presentation.add_slide double('slide', html: "second")
|
22
|
+
presentation
|
23
|
+
end
|
24
|
+
|
25
|
+
let :content do
|
26
|
+
presentation.content.strip
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns the content from each slide' do
|
30
|
+
expect(content).to start_with 'first'
|
31
|
+
expect(content).to end_with 'second'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#theme' do
|
37
|
+
it 'can be set and read' do
|
38
|
+
presentation = Presentation.new
|
39
|
+
presentation.theme = 'night'
|
40
|
+
expect(presentation.theme).to eq 'night'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'has a default value of "default"' do
|
44
|
+
expect(Presentation.new.theme).to eq 'default'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'responds to #title= and #title' do
|
49
|
+
presentation = Presentation.new
|
50
|
+
presentation.title = 'My Favorite Slides'
|
51
|
+
expect(presentation.title).to eq 'My Favorite Slides'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'responds to #author= and #author' do
|
55
|
+
presentation = Presentation.new
|
56
|
+
presentation.author = 'Hakim El Hattab'
|
57
|
+
expect(presentation.author).to eq 'Hakim El Hattab'
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#slide' do
|
61
|
+
it 'is a shortcut for creating a new Slide and calling #add_slide' do
|
62
|
+
presentation = Presentation.new
|
63
|
+
|
64
|
+
expect(Slide)
|
65
|
+
.to(receive(:new)
|
66
|
+
.with({ template: 'text', content: 'spec' })
|
67
|
+
.and_call_original)
|
68
|
+
|
69
|
+
expect(presentation)
|
70
|
+
.to(receive(:add_slide)
|
71
|
+
.with(kind_of(Slide)))
|
72
|
+
|
73
|
+
presentation.eval "slide('text', { content: 'spec' })"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RevealCK
|
4
|
+
describe Slide do
|
5
|
+
|
6
|
+
let :title_slide do
|
7
|
+
Slide.new template: 'title',
|
8
|
+
title: 'Reveal.js',
|
9
|
+
subtitle: 'HTML Presentations Made Easy',
|
10
|
+
author: 'Hakim El Hattab',
|
11
|
+
site: 'http://hakim.se',
|
12
|
+
twitter: 'hakimel'
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#html' do
|
16
|
+
it 'produces html output' do
|
17
|
+
output = title_slide.html
|
18
|
+
expect(output).to include 'Reveal.js'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
module RevealCK
|
5
|
+
describe SlidesHtmlBuilder do
|
6
|
+
|
7
|
+
let :data do
|
8
|
+
File.join 'spec', 'data', 'slides_html_builder'
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when working with slim' do
|
12
|
+
|
13
|
+
let :input_file do
|
14
|
+
File.join data, 'slides.slim'
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#render' do
|
18
|
+
it 'knows how to create slide content from slim' do
|
19
|
+
builder = SlidesHtmlBuilder.new input_file: input_file
|
20
|
+
expect(builder.render).to include "<section>"
|
21
|
+
expect(builder.render).to include "<h1>"
|
22
|
+
expect(builder.render).to include "Hello Slim!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'when working with haml' do
|
29
|
+
|
30
|
+
let :input_file do
|
31
|
+
File.join data, 'slides.haml'
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#render' do
|
35
|
+
it 'knows how to create slide content from haml' do
|
36
|
+
builder = SlidesHtmlBuilder.new input_file: input_file
|
37
|
+
expect(builder.render).to include "<section>"
|
38
|
+
expect(builder.render).to include "<h1>"
|
39
|
+
expect(builder.render).to include "Hello Haml!"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when working with ruby' do
|
46
|
+
|
47
|
+
let :input_file do
|
48
|
+
File.join data, 'slides.rb'
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#render' do
|
52
|
+
it 'knows how to create slide content from ruby' do
|
53
|
+
builder = SlidesHtmlBuilder.new input_file: input_file
|
54
|
+
expect(builder.render).to include "<section>"
|
55
|
+
expect(builder.render).to include "<h2>"
|
56
|
+
expect(builder.render).to include "Hello Ruby!"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when working with a Presentation' do
|
63
|
+
|
64
|
+
let :presentation do
|
65
|
+
quote = Slide.new({
|
66
|
+
template: 'quote',
|
67
|
+
content: 'Hello Ruby!',
|
68
|
+
citation: 'https://www.ruby-lang.org/en/about/'
|
69
|
+
})
|
70
|
+
presentation = Presentation.new
|
71
|
+
presentation.add_slide quote
|
72
|
+
presentation
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#render' do
|
76
|
+
it 'knows how to create slide content from a Presentation' do
|
77
|
+
builder = SlidesHtmlBuilder.new presentation: presentation
|
78
|
+
expect(builder.render).to include "<section>"
|
79
|
+
expect(builder.render).to include "<blockquote"
|
80
|
+
expect(builder.render).to include "Hello Ruby!"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#write_to' do
|
87
|
+
|
88
|
+
it 'can write #rendered output to a file' do
|
89
|
+
input_file = File.join data, 'slides.haml'
|
90
|
+
builder = SlidesHtmlBuilder.new input_file: input_file
|
91
|
+
tmp_file = Tempfile.new 'slides.html'
|
92
|
+
builder.write_to file: tmp_file.path
|
93
|
+
|
94
|
+
written_content = File.open(tmp_file).read
|
95
|
+
expect(written_content).to include "<section>"
|
96
|
+
expect(written_content).to include "<h1>"
|
97
|
+
expect(written_content).to include "Hello Haml!"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module RevealCK
|
6
|
+
|
7
|
+
describe TemplateFinder do
|
8
|
+
|
9
|
+
let :reveal_ck_dir do
|
10
|
+
Dir.pwd
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#paths' do
|
14
|
+
|
15
|
+
it 'defaults to Dir.pwd, Dir.pwd/templates, and reveal-ck/templates' do
|
16
|
+
finder = TemplateFinder.new
|
17
|
+
expect(finder.paths).to include Dir.pwd
|
18
|
+
expect(finder.paths).to include File.join(Dir.pwd, 'templates')
|
19
|
+
expect(finder.paths).to include File.join(reveal_ck_dir, 'templates')
|
20
|
+
expect(finder.paths.size).to eq 3
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can be assigned via initializer' do
|
24
|
+
Dir.mktmpdir do |dir|
|
25
|
+
finder = TemplateFinder.new paths: [ dir, File.join(dir, 'templates') ]
|
26
|
+
expect(finder.paths).to include dir
|
27
|
+
expect(finder.paths).to include File.join(dir, 'templates')
|
28
|
+
expect(finder.paths.size).to eq 2
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#find' do
|
35
|
+
|
36
|
+
let :template_finder_dir do
|
37
|
+
File.join reveal_ck_dir, 'spec', 'data', 'template_finder'
|
38
|
+
end
|
39
|
+
|
40
|
+
let :automated_dir do
|
41
|
+
File.join template_finder_dir, 'automated'
|
42
|
+
end
|
43
|
+
|
44
|
+
let :custom_dir do
|
45
|
+
File.join template_finder_dir, 'custom'
|
46
|
+
end
|
47
|
+
|
48
|
+
let :reveal_ck_templates_dir do
|
49
|
+
File.join reveal_ck_dir, 'templates'
|
50
|
+
end
|
51
|
+
|
52
|
+
let :finder do
|
53
|
+
paths = [custom_dir, automated_dir, reveal_ck_templates_dir]
|
54
|
+
TemplateFinder.new paths: paths
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'searches all paths to find templates' do
|
58
|
+
result = finder.find 'automated'
|
59
|
+
expect(result).to include File.join('template_finder', 'automated', 'automated.slim')
|
60
|
+
result = finder.find 'custom'
|
61
|
+
expect(result).to include File.join('template_finder', 'custom', 'custom.slim')
|
62
|
+
result = finder.find 'title'
|
63
|
+
expect(result).to include File.join('reveal-ck', 'templates', 'title.slim')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'searchs paths in order and returns the first match' do
|
67
|
+
result = finder.find 'common.haml'
|
68
|
+
expect(result).to include File.join('custom', 'common.haml')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'can search by partial file name' do
|
72
|
+
result = finder.find 'common'
|
73
|
+
expect(result).to include File.join('custom', 'common.haml')
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RevealCK, '::REVEALJS_FILES' do
|
4
|
+
|
5
|
+
it 'is a list of the bundled reveal.js files' do
|
6
|
+
bundled_files = RevealCK::REVEALJS_FILES
|
7
|
+
bundled_index_html = bundled_files.find do |name|
|
8
|
+
name.include? 'reveal.js/index.html'
|
9
|
+
end
|
10
|
+
|
11
|
+
expect(bundled_files).to be_an Array
|
12
|
+
expect(bundled_index_html).to_not be_nil
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/templates/code.slim
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
- headline = headline || nil
|
2
|
+
- notes = notes || nil
|
3
|
+
- link = link || nil
|
4
|
+
- alt = alt || ''
|
5
|
+
section
|
6
|
+
- if headline
|
7
|
+
h2= headline
|
8
|
+
- if link
|
9
|
+
a.image href="#{link}" target="_blank"
|
10
|
+
img width="#{width}" height="#{height}" src="#{src}" alt="#{alt}"/
|
11
|
+
- else
|
12
|
+
img width="#{width}" height="#{height}" src="#{src}" alt="#{alt}"/
|
13
|
+
- if notes
|
14
|
+
aside.notes= notes
|
data/templates/text.slim
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
- author = author || nil
|
2
|
+
- link = link || nil
|
3
|
+
- twitter = twitter || nil
|
4
|
+
- notes = notes || nil
|
5
|
+
- title = title || ''
|
6
|
+
- subtitle = subtitle || nil
|
7
|
+
section
|
8
|
+
h1= title
|
9
|
+
- if subtitle
|
10
|
+
h3= subtitle
|
11
|
+
- if author
|
12
|
+
p
|
13
|
+
small
|
14
|
+
| Created by
|
15
|
+
- if link
|
16
|
+
a<> href="#{link}"= author
|
17
|
+
- else
|
18
|
+
=<> author
|
19
|
+
- if twitter
|
20
|
+
| /
|
21
|
+
a<> href="http://twitter.com/#{twitter}"= "@#{twitter}"
|
22
|
+
- if notes
|
23
|
+
aside.notes= notes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reveal-ck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jed Northridge
|
@@ -243,12 +243,21 @@ files:
|
|
243
243
|
- lib/reveal-ck/file_slicer.rb
|
244
244
|
- lib/reveal-ck/file_splicer.rb
|
245
245
|
- lib/reveal-ck/file_string_replacer.rb
|
246
|
+
- lib/reveal-ck/presentation.rb
|
246
247
|
- lib/reveal-ck/presentation_builder.rb
|
248
|
+
- lib/reveal-ck/slide.rb
|
247
249
|
- lib/reveal-ck/slide_builder.rb
|
250
|
+
- lib/reveal-ck/slides_html_builder.rb
|
251
|
+
- lib/reveal-ck/template_finder.rb
|
248
252
|
- lib/reveal-ck/template_processor.rb
|
249
253
|
- lib/reveal-ck/version.rb
|
250
254
|
- rakelib/cucumber.rake
|
251
255
|
- rakelib/rspec.rake
|
256
|
+
- templates/code.slim
|
257
|
+
- templates/image.slim
|
258
|
+
- templates/quote.slim
|
259
|
+
- templates/text.slim
|
260
|
+
- templates/title.slim
|
252
261
|
- README.md
|
253
262
|
- features/data/images/ruby100.png
|
254
263
|
- features/step_definitions/file_management_steps.rb
|
@@ -261,17 +270,30 @@ files:
|
|
261
270
|
- spec/data/html/reveal-js-index.html
|
262
271
|
- spec/data/slicer/after_remove
|
263
272
|
- spec/data/slicer/before_remove
|
273
|
+
- spec/data/slides_html_builder/slides.haml
|
274
|
+
- spec/data/slides_html_builder/slides.rb
|
275
|
+
- spec/data/slides_html_builder/slides.slim
|
264
276
|
- spec/data/slim/basic.slim
|
265
277
|
- spec/data/splicer/abcd
|
266
278
|
- spec/data/splicer/after_insert
|
267
279
|
- spec/data/splicer/before_insert
|
268
280
|
- spec/data/string_replacer/after_replace
|
269
281
|
- spec/data/string_replacer/before_replace
|
282
|
+
- spec/data/template_finder/automated/automated.slim
|
283
|
+
- spec/data/template_finder/automated/common.haml
|
284
|
+
- spec/data/template_finder/custom/common.haml
|
285
|
+
- spec/data/template_finder/custom/custom.slim
|
270
286
|
- spec/lib/reveal-ck/config_spec.rb
|
271
287
|
- spec/lib/reveal-ck/file_slicer_spec.rb
|
272
288
|
- spec/lib/reveal-ck/file_splicer_spec.rb
|
273
289
|
- spec/lib/reveal-ck/file_string_replacer_spec.rb
|
290
|
+
- spec/lib/reveal-ck/presentation_builder_spec.rb
|
291
|
+
- spec/lib/reveal-ck/presentation_spec.rb
|
292
|
+
- spec/lib/reveal-ck/slide_spec.rb
|
293
|
+
- spec/lib/reveal-ck/slides_html_builder_spec.rb
|
294
|
+
- spec/lib/reveal-ck/template_finder_spec.rb
|
274
295
|
- spec/lib/reveal-ck/template_processor_spec.rb
|
296
|
+
- spec/lib/reveal-ck_spec.rb
|
275
297
|
- bin/reveal-ck
|
276
298
|
homepage: https://github.com/jedcn/reveal-ck
|
277
299
|
licenses:
|
@@ -310,14 +332,27 @@ test_files:
|
|
310
332
|
- spec/data/html/reveal-js-index.html
|
311
333
|
- spec/data/slicer/after_remove
|
312
334
|
- spec/data/slicer/before_remove
|
335
|
+
- spec/data/slides_html_builder/slides.haml
|
336
|
+
- spec/data/slides_html_builder/slides.rb
|
337
|
+
- spec/data/slides_html_builder/slides.slim
|
313
338
|
- spec/data/slim/basic.slim
|
314
339
|
- spec/data/splicer/abcd
|
315
340
|
- spec/data/splicer/after_insert
|
316
341
|
- spec/data/splicer/before_insert
|
317
342
|
- spec/data/string_replacer/after_replace
|
318
343
|
- spec/data/string_replacer/before_replace
|
344
|
+
- spec/data/template_finder/automated/automated.slim
|
345
|
+
- spec/data/template_finder/automated/common.haml
|
346
|
+
- spec/data/template_finder/custom/common.haml
|
347
|
+
- spec/data/template_finder/custom/custom.slim
|
319
348
|
- spec/lib/reveal-ck/config_spec.rb
|
320
349
|
- spec/lib/reveal-ck/file_slicer_spec.rb
|
321
350
|
- spec/lib/reveal-ck/file_splicer_spec.rb
|
322
351
|
- spec/lib/reveal-ck/file_string_replacer_spec.rb
|
352
|
+
- spec/lib/reveal-ck/presentation_builder_spec.rb
|
353
|
+
- spec/lib/reveal-ck/presentation_spec.rb
|
354
|
+
- spec/lib/reveal-ck/slide_spec.rb
|
355
|
+
- spec/lib/reveal-ck/slides_html_builder_spec.rb
|
356
|
+
- spec/lib/reveal-ck/template_finder_spec.rb
|
323
357
|
- spec/lib/reveal-ck/template_processor_spec.rb
|
358
|
+
- spec/lib/reveal-ck_spec.rb
|