slideshow 0.2 → 0.3

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.
data/lib/slideshow.rb CHANGED
@@ -1,234 +1,170 @@
1
1
  require 'optparse'
2
+ require 'erb'
2
3
  require 'RedCloth'
4
+ require 'BlueCloth'
5
+ require 'logger'
3
6
 
4
- module Slideshow
5
-
6
- def Slideshow.create_slideshow( fn )
7
7
 
8
+ module Slideshow
8
9
 
9
- gradient = <<EOS
10
- <svg xmlns="http://www.w3.org/2000/svg">
10
+ class Params
11
11
 
12
- <defs>
13
- <linearGradient id="dark" x1="0" y1="0" x2="1" y2="1">
14
- <stop offset="0" style="stop-color: red"/>
15
- <stop offset="1" style="stop-color: black"/>
16
- </linearGradient>
17
-
18
- <linearGradient id="dark_reverse" x1="0" y1="0" x2="1" y2="1">
19
- <stop offset="0" style="stop-color: black"/>
20
- <stop offset="1" style="stop-color: red"/>
21
- </linearGradient>
22
-
23
- <linearGradient id="light" x1="0" y1="0" x2="1" y2="1">
24
- <stop offset="0" style="stop-color: red"/>
25
- <stop offset="1" style="stop-color: orange"/>
26
- </linearGradient>
27
-
28
- <linearGradient id="top_bottom" x1="0" y1="0" x2="0" y2="1">
29
- <stop offset="0%" style="stop-color: red" />
30
- <stop offset="100%" style="stop-color: black" />
31
- </linearGradient>
32
-
33
- <linearGradient id="left_right" x1="0" y1="0" x2="1" y2="0">
34
- <stop offset="0%" style="stop-color: red" />
35
- <stop offset="100%" style="stop-color: orange" />
36
- </linearGradient>
37
-
38
- <linearGradient id="repeat" x1="0.4" y1="0.4" x2="0.5" y2="0.5"
39
- spreadMethod="repeat">
40
- <stop offset="0%" style="stop-color: red" />
41
- <stop offset="50%" style="stop-color: orange" />
42
- <stop offset="100%" style="stop-color: red" />
43
- </linearGradient>
44
-
45
- <radialGradient id="radial">
46
- <stop offset="0%" style="stop-color: black" />
47
- <stop offset="100%" style="stop-color: red" />
48
- </radialGradient>
49
-
50
-
51
- <radialGradient id="radial_off_center" fx="0.7" fy="0.7" cx="0.5" cy="0.5" r="0.4">
52
- <stop offset="0%" style="stop-color: orange" />
53
- <stop offset="100%" style="stop-color: red" />
54
- </radialGradient>
55
-
56
- <radialGradient id="radial_repeat" fx="0.5" fy="0.5" cx="0.6" cy="0.6" r="0.2"
57
- spreadMethod="repeat">
58
- <stop offset="0%" style="stop-color: red" />
59
- <stop offset="50%" style="stop-color: orange" />
60
- <stop offset="100%" style="stop-color: red" />
61
- </radialGradient>
12
+ def initialize( title, name )
13
+ @title = title
14
+ @svgname = "#{name}.svg"
15
+ @cssname = "#{name}.css"
16
+ end
62
17
 
63
- </defs>
64
-
65
- <rect width="100%" height="100%"
66
- style="fill: url(#dark) "/>
67
-
68
- </svg>
69
- EOS
70
-
71
- header = <<EOS
72
- <html>
73
- <head>
18
+ def params_binding
19
+ binding
20
+ end
74
21
 
75
- <meta name="slideselector" content=".slide">
76
- <meta name="titleselector" content="h1">
77
- <meta name="stepselector" content=".step">
22
+ end
78
23
 
79
- <title>Slideshow</title>
24
+ def Slideshow.load_template( name )
80
25
 
81
- <style type="text/css">
82
-
83
- @media screen {
84
- .layout { display: none; }
85
-
86
- .banner {
87
- display: block;
88
- border: green solid thick;
89
- padding: 1em;
90
- font-family: sans-serif;
91
- font-weight: bold;
92
- margin-bottom: 2em;
93
- }
94
- }
95
-
96
- @media projection {
97
-
98
- body
99
- {
100
- height: 100%; margin: 0px; padding: 0px;
101
- font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
102
- color: white;
103
- opacity: .99;
104
- }
105
-
106
- .slide
107
- {
108
- page-break-after: always;
109
- padding-left: 2em;
110
- padding-top: 2em;
111
- }
112
-
113
- .banner
114
- {
115
- display: none;
116
- }
117
-
118
- .layout
119
- {
120
- display: block;
121
- }
122
-
123
- div.background {
124
- position: fixed;
125
- left: 0px;
126
- right: 0px;
127
- top: 0px;
128
- bottom: 0px;
129
- z-index: -1;
130
- }
131
-
132
- a:link, a:visited {
133
- color: white;
134
- }
135
- a:hover { background-color: yellow; }
136
-
137
- h1, h2 { font-size: 36pt; }
138
- h3 { font-size: 25pt; }
139
- p, li, td, th { font-size: 18pt; }
140
-
141
- pre { font-size: 16pt; }
142
-
143
- pre.code { font-size: 16pt;
144
- background-color: black;
145
- color: white;
146
- padding: 5px;
147
- border: silver thick groove;
148
- -moz-border-radius: 11px;
149
- }
150
- }
151
-
152
- </style>
26
+ templatesdir = "#{File.dirname(__FILE__)}/templates"
27
+ logger.debug "templatesdir=#{templatesdir}"
153
28
 
