briefing 0.0.2 → 0.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/briefing/app.rb +14 -3
- data/lib/briefing/slides.rb +45 -17
- data/lib/briefing/version.rb +1 -1
- data/lib/briefing/views/index.erb +2 -2
- metadata +2 -2
data/lib/briefing/app.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'sinatra/reloader'
|
3
3
|
require 'briefing/slides'
|
4
|
+
require 'pathname'
|
4
5
|
|
5
6
|
module Briefing
|
6
7
|
class App < Sinatra::Base
|
8
|
+
configure do
|
9
|
+
set :briefing_dir, Pathname(File.dirname(__FILE__))
|
10
|
+
set :public_folder, briefing_dir + 'public'
|
11
|
+
set :views, briefing_dir + 'views'
|
12
|
+
end
|
13
|
+
|
7
14
|
configure :development do
|
8
15
|
register Sinatra::Reloader
|
9
|
-
|
10
|
-
set :public_folder, File.join(dir, 'public')
|
11
|
-
set :views, File.join(dir, 'views')
|
16
|
+
also_reload(briefing_dir + 'slides.rb')
|
12
17
|
end
|
13
18
|
|
14
19
|
get '/' do
|
@@ -16,5 +21,11 @@ module Briefing
|
|
16
21
|
@options = @slides.options
|
17
22
|
erb :index
|
18
23
|
end
|
24
|
+
|
25
|
+
get '/assets/:file.:ext' do |file, ext|
|
26
|
+
content_type ext
|
27
|
+
slides_file = Pathname(File.join(Dir::pwd, settings.slides_source))
|
28
|
+
send_file(slides_file.dirname + 'assets' + "#{file}.#{ext}")
|
29
|
+
end
|
19
30
|
end
|
20
31
|
end
|
data/lib/briefing/slides.rb
CHANGED
@@ -1,10 +1,43 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'cgi'
|
2
3
|
|
3
4
|
module Briefing
|
4
5
|
class Slides
|
5
6
|
attr_reader :sections, :options
|
7
|
+
|
8
|
+
def initialize(filepath)
|
9
|
+
@sections = []
|
10
|
+
buffer = []
|
11
|
+
File.open(filepath).read.each_line {|line|
|
12
|
+
if line.match /^-{3,}(.*)$/
|
13
|
+
@sections << buffer.join('') if buffer.length > 0
|
14
|
+
buffer = []
|
15
|
+
else
|
16
|
+
buffer << modify_assets_path(line)
|
17
|
+
end
|
18
|
+
}
|
19
|
+
@sections << buffer.join('') if buffer.length > 0
|
20
|
+
@options = Options.new(@sections.shift) if @sections.length > 0
|
21
|
+
end
|
22
|
+
|
23
|
+
def modify_assets_path(line)
|
24
|
+
##  => 
|
25
|
+
line.gsub(/!\[(.*)\]\((.+)\)/) {|matched|
|
26
|
+
alt = $1
|
27
|
+
path = $2
|
28
|
+
if path.match /^https?:\/\//
|
29
|
+
matched
|
30
|
+
elsif path.match /^assets\//
|
31
|
+
matched
|
32
|
+
else
|
33
|
+
"})"
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
6
38
|
|
7
|
-
|
39
|
+
class Options < Hash
|
40
|
+
REVEALJS_DEFAULTS = {
|
8
41
|
'controls' => false,
|
9
42
|
'progress' => true,
|
10
43
|
'history' => true,
|
@@ -18,23 +51,18 @@ module Briefing
|
|
18
51
|
'rollingLinks' => false
|
19
52
|
}
|
20
53
|
|
21
|
-
def initialize(
|
22
|
-
|
23
|
-
|
24
|
-
File.open(filepath).read.each_line {|line|
|
25
|
-
if line.match /^-{3,}(.*)$/
|
26
|
-
if buffer.length > 0
|
27
|
-
@sections << buffer.join("")
|
28
|
-
end
|
29
|
-
buffer = []
|
30
|
-
else
|
31
|
-
buffer << line
|
32
|
-
end
|
33
|
-
}
|
34
|
-
if buffer.length > 0
|
35
|
-
@sections << buffer.join("")
|
54
|
+
def initialize(yaml_text)
|
55
|
+
if options = YAML.load(yaml_text)
|
56
|
+
self.merge! options
|
36
57
|
end
|
37
|
-
|
58
|
+
end
|
59
|
+
|
60
|
+
def revealjs
|
61
|
+
options = {}
|
62
|
+
REVEALJS_DEFAULTS.each_pair {|key, value|
|
63
|
+
options[key] = self[key] || value
|
64
|
+
}
|
65
|
+
options
|
38
66
|
end
|
39
67
|
end
|
40
68
|
end
|
data/lib/briefing/version.rb
CHANGED
@@ -57,8 +57,8 @@
|
|
57
57
|
|
58
58
|
<script>
|
59
59
|
Reveal.initialize({
|
60
|
-
<%
|
61
|
-
<%= key.to_s %>: <%=
|
60
|
+
<% @options.revealjs.each_pair {|key, value| %>
|
61
|
+
<%= key.to_s %>: <%= value.to_s %>,
|
62
62
|
<% } %>
|
63
63
|
theme: '<%= @options['theme'] || 'default' %>', // available themes are in /css/theme
|
64
64
|
transition: '<%= @options['transition'] || 'default' %>', // default/cube/page/concave/zoom/linear/none
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: briefing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|