-
Notifications
You must be signed in to change notification settings - Fork 0
/
b2stub-devcon2015.html
1130 lines (992 loc) · 32.6 KB
/
b2stub-devcon2015.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
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<meta charset="utf-8">
<title>Using the Building Block Starter Project for Rapid Development</title>
<!-- Your Slides -->
<!-- One section is one slide -->
<section class="title-slide">
<!-- This is the first slide -->
<h1>All the Ducks' B2 Template</h1>
<footer>by <a href="https://www.alltheducks.com/about-us.html">Shane Argo and Wiley Fuller</a></footer>
</section>
<section>
<h3>What we're going to cover today</h3>
<ul>
<li>Why are we here?</li>
<li>Setting up for today's workshop.</li>
<li>Common issues in Building Block construction.</li>
<li>How we address these issues in our building blocks.</li>
<li>Writing a building block starting with the <a href="https://github.com/AllTheDucks/atd-b2-stub">ATD B2 Stub</a>.</li>
</ul>
</section>
<section>
<h3>Why are we here?</h3>
<p>We're going to do a demo. Starting from scratch, to deploying a building block
with Configuration and settings page, Stripes (MVC), Spring Beans (Dependency Injection),
Language Pack, Security Entitlements, and a Bb Course Tool.</p>
<p>Don't worry about following along on your computer right now, this is just to show you
how quickly it can be done.</p>
<p>Other things like schema.xml, course event listeners and rendering hooks can be added
by simply uncommenting some stuff.</p>
</section>
<section>
<blockquote class="nonquote"><<Insert mind-blowing demo here>></blockquote>
</section>
<section>
<h3>Setting up - USB Drives</h3>
<ul>
<li>Vagrant Installer</li>
<li>Bb Vagrant Image</li>
<li>JDK</li>
<li>ATD B2 Stub Project</li>
<li>IDEA (trial)</li>
<li>Sublime (trial)</li>
<li>Git</li>
<li>Atlassian SourceTree (GUI Git)</li>
</ul>
</section>
<section>
<h3>Common issues in Building Block construction</h3>
<ul>
<li>Development Environment</li>
<li>Bootstrapping, versioning, and config management</li>
<li>Separating Presentation logic from business logic</li>
<li>Configuration</li>
<li>Database Management (schema.xml)</li>
<li>Scheduled tasks</li>
<li>Testing</li>
<li>Language Packs / l10n</li>
</ul>
</section>
<section>
<h3>Development Environment</h3>
<ul>
<li>Operating System</li>
<li>Build Tool</li>
<li>IDE/Editor</li>
<li>Version Control</li>
<li>Collaboration</li>
<li>Blackboard Development Tools</li>
</ul>
</section>
<section>
<h3>Operating System</h3>
<ul>
<li>Windows</li>
<li class="preferred">Linux</li>
<li class="preferred">OSX</li>
<li>???</li>
</ul>
</section>
<section>
<h3>Build Tool</h3>
<ul>
<li class="preferred">Gradle :)</li>
<li>Maven</li>
<li>Ivy</li>
<li>ANT :(</li>
<li class="disliked">IDE Build :'(</li>
</ul>
</section>
<section>
<h3>IDE</h3>
<ul>
<li class="preferred">IntelliJ IDEA</li>
<li>Netbeans</li>
<li class="disliked">Eclipse :(</li>
<li class="preferred">Sublime Text</li>
<li>Atom</li>
<li>Notepad++</li>
<li>Vim/Emacs</li>
<li>Notepad</li>
<li>echo "my code" > Example.java</li>
</ul>
<p>If you are using Gradle, it's nice to have an IDE that supports it. (IDEA, Netbeans, Eclipse?)</p>
</section>
<section>
<h3>Version Control</h3>
<ul>
<li class="preferred">Git</li>
<li>SVN</li>
<li class="disliked">Team Foundation Server / Visual SourceSafe</li>
</ul>
</section>
<section>
<h3>Collaboration</h3>
<ul>
<li>Slack</li>
<li>Chrome Remote Desktop</li>
<li>Hangouts</li>
<li>Optus Unlimited Phone Plan</li>
</ul>
</section>
<section>
<h3>Blackboard Development Tools</h3>
<ul>
<li>Virtual Box</li>
<li>Vagrant</li>
<li>Bb Development Image</li>
<li>Starting Block / B2Deploy (Ant deploy task - works in Gradle)</li>
<li>pgAdmin</li>
<li>SSH - grep / less / tail</li>
</ul>
</section>
<section>
<blockquote class="nonquote">Let's wash this little pig.</blockquote>
</section>
<section>
<h3>So, how is this going to work?</h3>
<ul>
<li>We're going to be creating this: <a href="https://github.com/AllTheDucks/atd-enabler">https://github.com/AllTheDucks/atd-enabler</a>
<ul>
<li>This project has a branch for each step of this presentation.</li>
<li>At the top of each slide is a link to the whole file at that step in Github.</li>
</ul>
</li>
<li>This presentation is available at: <a href="https://alltheducks.github.io/atd-presentations/b2stub-devcon2015.html">https://alltheducks.github.io/atd-presentations/b2stub-devcon2015.html</a></li>
</ul>
</section>
<section>
<h3>1. Clone the stub.</h3>
<ol>
<li>Create a project directory</li>
<li>git clone https://github.com/AllTheDucks/atd-b2-stub</li>
<li>Change into project directory</li>
<li>./gradlew initb2 (not in Gradle daemon mode)</li>
</ol>
</section>
<section>
<h3>2. Test deploy.</h3>
<ol>
<li>./gradlew deployb2</li>
<li>Login to Blackboard, check the settings page works.</li>
</ol>
</section>
<section>
<h3>3. Create MVC Controller (Stripes action).</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/3/src/main/java/com/alltheducks/enabler/stripes/EnablerAction.java">src/main/java/com/alltheducks/enabler/stripes/EnablerAction.java</a></p>
<pre><code class="java">package com.alltheducks.enabler.stripes;
import net.sourceforge.stripes.action.*;
import com.alltheducks.bb.stripes.BlackboardActionBeanContext;
@EntitlementRestrictions(entitlements = "atd.enabler.admin.MODIFY", errorPage = "error.jsp")
public class EnablerAction implements ActionBean {
private BlackboardActionBeanContext context;
@DefaultHandler
public Resolution displayEnabler() {
return new ForwardResolution("/WEB-INF/jsp/enabler.jsp");
}
public ActionBeanContext getContext() {
return context;
}
public void setContext(ActionBeanContext context) {
this.context = (BlackboardActionBeanContext)context;
}
}
</code></pre>
</section>
<section>
<h3>4. Create MVC View (JSP).</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/4/src/main/webapp/WEB-INF/jsp/enabler.jsp">src/main/webapp/WEB-INF/jsp/enabler.jsp</a></p>
<pre><code class="xml"><!DOCTYPE html>
<%@ taglib uri="/bbNG" prefix="bbNG" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:message var="courseStepTitle" key="enabler-app.enabler.courseStep.title" />
<fmt:message var="batchUidLabel" key="enabler-app.enabler.courseStep.batchUid.label" />
<bbNG:genericPage bodyClass="normalBackground"
navItem="atd-enabler-app-nav-enabler">
<stripes:form beanclass="com.alltheducks.enabler.stripes.EnablerAction">
<input type="hidden" name="displayCourseStatus"/>
<bbNG:dataCollection>
<bbNG:step title="${courseStepTitle}">
<bbNG:dataElement isRequired="true" label="${batchUidLabel}">
<stripes:text name="batchUid"></stripes:text>
<stripes:errors field="courseId"></stripes:errors>
</bbNG:dataElement>
</bbNG:step>
<bbNG:stepSubmit />
</bbNG:dataCollection>
</stripes:form>
</bbNG:genericPage>
</code></pre>
</section>
<section>
<h3>5. Define Language Pack Keys.</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/5/src/main/webapp/WEB-INF/bundles/bb-manifest-en_GB.properties">src/webapp/WEB-INF/bundles/bb-manifest-en_GB.properties</a></p>
<p>Add these keys:</p>
<pre><code>enabler-app.enabler.courseStep.title=Select Course
enabler-app.enabler.courseStep.batchUid.label=Batch Uid
</code></pre>
</section>
<section>
<h3>6. Register the tool.</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/6/src/main/webapp/WEB-INF/bb-manifest.xml">src/webapp/WEB-INF/bb-manifest.xml</a></p>
<p>In the "enabler-app" application:</p>
<pre><code class="xml"><link>
<type value="system_tool"/>
<handle value="enablersys"/>
<name value="plugin.link.enabler.name"/>
<navhandle value="" />
<description value="plugin.link.enabler.description"/>
<url value="Enabler.action"/>
<entitlement-uid value="atd.enabler.admin.MODIFY" />
</link>
</code></pre>
</section>
<section>
<h3>7. Test deploy, again.</h3>
<ol>
<li>./gradlew deployb2</li>
<li>Login to Blackboard, naviage to System Admin.</li>
<li>Look for "Course Enabler" tool.</li>
</ol>
</section>
<section>
<blockquote class="nonquote">Now to read the status of the course.</blockquote>
</section>
<section>
<h3>8. Add another view (JSP) for the status...</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/8/src/main/webapp/WEB-INF/jsp/status.jsp" />src/main/webapp/WEB-INF/jsp/status.jsp</a></p>
<pre style="margin-top: 0;"><code class="xml" style="font-size: 10px; margin-top: 0;"><!DOCTYPE html>
<%@ taglib uri="/bbNG" prefix="bbNG" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:message var="statusTitle" key="enabler-app.enabler.statusStep.title" />
<fmt:message var="statusLabel" key="enabler-app.enabler.statusStep.status.label" />
<fmt:message var="batchUidLabel" key="enabler-app.enabler.statusStep.batchUid.label" />
<fmt:message var="courseNameLabel" key="enabler-app.enabler.statusStep.courseName.label" />
<bbNG:genericPage bodyClass="normalBackground"
navItem="atd-enabler-app-nav-enabler">
<stripes:form beanclass="com.alltheducks.enabler.stripes.EnablerAction">
<!-- Don't use stripes:hidden here, otherwise stripes looks for the bean field with that name. -->
<input type="hidden" name="setCourseStatus"/>
<bbNG:dataCollection>
<bbNG:step title="${statusTitle}">
<bbNG:dataElement label="${courseNameLabel}">
${actionBean.courseName}
</bbNG:dataElement>
<bbNG:dataElement label="${batchUidLabel}">
${actionBean.batchUid}
</bbNG:dataElement>
<bbNG:dataElement isRequired="true" label="${statusLabel}">
<stripes:checkbox name="courseEnabled"></stripes:checkbox>
</bbNG:dataElement>
</bbNG:step>
<bbNG:stepSubmit />
</bbNG:dataCollection>
</stripes:form>
</bbNG:genericPage>
</code></pre>
</section>
<section>
<h3>9. ... and update the controller.</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/9/src/main/java/com/alltheducks/enabler/stripes/EnablerAction.java">src/main/java/com/alltheducks/enabler/stripes/EnablerAction.java</a></p>
<pre><code class="java" style="font-size:10px;">private boolean courseEnabled;
private String batchUid;
private String courseName;
...
public Resolution displayCourseStatus() throws PersistenceException {
CourseSiteLoader courseLoader = CourseSiteDbLoader.Default.getInstance();
CourseSite cs = courseLoader.load(batchUid);
IAdminObject.RowStatus status = cs.getRowStatus();
courseEnabled = status.equals(IAdminObject.RowStatus.ENABLED);
courseName = cs.getTitle();
return new ForwardResolution("/WEB-INF/jsp/status.jsp");
}
public boolean isCourseEnabled() {
return courseEnabled;
}
public void setCourseEnabled(boolean courseEnabled) {
this.courseEnabled = courseEnabled;
}
public String getBatchUid() {
return batchUid;
}
public void setBatchUid(String batchUid) {
this.batchUid = batchUid;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
...
</code></pre>
</section>
<section>
<h3>10. And, dont forget the new language pack keys.</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/10/src/main/webapp/WEB-INF/bundles/bb-manifest-en_GB.properties">src/webapp/WEB-INF/bundles/bb-manifest-en_GB.properties</a></p>
<p>Add these keys:</p>
<pre><code>enabler-app.enabler.statusStep.title=Course Status
enabler-app.enabler.statusStep.status.label=Enabled
enabler-app.enabler.statusStep.batchUid.label=Batch Uid
enabler-app.enabler.statusStep.courseName.label=Course Name
</code></pre>
</section>
<section>
<h3>11. Test deploy, again, again.</h3>
<ol>
<li>./gradlew deployb2</li>
<li>Login to Blackboard, naviage to System Admin.</li>
<li>Look for "Course Enabler" tool.</li>
<li>Type in a course BatchUid and submit. (You may need to create a course first)</li>
</ol>
</section>
<section>
<blockquote class="nonquote">Finally, we need to persit changes to the status.</blockquote>
</section>
<section>
<h3>12. A new action method.</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/12/src/main/java/com/alltheducks/enabler/stripes/EnablerAction.java">src/main/java/com/alltheducks/enabler/stripes/EnablerAction.java</a></p>
<pre><code class="java">...
public Resolution saveCourseStatus() throws PersistenceException, ConstraintViolationException, ValidationException {
CourseSiteLoader courseLoader = CourseSiteDbLoader.Default.getInstance();
CourseSitePersister coursePersister = CourseSiteDbPersister.Default.getInstance();
CourseSite cs = courseLoader.load(batchUid);
if (courseEnabled) {
cs.setRowStatus(IAdminObject.RowStatus.ENABLED);
} else {
cs.setRowStatus(IAdminObject.RowStatus.DISABLED);
}
coursePersister.save(cs);
String destUrl = InlineReceiptUtil.addSuccessReceiptToUrl("Enabler.action",
getMessage("enabler-app.enabler.saveStatus.success.message", cs.getTitle()));
return new RedirectResolution(destUrl, false);
}
...
private String getMessage(String key, String... args) {
PlugInManager pluginMgr = PlugInManagerFactory.getInstance();
PlugIn plugin = pluginMgr.getPlugIn("atd", "enabler");
BundleManager bm = BundleManagerFactory.getInstance();
BbResourceBundle bundle = bm.getPluginBundle(plugin.getId());
return bundle.getString(key, args);
}
...
</code></pre>
</section>
<section>
<h3>13. And the language pack key!</h3>
<p class="path"><a href="https://github.com/AllTheDucks/atd-enabler/blob/step/13/src/main/webapp/WEB-INF/bundles/bb-manifest-en_GB.properties">src/webapp/WEB-INF/bundles/bb-manifest-en_GB.properties</a></p>
<p>Add this key:</p>
<pre><code>enabler-app.enabler.saveStatus.success.message=Saved Course '{0}'
</code></pre>
</section>
<section>
<h3>14. Finally... deploy.</h3>
<ol>
<li>./gradlew deployb2</li>
<li>Login to Blackboard, naviage to System Admin.</li>
<li>Look for "Course Enabler" tool.</li>
<li>Type in a course BatchUid and submit. (You may need to create a course first)</li>
<li>Tick or untick the status checkbox and submit.</li>
</ol>
</section>
<section>
<blockquote class="nonquote">Take the rest of the week off.</blockquote>
</section>
<!-- Your Style -->
<!-- Define the style of your presentation -->
<!-- Maybe a font from http://www.google.com/webfonts ? -->
<link href='//fonts.googleapis.com/css?family=Oswald' rel='stylesheet'>
<style>
html, .view body { background-color: black; counter-reset: slideidx; }
body, .view section { background-color: white; border-radius: 12px }
/* A section is a slide. It's size is 800x600, and this will never change */
section, .view head > title {
/* The font from Google */
font-family: 'Oswald', arial, serif;
font-size: 30px;
}
.view section:after {
counter-increment: slideidx;
content: counter(slideidx, decimal-leading-zero);
position: absolute; bottom: -80px; right: 100px;
color: white;
}
.view head > title {
color: white;
text-align: center;
margin: 1em 0 1em 0;
}
h1, h2 {
margin-top: 200px;
text-align: center;
font-size: 80px;
}
h3 {
margin: 40px 0 50px 50px
}
ul {
margin: 50px 200px;
}
li > ul {
margin: 15px 50px;
}
p {
margin: 75px;
font-size: 50px;
}
blockquote {
height: 100%;
background-color: black;
color: white;
font-size: 60px;
padding: 50px;
}
blockquote:before {
content: open-quote;
}
blockquote:after {
content: close-quote;
}
/* Figures are displayed full-page, with the caption
on top of the image/video */
figure {
background-color: black;
width: 100%;
height: 100%;
}
figure > * {
position: absolute;
}
figure > img, figure > video {
width: 100%; height: 100%;
}
figcaption {
margin: 70px;
font-size: 50px;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
padding: 40px;
text-align: right;
background-color: #F3F4F8;
border-top: 1px solid #CCC;
}
/* Transition effect */
/* Feel free to change the transition effect for original
animations. See here:
https://developer.mozilla.org/en/CSS/CSS_transitions
How to use CSS3 Transitions: */
section {
-moz-transition: left 400ms linear 0s;
-webkit-transition: left 400ms linear 0s;
-ms-transition: left 400ms linear 0s;
transition: left 400ms linear 0s;
background-image: url("images/image6.png");
background-size: cover;
}
.view section {
-moz-transition: none;
-webkit-transition: none;
-ms-transition: none;
transition: none;
}
.view section[aria-selected] {
border: 5px red solid;
}
/* Before */
section { left: -150%; }
/* Now */
section[aria-selected] { left: 0; }
/* After */
section[aria-selected] ~ section { left: +150%; }
/* Incremental elements */
/* By default, visible */
.incremental > * { opacity: 1; }
/* The current item */
.incremental > *[aria-selected] { opacity: 1; }
/* The items to-be-selected */
.incremental > *[aria-selected] ~ * { opacity: 0; }
/* The progressbar, at the bottom of the slides, show the global
progress of the presentation. */
#progress-bar {
height: 2px;
background: #AAA;
}
.title-slide {
background-image: url("images/image5.png");
background-size: cover;
color:white;
}
.title-slide footer {
color: #333;
}
</style>
<!-- {{{{ dzslides core
#
#
# __ __ __ . __ ___ __
# | \ / /__` | | | \ |__ /__`
# |__/ /_ .__/ |___ | |__/ |___ .__/ core :€
#
#
# The following block of code is not supposed to be edited.
# But if you want to change the behavior of these slides,
# feel free to hack it!
#
-->
<div id="progress-bar"></div>
<link rel="stylesheet" href="highlight/styles/default.css">
<script src="highlight/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<!-- Default Style -->
<style>
* { margin: 0; padding: 0; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
[role="note"] { display: none; }
body {
width: 1066px; height: 600px;
/*width: 100%; height: 100%;*/
margin-left: -533px; margin-top: -300px;
position: absolute; top: 50%; left: 50%;
overflow: hidden;
display: none;
}
.view body {
position: static;
margin: 0; padding: 0;
width: 100%; height: 100%;
display: inline-block;
overflow: visible; overflow-x: hidden;
/* undo Dz.onresize */
transform: none !important;
-moz-transform: none !important;
-webkit-transform: none !important;
-o-transform: none !important;
-ms-transform: none !important;
}
.view head, .view head > title { display: block }
section {
position: absolute;
pointer-events: none;
width: 100%; height: 100%;
}
.view section {
pointer-events: auto;
position: static;
width: 800px; height: 600px;
margin: -150px -200px;
float: left;
transform: scale(.4);
-moz-transform: scale(.4);
-webkit-transform: scale(.4);
-o-transform: scale(.4);
-ms-transform: scale(.4);
}
.view section > * { pointer-events: none; }
section[aria-selected] { pointer-events: auto; }
html { overflow: hidden; }
html.view { overflow: visible; }
body.loaded { display: block; }
.incremental {visibility: hidden; }
.incremental[active] {visibility: visible; }
#progress-bar{
bottom: 0;
position: absolute;
-moz-transition: width 400ms linear 0s;
-webkit-transition: width 400ms linear 0s;
-ms-transition: width 400ms linear 0s;
transition: width 400ms linear 0s;
}
.view #progress-bar {
display: none;
}
</style>
<style>
.preferred {
color: #009900;
font-weight: bold;
}
.disliked {
color :#990000;
}
p {
font-size: 25px;
margin: 30px 50px;
}
.nonquote {
text-align: center;
padding-top: 200px;
}
.nonquote::before {
content: none;
}
.nonquote::after {
content: none;
}
ol {
margin: 75px;
list-style: lower-alpha inside;
}
ol > li {
margin: 10px 0;
}
code {
font-size: 12px;
margin: 10px 50px;
}
.hljs {
background: none;
}
.path {
margin-top: 0;
margin-bottom: 0;
}
</style>
<script>
var Dz = {
remoteWindows: [],
idx: -1,
step: 0,
html: null,
slides: null,
progressBar : null,
params: {
autoplay: "1"
}
};
Dz.init = function() {
document.body.className = "loaded";
this.slides = Array.prototype.slice.call($$("body > section"));
this.progressBar = $("#progress-bar");
this.html = document.body.parentNode;
this.setupParams();
this.onhashchange();
this.setupTouchEvents();
this.onresize();
this.setupView();
}
Dz.setupParams = function() {
var p = window.location.search.substr(1).split('&');
p.forEach(function(e, i, a) {
var keyVal = e.split('=');
Dz.params[keyVal[0]] = decodeURIComponent(keyVal[1]);
});
// Specific params handling
if (!+this.params.autoplay)
$$.forEach($$("video"), function(v){ v.controls = true });
}
Dz.onkeydown = function(aEvent) {
// Don't intercept keyboard shortcuts
if (aEvent.altKey
|| aEvent.ctrlKey
|| aEvent.metaKey
|| aEvent.shiftKey) {
return;
}
if ( aEvent.keyCode == 37 // left arrow
|| aEvent.keyCode == 38 // up arrow
|| aEvent.keyCode == 33 // page up
) {
aEvent.preventDefault();
this.back();
}
if ( aEvent.keyCode == 39 // right arrow
|| aEvent.keyCode == 40 // down arrow
|| aEvent.keyCode == 34 // page down
) {
aEvent.preventDefault();
this.forward();
}
if (aEvent.keyCode == 35) { // end
aEvent.preventDefault();
this.goEnd();
}
if (aEvent.keyCode == 36) { // home
aEvent.preventDefault();
this.goStart();
}
if (aEvent.keyCode == 32) { // space
aEvent.preventDefault();
this.toggleContent();
}
if (aEvent.keyCode == 70) { // f
aEvent.preventDefault();
this.goFullscreen();
}
if (aEvent.keyCode == 79) { // o
aEvent.preventDefault();
this.toggleView();
}
}
/* Touch Events */
Dz.setupTouchEvents = function() {
var orgX, newX;
var tracking = false;
var db = document.body;
db.addEventListener("touchstart", start.bind(this), false);
db.addEventListener("touchmove", move.bind(this), false);
function start(aEvent) {
aEvent.preventDefault();
tracking = true;
orgX = aEvent.changedTouches[0].pageX;
}
function move(aEvent) {
if (!tracking) return;
newX = aEvent.changedTouches[0].pageX;
if (orgX - newX > 100) {
tracking = false;
this.forward();
} else {
if (orgX - newX < -100) {
tracking = false;
this.back();
}
}
}
}
Dz.setupView = function() {
document.body.addEventListener("click", function ( e ) {
if (!Dz.html.classList.contains("view")) return;
if (!e.target || e.target.nodeName != "SECTION") return;
Dz.html.classList.remove("view");
Dz.setCursor(Dz.slides.indexOf(e.target) + 1);
}, false);
}
/* Adapt the size of the slides to the window */
Dz.onresize = function() {
var db = document.body;
var sx = db.clientWidth / window.innerWidth;
var sy = db.clientHeight / window.innerHeight;
var transform = "scale(" + (1/Math.max(sx, sy)) + ")";
db.style.MozTransform = transform;
db.style.WebkitTransform = transform;
db.style.OTransform = transform;
db.style.msTransform = transform;
db.style.transform = transform;
}
Dz.getNotes = function(aIdx) {
var s = $("section:nth-of-type(" + aIdx + ")");
var d = s.$("[role='note']");
return d ? d.innerHTML : "";
}
Dz.onmessage = function(aEvent) {
var argv = aEvent.data.split(" "), argc = argv.length;
argv.forEach(function(e, i, a) { a[i] = decodeURIComponent(e) });
var win = aEvent.source;
if (argv[0] === "REGISTER" && argc === 1) {
this.remoteWindows.push(win);
this.postMsg(win, "REGISTERED", document.title, this.slides.length);
this.postMsg(win, "CURSOR", this.idx + "." + this.step);
return;
}
if (argv[0] === "BACK" && argc === 1)
this.back();
if (argv[0] === "FORWARD" && argc === 1)
this.forward();
if (argv[0] === "START" && argc === 1)
this.goStart();
if (argv[0] === "END" && argc === 1)
this.goEnd();
if (argv[0] === "TOGGLE_CONTENT" && argc === 1)
this.toggleContent();
if (argv[0] === "SET_CURSOR" && argc === 2)
window.location.hash = "#" + argv[1];
if (argv[0] === "GET_CURSOR" && argc === 1)
this.postMsg(win, "CURSOR", this.idx + "." + this.step);
if (argv[0] === "GET_NOTES" && argc === 1)
this.postMsg(win, "NOTES", this.getNotes(this.idx));
}
Dz.toggleContent = function() {
// If a Video is present in this new slide, play it.
// If a Video is present in the previous slide, stop it.
var s = $("section[aria-selected]");
if (s) {
var video = s.$("video");
if (video) {
if (video.ended || video.paused) {
video.play();
} else {
video.pause();
}
}
}
}
Dz.setCursor = function(aIdx, aStep) {
// If the user change the slide number in the URL bar, jump
// to this slide.
aStep = (aStep != 0 && typeof aStep !== "undefined") ? "." + aStep : ".0";
window.location.hash = "#" + aIdx + aStep;
}
Dz.onhashchange = function() {
var cursor = window.location.hash.split("#"),
newidx = 1,
newstep = 0;
if (cursor.length == 2) {
newidx = ~~cursor[1].split(".")[0];
newstep = ~~cursor[1].split(".")[1];
if (newstep > Dz.slides[newidx - 1].$$('.incremental > *').length) {
newstep = 0;
newidx++;
}
}
this.setProgress(newidx, newstep);
if (newidx != this.idx) {
this.setSlide(newidx);
}
if (newstep != this.step) {
this.setIncremental(newstep);
}
for (var i = 0; i < this.remoteWindows.length; i++) {
this.postMsg(this.remoteWindows[i], "CURSOR", this.idx + "." + this.step);
}
}
Dz.back = function() {
if (this.idx == 1 && this.step == 0) {
return;
}
if (this.step == 0) {
this.setCursor(this.idx - 1,
this.slides[this.idx - 2].$$('.incremental > *').length);
} else {
this.setCursor(this.idx, this.step - 1);
}
}
Dz.forward = function() {
if (this.idx >= this.slides.length &&
this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {
return;
}
if (this.step >= this.slides[this.idx - 1].$$('.incremental > *').length) {
this.setCursor(this.idx + 1, 0);
} else {
this.setCursor(this.idx, this.step + 1);
}
}
Dz.goStart = function() {
this.setCursor(1, 0);
}
Dz.goEnd = function() {
var lastIdx = this.slides.length;
var lastStep = this.slides[lastIdx - 1].$$('.incremental > *').length;
this.setCursor(lastIdx, lastStep);
}
Dz.toggleView = function() {
this.html.classList.toggle("view");
if (this.html.classList.contains("view")) {
$("section[aria-selected]").scrollIntoView(true);
}
}
Dz.setSlide = function(aIdx) {
this.idx = aIdx;
var old = $("section[aria-selected]");
var next = $("section:nth-of-type("+ this.idx +")");
if (old) {
old.removeAttribute("aria-selected");
var video = old.$("video");