29
+ File.read( "#{templatesdir}/#{name}" )
30
+ end
154
31
 
155
- </head>
156
- <body>
32
+ def Slideshow.render_template( content, b=TOPLEVEL_BINDING )
33
+ ERB.new( content ).result( b )
34
+ end
157
35
 
158
- <div class="layout">
159
- <div class="background">
160
- <object data="$svgname" width="100%" height="100%">
161
- </div>
162
- </div>
163
36
 
164
- <div class="banner">
165
- Turn this document into a (PowerPoint/KeyNote-style) slide show pressing F11.
166
- (Free <a href="https://addons.mozilla.org/en-US/firefox/addon/4650">FullerScreen</a> Firefox addon required).
167
- Learn more at the <a href="http://slideshow.rubyforge.org">Slide Show (S9)</a>
168
- RubyForge project site.
169
- </div>
170
- EOS
37
+ def Slideshow.create_slideshow( fn )
171
38
 
172
- footer = <<EOS
173
- </body>
174
- </html>
175
- EOS
39
+ headerdoc = load_template( 'header.html.erb' )
40
+ footerdoc = load_template( 'footer.html.erb' )
41
+ styledoc = load_template( 'style.css.erb' )
42
+ gradientdoc = load_template( 'gradient.svg.erb' )
176
43
 
177
44
  basename = File.basename( fn, '.*' )
178
45
  extname = File.extname( fn )
179
46
 
180
- extname = ".textile" if extname.eql?("")
47
+ params = Params.new( "Slideshow", basename )
48
+
49
+ known_textile_extnames = [ '.textile', '.t' ]
50
+ known_markdown_extnames = [ '.markdown', '.mark', '.m', '.txt', '.text' ]
51
+ known_extnames = known_textile_extnames + known_markdown_extnames
52
+
53
+ if extname.eql?("") then
54
+ extname = ".textile" # default to .textile
55
+
56
+ known_extnames.each { |e|
57
+ logger.debug "File.exists? #{basename}#{e}"
58
+ if File.exists?( "#{basename}#{e}" ) then
59
+ extname = e
60
+ logger.debug "extname=#{extname}"
61
+ break
62
+ end
63
+ }
64
+ end
181
65
 
182
66
  inname = "#{basename}#{extname}"
183
67
  outname = "#{basename}.html"
184
68
  svgname = "#{basename}.svg"
69
+ cssname = "#{basename}.css"
70
+
71
+ logger.debug "inname=#{inname}"
72
+
73
+ puts "Preparing slideshow stylesheet '#{cssname}'..."
74
+
75
+ out = File.new( cssname, "w+" )
76
+ out << render_template( styledoc, params.params_binding )
77
+ out.flush
78
+ out.close
185
79
 
186
80
  puts "Preparing slideshow theme '#{svgname}'..."
187
81
 
188
- out = File.new( svgname, "w+")
189
- out << gradient
82
+ out = File.new( svgname, "w+" )
83
+ out << render_template( gradientdoc, params.params_binding )
190
84
  out.flush
191
85
  out.close
192
86
 
193
87
  puts "Preparing slideshow '#{outname}'..."
194
88
 
195
- content = ''
196
- slide_counter = 0
89
+ # convert light-weight markup to hypertext
90
+
91
+ content = File.read( inname )
92
+
93
+ if known_markdown_extnames.include?( extname )
94
+ content = BlueCloth.new( content ).to_html
95
+ else
96
+ content = RedCloth.new( content ).to_html
97
+ end
98
+
99
+
100
+ # post-processing
197
101
 
