-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
694 lines (630 loc) · 24 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Lazy Programmer's Guide to html tables in Dancer2</title>
<meta name="author" content="(Jason Lewis)"/>
<style type="text/css">
.underline { text-decoration: underline; }
</style>
<link rel="stylesheet" href="/css/reveal.css"/>
<link rel="stylesheet" href="/css/theme/moon.css" id="theme"/>
<link rel="stylesheet" href="local.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>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="sec-title-slide"><h1 class="title">Lazy Programmer's Guide to html tables in Dancer2</h1><h2 class="author">Jason Lewis</h2><p class="date">Created: 2016-09-21 Wed 16:34</p>
</section>
<section id="table-of-contents">
<div id="table-of-contents">
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#/slide-orgheadline5">About me</a></li>
<li><a href="#/slide-orgheadline10">Hand coded html table in Template Toolkit</a></li>
<li><a href="#/slide-orgheadline18">add DataTables to the mix</a></li>
<li><a href="#/slide-orgheadline23">using JSON with DataTables</a></li>
<li><a href="#/slide-orgheadline28">styling the table</a></li>
<li><a href="#/slide-orgheadline38">table export options</a></li>
</ul>
</div>
</div>
</section>
<section>
<section id="slide-orgheadline5">
<h2 id="orgheadline5">About me</h2>
<p>
Jason Lewis
</p>
<p>
Owner of a wholesale distribution business in Australia
</p>
<p>
Jack of all trades…
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline1">
<h3 id="orgheadline1">contact</h3>
<ul>
<li>email: jason@dickson.st</li>
<li>IRC: k-man</li>
<li>Twitter: @jasonblewis</li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline2">
<h3 id="orgheadline2">Why am I doing this?</h3>
<p>
Business reporting done in Crystal Reports
</p>
<ul>
<li>Replace Crystal Reports with something less proprietary.</li>
<li>make reports accessable on the web</li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline3">
<h3 id="orgheadline3">Crystal Reports</h3>
<p>
Existing system was built in Crystal Reports
</p>
<ul>
<li>Pros:
<ul>
<li>very quick to build reports</li>
<li>quite easy to customise and make the reports just so</li>
</ul></li>
<li>Cons:
<ul>
<li>proprietary</li>
<li>distribution of reports difficult</li>
<li>not easy to put the reports on the web</li>
<li>win32 only</li>
</ul></li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline4">
<h3 id="orgheadline4">Why Dancer2?</h3>
<p>
I looked around
</p>
<p>
Dancer has an awesome community.
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline10">
<h2 id="orgheadline10">Hand coded html table in Template Toolkit</h2>
<div class="outline-text-2" id="text-orgheadline10">
</div><div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline6">
<h3 id="orgheadline6">Route handler</h3>
<div class="org-src-container">
<pre class="src src-perl">get <span style="color: #E6DB74;">'/demo01'</span> => <span style="color: #F92672;">sub</span> {
<span style="color: #F92672;">my</span> <span style="color: #FD971F;">$sth</span> = database->prepare(
<span style="color: #E6DB74;">'select * from invoices'</span>,
);
$sth->execute() <span style="color: #66D9EF;">or</span> <span style="color: #F92672;">die</span> $sth->errstr;
<span style="color: #F92672;">my</span> <span style="color: #FD971F;">$fields</span> = $sth->{<span style="color: #E6DB74;">NAME</span>};
<span style="color: #F92672;">my</span> <span style="color: #FD971F;">$invoices</span> = $sth->fetchall_arrayref({});
template <span style="color: #E6DB74;">'demo01'</span>,
{ <span style="color: #E6DB74;">title</span> => <span style="color: #E6DB74;">'demo01'</span>,
<span style="color: #E6DB74;">fields</span> => $fields,
<span style="color: #E6DB74;">invoices</span> => $invoices,
};
};
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline7">
<h3 id="orgheadline7">View</h3>
<div class="org-src-container">
<pre class="src src-html"><<span style="color: #A6E22E;">table</span> <span style="color: #FD971F;">width</span>=<span style="color: #E6DB74;">"80%"</span> <span style="color: #FD971F;">id</span>=<span style="color: #E6DB74;">"example-table"</span>>
...
<<span style="color: #A6E22E;">tbody</span>>
[% FOREACH invoice IN invoices %]
<<span style="color: #A6E22E;">tr</span>>
[% FOREACH field IN fields %]
<<span style="color: #A6E22E;">td</span>>[% invoice.$field %]</<span style="color: #A6E22E;">td</span>>
[% END %]
</<span style="color: #A6E22E;">tr</span>>
[% END %]
</<span style="color: #A6E22E;">tbody</span>>
</<span style="color: #A6E22E;">table</span>>
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline8">
<h3 id="orgheadline8">Demo 1</h3>
<p>
<a href="http://localhost:5000/demo01">http://localhost:5000/demo01</a>
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline9">
<h3 id="orgheadline9">Pros and Cons</h3>
<ul>
<li>pros:
<ul>
<li>simple to write</li>
</ul></li>
<li>Cons:
<ul>
<li>resulting web page very static</li>
<li>tables with many rows cumbersome</li>
</ul></li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline18">
<h2 id="orgheadline18">add DataTables to the mix</h2>
<p>
hand coded table + DataTables
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline11">
<h3 id="orgheadline11">What is DataTables?</h3>
<ul>
<li>JavaScript framework for manipulating html tables</li>
<li>adds about about 136k to your page (depending on components)</li>
<li><a href="https://datatables.net/">https://datatables.net/</a></li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline12">
<h3 id="orgheadline12">Include the CSS and JavaScript for DataTables</h3>
<p>
in the main.tt layout add:
</p>
<div class="org-src-container">
<pre class="src src-html"><span style="color: #75715E;"><!-- </span><span style="color: #75715E;">DataTables </span><span style="color: #75715E;">--></span>
<<span style="color: #A6E22E;">link</span> <span style="color: #FD971F;">rel</span>=<span style="color: #E6DB74;">"stylesheet"</span>
<span style="color: #FD971F;">href</span>=<span style="color: #E6DB74;">"[% request.uri_base %]/css/jquery.dataTables.min.css"</span>>
<<span style="color: #A6E22E;">script</span> <span style="color: #FD971F;">type</span>=<span style="color: #E6DB74;">"text/javascript"</span>
<span style="color: #FD971F;">src</span>=<span style="color: #E6DB74;">"javascripts/jquery.dataTables.min.js"</span>>
</<span style="color: #A6E22E;">script</span>>
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline13">
<h3 id="orgheadline13">call the DataTable enabler after document ready</h3>
<p>
add JavaScript DataTable call to the view:
</p>
<div class="org-src-container">
<pre class="src src-javascript"><script type=<span style="color: #E6DB74;">"text/javascript"</span>>
$(document).ready(<span style="color: #F92672;">function</span>(){
$(<span style="color: #E6DB74;">'#example-datatable'</span>).DataTable();
});
</script>
</pre>
</div>
<p>
#example-datatable is the CSS id of the table you want to make fancy
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline14">
<h3 id="orgheadline14">add #example CSS id to table</h3>
<div class="org-src-container">
<pre class="src src-html"><<span style="color: #A6E22E;">table</span> <span style="color: #FD971F;">width</span>=<span style="color: #E6DB74;">"80%"</span>>
<<span style="color: #A6E22E;">thead</span>>
<<span style="color: #A6E22E;">tr</span>>
[% FOREACH field IN fields %]
<<span style="color: #A6E22E;">th</span>>[% field %]</<span style="color: #A6E22E;">th</span>>
[% END %]
</<span style="color: #A6E22E;">tr</span>>
</<span style="color: #A6E22E;">thead</span>>
...
</<span style="color: #A6E22E;">table</span>>
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline15">
<h3 id="orgheadline15">add #example CSS id to table</h3>
<div class="org-src-container">
<pre class="src src-html"><<span style="color: #A6E22E;">table</span> <span style="color: #FD971F;">width</span>=<span style="color: #E6DB74;">"80%"</span> <span style="color: #FD971F;">id</span>=<span style="color: #E6DB74;">"example-datatable"</span>>
<<span style="color: #A6E22E;">thead</span>>
<<span style="color: #A6E22E;">tr</span>>
[% FOREACH field IN fields %]
<<span style="color: #A6E22E;">th</span>>[% field %]</<span style="color: #A6E22E;">th</span>>
[% END %]
</<span style="color: #A6E22E;">tr</span>>
</<span style="color: #A6E22E;">thead</span>>
...
</<span style="color: #A6E22E;">table</span>>
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline16">
<h3 id="orgheadline16">Demo 02</h3>
<p>
<a href="http://localhost:5000/demo02">http://localhost:5000/demo02</a>
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline17">
<h3 id="orgheadline17">Pros and Cons of hand coded html tables with DataTables</h3>
<ul>
<li>pros:
<ul>
<li>very configurabe, you can generate the HTML table just how you like it.</li>
<li>easy to give rows and columns custom CSS IDs and classes</li>
</ul></li>
<li>cons:
<ul>
<li>not very reusable, you have to hand code each each report</li>
<li>changes to data structure may require updates to the view</li>
</ul></li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline23">
<h2 id="orgheadline23">using JSON with DataTables</h2>
<ul>
<li>build the HTML table header in javascript</li>
<li>pass in a URL that returns JSON to DataTables</li>
<li>DataTables retrieves the data and fills the table.</li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline19">
<h3 id="orgheadline19">build the table header in JavaScript</h3>
<p>
insert the #tableDiv
</p>
<div class="org-src-container">
<pre class="src src-javascript">$( document ).ready( <span style="color: #F92672;">function</span>( <span style="color: #FD971F;">$</span> ) {
$.ajax({
<span style="color: #E6DB74;">"url"</span>: <span style="color: #E6DB74;">'[% json_data_url %]'</span>,
<span style="color: #E6DB74;">"success"</span>: <span style="color: #F92672;">function</span>(<span style="color: #FD971F;">json</span>) {
<span style="color: #F92672;">var</span> <span style="color: #FD971F;">tableHeaders</span> = <span style="color: #E6DB74;">''</span>;
$.each(json.columns, <span style="color: #F92672;">function</span>(<span style="color: #FD971F;">i</span>, <span style="color: #FD971F;">val</span>){
tableHeaders += <span style="color: #E6DB74;">"<th>"</span> + val.data + <span style="color: #E6DB74;">"</th>"</span>;
});
$(<span style="color: #E6DB74;">"#tableDiv"</span>).html(
<span style="color: #E6DB74;">'<table id="displayTable" \</span>
<span style="color: #E6DB74;"> class="display compact" \</span>
<span style="color: #E6DB74;"> cellspacing="0"><thead><tr>'</span>
+ tableHeaders + <span style="color: #E6DB74;">'</tr></thead></table>'</span>);
$(<span style="color: #E6DB74;">'#displayTable'</span>).DataTable(json);
},
<span style="color: #E6DB74;">"dataType"</span>: <span style="color: #E6DB74;">"json"</span>
});
});
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline20">
<h3 id="orgheadline20">build a json route</h3>
<p>
Include the columns you want to render and the results from the query
</p>
<div class="org-src-container">
<pre class="src src-perl">get <span style="color: #E6DB74;">'/api/demo03'</span> => <span style="color: #F92672;">sub</span> {
<span style="color: #75715E;"># </span><span style="color: #75715E;">return query as JSON</span>
<span style="color: #F92672;">my</span> <span style="color: #FD971F;">$sth</span> = database->prepare(
<span style="color: #E6DB74;">'select * from invoices'</span>,
);
$sth->execute() <span style="color: #66D9EF;">or</span> <span style="color: #F92672;">die</span> $sth->errstr;
<span style="color: #F92672;">my</span> <span style="color: #FD971F;">$invoices</span> = $sth->fetchall_arrayref({});
send_as <span style="color: #E6DB74;">JSON</span> => { <span style="color: #E6DB74;">columns</span> => [
{ <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'InvoiceId'</span>},
{ <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'InvoiceDate'</span>},
{ <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'CustomerId'</span> },
{ <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'BillingAddress'</span>}
],
<span style="color: #E6DB74;">data</span> => $invoices,
};
};
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline21">
<h3 id="orgheadline21">Demo 03</h3>
<p>
<a href="http://localhost:5000/demo03">http://localhost:5000/demo03</a>
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline22">
<h3 id="orgheadline22">Pros and Cons</h3>
<ul>
<li>pros
<ul>
<li>very easy to reuse code</li>
<li>page response feels faster for the user</li>
</ul></li>
<li>cons
<ul>
<li>you need an API route to return the data</li>
<li>more difficult to customise your resulting html table</li>
<li>adding custom CSS IDs to rows requires writing javascript</li>
</ul></li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline28">
<h2 id="orgheadline28">styling the table</h2>
<p>
DataTables comes with some predefined CSS
for example, classes for left and right alignment:
</p>
<ul>
<li>dt-left</li>
<li>dt-right</li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline24">
<h3 id="orgheadline24">css classes</h3>
<p>
Add CSS classes to columns
</p>
<div class="org-src-container">
<pre class="src src-perl">…
send_as <span style="color: #E6DB74;">JSON</span> => { <span style="color: #E6DB74;">columns</span> => [
{ <span style="color: #E6DB74;">className</span> => <span style="color: #E6DB74;">'dt-right'</span>, <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'InvoiceId'</span>, },
{ <span style="color: #E6DB74;">className</span> => <span style="color: #E6DB74;">'dt-left'</span>, <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'InvoiceDate'</span>, },
{ <span style="color: #E6DB74;">className</span> => <span style="color: #E6DB74;">'dt-right'</span>, <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'CustomerId'</span>, },
{ <span style="color: #E6DB74;">className</span> => <span style="color: #E6DB74;">'dt-left'</span>, <span style="color: #E6DB74;">data</span> => <span style="color: #E6DB74;">'BillingAddress'</span>,
<span style="color: #E6DB74;">title</span> => <span style="color: #E6DB74;">'Billing Address'</span>}
],
<span style="color: #E6DB74;">data</span> => $invoices,
};
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline25">
<h3 id="orgheadline25">Demo 04</h3>
<p>
<a href="http://localhost:5000/demo04">http://localhost:5000/demo04</a>
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline26">
<h3 id="orgheadline26">Other columns properties</h3>
<p>
columns has many other properties that can be useful
</p>
<ul>
<li>name: Descriptive name for the column</li>
<li>title: Column title</li>
<li>visible: enable or disable display of this column</li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline27">
<h3 id="orgheadline27">problem with this approach</h3>
<p>
formatting creeping into the data view
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline38">
<h2 id="orgheadline38">table export options</h2>
<div class="outline-text-2" id="text-orgheadline38">
</div><div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline29">
<h3 id="orgheadline29">Users are never satisfied</h3>
<ul>
<li>Can I export it to Excel?</li>
<li>DataTables makes that easy</li>
<li>Buttons component.</li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline30">
<h3 id="orgheadline30">CSS and JavaScript for DataTables Buttons</h3>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline31">
<h3 id="orgheadline31">Install pdfmake</h3>
<div class="org-src-container">
<pre class="src src-bash"><span style="color: #F92672;">cd</span> MyApp/public
bower install pdfmake
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline32">
<h3 id="orgheadline32">add the DataTables Buttons css</h3>
<div class="org-src-container">
<pre class="src src-html"><<span style="color: #A6E22E;">link</span> <span style="color: #FD971F;">rel</span>=<span style="color: #E6DB74;">"stylesheet"</span>
<span style="color: #FD971F;">type</span>=<span style="color: #E6DB74;">"text/css"</span>
<span style="color: #FD971F;">href</span>=<span style="color: #E6DB74;">"https://cdn.datatables.net/buttons/1.1.1/css/buttons.dataTables.min.css"</span>>
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline33">
<h3 id="orgheadline33">add the JavaScript</h3>
<div class="org-src-container">
<pre class="src src-html"><<span style="color: #A6E22E;">script</span> <span style="color: #FD971F;">src</span>=<span style="color: #E6DB74;">"/javascripts/buttons.html5.min.js"</span>></<span style="color: #A6E22E;">script</span>>
<<span style="color: #A6E22E;">script</span> <span style="color: #FD971F;">src</span>=<span style="color: #E6DB74;">"/javascripts/buttons.print.min.js"</span>></<span style="color: #A6E22E;">script</span>>
<<span style="color: #A6E22E;">script</span> <span style="color: #FD971F;">src</span>='/bower_components/pdfmake/build/pdfmake.min.js'></<span style="color: #A6E22E;">script</span>>
<<span style="color: #A6E22E;">script</span> <span style="color: #FD971F;">src</span>='/bower_components/pdfmake/build/vfs_fonts.js'></<span style="color: #A6E22E;">script</span>>
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline34">
<h3 id="orgheadline34">add buttons option to our javascript</h3>
<p>
Add this to our JavaScript from before
</p>
<div class="org-src-container">
<pre class="src src-javascript">json.dom = <span style="color: #E6DB74;">'Blfrtip'</span>; <span style="color: #75715E;">// </span><span style="color: #75715E;">customise the table</span>
json.buttons = [<span style="color: #E6DB74;">'copy'</span>,
<span style="color: #E6DB74;">'csv'</span>,
<span style="color: #E6DB74;">'excel'</span>,
{ extend: <span style="color: #E6DB74;">'pdfHtml5'</span>,
text: <span style="color: #E6DB74;">'PDF'</span>,
orientation: <span style="color: #E6DB74;">'landscape'</span>,
pageSize: <span style="color: #E6DB74;">'A4'</span>,
download: <span style="color: #E6DB74;">'download'</span>,
filename: <span style="color: #E6DB74;">'*'</span>,
extension: <span style="color: #E6DB74;">'pdf'</span>
},
<span style="color: #E6DB74;">'print'</span>];
</pre>
</div>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline35">
<h3 id="orgheadline35">Demo 05</h3>
<p>
<a href="http://localhost:5000/demo05">http://localhost:5000/demo05</a>
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline36">
<h3 id="orgheadline36">As yet unresolved challenges</h3>
<ul>
<li>move formatting and options out of api route</li>
<li>formatting dates like '2009-01-01 00:00:00'</li>
<li>rounding floats to fixed decimal places</li>
</ul>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
<section>
<section id="slide-orgheadline37">
<h3 id="orgheadline37">thanks for listening</h3>
<p>
Dancer2 with DataTables, in house business reporting.
</p>
<div class="slide-footer">Jason Lewis - @jasonblewis</div>
</section>
</section>
</div>
</div>
<script src="/lib/js/head.min.js"></script>
<script src="/js/reveal.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: false,
center: true,
slideNumber: 'c',
rollingLinks: false,
keyboard: true,
overview: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'fade', // default/cube/page/concave/zoom/linear/fade/none
transitionSpeed: 'default',
multiplex: {
secret: '', // null if client
id: '', // id, obtained from socket.io server
url: '' // Location of socket.io server
},
// 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/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>