nakajima-slidedown 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/bin/slidedown +1 -1
- data/lib/slide.rb +4 -4
- data/lib/slidedown.rb +43 -17
- data/templates/{template.erb → default.erb} +6 -6
- data/templates/import.erb +23 -0
- data/templates/{js → javascripts}/jquery-1.3.2.js +0 -0
- data/templates/{js → javascripts}/jquery.easing.js +0 -0
- data/templates/{js → javascripts}/jquery.hash-changed.js +0 -0
- data/templates/{js → javascripts}/slides.js +13 -2
- data/templates/{css → stylesheets}/screen.css +0 -0
- data/templates/{css → stylesheets}/slides.css +0 -0
- metadata +16 -17
data/README.md
CHANGED
@@ -74,6 +74,11 @@ Or for JavaScript
|
|
74
74
|
* Generate PDFs (maybe via cucumber)
|
75
75
|
* Stop making Nokogiri sad when parsing out snippets
|
76
76
|
|
77
|
+
## Contributors
|
78
|
+
|
79
|
+
* Pat Nakajima
|
80
|
+
* Dan Croak
|
81
|
+
|
77
82
|
(c) Copyright 2009 Pat Nakajima
|
78
83
|
|
79
84
|
Permission is hereby granted, free of charge, to any person
|
data/bin/slidedown
CHANGED
data/lib/slide.rb
CHANGED
data/lib/slidedown.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'optparse'
|
2
3
|
require 'nokogiri'
|
3
|
-
require 'rdiscount'
|
4
4
|
require 'makers-mark'
|
5
5
|
require 'erb'
|
6
6
|
require File.join(File.dirname(__FILE__), 'slide')
|
@@ -8,10 +8,40 @@ require File.join(File.dirname(__FILE__), 'slide')
|
|
8
8
|
$SILENT = true
|
9
9
|
|
10
10
|
class SlideDown
|
11
|
+
USAGE = "The SlideDown command line interface takes a .md (Markdown) file as its only required argument. It will convert the file to HTML in standard out. Options:
|
12
|
+
-t, --template [TEMPLATE] the .erb files in /templates directory. Default is -t default, which prints stylesheets and javascripts inline. The import template uses link and script tags."
|
13
|
+
|
11
14
|
attr_reader :classes
|
12
15
|
|
13
|
-
def self.
|
14
|
-
|
16
|
+
def self.run!(argv = ARGV)
|
17
|
+
args = argv.dup
|
18
|
+
|
19
|
+
if args.empty?
|
20
|
+
puts USAGE
|
21
|
+
else
|
22
|
+
source = args[0]
|
23
|
+
if args.length == 1
|
24
|
+
render(source)
|
25
|
+
else
|
26
|
+
option_parser(source).parse!(args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.option_parser(source)
|
32
|
+
OptionParser.new do |opts|
|
33
|
+
opts.on('-h', '--help') { puts USAGE }
|
34
|
+
opts.on('-t', '--template TEMPLATE') do |template|
|
35
|
+
render(source, template)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.render(source_path, template = "default")
|
41
|
+
if source_path
|
42
|
+
slideshow = new(File.read(source_path))
|
43
|
+
puts slideshow.render(template)
|
44
|
+
end
|
15
45
|
end
|
16
46
|
|
17
47
|
# Ensures that the first slide has proper !SLIDE declaration
|
@@ -25,33 +55,28 @@ class SlideDown
|
|
25
55
|
end
|
26
56
|
|
27
57
|
def read(path)
|
28
|
-
File.read(File.dirname(__FILE__)
|
58
|
+
File.read(File.join(File.dirname(__FILE__), '..', "templates", path))
|
29
59
|
end
|
30
60
|
|
31
|
-
def render
|
32
|
-
|
61
|
+
def render(name)
|
62
|
+
directory = File.join(File.dirname(__FILE__), "..", "templates")
|
63
|
+
path = File.join(directory, "#{name}.erb")
|
64
|
+
template = File.read(path)
|
33
65
|
ERB.new(template).result(binding)
|
34
66
|
end
|
35
67
|
|
36
68
|
private
|
37
69
|
|
38
70
|
def lines
|
39
|
-
@lines ||= @raw.split(/^!SLIDE\s*([a-z\s]*)$/)
|
40
|
-
.reject { |line| line.empty? }
|
41
|
-
end
|
42
|
-
|
43
|
-
def parse_snippets(slide)
|
44
|
-
slide.gsub!(/@@@\s([\w\s]+)\s*$/, %(<pre class="#{$1}"><code>))
|
45
|
-
slide.gsub!(/@@@\s*$/, %(</code></pre>))
|
71
|
+
@lines ||= @raw.split(/^!SLIDE\s*([a-z\s]*)$/).reject { |line| line.empty? }
|
46
72
|
end
|
47
73
|
|
48
|
-
# These get added to the dom.
|
49
74
|
def stylesheets
|
50
|
-
Dir[Dir.pwd + '/*.
|
75
|
+
Dir[Dir.pwd + '/*.stylesheets'].map { |path| File.read(path) }
|
51
76
|
end
|
52
77
|
|
53
78
|
def jabascripts
|
54
|
-
Dir[Dir.pwd + '/*.
|
79
|
+
Dir[Dir.pwd + '/*.javascripts'].map { |path| File.read(path) }
|
55
80
|
end
|
56
81
|
|
57
82
|
def extract_classes!
|
@@ -59,6 +84,7 @@ class SlideDown
|
|
59
84
|
@raw.gsub!(/^!SLIDE\s*([a-z\s]*)$/) do |klass|
|
60
85
|
@classes << klass.to_s.chomp.gsub('!SLIDE', '')
|
61
86
|
"!SLIDE"
|
62
|
-
end
|
87
|
+
end
|
88
|
+
@classes
|
63
89
|
end
|
64
90
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<head>
|
3
3
|
<title>Slides</title>
|
4
4
|
<style type="text/css" media="screen">
|
5
|
-
<%= read('
|
5
|
+
<%= read('stylesheets/slides.css') %>
|
6
6
|
</style>
|
7
7
|
<% stylesheets.each do |style| %>
|
8
8
|
<style type="text/css" media="screen">
|
@@ -10,16 +10,16 @@
|
|
10
10
|
</style>
|
11
11
|
<% end %>
|
12
12
|
<script type="text/javascript">
|
13
|
-
<%= read('
|
13
|
+
<%= read('javascripts/jquery-1.3.2.js') %>
|
14
14
|
</script>
|
15
15
|
<script type="text/javascript" charset="utf-8">
|
16
|
-
<%= read('
|
16
|
+
<%= read('javascripts/jquery.easing.js') %>
|
17
17
|
</script>
|
18
18
|
<script type="text/javascript" charset="utf-8">
|
19
|
-
<%= read('
|
19
|
+
<%= read('javascripts/jquery.hash-changed.js') %>
|
20
20
|
</script>
|
21
21
|
<script type="text/javascript" charset="utf-8">
|
22
|
-
<%= read('
|
22
|
+
<%= read('javascripts/slides.js') %>
|
23
23
|
</script>
|
24
24
|
<% jabascripts.each do |jaba| %>
|
25
25
|
<script type="text/javascript" charset="utf-8">
|
@@ -40,4 +40,4 @@
|
|
40
40
|
</div>
|
41
41
|
</div>
|
42
42
|
</body>
|
43
|
-
</html>
|
43
|
+
</html>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Slides</title>
|
4
|
+
<link href="/stylesheets/slides.css" media="screen" rel="stylesheet" charset="utf-8" type="text/css" />
|
5
|
+
<script src="/javascripts/jquery.js" type="text/javascript"></script>
|
6
|
+
<script src="/javascripts/jquery.easing.js" type="text/javascript"></script>
|
7
|
+
<script src="/javascripts/jquery.hash-changed.js" type="text/javascript"></script>
|
8
|
+
<script src="/javascripts/slides.js" type="text/javascript"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="slides">
|
12
|
+
<div id="track">
|
13
|
+
<% slides.each_with_index do |slide, idx| %>
|
14
|
+
<div class="<%= slide.classes.join(' ') %>">
|
15
|
+
<div id="slide-<%= idx %>" class="content">
|
16
|
+
<%= slide.html %>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</body>
|
23
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -72,17 +72,28 @@
|
|
72
72
|
37: -1, // ARROW LEFT
|
73
73
|
39: 1, // ARROW RIGHT
|
74
74
|
32: 1, // SPACE BAR
|
75
|
-
13: 1 // RETURN
|
75
|
+
13: 1, // RETURN
|
76
|
+
left: -1,
|
77
|
+
right: 1
|
76
78
|
}
|
77
79
|
|
78
|
-
if (dir = DIRECTIONS[event.which]) {
|
80
|
+
if (dir = DIRECTIONS[event.which || event]) {
|
79
81
|
setIndex(getIndex() + dir);
|
80
82
|
}
|
81
83
|
}
|
82
84
|
|
85
|
+
function clickMove(e) {
|
86
|
+
if (e.pageX < ($(window).width() / 2)) {
|
87
|
+
move('left');
|
88
|
+
} else {
|
89
|
+
move('right');
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
83
93
|
$(window).bind('resize', function() { adjustSlides(); });
|
84
94
|
$(document).bind('keydown', move);
|
85
95
|
$(document).bind('hash.changed', adjustSlides);
|
96
|
+
$(document).bind('click', clickMove);
|
86
97
|
$(document).ready(function() {
|
87
98
|
setIndex(getIndex() || 0);
|
88
99
|
$(this).trigger('hash.changed');
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nakajima-slidedown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Nakajima
|
8
|
+
- Dan Croak
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-03-
|
13
|
+
date: 2009-03-09 21:00:00 -07:00
|
13
14
|
default_executable: slidedown
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
+
name: makers-mark
|
17
18
|
type: :runtime
|
18
19
|
version_requirement:
|
19
20
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -41,24 +42,22 @@ extensions: []
|
|
41
42
|
extra_rdoc_files: []
|
42
43
|
|
43
44
|
files:
|
44
|
-
-
|
45
|
+
- README.md
|
45
46
|
- bin/slidedown
|
46
|
-
- lib/
|
47
47
|
- lib/slide.rb
|
48
48
|
- lib/slidedown.rb
|
49
|
-
-
|
50
|
-
- templates/
|
51
|
-
- templates/
|
52
|
-
- templates/
|
53
|
-
- templates/js
|
54
|
-
- templates/
|
55
|
-
- templates/
|
56
|
-
- templates/
|
57
|
-
- templates/
|
58
|
-
- templates/
|
59
|
-
- vendor
|
49
|
+
- templates/default.erb
|
50
|
+
- templates/import.erb
|
51
|
+
- templates/javascripts
|
52
|
+
- templates/javascripts/jquery-1.3.2.js
|
53
|
+
- templates/javascripts/jquery.easing.js
|
54
|
+
- templates/javascripts/jquery.hash-changed.js
|
55
|
+
- templates/javascripts/slides.js
|
56
|
+
- templates/stylesheets
|
57
|
+
- templates/stylesheets/screen.css
|
58
|
+
- templates/stylesheets/slides.css
|
60
59
|
- vendor/albino.rb
|
61
|
-
has_rdoc:
|
60
|
+
has_rdoc: true
|
62
61
|
homepage:
|
63
62
|
post_install_message:
|
64
63
|
rdoc_options: []
|