slideshow 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +93 -0
- data/Manifest.txt +58 -0
- data/README.txt +51 -0
- data/Rakefile +18 -0
- data/lib/slideshow.rb +23 -613
- data/lib/slideshow/gen.rb +483 -0
- data/lib/{helpers → slideshow/helpers}/capture_helper.rb +0 -0
- data/lib/{helpers → slideshow/helpers}/coderay_helper.rb +0 -0
- data/lib/{helpers → slideshow/helpers}/text_helper.rb +0 -0
- data/lib/{helpers → slideshow/helpers}/uv_helper.rb +0 -0
- data/lib/slideshow/opts.rb +136 -0
- data/templates/fullerscreen.txt +5 -0
- data/templates/fullerscreen.txt.gen +7 -0
- data/{lib/templates → templates}/fullerscreen.txt.sample +0 -0
- data/{lib/templates → templates/fullerscreen}/footer.html.erb +0 -0
- data/{lib/templates → templates/fullerscreen}/header.html.erb +0 -0
- data/{lib/templates → templates/fullerscreen}/style.css.erb +0 -0
- data/{lib/templates → templates}/gradient.svg.erb +0 -0
- data/{lib/templates → templates}/s5.txt +1 -1
- data/{lib/templates → templates}/s5.txt.gen +0 -0
- data/{lib/templates → templates}/s5.txt.sample +0 -0
- data/{lib/templates → templates}/s5/footer.html.erb +0 -0
- data/{lib/templates → templates}/s5/header.html.erb +0 -0
- data/{lib/templates → templates}/s5/opera.css +0 -0
- data/{lib/templates → templates}/s5/outline.css +0 -0
- data/{lib/templates → templates}/s5/print.css +0 -0
- data/{lib/templates → templates}/s5/s5-core.css +0 -0
- data/{lib/templates → templates}/s5/slides.js +0 -0
- data/{lib/templates → templates}/s5/style.css.erb +0 -0
- data/{lib/templates → templates}/s5blank.txt.gen +0 -0
- data/{lib/templates → templates}/s5blank.txt.sample +0 -0
- data/{lib/templates → templates}/s5blank/blank.textile +0 -0
- data/{lib/templates → templates}/s5blank/footer.html.erb +0 -0
- data/{lib/templates → templates}/s5blank/header.html.erb +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/blank.gif +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/bodybg.gif +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/framing.css +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/iepngfix.htc +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/opera.css +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/outline.css +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/pretty.css +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/print.css +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/s5-core.css +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/slides.css +0 -0
- data/{lib/templates → templates}/s5blank/ui/default/slides.js +0 -0
- data/{lib/templates → templates}/s6.txt +0 -0
- data/{lib/templates → templates}/s6.txt.gen +0 -0
- data/{lib/templates → templates}/s6.txt.sample +0 -0
- data/{lib/templates → templates}/s6/footer.html.erb +0 -0
- data/{lib/templates → templates}/s6/header.html.erb +0 -0
- data/{lib/templates → templates}/s6/jquery.js +0 -0
- data/{lib/templates → templates}/s6/outline.css +0 -0
- data/{lib/templates → templates}/s6/print.css +0 -0
- data/{lib/templates → templates}/s6/slides.core.js +0 -0
- data/{lib/templates → templates}/s6/slides.css +0 -0
- data/{lib/templates → templates}/s6/slides.js +0 -0
- data/{lib/templates → templates}/s6/style.css.erb +0 -0
- metadata +81 -66
- data/lib/templates/fullerscreen.txt +0 -5
- data/lib/templates/fullerscreen.txt.gen +0 -7
data/History.txt
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
=== 0.7.8 / 2009-03-09
|
2
|
+
|
3
|
+
* Adding SLIDESHOWOPT env variable; lets you set default command line options (e.g. -o slides)
|
4
|
+
* Using Hoe Rake tasks to manage gem; adding required files and build script
|
5
|
+
* Move templates folder to top-level (out of lib/)
|
6
|
+
* Minor code clean-up
|
7
|
+
|
8
|
+
=== 0.7.7 / 2009-03-02
|
9
|
+
|
10
|
+
* Added new helpers for syntax highlighting (using ultraviolet and coderay gems)
|
11
|
+
|
12
|
+
=== 0.7.6 / 2009-02-24
|
13
|
+
|
14
|
+
* Added plugin/helpers support
|
15
|
+
* Added include and content_for helpers
|
16
|
+
* Added __SKIP__/__END__ pragmas
|
17
|
+
|
18
|
+
=== 0.7.5 / 2009-02-19
|
19
|
+
|
20
|
+
* Updated s6 templates (added support for steps/incrementals)
|
21
|
+
|
22
|
+
=== 0.7.4 / 2009-02-06
|
23
|
+
|
24
|
+
* Added sample template package generation for S5 v11 blank package
|
25
|
+
|
26
|
+
=== 0.7.3 / 2009-02-04
|
27
|
+
|
28
|
+
* Added check for installed markdown libs/gems
|
29
|
+
* Added support for rdiscount, rpeg-markdown libs/gems
|
30
|
+
|
31
|
+
=== 0.7.2 / 2009-01-27
|
32
|
+
|
33
|
+
* Added support for output directory switch -o/--output and relative or absolute source file [Thanks Jorge L. Cangas]
|
34
|
+
|
35
|
+
=== 0.7.1 / 2009-01-26
|
36
|
+
|
37
|
+
* Fixed newline in manifests for file paths on unix bug
|
38
|
+
|
39
|
+
=== 0.7 / 2009-01-26
|
40
|
+
|
41
|
+
* Adding support for custom template packages using manifests
|
42
|
+
|
43
|
+
=== 0.6.1 / 2008-08-31
|
44
|
+
|
45
|
+
* Fixed gradient header bug [Thanks Suraj N. Kurapati]
|
46
|
+
|
47
|
+
=== 0.6 / 2008-08-26
|
48
|
+
|
49
|
+
* Added support for custom templates
|
50
|
+
|
51
|
+
=== 0.5.2 / 2008-07-23
|
52
|
+
|
53
|
+
* Pumped RedCloth gem dependency to use new 4.0 release
|
54
|
+
|
55
|
+
=== 0.5.1 / 2008-07-08
|
56
|
+
|
57
|
+
* Added support for S6 JavaScript slide shows as new default
|
58
|
+
|
59
|
+
=== 0.5 / 2008-07-03
|
60
|
+
|
61
|
+
* Added support for S5
|
62
|
+
|
63
|
+
=== 0.4.2 / 2008-05-20
|
64
|
+
|
65
|
+
* Added escaping of code blocks and unescaping of html entities in highlighted code
|
66
|
+
|
67
|
+
=== 0.4.1 / 2008-05-19
|
68
|
+
|
69
|
+
* {{{ and }}} shortcuts now supported standing in for <pre class='code'> and </pre>
|
70
|
+
* Added patch for h1 pattern
|
71
|
+
|
72
|
+
=== 0.4 / 2008-05-17
|
73
|
+
|
74
|
+
* Added support for code syntax highlighting using Ultraviolet gem [Thanks zimbatm]
|
75
|
+
|
76
|
+
=== 0.3.1 / 2008-05-17
|
77
|
+
|
78
|
+
* Switched markdown processor to maruku gem [Thanks zimbatm]
|
79
|
+
* Fix gem executable install for unix systems [Thanks zimbatm]
|
80
|
+
|
81
|
+
=== 0.3 / 2008-03-09
|
82
|
+
|
83
|
+
* Added support for Markdown using BlueCloth
|
84
|
+
* Moved all templates into templates folder processed using erb (embedded ruby)
|
85
|
+
|
86
|
+
=== 0.2 / 2008-02-26
|
87
|
+
|
88
|
+
* Added theming support using svg gradients
|
89
|
+
* Added compatibility support for Opera Show (no browser plugin/addon required)
|
90
|
+
|
91
|
+
=== 0.1 / 2008-02-17
|
92
|
+
|
93
|
+
* Everything is new. First release
|
data/Manifest.txt
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
bin/slideshow
|
6
|
+
lib/slideshow.rb
|
7
|
+
lib/slideshow/gen.rb
|
8
|
+
lib/slideshow/helpers/capture_helper.rb
|
9
|
+
lib/slideshow/helpers/coderay_helper.rb
|
10
|
+
lib/slideshow/helpers/text_helper.rb
|
11
|
+
lib/slideshow/helpers/uv_helper.rb
|
12
|
+
lib/slideshow/opts.rb
|
13
|
+
templates/fullerscreen.txt
|
14
|
+
templates/fullerscreen.txt.gen
|
15
|
+
templates/fullerscreen.txt.sample
|
16
|
+
templates/fullerscreen/footer.html.erb
|
17
|
+
templates/fullerscreen/header.html.erb
|
18
|
+
templates/fullerscreen/style.css.erb
|
19
|
+
templates/gradient.svg.erb
|
20
|
+
templates/s5.txt
|
21
|
+
templates/s5.txt.gen
|
22
|
+
templates/s5.txt.sample
|
23
|
+
templates/s5/footer.html.erb
|
24
|
+
templates/s5/header.html.erb
|
25
|
+
templates/s5/opera.css
|
26
|
+
templates/s5/outline.css
|
27
|
+
templates/s5/print.css
|
28
|
+
templates/s5/s5-core.css
|
29
|
+
templates/s5/slides.js
|
30
|
+
templates/s5/style.css.erb
|
31
|
+
templates/s5blank.txt.gen
|
32
|
+
templates/s5blank.txt.sample
|
33
|
+
templates/s5blank/blank.textile
|
34
|
+
templates/s5blank/footer.html.erb
|
35
|
+
templates/s5blank/header.html.erb
|
36
|
+
templates/s5blank/ui/default/blank.gif
|
37
|
+
templates/s5blank/ui/default/bodybg.gif
|
38
|
+
templates/s5blank/ui/default/framing.css
|
39
|
+
templates/s5blank/ui/default/iepngfix.htc
|
40
|
+
templates/s5blank/ui/default/opera.css
|
41
|
+
templates/s5blank/ui/default/outline.css
|
42
|
+
templates/s5blank/ui/default/pretty.css
|
43
|
+
templates/s5blank/ui/default/print.css
|
44
|
+
templates/s5blank/ui/default/s5-core.css
|
45
|
+
templates/s5blank/ui/default/slides.css
|
46
|
+
templates/s5blank/ui/default/slides.js
|
47
|
+
templates/s6.txt
|
48
|
+
templates/s6.txt.gen
|
49
|
+
templates/s6.txt.sample
|
50
|
+
templates/s6/footer.html.erb
|
51
|
+
templates/s6/header.html.erb
|
52
|
+
templates/s6/jquery.js
|
53
|
+
templates/s6/outline.css
|
54
|
+
templates/s6/print.css
|
55
|
+
templates/s6/slides.core.js
|
56
|
+
templates/s6/slides.css
|
57
|
+
templates/s6/slides.js
|
58
|
+
templates/s6/style.css.erb
|
data/README.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= slideshow
|
2
|
+
|
3
|
+
Slide Show (S9) - A Free Web Alternative to PowerPoint and KeyNote in Ruby
|
4
|
+
|
5
|
+
* http://slideshow.rubyforge.org
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
The Slide Show (S9) Ruby gem lets you create slide shows and author slides in plain text
|
10
|
+
using a wiki-style markup language that's easy-to-write and easy-to-read.
|
11
|
+
The Slide Show (S9) project also collects and welcomes themes and ships
|
12
|
+
"out-of-the-gem" with built-in support for "loss-free" gradient vector graphics themes.
|
13
|
+
|
14
|
+
== SYNOPSIS:
|
15
|
+
|
16
|
+
Usage: slideshow [options] name
|
17
|
+
|
18
|
+
Examples:
|
19
|
+
|
20
|
+
slideshow microformats
|
21
|
+
slideshow microformats.textile
|
22
|
+
slideshow -s5 microformats # S5 compatible
|
23
|
+
slideshow -f microformats # FullerScreen compatible
|
24
|
+
slideshow -o slides microformats # Output slideshow to slides folder
|
25
|
+
|
26
|
+
More examles:
|
27
|
+
|
28
|
+
slideshow -g # Generate slide show templates
|
29
|
+
slideshow -g -s5 # Generate S5 compatible slide show templates
|
30
|
+
slideshow -g -f # Generate FullerScreen compatible slide show templates
|
31
|
+
|
32
|
+
slideshow -t s3.txt microformats # Use custom slide show templates
|
33
|
+
|
34
|
+
== REQUIREMENTS:
|
35
|
+
|
36
|
+
* RedCloth (Textile Markup)
|
37
|
+
* BlueCloth (Markdown Markup)
|
38
|
+
|
39
|
+
* RDiscount (Markdown Markup) [Optional]
|
40
|
+
* Coderay (Syntax Highlighting) [Optional]
|
41
|
+
* Ultraviolet (Syntax Highlighting) [Optional]
|
42
|
+
|
43
|
+
== INSTALL:
|
44
|
+
|
45
|
+
Just install the gem:
|
46
|
+
|
47
|
+
$ sudo gem install slideshow
|
48
|
+
|
49
|
+
== LICENSE:
|
50
|
+
|
51
|
+
The slide show scripts and templates are dedicated to the public domain. Use it as you please with no restrictions whatsoever.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/slideshow.rb'
|
3
|
+
|
4
|
+
Hoe.new('slideshow', Slideshow::VERSION) do |p|
|
5
|
+
|
6
|
+
p.summary = 'Slide Show (S9) - A Free Web Alternative to PowerPoint and KeyNote in Ruby'
|
7
|
+
p.url = 'http://slideshow.rubyforge.org'
|
8
|
+
|
9
|
+
p.author = 'Gerald Bauer'
|
10
|
+
p.email = 'webslideshow@googlegroups.com'
|
11
|
+
|
12
|
+
p.extra_deps = [
|
13
|
+
['RedCloth','>= 4.0.0'],
|
14
|
+
['BlueCloth','>= 1.0.0']
|
15
|
+
]
|
16
|
+
|
17
|
+
p.remote_rdoc_dir = 'doc'
|
18
|
+
end
|
data/lib/slideshow.rb
CHANGED
@@ -1,635 +1,45 @@
|
|
1
1
|
$KCODE = 'utf'
|
2
2
|
|
3
|
+
LIB_PATH = File.expand_path( File.dirname(__FILE__) )
|
4
|
+
$:.unshift(LIB_PATH)
|
5
|
+
|
6
|
+
# core and stlibs
|
3
7
|
require 'optparse'
|
4
8
|
require 'erb'
|
5
|
-
require 'redcloth'
|
6
9
|
require 'logger'
|
7
10
|
require 'fileutils'
|
8
11
|
require 'ftools'
|
9
12
|
require 'pp'
|
10
13
|
|
14
|
+
# required gems
|
15
|
+
require 'redcloth'
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
# todo: split (command line) options and headers?
|
17
|
-
# e.g. share (command line) options between slide shows (but not headers?)
|
18
|
-
|
19
|
-
class Opts
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
@hash = {}
|
23
|
-
end
|
24
|
-
|
25
|
-
def put( key, value )
|
26
|
-
key = normalize_key( key )
|
27
|
-
setter = "#{key}=".to_sym
|
28
|
-
|
29
|
-
if respond_to? setter
|
30
|
-
send setter, value
|
31
|
-
else
|
32
|
-
@hash[ key ] = value
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def gradient=( value )
|
37
|
-
put_gradient( value, :theme, :color1, :color2 )
|
38
|
-
end
|
39
|
-
|
40
|
-
def gradient_colors=( value )
|
41
|
-
put_gradient( value, :color1, :color2 )
|
42
|
-
end
|
43
|
-
|
44
|
-
def gradient_color=( value )
|
45
|
-
put_gradient( value, :color1 )
|
46
|
-
end
|
47
|
-
|
48
|
-
def gradient_theme=( value )
|
49
|
-
put_gradient( value, :theme )
|
50
|
-
end
|
51
|
-
|
52
|
-
def []( key )
|
53
|
-
value = @hash[ normalize_key( key ) ]
|
54
|
-
if value.nil?
|
55
|
-
puts "** Warning: header '#{key}' undefined"
|
56
|
-
"- #{key} not found -"
|
57
|
-
else
|
58
|
-
value
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def generate?
|
63
|
-
get_boolean( 'generate', false )
|
64
|
-
end
|
65
|
-
|
66
|
-
def has_includes?
|
67
|
-
@hash[ :include ]
|
68
|
-
end
|
69
|
-
|
70
|
-
def includes
|
71
|
-
# fix: use os-agnostic delimiter (use : for Mac/Unix?)
|
72
|
-
has_includes? ? @hash[ :include ].split( ';' ) : []
|
73
|
-
end
|
74
|
-
|
75
|
-
def s5?
|
76
|
-
get_boolean( 's5', false )
|
77
|
-
end
|
78
|
-
|
79
|
-
def fullerscreen?
|
80
|
-
get_boolean( 'fuller', false ) || get_boolean( 'fullerscreen', false )
|
81
|
-
end
|
82
|
-
|
83
|
-
def manifest
|
84
|
-
get( 'manifest', 's6.txt' )
|
85
|
-
end
|
86
|
-
|
87
|
-
def output_path
|
88
|
-
get( 'output', '.' )
|
89
|
-
end
|
90
|
-
|
91
|
-
def code_engine
|
92
|
-
get( 'code-engine', DEFAULTS[ :code_engine ] )
|
93
|
-
end
|
94
|
-
|
95
|
-
def code_txmt
|
96
|
-
get( 'code-txmt', DEFAULTS[ :code_txmt ])
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
DEFAULTS =
|
101
|
-
{
|
102
|
-
:title => 'Untitled Slide Show',
|
103
|
-
:footer => '',
|
104
|
-
:subfooter => '',
|
105
|
-
:gradient_theme => 'dark',
|
106
|
-
:gradient_color1 => 'red',
|
107
|
-
:gradient_color2 => 'black',
|
108
|
-
|
109
|
-
:code_engine => 'uv', # ultraviolet (uv) | coderay (cr)
|
110
|
-
:code_txmt => 'false', # Text Mate Hyperlink for Source?
|
111
|
-
}
|
112
|
-
|
113
|
-
def set_defaults
|
114
|
-
DEFAULTS.each_pair do | key, value |
|
115
|
-
@hash[ key ] = value if @hash[ key ].nil?
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def get( key, default )
|
120
|
-
@hash.fetch( normalize_key(key), default )
|
121
|
-
end
|
122
|
-
|
123
|
-
private
|
124
|
-
|
125
|
-
def normalize_key( key )
|
126
|
-
key.to_s.downcase.tr('-', '_').to_sym
|
127
|
-
end
|
128
|
-
|
129
|
-
# Assigns the given gradient-* keys to the values in the given string.
|
130
|
-
def put_gradient( string, *keys )
|
131
|
-
values = string.split( ' ' )
|
132
|
-
|
133
|
-
values.zip(keys).each do |v, k|
|
134
|
-
@hash[ normalize_key( "gradient-#{k}" ) ] = v.tr( '-', '_' )
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def get_boolean( key, default )
|
139
|
-
value = @hash[ normalize_key( key ) ]
|
140
|
-
if value.nil?
|
141
|
-
default
|
142
|
-
else
|
143
|
-
(value == true || value =~ /true|yes|on/i) ? true : false
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
end # class Opts
|
148
|
-
|
149
|
-
|
150
|
-
class Gen
|
151
|
-
|
152
|
-
KNOWN_TEXTILE_EXTNAMES = [ '.textile', '.t' ]
|
153
|
-
KNOWN_MARKDOWN_EXTNAMES = [ '.markdown', '.m', '.mark', '.mkdn', '.md', '.txt', '.text' ]
|
154
|
-
KNOWN_EXTNAMES = KNOWN_TEXTILE_EXTNAMES + KNOWN_MARKDOWN_EXTNAMES
|
155
|
-
|
156
|
-
# note: only bluecloth is listed as a dependency in gem specs (because it's Ruby only and, thus, easy to install)
|
157
|
-
# if you want to use other markdown libs install the required/desired lib e.g.
|
158
|
-
# use gem install rdiscount for rdiscount and so on
|
159
|
-
#
|
160
|
-
# also note for now the first present markdown library gets used
|
161
|
-
# the search order is first come, first serve, that is: rdiscount, rpeg-markdown, maruku, bluecloth (fallback, always present)
|
162
|
-
KNOWN_MARKDOWN_LIBS = [
|
163
|
-
[ 'rdiscount', lambda { |content| RDiscount.new( content ).to_html } ],
|
164
|
-
[ 'rpeg-markdown', lambda { |content| PEGMarkdown.new( content ).to_html } ],
|
165
|
-
[ 'maruku', lambda { |content| Maruku.new( content, {:on_error => :raise} ).to_html } ],
|
166
|
-
[ 'bluecloth', lambda { |content| BlueCloth.new( content ).to_html } ]
|
167
|
-
]
|
168
|
-
|
169
|
-
BUILTIN_MANIFESTS = [ 'fullerscreen.txt', 'fullerscreen.txt.gen',
|
170
|
-
's5.txt', 's5.txt.gen',
|
171
|
-
's6.txt', 's6.txt.gen',
|
172
|
-
's5blank.txt.gen' ]
|
173
|
-
|
174
|
-
def initialize
|
175
|
-
@logger = Logger.new(STDOUT)
|
176
|
-
@logger.level = Logger::INFO
|
177
|
-
@opts = Opts.new
|
178
|
-
end
|
179
|
-
|
180
|
-
# replace w/ attr_reader :logger, :opts ??
|
181
|
-
|
182
|
-
def logger
|
183
|
-
@logger
|
184
|
-
end
|
185
|
-
|
186
|
-
def opts
|
187
|
-
@opts
|
188
|
-
end
|
189
|
-
|
190
|
-
def headers
|
191
|
-
# give access to helpers to opts with a different name
|
192
|
-
@opts
|
193
|
-
end
|
194
|
-
|
195
|
-
def session
|
196
|
-
# give helpers/plugins a session-like hash
|
197
|
-
@session
|
198
|
-
end
|
199
|
-
|
200
|
-
def markup_type
|
201
|
-
@markup_type # :textile, :markdown
|
202
|
-
end
|
203
|
-
|
204
|
-
def load_markdown_libs
|
205
|
-
# check for available markdown libs/gems
|
206
|
-
# try to require each lib and remove any not installed
|
207
|
-
@markdown_libs = []
|
208
|
-
|
209
|
-
KNOWN_MARKDOWN_LIBS.each do |lib|
|
210
|
-
begin
|
211
|
-
require lib[0]
|
212
|
-
@markdown_libs << lib
|
213
|
-
rescue LoadError => ex
|
214
|
-
logger.debug "Markdown library #{lib[0]} not found. Use gem install #{lib[0]} to install."
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
logger.debug "Installed Markdown libraries: #{@markdown_libs.map{ |lib| lib[0] }.join(', ')}"
|
219
|
-
logger.debug "Using Markdown library #{@markdown_libs.first[0]}."
|
220
|
-
end
|
221
|
-
|
222
|
-
# todo: move to filter (for easier reuse)
|
223
|
-
def markdown_to_html( content )
|
224
|
-
@markdown_libs.first[1].call( content )
|
225
|
-
end
|
226
|
-
|
227
|
-
# todo: move to filter (for easier reuse)
|
228
|
-
def textile_to_html( content )
|
229
|
-
# turn off hard line breaks
|
230
|
-
# turn off span caps (see http://rubybook.ca/2008/08/16/redcloth)
|
231
|
-
red = RedCloth.new( content, [:no_span_caps] )
|
232
|
-
red.hard_breaks = false
|
233
|
-
content = red.to_html
|
234
|
-
end
|
235
|
-
|
236
|
-
def wrap_markup( text )
|
237
|
-
if markup_type == :textile
|
238
|
-
# saveguard with notextile wrapper etc./no further processing needed
|
239
|
-
"<notextile>\n#{text}\n</notextile>"
|
240
|
-
else
|
241
|
-
text
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
def cache_dir
|
246
|
-
PLATFORM =~ /win32/ ? win32_cache_dir : File.join(File.expand_path("~"), ".slideshow")
|
247
|
-
end
|
248
|
-
|
249
|
-
def win32_cache_dir
|
250
|
-
unless File.exists?(home = ENV['HOMEDRIVE'] + ENV['HOMEPATH'])
|
251
|
-
puts "No HOMEDRIVE or HOMEPATH environment variable. Set one to save a" +
|
252
|
-
"local cache of stylesheets for syntax highlighting and more."
|
253
|
-
return false
|
254
|
-
else
|
255
|
-
return File.join(home, 'slideshow')
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
def load_manifest( path )
|
260
|
-
|
261
|
-
# check if file exists (if yes use custom template package!) - allows you to override builtin package with same name
|
262
|
-
if BUILTIN_MANIFESTS.include?( path ) && !File.exists?( path )
|
263
|
-
templatesdir = "#{File.dirname(__FILE__)}/templates"
|
264
|
-
logger.debug "use builtin template package"
|
265
|
-
logger.debug "templatesdir=#{templatesdir}"
|
266
|
-
filename = "#{templatesdir}/#{path}"
|
267
|
-
else
|
268
|
-
templatesdir = File.dirname( path )
|
269
|
-
logger.debug "use custom template package"
|
270
|
-
logger.debug "templatesdir=#{templatesdir}"
|
271
|
-
filename = path
|
272
|
-
end
|
273
|
-
|
274
|
-
manifest = []
|
275
|
-
puts " Loading template manifest #{filename}..."
|
276
|
-
|
277
|
-
File.open( filename ).readlines.each_with_index do |line,i|
|
278
|
-
case line
|
279
|
-
when /^\s*$/
|
280
|
-
# skip empty lines
|
281
|
-
when /^\s*#.*$/
|
282
|
-
# skip comment lines
|
283
|
-
else
|
284
|
-
logger.debug "line #{i+1}: #{line.strip}"
|
285
|
-
values = line.strip.split( /[ <,+]+/ )
|
286
|
-
|
287
|
-
# add source for shortcuts (assumes relative path; if not issue warning/error)
|
288
|
-
values << values[0] if values.size == 1
|
289
|
-
|
290
|
-
# normalize all source paths (1..-1) /make full path/add template dir
|
291
|
-
(1..values.size-1).each do |i|
|
292
|
-
values[i] = "#{templatesdir}/#{values[i]}"
|
293
|
-
logger.debug " path[#{i}]=>#{values[i]}<"
|
294
|
-
end
|
295
|
-
|
296
|
-
manifest << values
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
manifest
|
301
|
-
end
|
302
|
-
|
303
|
-
def load_template( path )
|
304
|
-
puts " Loading template #{path}..."
|
305
|
-
return File.read( path )
|
306
|
-
end
|
307
|
-
|
308
|
-
def render_template( content, the_binding )
|
309
|
-
ERB.new( content ).result( the_binding )
|
310
|
-
end
|
311
|
-
|
312
|
-
def load_template_old_delete( name, builtin )
|
313
|
-
|
314
|
-
if opts.has_includes?
|
315
|
-
opts.includes.each do |path|
|
316
|
-
logger.debug "File.exists? #{path}/#{name}"
|
317
|
-
|
318
|
-
if File.exists?( "#{path}/#{name}" ) then
|
319
|
-
puts "Loading custom template #{path}/#{name}..."
|
320
|
-
return File.read( "#{path}/#{name}" )
|
321
|
-
end
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
# fallback load builtin template packaged with gem
|
326
|
-
load_builtin_template( builtin )
|
327
|
-
end
|
328
|
-
|
329
|
-
def with_output_path( dest, output_path )
|
330
|
-
dest_full = File.expand_path( dest, output_path )
|
331
|
-
logger.debug "dest_full=#{dest_full}"
|
332
|
-
|
333
|
-
# make sure dest path exists
|
334
|
-
dest_path = File.dirname( dest_full )
|
335
|
-
logger.debug "dest_path=#{dest_path}"
|
336
|
-
File.makedirs( dest_path ) unless File.directory? dest_path
|
337
|
-
dest_full
|
338
|
-
end
|
339
|
-
|
340
|
-
def create_slideshow_templates
|
341
|
-
logger.debug "manifest=#{opts.manifest}.gen"
|
342
|
-
manifest = load_manifest( opts.manifest+".gen" )
|
343
|
-
|
344
|
-
# expand output path in current dir and make sure output path exists
|
345
|
-
outpath = File.expand_path( opts.output_path )
|
346
|
-
logger.debug "outpath=#{outpath}"
|
347
|
-
File.makedirs( outpath ) unless File.directory? outpath
|
348
|
-
|
349
|
-
manifest.each do |entry|
|
350
|
-
dest = entry[0]
|
351
|
-
source = entry[1]
|
352
|
-
|
353
|
-
puts "Copying to #{dest} from #{source}..."
|
354
|
-
File.copy( source, with_output_path( dest, outpath ) )
|
355
|
-
end
|
356
|
-
|
357
|
-
puts "Done."
|
358
|
-
end
|
359
|
-
|
360
|
-
def create_slideshow( fn )
|
361
|
-
|
362
|
-
logger.debug "manifest=#{opts.manifest}"
|
363
|
-
manifest = load_manifest( opts.manifest )
|
364
|
-
# pp manifest
|
365
|
-
|
366
|
-
# expand output path in current dir and make sure output path exists
|
367
|
-
outpath = File.expand_path( opts.output_path )
|
368
|
-
logger.debug "outpath=#{outpath}"
|
369
|
-
File.makedirs( outpath ) unless File.directory? outpath
|
370
|
-
|
371
|
-
dirname = File.dirname( fn )
|
372
|
-
basename = File.basename( fn, '.*' )
|
373
|
-
extname = File.extname( fn )
|
374
|
-
logger.debug "dirname=#{dirname}, basename=#{basename}, extname=#{extname}"
|
375
|
-
|
376
|
-
# change working dir to sourcefile dir
|
377
|
-
# todo: add a -c option to commandline? to let you set cwd?
|
378
|
-
|
379
|
-
newcwd = File.expand_path( dirname )
|
380
|
-
oldcwd = File.expand_path( Dir.pwd )
|
381
|
-
|
382
|
-
unless newcwd == oldcwd then
|
383
|
-
logger.debug "oldcwd=#{oldcwd}"
|
384
|
-
logger.debug "newcwd=#{newcwd}"
|
385
|
-
Dir.chdir newcwd
|
386
|
-
end
|
387
|
-
|
388
|
-
puts "Preparing slideshow '#{basename}'..."
|
389
|
-
|
390
|
-
if extname.empty? then
|
391
|
-
extname = ".textile" # default to .textile
|
392
|
-
|
393
|
-
KNOWN_EXTNAMES.each do |e|
|
394
|
-
logger.debug "File.exists? #{dirname}/#{basename}#{e}"
|
395
|
-
if File.exists?( "#{dirname}/#{basename}#{e}" ) then
|
396
|
-
extname = e
|
397
|
-
logger.debug "extname=#{extname}"
|
398
|
-
break
|
399
|
-
end
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
|
-
if KNOWN_MARKDOWN_EXTNAMES.include?( extname )
|
404
|
-
@markup_type = :markdown
|
405
|
-
else
|
406
|
-
@markup_type = :textile
|
407
|
-
end
|
408
|
-
|
409
|
-
# shared variables for templates (binding)
|
410
|
-
@content_for = {} # reset content_for hash
|
411
|
-
@name = basename
|
412
|
-
@headers = @opts # deprecate/remove: use headers method in template
|
413
|
-
|
414
|
-
@session = {} # reset session hash for plugins/helpers
|
415
|
-
|
416
|
-
inname = "#{dirname}/#{basename}#{extname}"
|
417
|
-
|
418
|
-
logger.debug "inname=#{inname}"
|
419
|
-
|
420
|
-
content_with_headers = File.read( inname )
|
421
|
-
|
422
|
-
# todo: read headers before command line options (lets you override options using commandline switch)?
|
423
|
-
|
424
|
-
# read source document; split off optional header from source
|
425
|
-
# strip leading optional headers (key/value pairs) including optional empty lines
|
426
|
-
|
427
|
-
read_headers = true
|
428
|
-
content = ""
|
429
|
-
|
430
|
-
# fix: allow comments in header too (#)
|
431
|
-
|
432
|
-
content_with_headers.each do |line|
|
433
|
-
if read_headers && line =~ /^\s*(\w[\w-]*)[ \t]*:[ \t]*(.*)/
|
434
|
-
key = $1.downcase
|
435
|
-
value = $2.strip
|
436
|
-
|
437
|
-
logger.debug " adding option: key=>#{key}< value=>#{value}<"
|
438
|
-
opts.put( key, value )
|
439
|
-
elsif line =~ /^\s*$/
|
440
|
-
content << line unless read_headers
|
441
|
-
else
|
442
|
-
read_headers = false
|
443
|
-
content << line
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
opts.set_defaults
|
448
|
-
|
449
|
-
# ruby note: .*? is non-greedy (shortest-possible) regex match
|
450
|
-
content.gsub!(/__SKIP__.*?__END__/m, '')
|
451
|
-
content.sub!(/__END__.*/m, '')
|
452
|
-
|
453
|
-
# allow plugins/helpers; process source (including header) using erb
|
454
|
-
|
455
|
-
# note: include is a ruby keyword; rename to __include__ so we can use it
|
456
|
-
content.gsub!( /<%=[ \t]*include/, '<%= __include__' )
|
457
|
-
|
458
|
-
content = ERB.new( content ).result( binding )
|
459
|
-
|
460
|
-
# run pre-filters (built-in macros)
|
461
|
-
# o replace {{{ w/ <pre class='code'>
|
462
|
-
# o replace }}} w/ </pre>
|
463
|
-
content.gsub!( "{{{{{{", "<pre class='code'>_S9BEGIN_" )
|
464
|
-
content.gsub!( "}}}}}}", "_S9END_</pre>" )
|
465
|
-
content.gsub!( "{{{", "<pre class='code'>" )
|
466
|
-
content.gsub!( "}}}", "</pre>" )
|
467
|
-
# restore escaped {{{}}} I'm sure there's a better way! Rubyize this! Anyone?
|
468
|
-
content.gsub!( "_S9BEGIN_", "{{{" )
|
469
|
-
content.gsub!( "_S9END_", "}}}" )
|
470
|
-
|
471
|
-
# convert light-weight markup to hypertext
|
472
|
-
|
473
|
-
content = case @markup_type
|
474
|
-
when :markdown
|
475
|
-
markdown_to_html( content )
|
476
|
-
when :textile
|
477
|
-
textile_to_html( content )
|
478
|
-
end
|
479
|
-
|
480
|
-
# post-processing
|
481
|
-
|
482
|
-
slide_counter = 0
|
483
|
-
content2 = ''
|
484
|
-
|
485
|
-
## todo: move this to a filter (for easier reuse)
|
486
|
-
|
487
|
-
# wrap h1's in slide divs; note use just <h1 since some processors add ids e.g. <h1 id='x'>
|
488
|
-
content.each_line do |line|
|
489
|
-
if line.include?( '<h1' ) then
|
490
|
-
content2 << "\n\n</div>" if slide_counter > 0
|
491
|
-
content2 << "<div class='slide'>\n\n"
|
492
|
-
slide_counter += 1
|
493
|
-
end
|
494
|
-
content2 << line
|
495
|
-
end
|
496
|
-
content2 << "\n\n</div>" if slide_counter > 0
|
497
|
-
|
498
|
-
manifest.each do |entry|
|
499
|
-
outname = entry[0]
|
500
|
-
if outname.include? '__file__' # process
|
501
|
-
outname = outname.gsub( '__file__', basename )
|
502
|
-
puts "Preparing #{outname}..."
|
503
|
-
|
504
|
-
out = File.new( with_output_path( outname, outpath ), "w+" )
|
505
|
-
|
506
|
-
out << render_template( load_template( entry[1] ), binding )
|
507
|
-
|
508
|
-
if entry.size > 2 # more than one source file? assume header and footer with content added inbetween
|
509
|
-
out << content2
|
510
|
-
out << render_template( load_template( entry[2] ), binding )
|
511
|
-
end
|
512
|
-
|
513
|
-
out.flush
|
514
|
-
out.close
|
515
|
-
|
516
|
-
else # just copy verbatim if target/dest has no __file__ in name
|
517
|
-
dest = entry[0]
|
518
|
-
source = entry[1]
|
519
|
-
|
520
|
-
puts "Copying to #{dest} from #{source}..."
|
521
|
-
File.copy( source, with_output_path( dest, outpath ) )
|
522
|
-
end
|
523
|
-
end
|
524
|
-
|
525
|
-
puts "Done."
|
526
|
-
end
|
17
|
+
# own code
|
18
|
+
require 'slideshow/opts'
|
19
|
+
require 'slideshow/gen'
|
527
20
|
|
528
|
-
|
529
|
-
|
530
|
-
# use lib folder unless we're in our very own folder
|
531
|
-
# (that use lib for its core functionality), thus, use plugins instead
|
532
|
-
if( File.expand_path( File.dirname(__FILE__) ) == File.expand_path( 'lib' ) )
|
533
|
-
pattern = 'plugins/**/*.rb'
|
534
|
-
else
|
535
|
-
pattern = 'lib/**/*.rb'
|
536
|
-
end
|
537
|
-
|
538
|
-
logger.debug "pattern=#{pattern}"
|
539
|
-
|
540
|
-
Dir.glob( pattern ) do |plugin|
|
541
|
-
begin
|
542
|
-
puts "Loading plugins in '#{plugin}'..."
|
543
|
-
require( plugin )
|
544
|
-
rescue Exception => e
|
545
|
-
puts "** error: failed loading plugins in '#{plugin}': #{e}"
|
546
|
-
end
|
547
|
-
end
|
548
|
-
end
|
21
|
+
module Slideshow
|
549
22
|
|
550
|
-
|
23
|
+
VERSION = '0.7.8'
|
551
24
|
|
552
|
-
|
553
|
-
|
554
|
-
cmd.banner = "Usage: slideshow [options] name"
|
25
|
+
def Slideshow.main
|
555
26
|
|
556
|
-
#
|
557
|
-
#
|
558
|
-
|
559
|
-
cmd.on( '-f[OPTIONAL]', '--fullerscreen', 'FullerScreen Compatible Slide Show' ) { opts.put( 'fuller', true ); opts.put( 'manifest', 'fullerscreen.txt' ) }
|
560
|
-
# opts.on( "-s", "--style STYLE", "Select Stylesheet" ) { |s| $options[:style]=s }
|
561
|
-
# opts.on( "-v", "--version", "Show version" ) {}
|
27
|
+
# allow env variable to set RUBYOPT-style default command line options
|
28
|
+
# e.g. -o slides -t <your_template_manifest_here>
|
29
|
+
slideshowopt = ENV[ 'SLIDESHOWOPT' ]
|
562
30
|
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
# use -d or -o to select output directory for slideshow or slideshow templates?
|
568
|
-
# cmd.on( '-d', '--directory DIRECTORY', 'Output Directory' ) { |s| opts.put( 'directory', s ) }
|
569
|
-
# cmd.on( '-i', '--include PATH', 'Load Path' ) { |s| opts.put( 'include', s ) }
|
570
|
-
|
571
|
-
# todo: find different letter for debug trace switch (use v for version?)
|
572
|
-
cmd.on( "-v", "--verbose", "Show debug trace" ) do
|
573
|
-
logger.datetime_format = "%H:%H:%S"
|
574
|
-
logger.level = Logger::DEBUG
|
575
|
-
end
|
576
|
-
|
577
|
-
cmd.on( "-t", "--template TEMPLATE", "Template Manifest" ) do |t|
|
578
|
-
# todo: do some checks on passed in template argument
|
579
|
-
opts.put( 'manifest', t )
|
580
|
-
end
|
581
|
-
|
582
|
-
cmd.on_tail( "-h", "--help", "Show this message" ) do
|
583
|
-
puts
|
584
|
-
puts "Slide Show (S9) is a free web alternative to PowerPoint or KeyNote in Ruby"
|
585
|
-
puts
|
586
|
-
puts cmd.help
|
587
|
-
puts
|
588
|
-
puts "Examples:"
|
589
|
-
puts " slideshow microformats"
|
590
|
-
puts " slideshow microformats.textile"
|
591
|
-
puts " slideshow -s5 microformats # S5 compatible"
|
592
|
-
puts " slideshow -f microformats # FullerScreen compatible"
|
593
|
-
puts " slideshow -o slides microformats # Output slideshow to slides folder"
|
594
|
-
puts
|
595
|
-
puts "More examles:"
|
596
|
-
puts " slideshow -g # Generate slide show templates"
|
597
|
-
puts " slideshow -g -s5 # Generate S5 compatible slide show templates"
|
598
|
-
puts " slideshow -g -f # Generate FullerScreen compatible slide show templates"
|
599
|
-
puts
|
600
|
-
puts " slideshow -t s3.txt microformats # Use custom slide show templates"
|
601
|
-
puts
|
602
|
-
puts "Further information:"
|
603
|
-
puts " http://slideshow.rubyforge.org"
|
604
|
-
exit
|
605
|
-
end
|
606
|
-
end
|
607
|
-
|
608
|
-
opt.parse!( args )
|
609
|
-
|
610
|
-
puts "Slide Show (S9) Version: #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
611
|
-
|
612
|
-
if opts.generate?
|
613
|
-
create_slideshow_templates
|
614
|
-
else
|
615
|
-
load_markdown_libs
|
616
|
-
load_plugins # check for optional plugins/extension in ./lib folder
|
31
|
+
args = []
|
32
|
+
args += slideshowopt.split if slideshowopt
|
33
|
+
args += ARGV.dup
|
617
34
|
|
618
|
-
|
35
|
+
Gen.new.run(args)
|
619
36
|
end
|
620
|
-
end
|
621
|
-
|
622
|
-
end # class Gen
|
623
|
-
|
624
|
-
def Slideshow.main
|
625
|
-
Gen.new.run(ARGV)
|
626
|
-
end
|
627
37
|
|
628
38
|
end # module Slideshow
|
629
39
|
|
630
40
|
# load built-in (required) helpers/plugins
|
631
|
-
require
|
632
|
-
require
|
41
|
+
require 'slideshow/helpers/text_helper.rb'
|
42
|
+
require 'slideshow/helpers/capture_helper.rb'
|
633
43
|
|
634
44
|
# load built-in (optional) helpers/plugins
|
635
45
|
# If a helper fails to load, simply ingnore it
|
@@ -637,8 +47,8 @@ require "#{File.dirname(__FILE__)}/helpers/capture_helper.rb"
|
|
637
47
|
# gem install coderay
|
638
48
|
# gem install ultraviolet etc.
|
639
49
|
BUILTIN_OPT_HELPERS = [
|
640
|
-
|
641
|
-
|
50
|
+
'slideshow/helpers/uv_helper.rb',
|
51
|
+
'slideshow/helpers/coderay_helper.rb',
|
642
52
|
]
|
643
53
|
|
644
54
|
BUILTIN_OPT_HELPERS.each do |helper|
|