slidedown 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.
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
@@ -2,4 +2,4 @@
2
2
 
3
3
  require File.join(File.dirname(__FILE__), *%w[.. lib slidedown])
4
4
 
5
- puts SlideDown.render(ARGV.dup)
5
+ SlideDown.run!
data/lib/slide.rb CHANGED
@@ -1,12 +1,24 @@
1
1
  class Slide
2
- attr_accessor :text, :classes
3
-
2
+ attr_accessor :text, :classes, :notes
3
+
4
4
  def initialize(text, *classes)
5
- @text = text
5
+ @text = text
6
6
  @classes = classes
7
+ @notes = nil
8
+
9
+ extract_notes!
7
10
  end
8
-
11
+
9
12
  def html
10
13
  MakersMark::Generator.new(@text).to_html
11
14
  end
12
- end
15
+
16
+ private
17
+
18
+ def extract_notes!
19
+ @text.gsub!(/^!NOTES\s*(.*\n)$/m) do |note|
20
+ @notes = note.to_s.chomp.gsub('!NOTES', '')
21
+ ''
22
+ end
23
+ end
24
+ end
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,16 +8,50 @@ 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
+
14
+ attr_accessor :stylesheets, :title
11
15
  attr_reader :classes
12
16
 
13
- def self.render(args)
14
- new(File.read(File.join(Dir.pwd, *args))).render
17
+ def self.run!(argv = ARGV)
18
+ args = argv.dup
19
+
20
+ if args.empty?
21
+ puts USAGE
22
+ else
23
+ source = args[0]
24
+ if args.length == 1
25
+ render(source)
26
+ else
27
+ option_parser(source).parse!(args)
28
+ end
29
+ end
30
+ end
31
+
32
+ def self.option_parser(source)
33
+ OptionParser.new do |opts|
34
+ opts.on('-h', '--help') { puts USAGE }
35
+ opts.on('-t', '--template TEMPLATE') do |template|
36
+ render(source, template)
37
+ end
38
+ end
39
+ end
40
+
41
+ def self.render(source_path, template = "default")
42
+ if source_path
43
+ slideshow = new(File.read(source_path))
44
+ puts slideshow.render(template)
45
+ end
15
46
  end
16
47
 
17
48
  # Ensures that the first slide has proper !SLIDE declaration
18
- def initialize(raw)
49
+ def initialize(raw, opts = {})
19
50
  @raw = raw =~ /\A!SLIDE/ ? raw : "!SLIDE\n#{raw}"
20
51
  extract_classes!
52
+
53
+ self.stylesheets = opts[:stylesheets] || local_stylesheets
54
+ self.title = opts[:title] || "Slides"
21
55
  end
22
56
 
23
57
  def slides
@@ -25,33 +59,28 @@ class SlideDown
25
59
  end
26
60
 
27
61
  def read(path)
28
- File.read(File.dirname(__FILE__) + '/../templates/%s' % path)
62
+ File.read(File.join(File.dirname(__FILE__), '..', "templates", path))
29
63
  end
30
64
 
31
- def render
32
- template = File.read(File.dirname(__FILE__) + '/../templates/template.erb')
65
+ def render(name)
66
+ directory = File.join(File.dirname(__FILE__), "..", "templates")
67
+ path = File.join(directory, "#{name}.erb")
68
+ template = File.read(path)
33
69
  ERB.new(template).result(binding)
34
70
  end
35
71
 
36
72
  private
37
73
 
38
74
  def lines
39
- @lines ||= @raw.split(/^!SLIDE/) \
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>))
75
+ @lines ||= @raw.split(/^!SLIDE\s*([a-z\s]*)$/).reject { |line| line.empty? }
46
76
  end
47
77
 
48
- # These get added to the dom.
49
- def stylesheets
50
- Dir[Dir.pwd + '/*.css'].map { |path| File.read(path) }
78
+ def local_stylesheets
79
+ Dir[Dir.pwd + '/*.stylesheets']
51
80
  end
52
81
 
53
82
  def jabascripts
54
- Dir[Dir.pwd + '/*.js'].map { |path| File.read(path) }
83
+ Dir[Dir.pwd + '/*.javascripts'].map { |path| File.read(path) }
55
84
  end
56
85
 
57
86
  def extract_classes!
@@ -59,6 +88,16 @@ class SlideDown
59
88
  @raw.gsub!(/^!SLIDE\s*([a-z\s]*)$/) do |klass|
60
89
  @classes << klass.to_s.chomp.gsub('!SLIDE', '')
61
90
  "!SLIDE"
