prez 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/prez +1 -1
- data/lib/prez/assets.rb +4 -0
- data/lib/prez/builder.rb +2 -0
- data/lib/prez/helpers.rb +26 -2
- data/lib/prez/start.rb +40 -8
- data/lib/prez/version.rb +1 -1
- data/templates/build.html.tt +1 -1
- data/vendor/javascripts/prez-controller.js.coffee +34 -7
- data/vendor/stylesheets/prez-controller.scss +6 -0
- data/vendor/stylesheets/prez.scss +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8a3c4b86dda6730ee9740ea901ac7a5e3dbc6a1
|
4
|
+
data.tar.gz: 739a8d0578e0a1042f0521995a86fe62d725ff5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c62e954206895f70899306942c6940083064e3bc73181e6528b93f4174382605059b76fa7e90797155120f2fea85474ecff72d802a25938af04221cf35f6cab2
|
7
|
+
data.tar.gz: 45ad9018218f0584c38d878b7f55aa8e3e243022067d9573582ef66eb6233d4ab5067acf75686f392fabf577c1c6546e2c42daa968da50b308a909ff1b2e0d79
|
data/bin/prez
CHANGED
data/lib/prez/assets.rb
CHANGED
data/lib/prez/builder.rb
CHANGED
data/lib/prez/helpers.rb
CHANGED
@@ -6,6 +6,10 @@ module Prez
|
|
6
6
|
module Helpers
|
7
7
|
protected
|
8
8
|
|
9
|
+
def reset_helpers!
|
10
|
+
@duration = nil
|
11
|
+
end
|
12
|
+
|
9
13
|
def duration(value)
|
10
14
|
if @duration
|
11
15
|
raise Prez::Error.new("The duration helper can only be called once!")
|
@@ -48,8 +52,28 @@ module Prez
|
|
48
52
|
end
|
49
53
|
end
|
50
54
|
|
51
|
-
def html_escape(value)
|
52
|
-
|
55
|
+
def html_escape(value = nil, &block)
|
56
|
+
if block
|
57
|
+
value = capture &block
|
58
|
+
end
|
59
|
+
|
60
|
+
value = CGI.escape_html value
|
61
|
+
|
62
|
+
if block
|
63
|
+
concat value
|
64
|
+
else
|
65
|
+
value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def capture()
|
70
|
+
buf = ""
|
71
|
+
old_buffer = @output_buffer
|
72
|
+
@output_buffer = buf
|
73
|
+
yield
|
74
|
+
buf.to_s
|
75
|
+
ensure
|
76
|
+
@output_buffer = old_buffer
|
53
77
|
end
|
54
78
|
|
55
79
|
def slide(options = {})
|
data/lib/prez/start.rb
CHANGED
@@ -10,6 +10,7 @@ module Prez
|
|
10
10
|
include Thor::Actions
|
11
11
|
include Prez::Builder
|
12
12
|
argument :name, type: :string
|
13
|
+
class_option :server, type: :boolean, desc: "Keep the server up for dynamic refreshes"
|
13
14
|
|
14
15
|
def check_file!
|
15
16
|
if File.exists? name
|
@@ -26,30 +27,61 @@ module Prez
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def generate_html
|
29
|
-
|
30
|
+
return if options[:server]
|
30
31
|
@html = build_html filename
|
31
32
|
end
|
32
33
|
|
33
34
|
def start_server
|
34
35
|
say "Starting server..."
|
35
|
-
server = WEBrick::HTTPServer.new Port: 0, Logger: Prez::Start::NoopLog.new, AccessLog: []
|
36
|
-
port = server.config[:Port]
|
36
|
+
@server = WEBrick::HTTPServer.new Port: 0, Logger: Prez::Start::NoopLog.new, AccessLog: []
|
37
|
+
port = @server.config[:Port]
|
37
38
|
|
38
|
-
server
|
39
|
-
|
40
|
-
|
39
|
+
if options[:server]
|
40
|
+
["INT", "TERM"].each do |signal|
|
41
|
+
trap signal do
|
42
|
+
stop_server
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
@server.mount_proc "/" do |request, response|
|
48
|
+
if request.path == "/"
|
49
|
+
response.body = html
|
50
|
+
|
51
|
+
unless options[:server]
|
52
|
+
@server.stop
|
53
|
+
end
|
54
|
+
else
|
55
|
+
say "Ignoring request: #{request.path}"
|
56
|
+
response.status = 404
|
57
|
+
end
|
41
58
|
end
|
42
59
|
|
43
60
|
begin
|
44
61
|
Launchy.open "http://localhost:#{port}/"
|
45
|
-
server.start
|
62
|
+
@server.start
|
46
63
|
ensure
|
47
|
-
server
|
64
|
+
unless options[:server]
|
65
|
+
stop_server
|
66
|
+
end
|
48
67
|
end
|
49
68
|
end
|
50
69
|
|
51
70
|
private
|
52
71
|
|
72
|
+
def stop_server
|
73
|
+
say "Shutting down server..."
|
74
|
+
@server.shutdown
|
75
|
+
end
|
76
|
+
|
77
|
+
def html
|
78
|
+
if options[:server]
|
79
|
+
build_html filename
|
80
|
+
else
|
81
|
+
@html
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
53
85
|
def filename
|
54
86
|
@filename
|
55
87
|
end
|
data/lib/prez/version.rb
CHANGED
data/templates/build.html.tt
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
<div class="col-xs-8">
|
66
66
|
<p class="lead text-center">
|
67
|
-
<strong>Current slide: <
|
67
|
+
<strong>Current slide: <select class="form-control current-slide-number"></select> of <span class="total-slides"></span></strong>
|
68
68
|
</p>
|
69
69
|
</div>
|
70
70
|
|
@@ -8,6 +8,7 @@ class Prez
|
|
8
8
|
DEFAULT_OPTIONS =
|
9
9
|
useHash: true
|
10
10
|
duration: 0
|
11
|
+
slideElementStyle: "hide"
|
11
12
|
|
12
13
|
constructor: (options) ->
|
13
14
|
@options = $.extend {}, DEFAULT_OPTIONS, options
|
@@ -15,6 +16,7 @@ class Prez
|
|
15
16
|
@document = @window.document
|
16
17
|
@document.write $("#slides-document").text()
|
17
18
|
@document.close()
|
19
|
+
@options.beforeStart?(@)
|
18
20
|
@start()
|
19
21
|
|
20
22
|
start: ->
|
@@ -37,11 +39,14 @@ class Prez
|
|
37
39
|
|
38
40
|
false
|
39
41
|
|
42
|
+
slideElementClass = "#{@options.slideElementStyle}-style"
|
43
|
+
|
40
44
|
$(".prez-slide", @document).each (i) ->
|
41
45
|
$(@).attr "data-slide", "#{i + 1}"
|
42
46
|
|
43
47
|
$(@).find(".prez-element").each (j) ->
|
44
48
|
$(@).attr "data-slide-element", "#{j + 1}"
|
49
|
+
$(@).addClass("hidden #{slideElementClass}")
|
45
50
|
|
46
51
|
@startTime = Date.now()
|
47
52
|
@changeSlideTo 1 unless changeToHashSlide()
|
@@ -72,13 +77,18 @@ class Prez
|
|
72
77
|
@slideStarted $next
|
73
78
|
|
74
79
|
if nextElement == 0
|
75
|
-
$next.find(".prez-element").
|
80
|
+
$next.find(".prez-element").addClass("hidden").removeClass("visible")
|
76
81
|
else if @currentElement() > nextElement
|
77
82
|
for i in [@currentElement()..(nextElement + 1)]
|
78
|
-
$next.find(".prez-element[data-slide-element='#{i}']").
|
83
|
+
$next.find(".prez-element[data-slide-element='#{i}']").addClass("hidden").removeClass("visible")
|
79
84
|
else if @currentElement() < nextElement
|
80
85
|
for i in [(@currentElement() + 1)..nextElement]
|
81
|
-
$next.find(".prez-element[data-slide-element='#{i}']").
|
86
|
+
$next.find(".prez-element[data-slide-element='#{i}']").removeClass("hidden").addClass("visible")
|
87
|
+
|
88
|
+
# Hack to fix Chrome sometimes not rendering opacity changes,
|
89
|
+
# thanks to http://stackoverflow.com/a/8840703/122
|
90
|
+
if @options.slideElementStyle == "opacity"
|
91
|
+
$next.hide().show(0)
|
82
92
|
|
83
93
|
@options.slideChanged? $next, nextValue, nextElement
|
84
94
|
true
|
@@ -89,14 +99,17 @@ class Prez
|
|
89
99
|
|
90
100
|
currentElement: ->
|
91
101
|
return null if @currentSlide() == null
|
92
|
-
return 0 if $(".prez-
|
93
|
-
parseInt $(".prez-
|
102
|
+
return 0 if $(".prez-slide:visible .prez-element.visible", @document).size() == 0
|
103
|
+
parseInt $(".prez-slide:visible .prez-element.visible:last", @document).data("slide-element"), 10
|
94
104
|
|
95
105
|
countSlideElements: (slide) ->
|
96
106
|
$slide = $(".prez-slide[data-slide='#{slide}']", @document)
|
97
107
|
return 0 if $slide.size() == 0
|
98
108
|
$slide.find(".prez-element").size()
|
99
109
|
|
110
|
+
countSlides: ->
|
111
|
+
$(".prez-slide", @document).size()
|
112
|
+
|
100
113
|
changeSlideBy: (amount) ->
|
101
114
|
slide = @currentSlide()
|
102
115
|
element = @currentElement()
|
@@ -241,6 +254,7 @@ $(document).on "click", "#launch", (e) ->
|
|
241
254
|
iframePrez = new Prez
|
242
255
|
window: iframe
|
243
256
|
useHash: false
|
257
|
+
slideElementStyle: "opacity"
|
244
258
|
|
245
259
|
Prez.current = new Prez
|
246
260
|
duration: Prez.timeToSeconds($("#prez-duration").val())
|
@@ -248,11 +262,17 @@ $(document).on "click", "#launch", (e) ->
|
|
248
262
|
slideChanged: ($slide, slideNumber, elementNumber) ->
|
249
263
|
notes = $slide.find(".prez-notes").html() || ""
|
250
264
|
$("#slide-notes").html notes
|
251
|
-
$(".current-slide-number").text $slide.data("slide")
|
265
|
+
$(".current-slide-number:not(select)").text $slide.data("slide")
|
266
|
+
$("select.current-slide-number").val $slide.data("slide")
|
252
267
|
Prez.handlers.timeChange()
|
253
268
|
iframePrez.changeSlideTo slideNumber, elementNumber
|
269
|
+
beforeStart: (prez) ->
|
270
|
+
$("select.current-slide-number").empty()
|
271
|
+
|
272
|
+
for i in [1..prez.countSlides()]
|
273
|
+
$("select.current-slide-number").append """<option value="#{i}">#{i}</option>"""
|
254
274
|
|
255
|
-
$(".total-slides").text
|
275
|
+
$(".total-slides").text Prez.current.countSlides()
|
256
276
|
$("#pre-launch").hide()
|
257
277
|
$("#post-launch").show()
|
258
278
|
|
@@ -274,6 +294,13 @@ $(document).on "click", ".end-prez", (e) ->
|
|
274
294
|
e.preventDefault()
|
275
295
|
Prez.current?.end()
|
276
296
|
|
297
|
+
$(document).on "change", "select.current-slide-number", (e) ->
|
298
|
+
Prez.current?.changeSlideTo parseInt($(@).val(), 10)
|
299
|
+
$(@).blur()
|
300
|
+
|
301
|
+
$(window).bind "beforeunload", ->
|
302
|
+
Prez.current?.end()
|
303
|
+
|
277
304
|
$(document).on "keydown", Prez.handlers.keyDown
|
278
305
|
$.setInterval 50, Prez.handlers.timeChange
|
279
306
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
body {
|
4
4
|
margin: 0;
|
5
|
-
padding:
|
5
|
+
padding: 0;
|
6
6
|
}
|
7
7
|
|
8
8
|
.header {
|
@@ -29,6 +29,7 @@ body {
|
|
29
29
|
|
30
30
|
display: none;
|
31
31
|
min-height: $prez-slide-min-height;
|
32
|
+
padding: $prez-padding;
|
32
33
|
text-align: center;
|
33
34
|
|
34
35
|
&.left-aligned {
|
@@ -39,9 +40,13 @@ body {
|
|
39
40
|
text-align: right;
|
40
41
|
}
|
41
42
|
|
42
|
-
.prez-element {
|
43
|
+
.prez-element.hide-style.hidden {
|
43
44
|
display: none;
|
44
45
|
}
|
46
|
+
|
47
|
+
.prez-element.opacity-style.hidden {
|
48
|
+
opacity: 0.25;
|
49
|
+
}
|
45
50
|
}
|
46
51
|
|
47
52
|
.smaller {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prez
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Virata-Stone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-script
|