slideit 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +17 -3
- data/TODO.md +6 -0
- data/bin/slideit +8 -2
- data/lib/slideit/container.rb +80 -0
- data/lib/slideit/template.rb +143 -0
- data/lib/slideit/version.rb +1 -1
- data/lib/slideit.rb +3 -103
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9638c4137828789cd4117480e1991dfc367ce5
|
4
|
+
data.tar.gz: f37b4112914ac78761ea802eef66c1f90d2670fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4154c805d760cebaa4c5fcea56b55c376d315808f7ed4ff4dc1b1715fa9e652be88243430338ad0541aff9ae1f13dd449364b5e14800cd68b0d5ae86df33c1da
|
7
|
+
data.tar.gz: cea980b6f84a08cd5e70cb5c00922245f676a52c40529e9574e1696d62c68e29bd4d98aa48f42b0e46d2b8c6fc50c3817da371ff51ebce7385532bdec435c967
|
data/README.md
CHANGED
@@ -13,11 +13,25 @@ test.md's content is following
|
|
13
13
|
```
|
14
14
|
## Demo 1
|
15
15
|
Slide 1
|
16
|
+
|
16
17
|
---
|
17
|
-
|
18
|
-
|
18
|
+
|
19
|
+
## Demo 2.1
|
20
|
+
Slide 2.1
|
21
|
+
|
22
|
+
----
|
23
|
+
|
24
|
+
## Demo 2.2
|
25
|
+
Slide 2.2
|
26
|
+
|
27
|
+
----
|
28
|
+
|
29
|
+
## Demo 2.3
|
30
|
+
Slide 2.3
|
31
|
+
|
19
32
|
---
|
20
|
-
|
33
|
+
|
34
|
+
## Demo 3
|
21
35
|
Slide 3
|
22
36
|
```
|
23
37
|
|
data/TODO.md
ADDED
data/bin/slideit
CHANGED
@@ -27,8 +27,14 @@ end.parse!
|
|
27
27
|
#puts "ARGV is #{ARGV.inspect}"
|
28
28
|
|
29
29
|
if ARGV.size == 0
|
30
|
-
puts "Please input slide
|
30
|
+
puts "Please input slide file!"
|
31
31
|
exit(1)
|
32
32
|
else
|
33
|
-
|
33
|
+
file = ARGV[0]
|
34
|
+
if FileTest.file? file
|
35
|
+
Slideit.show file, options
|
36
|
+
else
|
37
|
+
puts "#{file} does not exist!"
|
38
|
+
exit(1)
|
39
|
+
end
|
34
40
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "slideit/template"
|
2
|
+
|
3
|
+
module Slideit
|
4
|
+
class Container
|
5
|
+
def initialize(file, options = {})
|
6
|
+
@file = file
|
7
|
+
@options = options
|
8
|
+
prepare
|
9
|
+
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
if @server
|
13
|
+
file_name = File.basename(@file)
|
14
|
+
url = "http://localhost:#{@port}/#{file_name}"
|
15
|
+
if @options[:pdf]
|
16
|
+
url << "?print-pdf"
|
17
|
+
end
|
18
|
+
Thread.new {
|
19
|
+
puts "Just waiting for 1 second...\n"
|
20
|
+
sleep 1
|
21
|
+
system "open #{url}"
|
22
|
+
}
|
23
|
+
|
24
|
+
@server.start
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def prepare
|
31
|
+
root = File.expand_path "../../../res/reveal.js-3.3.0", __FILE__
|
32
|
+
@port = @options[:port] ? @options[:port].to_i : 8000
|
33
|
+
|
34
|
+
@server = WEBrick::HTTPServer.new Port: @port, DocumentRoot: root
|
35
|
+
|
36
|
+
trap 'INT' do @server.shutdown end
|
37
|
+
|
38
|
+
mount_slide
|
39
|
+
mount_assets
|
40
|
+
end
|
41
|
+
|
42
|
+
def mount_slide
|
43
|
+
file_name = File.basename(@file)
|
44
|
+
@server.mount_proc "/#{file_name}" do |req, res|
|
45
|
+
res.status = 200
|
46
|
+
res['Content-Type'] = 'text/html'
|
47
|
+
res.body = slide_content(file_name)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def slide_content(file_name)
|
52
|
+
markdown = File.read(@file)
|
53
|
+
template = Template.new file_name, markdown, @options
|
54
|
+
template.render
|
55
|
+
end
|
56
|
+
|
57
|
+
def mount_assets
|
58
|
+
#puts "assets is #{asset_files.inspect}"
|
59
|
+
asset_files.each do |key, file|
|
60
|
+
@server.mount(key,
|
61
|
+
WEBrick::HTTPServlet::DefaultFileHandler,
|
62
|
+
file)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
EXECLUDES = %W(.md .rb)
|
67
|
+
def asset_files
|
68
|
+
md_dir = File.expand_path "..", @file
|
69
|
+
files = Dir["#{md_dir}/**/*"]
|
70
|
+
pairs = {}
|
71
|
+
files.each do |file|
|
72
|
+
if File.file?(file) && !EXECLUDES.include?(File.extname(file))
|
73
|
+
key = file.sub md_dir, ""
|
74
|
+
pairs[key] = file
|
75
|
+
end
|
76
|
+
end
|
77
|
+
pairs
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module Slideit
|
4
|
+
class Template
|
5
|
+
Themes = %w(beige black blood league moon night serif simple sky solarized white)
|
6
|
+
Default = {
|
7
|
+
:separator => "^\n---\n",
|
8
|
+
:"separator-vertical" => "^\n----\n",
|
9
|
+
:"separator-notes" => "^Note:",
|
10
|
+
:theme => "league"
|
11
|
+
}
|
12
|
+
BASE = <<-REVEAL_JS_TEMPLATE
|
13
|
+
<!doctype html>
|
14
|
+
<html>
|
15
|
+
<head>
|
16
|
+
<meta charset="utf-8">
|
17
|
+
|
18
|
+
<title>{__slide_title__}</title>
|
19
|
+
|
20
|
+
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
|
21
|
+
<meta name="author" content="Hakim El Hattab">
|
22
|
+
|
23
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
24
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
25
|
+
|
26
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
27
|
+
|
28
|
+
<link rel="stylesheet" href="/css/reveal.css">
|
29
|
+
<link rel="stylesheet" href="/css/theme/{__theme__}.css" id="theme">
|
30
|
+
|
31
|
+
<!-- Theme used for syntax highlighting of code -->
|
32
|
+
<link rel="stylesheet" href="/lib/css/zenburn.css">
|
33
|
+
|
34
|
+
<!-- Printing and PDF exports -->
|
35
|
+
<script>
|
36
|
+
var link = document.createElement( 'link' );
|
37
|
+
link.rel = 'stylesheet';
|
38
|
+
link.type = 'text/css';
|
39
|
+
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
40
|
+
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
41
|
+
</script>
|
42
|
+
|
43
|
+
<!--[if lt IE 9]>
|
44
|
+
<script src="lib/js/html5shiv.js"></script>
|
45
|
+
<![endif]-->
|
46
|
+
</head>
|
47
|
+
|
48
|
+
<body>
|
49
|
+
|
50
|
+
<div class="reveal">
|
51
|
+
|
52
|
+
<div class="slides">
|
53
|
+
|
54
|
+
<section data-markdown
|
55
|
+
data-separator="{__separator__}"
|
56
|
+
data-separator-vertical="{__separator-vertical__}"
|
57
|
+
data-separator-notes="{__separator-notes__}"
|
58
|
+
data-charset="utf-8">
|
59
|
+
<script type="text/template">
|
60
|
+
{__slide_markdown__}
|
61
|
+
</script>
|
62
|
+
</section>
|
63
|
+
|
64
|
+
</div>
|
65
|
+
|
66
|
+
</div>
|
67
|
+
|
68
|
+
<script src="/lib/js/head.min.js"></script>
|
69
|
+
<script src="/js/reveal.js"></script>
|
70
|
+
|
71
|
+
<script>
|
72
|
+
|
73
|
+
// More info https://github.com/hakimel/reveal.js#configuration
|
74
|
+
Reveal.initialize({
|
75
|
+
controls: true,
|
76
|
+
progress: true,
|
77
|
+
history: true,
|
78
|
+
center: true,
|
79
|
+
|
80
|
+
transition: 'slide', // none/fade/slide/convex/concave/zoom
|
81
|
+
|
82
|
+
// More info https://github.com/hakimel/reveal.js#dependencies
|
83
|
+
dependencies: [
|
84
|
+
{ src: '/lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
85
|
+
{ src: '/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
86
|
+
{ src: '/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
87
|
+
{ src: '/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
|
88
|
+
{ src: '/plugin/zoom-js/zoom.js', async: true },
|
89
|
+
{ src: '/plugin/notes/notes.js', async: true }
|
90
|
+
]
|
91
|
+
});
|
92
|
+
|
93
|
+
{__print-pdf-scrit__}
|
94
|
+
|
95
|
+
</script>
|
96
|
+
|
97
|
+
</body>
|
98
|
+
</html>
|
99
|
+
REVEAL_JS_TEMPLATE
|
100
|
+
|
101
|
+
def initialize(title, markdown, options = {})
|
102
|
+
@title = title
|
103
|
+
@markdown = markdown
|
104
|
+
@options = Default.dup
|
105
|
+
@options.update options
|
106
|
+
|
107
|
+
# make sure theme exists
|
108
|
+
unless Themes.include?(@options[:theme])
|
109
|
+
@options[:theme] = Default[:theme]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
TITLE_PATTERN = "{__slide_title__}"
|
114
|
+
MARKDOWN_PATTERN = "{__slide_markdown__}"
|
115
|
+
THEME_PATTERN = "{__theme__}"
|
116
|
+
SEPARATOR_PATTERN = "{__separator__}"
|
117
|
+
SEPARATOR_VERTICAL_PATTERN = "{__separator-vertical__}"
|
118
|
+
SEPARATOR_NOTES_PATTERN = "{__separator-notes__}"
|
119
|
+
PRINT_PDF_PATTERN = "{__print-pdf-scrit__}"
|
120
|
+
|
121
|
+
def render
|
122
|
+
html = BASE.dup
|
123
|
+
html.sub! TITLE_PATTERN, "#{CGI::escapeHTML(@title)} - slideit"
|
124
|
+
html.sub! MARKDOWN_PATTERN, @markdown
|
125
|
+
html.sub! THEME_PATTERN, @options[:theme]
|
126
|
+
html.sub! SEPARATOR_PATTERN, @options[:separator]
|
127
|
+
html.sub! SEPARATOR_VERTICAL_PATTERN, @options[:"separator-vertical"]
|
128
|
+
html.sub! SEPARATOR_NOTES_PATTERN, @options[:"separator-notes"]
|
129
|
+
html.sub! PRINT_PDF_PATTERN, print_pdf_script
|
130
|
+
html
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def print_pdf_script
|
136
|
+
if @options[:pdf]
|
137
|
+
"window.onload = function() { window.print(); };"
|
138
|
+
else
|
139
|
+
""
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
data/lib/slideit/version.rb
CHANGED
data/lib/slideit.rb
CHANGED
@@ -1,110 +1,10 @@
|
|
1
1
|
require "slideit/version"
|
2
|
+
require "slideit/container"
|
3
|
+
|
2
4
|
require 'webrick'
|
3
5
|
|
4
6
|
module Slideit
|
5
7
|
def self.show(file, options)
|
6
|
-
|
7
|
-
#puts "root is #{root}"
|
8
|
-
|
9
|
-
port = options[:port] ? options[:port].to_i : 8000
|
10
|
-
server = WEBrick::HTTPServer.new Port: port, DocumentRoot: root
|
11
|
-
|
12
|
-
trap 'INT' do server.shutdown end
|
13
|
-
|
14
|
-
file_name = File.basename(file)
|
15
|
-
server.mount_proc "/#{file_name}" do |req, res|
|
16
|
-
res.status = 200
|
17
|
-
res['Content-Type'] = 'text/html'
|
18
|
-
res.body = slide_content(file)
|
19
|
-
end
|
20
|
-
|
21
|
-
server.start
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.slide_content(file)
|
25
|
-
markdown_body = File.read(file)
|
26
|
-
html_body = %Q[
|
27
|
-
<!doctype html>
|
28
|
-
<html lang="en">
|
29
|
-
|
30
|
-
<head>
|
31
|
-
<meta charset="utf-8">
|
32
|
-
|
33
|
-
<title>reveal.js – The HTML Presentation Framework</title>
|
34
|
-
|
35
|
-
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
|
36
|
-
<meta name="author" content="Hakim El Hattab">
|
37
|
-
|
38
|
-
<meta name="apple-mobile-web-app-capable" content="yes">
|
39
|
-
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
40
|
-
|
41
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
42
|
-
|
43
|
-
<link rel="stylesheet" href="css/reveal.css">
|
44
|
-
<link rel="stylesheet" href="css/theme/black.css" id="theme">
|
45
|
-
|
46
|
-
<!-- Theme used for syntax highlighting of code -->
|
47
|
-
<link rel="stylesheet" href="lib/css/zenburn.css">
|
48
|
-
|
49
|
-
<!-- Printing and PDF exports -->
|
50
|
-
<script>
|
51
|
-
var link = document.createElement( 'link' );
|
52
|
-
link.rel = 'stylesheet';
|
53
|
-
link.type = 'text/css';
|
54
|
-
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
|
55
|
-
document.getElementsByTagName( 'head' )[0].appendChild( link );
|
56
|
-
</script>
|
57
|
-
|
58
|
-
<!--[if lt IE 9]>
|
59
|
-
<script src="lib/js/html5shiv.js"></script>
|
60
|
-
<![endif]-->
|
61
|
-
</head>
|
62
|
-
|
63
|
-
<body>
|
64
|
-
|
65
|
-
<div class="reveal">
|
66
|
-
|
67
|
-
<div class="slides">
|
68
|
-
|
69
|
-
<section data-markdown data-separator="---">
|
70
|
-
<script type="text/template">
|
71
|
-
#{markdown_body}
|
72
|
-
</script>
|
73
|
-
</section>
|
74
|
-
|
75
|
-
</div>
|
76
|
-
|
77
|
-
</div>
|
78
|
-
|
79
|
-
<script src="lib/js/head.min.js"></script>
|
80
|
-
<script src="js/reveal.js"></script>
|
81
|
-
|
82
|
-
<script>
|
83
|
-
|
84
|
-
// More info https://github.com/hakimel/reveal.js#configuration
|
85
|
-
Reveal.initialize({
|
86
|
-
controls: true,
|
87
|
-
progress: true,
|
88
|
-
history: true,
|
89
|
-
center: true,
|
90
|
-
|
91
|
-
transition: 'slide', // none/fade/slide/convex/concave/zoom
|
92
|
-
|
93
|
-
// More info https://github.com/hakimel/reveal.js#dependencies
|
94
|
-
dependencies: [
|
95
|
-
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
|
96
|
-
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
97
|
-
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
|
98
|
-
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
|
99
|
-
{ src: 'plugin/zoom-js/zoom.js', async: true },
|
100
|
-
{ src: 'plugin/notes/notes.js', async: true }
|
101
|
-
]
|
102
|
-
});
|
103
|
-
|
104
|
-
</script>
|
105
|
-
|
106
|
-
</body>
|
107
|
-
</html>]
|
108
|
-
|
8
|
+
Container.new(file, options).start
|
109
9
|
end
|
110
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slideit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vincent
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,8 +66,11 @@ files:
|
|
66
66
|
- Gemfile
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
|
+
- TODO.md
|
69
70
|
- bin/slideit
|
70
71
|
- lib/slideit.rb
|
72
|
+
- lib/slideit/container.rb
|
73
|
+
- lib/slideit/template.rb
|
71
74
|
- lib/slideit/version.rb
|
72
75
|
- res/reveal.js-3.3.0/.gitignore
|
73
76
|
- res/reveal.js-3.3.0/.travis.yml
|