forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
319 lines (262 loc) · 8.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Gulp based Cordova workflow</title>
<meta name="description" content="A framework for easily creating beautiful presentations using HTML">
<meta name="author" content="Hakim El Hattab">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Cordova + Gulp</h1>
<h3>Combining Cordova with other tools like Sass and CoffeeScript</h3>
<p>
<small>By Mark Koudritsky - kamrik@google.com / <a href="https://github.com/kamrik">GitHub</a></small>
</p>
<br/>
<small>
<a href="index.html?theme=beige#/">biege theme</a>
-
<a href="GulpCordova.pdf">PDF</a>
-
<a href="index.html?print-pdf&theme=beige">export as PDF (Cmd-P, Chrome only)</a>
</small>
</section>
<section>
<h2>What is Gulp?</h2>
<p>
Yet another task runner, like Grunt which is like Make.
</p>
</section>
<section>
<h2>Why?</h2>
<p>
<ul>
<li>Pre-process files with tools like Sass or CoffeeScript</li>
<li>Use cordova as a drop in tool to mobile-enable existing web apps (and Chrome Apps)</li>
<li>Automate more of the process</li>
</ul>
</p>
<aside class="notes">
Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).
</aside>
</section>
<section>
<h2>What is Gulp again?</h2>
<h3>And why I use it</h3>
<div style="float:right">
<a class="image" href="http://gulpjs.com/" target="_blank">
<img width="66" height="150" src="GulpLogo.png" alt="Gulp logo">
</a>
</div>
<p>
<ul>
<li>Gulp is minimal, liberal and simple task runner</li>
<li>Gulpfile is just a JS file that can contain any code</li>
<li>Way less declarative than Grunt</li>
<li>Very easy to experiment and prototype with</li>
<li>Based on <a href="https://github.com/substack/stream-handbook">streams</a> but I don't really care</li>
</ul>
</p>
<br/>
<p><small>Take a loot at <a href="http://gulpjs.com/">gulpjs.com</a> or a <a href="https://medium.com/@contrahacks/gulp-3828e8126466">presentatioin about Gulp</a></small></p>
</section>
<section>
<p>
A simple Gulpfile that can convert SCSS files to CSS
</p>
<pre><code data-trim contenteditable>
var gulp = require('gulp');
var sass = require('gulp-sass')
var del = require('del');
gulp.task('clean', function(cb) {
del(['./css'], cb);
});
gulp.task('sass', function () {
gulp.src('./scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('./css'));
});
</code></pre>
<p>Execute tasks by running</p>
<pre><code data-trim contenteditable>
$ cd my_cool_app
$ gulp clean
$ gulp sass
</code></pre>
</section>
<section>
<h3>Basic app walktrhough</h3>
<p>GitHub</p>
<p>
<a href="http://github.com/kamrik/CordovaGulpTemplate">github.com/kamrik/CordovaGulpTemplate</a>
</p>
</section>
<section data-markdown>
<script type="text/template">
## Minimal Cordova project
- `./config.xml`
- `./www/index.html`
- `./plugins/` - empty dir
</script>
</section>
<section>
<h3>Example App Structure</h3>
<ul>
<li>build/ - cordova project lives here, nuked on every "clean"</li>
<li>package.json - the npm package file</li>
<li>gulpfile.js</li>
<li>src/
<ul>
<li>www/
<ul>
<li>index.html</li>
<li>js/</li>
<li>css/</li>
</ul>
</li>
<li>CordovaConfig.xml - Cordova's config.xml file</li>
</ul>
</li>
</ul>
</section>
<section>
<h2>package.json</h2>
<pre><code data-trim contenteditable>
...
"name": "HelloGulpApp",
"version": "0.0.1",
"devDependencies": {
"cordova-lib": "latest",
"gulp": "latest",
...
},
"dependencies": {
"cordova-android": "^3.5.1",
"cordova-ios": "^3.5.0"
}
...
</code></pre>
<p>Note: can't list plugins in package.json - they are not (yet?) in npm registry!</p>
</section>
<section>
<h2>gulpfile.js - setup</h2>
<pre><code data-trim contenteditable>
var cordova = require('cordova-lib').cordova.raw; // promises API
var buildDir = path.join(__dirname, 'build');
var plugins = ['org.apache.cordova.file'];
</code></pre>
</section>
<section>
<h2>gulpfile.js - "cordova create"</h2>
<pre><code data-trim contenteditable>
gulp.task('create', ['clean'], function() {
fs.mkdirSync(buildDir);
process.chdir(buildDir);
fs.symlinkSync(path.join('..', 'src', 'CordovaC onfig.xml'), 'config.xml');
fs.symlinkSync(path.join('..', 'src', 'www'), 'www');
return cordova.plugins('add', plugins)
.then(function() {
// point to node_modules/cordova-android/
return cordova.platform('add', platform_dirs);
});
});
</code></pre>
</section>
<section>
<h2>gulpfile.js - "cordova build"</h2>
<pre><code data-trim contenteditable>
gulp.task('build', function() {
process.chdir(buildDir);
return cordova.build();
});
</code></pre>
</section>
<section>
<h2>Usage</h2>
<pre><code data-trim contenteditable>
$ git clone https://github.com/kamrik/CordovaGulpTemplate.git .
$ npm install
$ gulp create
$ gulp run
</code></pre>
</section>
<section>
<h2>Alternative "cordova create"</h2>
<pre><code data-trim contenteditable>
var cfg = {lib: {www: {uri: srcDir, url: srcDir, link: true}}};
return cordova.create(buildDir, appId, pkg.name, cfg)
.then(...)
</code></pre>
<p> + no need to maintain config.xml</p>
<p> - less control over config.xml</p>
</section>
<section>
<h2>possible directions</h2>
<ul>
<li>Store all info in package.json and generate config.xml as part of create task</li>
<li>Additional post-build tasks - e.g. run tests on several devices</li>
</ul>
</section>
<section>
<h2>Questions?</h2>
</section>
<section>
<h1>THE END</h1>
<p>
<a href="http://github.com/kamrik/CordovaGulpTemplate">github.com/kamrik/CordovaGulpTemplate</a>
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>