reveal.rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,258 @@
1
+ // Custom reveal.js integration
2
+ (function(){
3
+ var isEnabled = true;
4
+
5
+ document.querySelector( '.reveal' ).addEventListener( 'mousedown', function( event ) {
6
+ var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'alt' ) + 'Key';
7
+
8
+ if( event[ modifier ] && isEnabled ) {
9
+ event.preventDefault();
10
+ zoom.to({ element: event.target, pan: false });
11
+ }
12
+ } );
13
+
14
+ Reveal.addEventListener( 'overviewshown', function() { isEnabled = false; } );
15
+ Reveal.addEventListener( 'overviewhidden', function() { isEnabled = true; } );
16
+ })();
17
+
18
+ /*!
19
+ * zoom.js 0.2 (modified version for use with reveal.js)
20
+ * http://lab.hakim.se/zoom-js
21
+ * MIT licensed
22
+ *
23
+ * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
24
+ */
25
+ var zoom = (function(){
26
+
27
+ // The current zoom level (scale)
28
+ var level = 1;
29
+
30
+ // The current mouse position, used for panning
31
+ var mouseX = 0,
32
+ mouseY = 0;
33
+
34
+ // Timeout before pan is activated
35
+ var panEngageTimeout = -1,
36
+ panUpdateInterval = -1;
37
+
38
+ var currentOptions = null;
39
+
40
+ // Check for transform support so that we can fallback otherwise
41
+ var supportsTransforms = 'WebkitTransform' in document.body.style ||
42
+ 'MozTransform' in document.body.style ||
43
+ 'msTransform' in document.body.style ||
44
+ 'OTransform' in document.body.style ||
45
+ 'transform' in document.body.style;
46
+
47
+ if( supportsTransforms ) {
48
+ // The easing that will be applied when we zoom in/out
49
+ document.body.style.transition = 'transform 0.8s ease';
50
+ document.body.style.OTransition = '-o-transform 0.8s ease';
51
+ document.body.style.msTransition = '-ms-transform 0.8s ease';
52
+ document.body.style.MozTransition = '-moz-transform 0.8s ease';
53
+ document.body.style.WebkitTransition = '-webkit-transform 0.8s ease';
54
+ }
55
+
56
+ // Zoom out if the user hits escape
57
+ document.addEventListener( 'keyup', function( event ) {
58
+ if( level !== 1 && event.keyCode === 27 ) {
59
+ zoom.out();
60
+ }
61
+ }, false );
62
+
63
+ // Monitor mouse movement for panning
64
+ document.addEventListener( 'mousemove', function( event ) {
65
+ if( level !== 1 ) {
66
+ mouseX = event.clientX;
67
+ mouseY = event.clientY;
68
+ }
69
+ }, false );
70
+
71
+ /**
72
+ * Applies the CSS required to zoom in, prioritizes use of CSS3
73
+ * transforms but falls back on zoom for IE.
74
+ *
75
+ * @param {Number} pageOffsetX
76
+ * @param {Number} pageOffsetY
77
+ * @param {Number} elementOffsetX
78
+ * @param {Number} elementOffsetY
79
+ * @param {Number} scale
80
+ */
81
+ function magnify( pageOffsetX, pageOffsetY, elementOffsetX, elementOffsetY, scale ) {
82
+
83
+ if( supportsTransforms ) {
84
+ var origin = pageOffsetX +'px '+ pageOffsetY +'px',
85
+ transform = 'translate('+ -elementOffsetX +'px,'+ -elementOffsetY +'px) scale('+ scale +')';
86
+
87
+ document.body.style.transformOrigin = origin;
88
+ document.body.style.OTransformOrigin = origin;
89
+ document.body.style.msTransformOrigin = origin;
90
+ document.body.style.MozTransformOrigin = origin;
91
+ document.body.style.WebkitTransformOrigin = origin;
92
+
93
+ document.body.style.transform = transform;
94
+ document.body.style.OTransform = transform;
95
+ document.body.style.msTransform = transform;
96
+ document.body.style.MozTransform = transform;
97
+ document.body.style.WebkitTransform = transform;
98
+ }
99
+ else {
100
+ // Reset all values
101
+ if( scale === 1 ) {
102
+ document.body.style.position = '';
103
+ document.body.style.left = '';
104
+ document.body.style.top = '';
105
+ document.body.style.width = '';
106
+ document.body.style.height = '';
107
+ document.body.style.zoom = '';
108
+ }
109
+ // Apply scale
110
+ else {
111
+ document.body.style.position = 'relative';
112
+ document.body.style.left = ( - ( pageOffsetX + elementOffsetX ) / scale ) + 'px';
113
+ document.body.style.top = ( - ( pageOffsetY + elementOffsetY ) / scale ) + 'px';
114
+ document.body.style.width = ( scale * 100 ) + '%';
115
+ document.body.style.height = ( scale * 100 ) + '%';
116
+ document.body.style.zoom = scale;
117
+ }
118
+ }
119
+
120
+ level = scale;
121
+
122
+ if( level !== 1 && document.documentElement.classList ) {
123
+ document.documentElement.classList.add( 'zoomed' );
124
+ }
125
+ else {
126
+ document.documentElement.classList.remove( 'zoomed' );
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Pan the document when the mosue cursor approaches the edges
132
+ * of the window.
133
+ */
134
+ function pan() {
135
+ var range = 0.12,
136
+ rangeX = window.innerWidth * range,
137
+ rangeY = window.innerHeight * range,
138
+ scrollOffset = getScrollOffset();
139
+
140
+ // Up
141
+ if( mouseY < rangeY ) {
142
+ window.scroll( scrollOffset.x, scrollOffset.y - ( 1 - ( mouseY / rangeY ) ) * ( 14 / level ) );
143
+ }
144
+ // Down
145
+ else if( mouseY > window.innerHeight - rangeY ) {
146
+ window.scroll( scrollOffset.x, scrollOffset.y + ( 1 - ( window.innerHeight - mouseY ) / rangeY ) * ( 14 / level ) );
147
+ }
148
+
149
+ // Left
150
+ if( mouseX < rangeX ) {
151
+ window.scroll( scrollOffset.x - ( 1 - ( mouseX / rangeX ) ) * ( 14 / level ), scrollOffset.y );
152
+ }
153
+ // Right
154
+ else if( mouseX > window.innerWidth - rangeX ) {
155
+ window.scroll( scrollOffset.x + ( 1 - ( window.innerWidth - mouseX ) / rangeX ) * ( 14 / level ), scrollOffset.y );
156
+ }
157
+ }
158
+
159
+ function getScrollOffset() {
160
+ return {
161
+ x: window.scrollX !== undefined ? window.scrollX : window.pageXOffset,
162
+ y: window.scrollY !== undefined ? window.scrollY : window.pageXYffset
163
+ }
164
+ }
165
+
166
+ return {
167
+ /**
168
+ * Zooms in on either a rectangle or HTML element.
169
+ *
170
+ * @param {Object} options
171
+ * - element: HTML element to zoom in on
172
+ * OR
173
+ * - x/y: coordinates in non-transformed space to zoom in on
174
+ * - width/height: the portion of the screen to zoom in on
175
+ * - scale: can be used instead of width/height to explicitly set scale
176
+ */
177
+ to: function( options ) {
178
+ // Due to an implementation limitation we can't zoom in
179
+ // to another element without zooming out first
180
+ if( level !== 1 ) {
181
+ zoom.out();
182
+ }
183
+ else {
184
+ options.x = options.x || 0;
185
+ options.y = options.y || 0;
186
+
187
+ // If an element is set, that takes precedence
188
+ if( !!options.element ) {
189
+ // Space around the zoomed in element to leave on screen
190
+ var padding = 20;
191
+
192
+ options.width = options.element.getBoundingClientRect().width + ( padding * 2 );
193
+ options.height = options.element.getBoundingClientRect().height + ( padding * 2 );
194
+ options.x = options.element.getBoundingClientRect().left - padding;
195
+ options.y = options.element.getBoundingClientRect().top - padding;
196
+ }
197
+
198
+ // If width/height values are set, calculate scale from those values
199
+ if( options.width !== undefined && options.height !== undefined ) {
200
+ options.scale = Math.max( Math.min( window.innerWidth / options.width, window.innerHeight / options.height ), 1 );
201
+ }
202
+
203
+ if( options.scale > 1 ) {
204
+ options.x *= options.scale;
205
+ options.y *= options.scale;
206
+
207
+ var scrollOffset = getScrollOffset();
208
+
209
+ if( options.element ) {
210
+ scrollOffset.x -= ( window.innerWidth - ( options.width * options.scale ) ) / 2;
211
+ }
212
+
213
+ magnify( scrollOffset.x, scrollOffset.y, options.x, options.y, options.scale );
214
+
215
+ if( options.pan !== false ) {
216
+
217
+ // Wait with engaging panning as it may conflict with the
218
+ // zoom transition
219
+ panEngageTimeout = setTimeout( function() {
220
+ panUpdateInterval = setInterval( pan, 1000 / 60 );
221
+ }, 800 );
222
+
223
+ }
224
+ }
225
+
226
+ currentOptions = options;
227
+ }
228
+ },
229
+
230
+ /**
231
+ * Resets the document zoom state to its default.
232
+ */
233
+ out: function() {
234
+ clearTimeout( panEngageTimeout );
235
+ clearInterval( panUpdateInterval );
236
+
237
+ var scrollOffset = getScrollOffset();
238
+
239
+ if( currentOptions && currentOptions.element ) {
240
+ scrollOffset.x -= ( window.innerWidth - ( currentOptions.width * currentOptions.scale ) ) / 2;
241
+ }
242
+
243
+ magnify( scrollOffset.x, scrollOffset.y, 0, 0, 1 );
244
+
245
+ level = 1;
246
+ },
247
+
248
+ // Alias
249
+ magnify: function( options ) { this.to( options ) },
250
+ reset: function() { this.out() },
251
+
252
+ zoomLevel: function() {
253
+ return level;
254
+ }
255
+ }
256
+
257
+ })();
258
+
@@ -0,0 +1,84 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+
7
+ <title>reveal.js - The HTML Presentation Framework</title>
8
+
9
+ <meta name="description" content="A framework for easily creating beautiful presentations using HTML">
10
+ <meta name="author" content="Hakim El Hattab">
11
+
12
+ <meta name="apple-mobile-web-app-capable" content="yes" />
13
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
14
+
15
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
16
+
17
+ <link rel="stylesheet" href="css/reveal.min.css">
18
+ <link rel="stylesheet" href="css/theme/default.css" id="theme">
19
+
20
+ <!-- For syntax highlighting -->
21
+ <link rel="stylesheet" href="lib/css/zenburn.css">
22
+
23
+ <!-- If the query includes 'print-pdf', include the PDF print sheet -->
24
+ <script>
25
+ if( window.location.search.match( /print-pdf/gi ) ) {
26
+ var link = document.createElement( 'link' );
27
+ link.rel = 'stylesheet';
28
+ link.type = 'text/css';
29
+ link.href = 'css/print/pdf.css';
30
+ document.getElementsByTagName( 'head' )[0].appendChild( link );
31
+ }
32
+ </script>
33
+
34
+ <!--[if lt IE 9]>
35
+ <script src="lib/js/html5shiv.js"></script>
36
+ <![endif]-->
37
+ </head>
38
+
39
+ <body>
40
+
41
+ <div class="reveal">
42
+
43
+ <!-- Any section element inside of this container is displayed as a slide -->
44
+ <div class="slides">
45
+ <slides>
46
+ </div>
47
+
48
+ </div>
49
+
50
+ <script src="lib/js/head.min.js"></script>
51
+ <script src="js/reveal.min.js"></script>
52
+
53
+ <script>
54
+
55
+ // Full list of configuration options available here:
56
+ // https://github.com/hakimel/reveal.js#configuration
57
+ Reveal.initialize({
58
+ controls: true,
59
+ progress: true,
60
+ history: true,
61
+ center: true,
62
+
63
+ theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
64
+ transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
65
+
66
+ // Parallax scrolling
67
+ // parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
68
+ // parallaxBackgroundSize: '2100px 900px',
69
+
70
+ // Optional libraries used to extend on reveal.js
71
+ dependencies: [
72
+ { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
73
+ { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
74
+ { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
75
+ { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
76
+ { src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
77
+ { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
78
+ ]
79
+ });
80
+
81
+ </script>
82
+
83
+ </body>
84
+ </html>
@@ -0,0 +1,3 @@
1
+ module Reveal
2
+ VERSION = "0.1.0"
3
+ end
data/lib/reveal.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Reveal
2
+ end
3
+
4
+ require File.expand_path(File.join(File.dirname(__FILE__), 'reveal', 'version'))
5
+ require File.expand_path(File.join(File.dirname(__FILE__), 'reveal', 'cli'))
data/reveal.rb.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'reveal/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "reveal.rb"
7
+ gem.version = Reveal::VERSION
8
+ gem.authors = ["Guilherme Garnier"]
9
+ gem.email = ["guilherme.garnier@gmail.com"]
10
+ gem.summary = "Presentation generator using reveal.js"
11
+ gem.description = "Generates presentations using reveal.js"
12
+ gem.homepage = "https://github.com/ggarnier/reveal.rb"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reveal.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Guilherme Garnier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Generates presentations using reveal.js
14
+ email:
15
+ - guilherme.garnier@gmail.com
16
+ executables:
17
+ - reveal
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .ruby-gemset
22
+ - .ruby-version
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE
26
+ - README.md
27
+ - bin/reveal
28
+ - lib/reveal.rb
29
+ - lib/reveal/cli.rb
30
+ - lib/reveal/templates/revealjs/css/print/pdf.css
31
+ - lib/reveal/templates/revealjs/css/reveal.min.css
32
+ - lib/reveal/templates/revealjs/css/theme/default.css
33
+ - lib/reveal/templates/revealjs/js/reveal.min.js
34
+ - lib/reveal/templates/revealjs/lib/css/zenburn.css
35
+ - lib/reveal/templates/revealjs/lib/font/league_gothic-webfont.eot
36
+ - lib/reveal/templates/revealjs/lib/font/league_gothic-webfont.ttf
37
+ - lib/reveal/templates/revealjs/lib/font/league_gothic-webfont.woff
38
+ - lib/reveal/templates/revealjs/lib/js/classList.js
39
+ - lib/reveal/templates/revealjs/lib/js/head.min.js
40
+ - lib/reveal/templates/revealjs/plugin/highlight/highlight.js
41
+ - lib/reveal/templates/revealjs/plugin/markdown/markdown.js
42
+ - lib/reveal/templates/revealjs/plugin/markdown/marked.js
43
+ - lib/reveal/templates/revealjs/plugin/notes/notes.js
44
+ - lib/reveal/templates/revealjs/plugin/zoom-js/zoom.js
45
+ - lib/reveal/templates/template.html
46
+ - lib/reveal/version.rb
47
+ - reveal.rb.gemspec
48
+ homepage: https://github.com/ggarnier/reveal.rb
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.1.11
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Presentation generator using reveal.js
72
+ test_files: []