198
- infile = File.new( inname )
199
- infile.each { |line|
200
- if line.include?( 'h1.' ) then
201
- content << "\n\n</div>" if slide_counter > 0
202
- content << "<div class='slide'>\n\n"
102
+ slide_counter = 0
103
+ content2 = ''
104
+
105
+ # wrap h1's in slide divs
106
+ content.each_line { |line|
107
+ if line.include?( '<h1>' ) then
108
+ content2 << "\n\n</div>" if slide_counter > 0
109
+ content2 << "<div class='slide'>\n\n"
203
110
  slide_counter += 1
204
111
  end
205
- content << line
112
+ content2 << line
206
113
  }
114
+ content2 << "\n\n</div>" if slide_counter > 0
207
115
 
208
- content << "\n\n</div>" if slide_counter > 0
209
-
210
- out = File.new( outname, "w+")
211
- out << header.gsub( '$svgname', svgname )
212
- out << RedCloth.new( content ).to_html
213
- out << footer
116
+ out = File.new( outname, "w+" )
117
+ out << render_template( headerdoc, params.params_binding )
118
+ out << content2
119
+ out << render_template( footerdoc, params.params_binding )
214
120
  out.flush
215
121
  out.close
216
122
 
217
123
  puts "Done."
218
124
  end
219
125
 
126
+ def Slideshow.logger
127
+ if @@logger.nil?
128
+ @@logger = Logger.new(STDOUT)
129
+ end
130
+ @@logger
131
+ end
220
132
 
221
133
  def Slideshow.main
222
134
 
135
+ @@logger = nil
223
136
  $options = {}
224
137
 
138
+ logger.level = Logger::INFO
139
+
225
140
  opt=OptionParser.new do |opts|
226
141
  opts.banner = "Usage: slideshow [options] name"
227
142
  # opts.on( "-s", "--style STYLE", "Select Stylesheet" ) { |s| $options[:style]=s }
228
- opts.on_tail( "-h", "--help", "Show this message" ) { puts opts.help; exit }
143
+ # opts.on( "-v", "--version", "Show version" ) {}
144
+ opts.on( "-t", "--trace", "Show debug trace" ) {
145
+ logger.datetime_format = "%H:%H:%S"
146
+ logger.level = Logger::DEBUG
147
+ }
148
+ opts.on_tail( "-h", "--help", "Show this message" ) {
149
+ puts
150
+ puts "Slide Show (S9) is a free web alternative to PowerPoint or KeyNote in Ruby"
151
+ puts
152
+ puts opts.help
153
+ puts
154
+ puts "Examples:"
155
+ puts " slideshow microformats"
156
+ puts " slideshow microformats.textile"
157
+ puts
158
+ puts "Further information:"
159
+ puts " http://slideshow.rubyforge.org"
160
+ exit
161
+ }
229
162
  end
230
163
 
231
164
  opt.parse!
165
+
166
+ puts "Slide Show (S9) Version: 0.3 on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
167
+
232
168
  ARGV.each { |fn| Slideshow.create_slideshow( fn ) }
233
169
  end
234
170
 
@@ -0,0 +1,3 @@
1
+
2
+ </body>
3
+ </html>
@@ -0,0 +1,59 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg">
2
+
3
+ <defs>
4
+ <linearGradient id="dark" x1="0" y1="0" x2="1" y2="1">
5
+ <stop offset="0" style="stop-color: red"/>
6
+ <stop offset="1" style="stop-color: black"/>
7
+ </linearGradient>
8
+
9
+ <linearGradient id="dark_reverse" x1="0" y1="0" x2="1" y2="1">
10
+ <stop offset="0" style="stop-color: black"/>
11
+ <stop offset="1" style="stop-color: red"/>
12
+ </linearGradient>
13
+
14
+ <linearGradient id="light" x1="0" y1="0" x2="1" y2="1">
15
+ <stop offset="0" style="stop-color: red"/>
16
+ <stop offset="1" style="stop-color: orange"/>
17
+ </linearGradient>
18
+
19
+ <linearGradient id="top_bottom" x1="0" y1="0" x2="0" y2="1">
20
+ <stop offset="0%" style="stop-color: red" />
21
+ <stop offset="100%" style="stop-color: black" />
22
+ </linearGradient>
23
+
24
+ <linearGradient id="left_right" x1="0" y1="0" x2="1" y2="0">
25
+ <stop offset="0%" style="stop-color: red" />
26
+ <stop offset="100%" style="stop-color: orange" />
27
+ </linearGradient>
28
+
29
+ <linearGradient id="repeat" x1="0.4" y1="0.4" x2="0.5" y2="0.5"
30
+ spreadMethod="repeat">
31
+ <stop offset="0%" style="stop-color: red" />
32
+ <stop offset="50%" style="stop-color: orange" />
33
+ <stop offset="100%" style="stop-color: red" />
34
+ </linearGradient>
35
+
36
+ <radialGradient id="radial">
37
+ <stop offset="0%" style="stop-color: black" />
38
+ <stop offset="100%" style="stop-color: red" />
39
+ </radialGradient>
40
+
41
+
42
+ <radialGradient id="radial_off_center" fx="0.7" fy="0.7" cx="0.5" cy="0.5" r="0.4">
43
+ <stop offset="0%" style="stop-color: orange" />
44
+ <stop offset="100%" style="stop-color: red" />
45
+ </radialGradient>
46
+
47
+ <radialGradient id="radial_repeat" fx="0.5" fy="0.5" cx="0.6" cy="0.6" r="0.2"
48
+ spreadMethod="repeat">
49
+ <stop offset="0%" style="stop-color: red" />
50
+ <stop offset="50%" style="stop-color: orange" />
51
+ <stop offset="100%" style="stop-color: red" />
52
+ </radialGradient>
53
+
54
+ </defs>
55
+
56
+ <rect width="100%" height="100%"
57
+ style="fill: url(#dark) "/>
58
+
59
+ </svg>
@@ -0,0 +1,27 @@
1
+ <html>
2
+ <head>
3
+
4
+ <meta name="slideselector" content=".slide">
5
+ <meta name="titleselector" content="h1">
6
+ <meta name="stepselector" content=".step">
7
+
8
+ <title><%= @title %></title>
9
+
10
+ <link title="Style" href="<%= @cssname %>" type="text/css" rel="STYLESHEET">
11
+
12
+ </head>
13
+ <body>
14
+
15
+ <div class="layout">
16
+ <div class="background">
17
+ <object data="<%= @svgname %>" width="100%" height="100%">
18
+ </div>
19
+ </div>
20
+
21
+ <div class="banner">
22
+ Turn this document into a (PowerPoint/KeyNote-style) slide show pressing F11.
23
+ (Free <a href="https://addons.mozilla.org/en-US/firefox/addon/4650">FullerScreen</a> Firefox addon required).
24
+ Learn more at the <a href="http://slideshow.rubyforge.org">Slide Show (S9)</a>
25
+ RubyForge project site.
26
+ </div>
27
+
@@ -0,0 +1,79 @@
1
+ @media screen {
2
+ .layout { display: none; }
3
+
4
+ .banner {
5
+ display: block;
6
+ border: green solid thick;
7
+ padding: 1em;
8
+ font-family: sans-serif;
9
+ font-weight: bold;
10
+ margin-bottom: 2em;
11
+ }
12
+
13
+ a:link, a:visited { color: black; }
14
+ a:hover { background-color: yellow; }
15
+
16
+ body { color: black; }
17
+
18
+ pre.code {
19
+ background-color: black;
20
+ color: white;
21
+ padding: 5px;
22
+ }
23
+ }
24
+
25
+ @media projection {
26
+
27
+ body
28
+ {
29
+ height: 100%; margin: 0px; padding: 0px;
30
+ font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
31
+ color: white;
32
+ opacity: .99;
33
+ }
34
+
35
+ .slide
36
+ {
37
+ page-break-after: always;
38
+ padding-left: 2em;
39
+ padding-top: 2em;
40
+ }
41
+
42
+ .banner
43
+ {
44
+ display: none;
45
+ }
46
+
47
+ .layout
48
+ {
49
+ display: block;
50
+ }
51
+
52
+ div.background {
53
+ position: fixed;
54
+ left: 0px;
55
+ right: 0px;
56
+ top: 0px;
57
+ bottom: 0px;
58
+ z-index: -1;
59
+ }
60
+
61
+ a:link, a:visited {
62
+ color: white;
63
+ }
64
+ a:hover { background-color: yellow; }
65
+
66
+ h1, h2 { font-size: 36pt; }
67
+ h3 { font-size: 25pt; }
68
+ p, li, td, th { font-size: 18pt; }
69
+
70
+ pre { font-size: 16pt; }
71
+
72
+ pre.code { font-size: 16pt;
73
+ background-color: black;
74
+ color: white;
75
+ padding: 5px;
76
+ border: silver thick groove;
77
+ -moz-border-radius: 11px;
78
+ }
79
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.2"
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-26 00:00:00 -08:00
12
+ date: 2008-03-08 00:00:00 -08:00
13
13
  default_executable: slideshow
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -21,6 +21,15 @@ dependencies:
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.0
23
23
  version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: BlueCloth
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.0.0
32
+ version:
24
33
  description:
25
34
  email: geraldbauer2007@gmail.com
26
35
  executables: []
@@ -31,6 +40,11 @@ extra_rdoc_files: []
31
40
 
32
41
  files:
33
42
  - lib/slideshow.rb
43
+ - lib/templates
44
+ - lib/templates/footer.html.erb
45
+ - lib/templates/gradient.svg.erb
46
+ - lib/templates/header.html.erb
47
+ - lib/templates/style.css.erb
34
48
  - bin/slideshow
35
49
  has_rdoc: false
36
50
  homepage: http://slideshow.rubyforge.org