magic_reveal 2.6.1.2 → 2.6.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Guardfile +19 -4
- data/README.md +3 -1
- data/bin/magic-reveal +1 -1
- data/lib/magic_reveal.rb +1 -1
- data/lib/magic_reveal/app.rb +1 -1
- data/lib/magic_reveal/cli.rb +25 -22
- data/lib/magic_reveal/cli/options.rb +4 -3
- data/lib/magic_reveal/conductor.rb +7 -7
- data/lib/magic_reveal/creator.rb +2 -1
- data/lib/magic_reveal/identifier.rb +2 -1
- data/lib/magic_reveal/index_libber.rb +30 -21
- data/lib/magic_reveal/project_config.rb +15 -14
- data/lib/magic_reveal/reveal_js_fetcher.rb +3 -2
- data/lib/magic_reveal/slide_renderer.rb +24 -28
- data/lib/magic_reveal/version.rb +2 -1
- data/magic-reveal.gemspec +25 -29
- data/spec/integration/renderer_spec.rb +29 -0
- data/spec/magic_reveal/cli/options_spec.rb +2 -2
- data/spec/magic_reveal/cli_spec.rb +22 -24
- data/spec/magic_reveal/conductor_spec.rb +8 -8
- data/spec/magic_reveal/creator_spec.rb +22 -17
- data/spec/magic_reveal/identifier_spec.rb +18 -18
- data/spec/magic_reveal/index_libber_spec.rb +21 -21
- data/spec/magic_reveal/project_config_spec.rb +12 -12
- data/spec/magic_reveal/reveal_js_fetcher_spec.rb +10 -10
- data/spec/magic_reveal/slide_renderer_spec.rb +57 -51
- data/spec/spec_helper.rb +14 -12
- metadata +23 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d26848d4efe7ddf18d1f06cf7466b705c990b33
|
4
|
+
data.tar.gz: eb2219d4d227d87c2f6031541cd953e029c7c8f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285e3207220eef9ed03e789b96fbd2eaccabb9b4f16d1f5e2348a6233c82f3bf0ed11c009f62f95239895d61081d5848b4f5914ab8f5ef8625717dd5327c3b72
|
7
|
+
data.tar.gz: dd484b481a9a8834a9f538719c1581dc0ce057c9f858a0532ef7b171db569678d19056bb977926503e8d290f1a61c4776a164e9ce230a84e9cbd767d1f6c218f
|
data/.travis.yml
CHANGED
data/Guardfile
CHANGED
@@ -1,5 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
group :red_green_refactor, halt_on_fail: true do
|
2
|
+
guard(
|
3
|
+
:rspec,
|
4
|
+
cmd: 'bundle exec rspec --color --order default --format doc',
|
5
|
+
failed_mode: :none,
|
6
|
+
all_on_start: true,
|
7
|
+
all_after_pass: true,
|
8
|
+
run_all: { cmd: 'bundle exec rspec --color --order random --format progress' }
|
9
|
+
) do
|
10
|
+
watch(%r{^spec/.+_spec\.rb$})
|
11
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
12
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
13
|
+
watch(%r{^spec/integration/.+_spec\.rb$}) { 'spec' }
|
14
|
+
end
|
15
|
+
|
16
|
+
guard :rubocop, cli: 'lib spec -D', all_on_start: true do
|
17
|
+
watch(%r{^(lib|spec)/.+\.rb$})
|
18
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
19
|
+
end
|
5
20
|
end
|
data/README.md
CHANGED
@@ -4,9 +4,11 @@ Magic Reveal makes creating presentations easy and fun.
|
|
4
4
|
|
5
5
|
See it in action at the [demo/tutorial](http://docwhat.github.io/magic_reveal/)
|
6
6
|
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/magic_reveal.png)](http://badge.fury.io/rb/magic_reveal)
|
7
8
|
[![Build Status](https://secure.travis-ci.org/docwhat/magic_reveal.png?branch=master)](http://travis-ci.org/docwhat/magic_reveal)
|
8
9
|
[![Dependencies](https://gemnasium.com/docwhat/magic_reveal.png?branch=master)](https://gemnasium.com/docwhat/magic_reveal)
|
9
10
|
[![Coverage Status](https://coveralls.io/repos/docwhat/magic_reveal/badge.png?branch=master)](https://coveralls.io/r/docwhat/magic_reveal)
|
11
|
+
[![Code Climate](https://codeclimate.com/github/docwhat/magic_reveal.png)](https://codeclimate.com/github/docwhat/magic_reveal)
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
@@ -20,7 +22,7 @@ the revision specific to Magic Reveal.
|
|
20
22
|
|
21
23
|
### Requirements
|
22
24
|
|
23
|
-
* Ruby 1.9.
|
25
|
+
* Ruby 1.9.3 or newer
|
24
26
|
* A recent version of [Bundler](http://bundler.io/)
|
25
27
|
|
26
28
|
<br/>
|
data/bin/magic-reveal
CHANGED
data/lib/magic_reveal.rb
CHANGED
data/lib/magic_reveal/app.rb
CHANGED
@@ -12,6 +12,7 @@ rescue LoadError
|
|
12
12
|
end
|
13
13
|
|
14
14
|
module MagicReveal
|
15
|
+
# The web application
|
15
16
|
class App < Sinatra::Base
|
16
17
|
if HAS_BETTER_ERRORS
|
17
18
|
configure :development do
|
@@ -41,6 +42,5 @@ module MagicReveal
|
|
41
42
|
config = ProjectConfig.new(Pathname.pwd + 'config.json')
|
42
43
|
config.to_js
|
43
44
|
end
|
44
|
-
|
45
45
|
end
|
46
46
|
end
|
data/lib/magic_reveal/cli.rb
CHANGED
@@ -8,6 +8,7 @@ require 'magic_reveal/index_libber'
|
|
8
8
|
require 'magic_reveal/project_config'
|
9
9
|
|
10
10
|
module MagicReveal
|
11
|
+
# Command line interface
|
11
12
|
class Cli
|
12
13
|
extend Forwardable
|
13
14
|
|
@@ -18,26 +19,28 @@ module MagicReveal
|
|
18
19
|
attr_writer :creator
|
19
20
|
|
20
21
|
# Helper method
|
21
|
-
def self.run
|
22
|
-
|
22
|
+
def self.run(args = ARGV)
|
23
|
+
new.run args
|
23
24
|
end
|
24
25
|
|
25
26
|
# Action Classes
|
26
|
-
def show_help
|
27
|
-
puts
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
27
|
+
def show_help # rubocop:disable MethodLength
|
28
|
+
puts <<-EOF
|
29
|
+
Usage: #{program_name} <command>
|
30
|
+
Magic reveal version: #{MagicReveal::VERSION}
|
31
|
+
|
32
|
+
new <name>
|
33
|
+
Creates new presentation in directory <name>
|
34
|
+
|
35
|
+
force-reload
|
36
|
+
Refreshes the reveal.js files. WARNING: This may override customizations!
|
37
|
+
|
38
|
+
start [options]
|
39
|
+
Starts serving the presentation in the current directory
|
40
|
+
|
41
|
+
static
|
42
|
+
Creates a static index.html file from your slides
|
43
|
+
EOF
|
41
44
|
exit
|
42
45
|
end
|
43
46
|
|
@@ -52,7 +55,7 @@ module MagicReveal
|
|
52
55
|
exit
|
53
56
|
end
|
54
57
|
|
55
|
-
def create_static
|
58
|
+
def create_static # rubocop:disable MethodLength
|
56
59
|
slides = Pathname.pwd + 'slides.md'
|
57
60
|
markdown = SlideRenderer.markdown_renderer
|
58
61
|
libber = IndexLibber.new
|
@@ -71,8 +74,8 @@ module MagicReveal
|
|
71
74
|
end
|
72
75
|
|
73
76
|
def avenge_programmer
|
74
|
-
puts
|
75
|
-
puts
|
77
|
+
puts 'The programmer messed up.'
|
78
|
+
puts 'Please file a bug at https://github.com/docwhat/magic_reveal'
|
76
79
|
exit 13
|
77
80
|
end
|
78
81
|
|
@@ -80,14 +83,14 @@ module MagicReveal
|
|
80
83
|
@options ||= Options.new
|
81
84
|
end
|
82
85
|
|
83
|
-
def run
|
86
|
+
def run(args = ARGV) # rubocop:disable MethodLength, CyclomaticComplexity
|
84
87
|
options.parse args
|
85
88
|
|
86
89
|
case command
|
87
90
|
when :new
|
88
91
|
creator.create_project(project)
|
89
92
|
when :force_reload
|
90
|
-
theyre_sure = (ask('This may overwrite customizations. Are you sure? (y/N) ') { |q| q.limit = 1; q.case = :downcase }) == 'y'
|
93
|
+
theyre_sure = (ask('This may overwrite customizations. Are you sure? (y/N) ') { |q| q.limit = 1; q.case = :downcase }) == 'y' # rubocop:disable Semicolon
|
91
94
|
creator.update_project(Dir.getwd) if theyre_sure
|
92
95
|
when :start
|
93
96
|
start_server
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module MagicReveal
|
2
2
|
class Cli
|
3
|
+
# Command line options
|
3
4
|
class Options
|
4
5
|
attr_accessor(
|
5
6
|
:command,
|
6
|
-
:project
|
7
|
+
:project
|
7
8
|
)
|
8
9
|
|
9
10
|
def program_name
|
10
|
-
@program_name ||= File.basename($
|
11
|
+
@program_name ||= File.basename($PROGRAM_NAME)
|
11
12
|
end
|
12
13
|
|
13
|
-
def parse
|
14
|
+
def parse(args) # rubocop:disable MethodLength
|
14
15
|
case args.first
|
15
16
|
when 'new'
|
16
17
|
if args.length != 2
|
@@ -9,16 +9,16 @@ module MagicReveal
|
|
9
9
|
class Conductor
|
10
10
|
attr_reader :url, :enable_warnings
|
11
11
|
|
12
|
-
def initialize
|
12
|
+
def initialize(url = nil)
|
13
13
|
self.url = url unless url.nil?
|
14
14
|
end
|
15
15
|
|
16
|
-
def url=
|
16
|
+
def url=(url)
|
17
17
|
@url = URI.parse url
|
18
18
|
end
|
19
19
|
|
20
|
-
def fetch
|
21
|
-
|
20
|
+
def fetch(save_path, limit = 5) # rubocop:disable MethodLength
|
21
|
+
fail TooManyRedirects if limit <= 0
|
22
22
|
save_path = Pathname.new save_path
|
23
23
|
|
24
24
|
request = Net::HTTP::Get.new url.path
|
@@ -32,13 +32,13 @@ module MagicReveal
|
|
32
32
|
warn "redirected to #{url}" if enable_warnings
|
33
33
|
fetch(save_path, limit - 1)
|
34
34
|
else
|
35
|
-
|
35
|
+
fail Error, "Huh? #{response.value}"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def unpack
|
39
|
+
def unpack(zip_file, directory)
|
40
40
|
directory = Pathname.new directory
|
41
|
-
|
41
|
+
fail Error, "Directory '#{directory}' already exists." if directory.exist?
|
42
42
|
|
43
43
|
Archive::Zip.extract zip_file.to_s, directory.to_s
|
44
44
|
|
data/lib/magic_reveal/creator.rb
CHANGED
@@ -6,6 +6,7 @@ require 'magic_reveal/reveal_js_fetcher'
|
|
6
6
|
require 'magic_reveal/project_config'
|
7
7
|
|
8
8
|
module MagicReveal
|
9
|
+
# Creates the world!
|
9
10
|
class Creator
|
10
11
|
attr_reader :directory
|
11
12
|
attr_writer :reveal_js_fetcher, :template_slides, :template_config_ru
|
@@ -32,7 +33,7 @@ module MagicReveal
|
|
32
33
|
reveal_js_fetcher.save_important_parts_to(top_dir)
|
33
34
|
end
|
34
35
|
|
35
|
-
def create_project(project)
|
36
|
+
def create_project(project) # rubocop:disable MethodLength
|
36
37
|
top_dir = directory + project
|
37
38
|
gemfile = top_dir + 'Gemfile'
|
38
39
|
|
@@ -7,20 +7,20 @@ module MagicReveal
|
|
7
7
|
class IndexLibber
|
8
8
|
attr_reader :html
|
9
9
|
|
10
|
-
def initialize
|
10
|
+
def initialize(html_text = nil)
|
11
11
|
if html_text.nil?
|
12
12
|
template_path = Pathname.new(__FILE__).dirname + 'template.html'
|
13
13
|
html_text = template_path.read
|
14
14
|
end
|
15
15
|
@html = Nokogiri::HTML(html_text, &:noblanks)
|
16
16
|
# Add autogenerated comment
|
17
|
-
#html.children.first.add_previous_sibling(Nokogiri::XML::Comment.new("Generated at #{Time.now}"))
|
17
|
+
# html.children.first.add_previous_sibling(Nokogiri::XML::Comment.new("Generated at #{Time.now}"))
|
18
18
|
html.root.children.first.before Nokogiri::XML::Comment.new(html, "Generated at #{Time.now}")
|
19
19
|
end
|
20
20
|
|
21
|
-
def set_meta
|
21
|
+
def set_meta(name, content)
|
22
22
|
meta = html.at_css("meta[@name='#{name}']")
|
23
|
-
|
23
|
+
unless meta
|
24
24
|
meta = Nokogiri::XML::Node.new('meta', html)
|
25
25
|
meta[:name] = name
|
26
26
|
|
@@ -30,22 +30,22 @@ module MagicReveal
|
|
30
30
|
meta[:content] = content
|
31
31
|
end
|
32
32
|
|
33
|
-
def title=
|
33
|
+
def title=(title)
|
34
34
|
html.title = title
|
35
35
|
end
|
36
36
|
|
37
|
-
def author=
|
37
|
+
def author=(author)
|
38
38
|
set_meta 'author', author
|
39
39
|
end
|
40
40
|
|
41
|
-
def description=
|
41
|
+
def description=(description)
|
42
42
|
set_meta 'description', description
|
43
43
|
end
|
44
44
|
|
45
|
-
def theme=
|
45
|
+
def theme=(theme)
|
46
46
|
# <link rel="stylesheet" href="css/theme/default.css" id="theme">
|
47
|
-
node = html.at_css(
|
48
|
-
|
47
|
+
node = html.at_css('link#theme')
|
48
|
+
unless node
|
49
49
|
node = Nokogiri::XML::Node.new('link', html)
|
50
50
|
node[:id] = 'theme'
|
51
51
|
node[:rel] = 'stylesheet'
|
@@ -56,7 +56,7 @@ module MagicReveal
|
|
56
56
|
node[:href] = "css/theme/#{theme}.css"
|
57
57
|
end
|
58
58
|
|
59
|
-
def slides=
|
59
|
+
def slides=(text)
|
60
60
|
slides = Nokogiri::HTML.fragment(text).children
|
61
61
|
container = html.at_css('div.reveal div.slides')
|
62
62
|
container.children = slides
|
@@ -64,21 +64,30 @@ module MagicReveal
|
|
64
64
|
self.title = headers.first.text unless headers.nil? || headers.empty?
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
67
|
+
def github_banner_img
|
68
|
+
Nokogiri::XML::Node.new('img', html).tap do |img|
|
69
|
+
img[:style] = 'position: absolute; top: 0; right: 0; border: 0;'
|
70
|
+
img[:src] = 'https://a248.e.akamai.net/camo.github.com/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67'
|
71
|
+
img[:alt] = 'Fork me on GitHub'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def github_fork_link(project)
|
76
|
+
Nokogiri::XML::Node.new('a', html).tap do |a|
|
77
|
+
a[:class] = 'fork-me'
|
78
|
+
a[:style] = 'display: none;'
|
79
|
+
a[:href] = "https://github.com/#{project}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_github_forkme(project)
|
84
|
+
a = github_fork_link project
|
76
85
|
script = Nokogiri::XML::Node.new('script', html)
|
77
86
|
script.content = "if( !navigator.userAgent.match( /iphone|ipod|android|ipad|blackberry/gi ) && !!document.querySelector ) { document.querySelector('.fork-me' ).style.display = 'block'; }"
|
78
87
|
|
79
88
|
parent = (body = html.at('body')) ? body : html.root
|
80
89
|
parent << a
|
81
|
-
a <<
|
90
|
+
a << github_banner_img
|
82
91
|
parent << script
|
83
92
|
end
|
84
93
|
|
@@ -2,13 +2,20 @@ require 'pathname'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module MagicReveal
|
5
|
+
# A Project's configuration
|
5
6
|
class ProjectConfig
|
6
7
|
DEFAULT_TEMPLATE = File.expand_path('../template-config.json', __FILE__)
|
8
|
+
DEPENDENCY_ENABLER_JS = {
|
9
|
+
'highlight' => '{ src: "plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } }',
|
10
|
+
'zoom' => '{ src: "plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } }',
|
11
|
+
'notes' => '{ src: "plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }'
|
12
|
+
}
|
13
|
+
|
7
14
|
attr_reader :json
|
8
15
|
|
9
|
-
def initialize
|
16
|
+
def initialize(io_or_path)
|
10
17
|
io = io_or_path.respond_to?(:read) ? io_or_path : Pathname.new(io_or_path)
|
11
|
-
@json = JSON
|
18
|
+
@json = JSON.load(io.read)
|
12
19
|
end
|
13
20
|
|
14
21
|
def dependencies
|
@@ -16,22 +23,16 @@ module MagicReveal
|
|
16
23
|
# you always want this
|
17
24
|
out << '{ src: "lib/js/classList.js", condition: function() { return !document.body.classList; } }'
|
18
25
|
|
19
|
-
|
20
|
-
out <<
|
21
|
-
end
|
22
|
-
if json['plugins'].include? 'zoom'
|
23
|
-
out << '{ src: "plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } }'
|
24
|
-
end
|
25
|
-
if json['plugins'].include? 'notes'
|
26
|
-
out << '{ src: "plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }'
|
26
|
+
DEPENDENCY_ENABLER_JS.keys.each do |plugin|
|
27
|
+
out << DEPENDENCY_ENABLER_JS[plugin] if json['plugins'].include?(plugin)
|
27
28
|
end
|
28
29
|
|
29
30
|
"\"dependencies\": [\n#{out.join(",\n")}\n]"
|
30
31
|
end
|
31
32
|
|
32
|
-
def to_js
|
33
|
+
def to_js # rubocop:disable MethodLength
|
33
34
|
var = []
|
34
|
-
keys = json.keys.reject { |k|
|
35
|
+
keys = json.keys.reject { |k| %w{ 'dependencies', 'github' }.include?(k) }
|
35
36
|
keys.each do |key|
|
36
37
|
value = json[key]
|
37
38
|
var << " #{key}: #{value.to_json}"
|
@@ -39,10 +40,10 @@ module MagicReveal
|
|
39
40
|
|
40
41
|
out = []
|
41
42
|
out << "/* Generated at #{Time.now} */"
|
42
|
-
out <<
|
43
|
+
out << 'var config = {'
|
43
44
|
out << "#{var.join(",\n")},\n#{dependencies}"
|
44
45
|
out << "\n};"
|
45
|
-
out <<
|
46
|
+
out << 'Reveal.initialize(config);'
|
46
47
|
out.join("\n")
|
47
48
|
end
|
48
49
|
end
|
@@ -3,11 +3,12 @@ require 'magic_reveal/version'
|
|
3
3
|
require 'magic_reveal/conductor'
|
4
4
|
|
5
5
|
module MagicReveal
|
6
|
+
# Fetches Reveal.js
|
6
7
|
class RevealJsFetcher
|
7
8
|
attr_reader :version
|
8
9
|
attr_writer :conductor
|
9
10
|
|
10
|
-
def initialize(version=REVEAL_JS_VERSION)
|
11
|
+
def initialize(version = REVEAL_JS_VERSION)
|
11
12
|
@version = version
|
12
13
|
end
|
13
14
|
|
@@ -36,7 +37,7 @@ module MagicReveal
|
|
36
37
|
Dir.mktmpdir do |tmpdir|
|
37
38
|
tmp_reveal_dir = Pathname(tmpdir) + 'reveal.js'
|
38
39
|
save_to(tmp_reveal_dir.to_s)
|
39
|
-
tmp_reveal_dir.children.select(&:directory?).reject{|c| %w[test].include? c.basename.to_s}.each do |dir|
|
40
|
+
tmp_reveal_dir.children.select(&:directory?).reject { |c| %w[test].include? c.basename.to_s }.each do |dir|
|
40
41
|
FileUtils.cp_r(dir.to_s, reveal_dir.to_s)
|
41
42
|
end
|
42
43
|
end
|