62
- end ; @classes
91
+ end
92
+ @classes
93
+ end
94
+
95
+ def extract_notes!
96
+ @raw.gsub!(/^!NOTES\s*(.*)!SLIDE$/m) do |note|
97
+ '!SLIDE'
98
+ end
99
+ @raw.gsub!(/^!NOTES\s*(.*\n)$/m) do |note|
100
+ ''
101
+ end
63
102
  end
64
103
  end
@@ -1,25 +1,23 @@
1
1
  <html>
2
2
  <head>
3
- <title>Slides</title>
3
+ <title><%= title %></title>
4
4
  <style type="text/css" media="screen">
5
- <%= read('css/slides.css') %>
5
+ <%= read('stylesheets/slides.css') %>
6
6
  </style>
7
7
  <% stylesheets.each do |style| %>
8
- <style type="text/css" media="screen">
9
- <%= style %>
10
- </style>
8
+ <link rel="stylesheet" href="<%= style %>" type="text/css" media="screen" charset="utf-8" />
11
9
  <% end %>
12
10
  <script type="text/javascript">
13
- <%= read('js/jquery-1.3.2.js') %>
11
+ <%= read('javascripts/jquery-1.3.2.js') %>
14
12
  </script>
15
13
  <script type="text/javascript" charset="utf-8">
16
- <%= read('js/jquery.easing.js') %>
14
+ <%= read('javascripts/jquery.easing.js') %>
17
15
  </script>
18
16
  <script type="text/javascript" charset="utf-8">
19
- <%= read('js/jquery.hash-changed.js') %>
17
+ <%= read('javascripts/jquery.hash-changed.js') %>
20
18
  </script>
21
19
  <script type="text/javascript" charset="utf-8">
22
- <%= read('js/slides.js') %>
20
+ <%= read('javascripts/slides.js') %>
23
21
  </script>
24
22
  <% jabascripts.each do |jaba| %>
25
23
  <script type="text/javascript" charset="utf-8">
@@ -40,4 +38,4 @@
40
38
  </div>
41
39
  </div>
42
40
  </body>
43
- </html>
41
+ </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
File without changes
File without changes
data/vendor/albino.rb CHANGED
@@ -41,7 +41,7 @@
41
41
  # Chris Wanstrath // chris@ozmm.org
42
42
  # GitHub // http://github.com
43
43
  #
44
- require 'open4'
44
+ require 'open3'
45
45
 
46
46
  class Albino
47
47
  @@bin = '/usr/local/bin/pygmentize'
@@ -60,7 +60,7 @@ class Albino
60
60
  end
61
61
 
62
62
  def execute(command)
63
- pid, stdin, stdout, stderr = Open4.popen4(command)
63
+ stdin, stdout, stderr = Open3.popen3(command)
64
64
  stdin.puts @target
65
65
  stdin.close
66
66
  stdout.read.strip
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slidedown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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: []
@@ -13,7 +14,7 @@ date: 2009-03-10 00:00:00 -04:00
13
14
  default_executable: slidedown
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- name: rdiscount
17
+ name: makers-mark
17
18
  type: :runtime
18
19
  version_requirement:
19
20
  version_requirements: !ruby/object:Gem::Requirement
@@ -32,16 +33,6 @@ dependencies:
32
33
  - !ruby/object:Gem::Version
33
34
  version: "0"
34
35
  version:
35
- - !ruby/object:Gem::Dependency
36
- name: nakajima-makers-mark
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
45
36
  description:
46
37
  email:
47
38
  executables:
@@ -51,17 +42,18 @@ extensions: []
51
42
  extra_rdoc_files: []
52
43
 
53
44
  files:
45
+ - README.md
54
46
  - bin/slidedown
55
47
  - lib/slide.rb
56
48
  - lib/slidedown.rb
57
- - README.md
58
- - templates/css/screen.css
59
- - templates/css/slides.css
60
- - templates/js/jquery-1.3.2.js
61
- - templates/js/jquery.easing.js
62
- - templates/js/jquery.hash-changed.js
63
- - templates/js/slides.js
64
- - templates/template.erb
49
+ - templates/default.erb
50
+ - templates/import.erb
51
+ - templates/javascripts/jquery-1.3.2.js
52
+ - templates/javascripts/jquery.easing.js
53
+ - templates/javascripts/jquery.hash-changed.js
54
+ - templates/javascripts/slides.js
55
+ - templates/stylesheets/screen.css
56
+ - templates/stylesheets/slides.css
65
57
  - vendor/albino.rb
66
58
  has_rdoc: true
67
59
  homepage: