code_zauker 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1000 @@
1
+ Licensed under the tri-license MPL/LGPL/GPL.
2
+
3
+ MOZILLA PUBLIC LICENSE
4
+ Version 1.1
5
+
6
+ ---------------
7
+
8
+ 1. Definitions.
9
+
10
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
11
+ Covered Code available to a third party.
12
+
13
+ 1.1. "Contributor" means each entity that creates or contributes to
14
+ the creation of Modifications.
15
+
16
+ 1.2. "Contributor Version" means the combination of the Original
17
+ Code, prior Modifications used by a Contributor, and the Modifications
18
+ made by that particular Contributor.
19
+
20
+ 1.3. "Covered Code" means the Original Code or Modifications or the
21
+ combination of the Original Code and Modifications, in each case
22
+ including portions thereof.
23
+
24
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
25
+ accepted in the software development community for the electronic
26
+ transfer of data.
27
+
28
+ 1.5. "Executable" means Covered Code in any form other than Source
29
+ Code.
30
+
31
+ 1.6. "Initial Developer" means the individual or entity identified
32
+ as the Initial Developer in the Source Code notice required by Exhibit
33
+ A.
34
+
35
+ 1.7. "Larger Work" means a work which combines Covered Code or
36
+ portions thereof with code not governed by the terms of this License.
37
+
38
+ 1.8. "License" means this document.
39
+
40
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
41
+ extent possible, whether at the time of the initial grant or
42
+ subsequently acquired, any and all of the rights conveyed herein.
43
+
44
+ 1.9. "Modifications" means any addition to or deletion from the
45
+ substance or structure of either the Original Code or any previous
46
+ Modifications. When Covered Code is released as a series of files, a
47
+ Modification is:
48
+ A. Any addition to or deletion from the contents of a file
49
+ containing Original Code or previous Modifications.
50
+
51
+ B. Any new file that contains any part of the Original Code or
52
+ previous Modifications.
53
+
54
+ 1.10. "Original Code" means Source Code of computer software code
55
+ which is described in the Source Code notice required by Exhibit A as
56
+ Original Code, and which, at the time of its release under this
57
+ License is not already Covered Code governed by this License.
58
+
59
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
60
+ hereafter acquired, including without limitation, method, process,
61
+ and apparatus claims, in any patent Licensable by grantor.
62
+
63
+ 1.11. "Source Code" means the preferred form of the Covered Code for
64
+ making modifications to it, including all modules it contains, plus
65
+ any associated interface definition files, scripts used to control
66
+ compilation and installation of an Executable, or source code
67
+ differential comparisons against either the Original Code or another
68
+ well known, available Covered Code of the Contributor's choice. The
69
+ Source Code can be in a compressed or archival form, provided the
70
+ appropriate decompression or de-archiving software is widely available
71
+ for no charge.
72
+
73
+ 1.12. "You" (or "Your") means an individual or a legal entity
74
+ exercising rights under, and complying with all of the terms of, this
75
+ License or a future version of this License issued under Section 6.1.
76
+ For legal entities, "You" includes any entity which controls, is
77
+ controlled by, or is under common control with You. For purposes of
78
+ this definition, "control" means (a) the power, direct or indirect,
79
+ to cause the direction or management of such entity, whether by
80
+ contract or otherwise, or (b) ownership of more than fifty percent
81
+ (50%) of the outstanding shares or beneficial ownership of such
82
+ entity.
83
+
84
+ 2. Source Code License.
85
+
86
+ 2.1. The Initial Developer Grant.
87
+ The Initial Developer hereby grants You a world-wide, royalty-free,
88
+ non-exclusive license, subject to third party intellectual property
89
+ claims:
90
+ (a) under intellectual property rights (other than patent or
91
+ trademark) Licensable by Initial Developer to use, reproduce,
92
+ modify, display, perform, sublicense and distribute the Original
93
+ Code (or portions thereof) with or without Modifications, and/or
94
+ as part of a Larger Work; and
95
+
96
+ (b) under Patents Claims infringed by the making, using or
97
+ selling of Original Code, to make, have made, use, practice,
98
+ sell, and offer for sale, and/or otherwise dispose of the
99
+ Original Code (or portions thereof).
100
+
101
+ (c) the licenses granted in this Section 2.1(a) and (b) are
102
+ effective on the date Initial Developer first distributes
103
+ Original Code under the terms of this License.
104
+
105
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
106
+ granted: 1) for code that You delete from the Original Code; 2)
107
+ separate from the Original Code; or 3) for infringements caused
108
+ by: i) the modification of the Original Code or ii) the
109
+ combination of the Original Code with other software or devices.
110
+
111
+ 2.2. Contributor Grant.
112
+ Subject to third party intellectual property claims, each Contributor
113
+ hereby grants You a world-wide, royalty-free, non-exclusive license
114
+
115
+ (a) under intellectual property rights (other than patent or
116
+ trademark) Licensable by Contributor, to use, reproduce, modify,
117
+ display, perform, sublicense and distribute the Modifications
118
+ created by such Contributor (or portions thereof) either on an
119
+ unmodified basis, with other Modifications, as Covered Code
120
+ and/or as part of a Larger Work; and
121
+
122
+ (b) under Patent Claims infringed by the making, using, or
123
+ selling of Modifications made by that Contributor either alone
124
+ and/or in combination with its Contributor Version (or portions
125
+ of such combination), to make, use, sell, offer for sale, have
126
+ made, and/or otherwise dispose of: 1) Modifications made by that
127
+ Contributor (or portions thereof); and 2) the combination of
128
+ Modifications made by that Contributor with its Contributor
129
+ Version (or portions of such combination).
130
+
131
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
132
+ effective on the date Contributor first makes Commercial Use of
133
+ the Covered Code.
134
+
135
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
136
+ granted: 1) for any code that Contributor has deleted from the
137
+ Contributor Version; 2) separate from the Contributor Version;
138
+ 3) for infringements caused by: i) third party modifications of
139
+ Contributor Version or ii) the combination of Modifications made
140
+ by that Contributor with other software (except as part of the
141
+ Contributor Version) or other devices; or 4) under Patent Claims
142
+ infringed by Covered Code in the absence of Modifications made by
143
+ that Contributor.
144
+
145
+ 3. Distribution Obligations.
146
+
147
+ 3.1. Application of License.
148
+ The Modifications which You create or to which You contribute are
149
+ governed by the terms of this License, including without limitation
150
+ Section 2.2. The Source Code version of Covered Code may be
151
+ distributed only under the terms of this License or a future version
152
+ of this License released under Section 6.1, and You must include a
153
+ copy of this License with every copy of the Source Code You
154
+ distribute. You may not offer or impose any terms on any Source Code
155
+ version that alters or restricts the applicable version of this
156
+ License or the recipients' rights hereunder. However, You may include
157
+ an additional document offering the additional rights described in
158
+ Section 3.5.
159
+
160
+ 3.2. Availability of Source Code.
161
+ Any Modification which You create or to which You contribute must be
162
+ made available in Source Code form under the terms of this License
163
+ either on the same media as an Executable version or via an accepted
164
+ Electronic Distribution Mechanism to anyone to whom you made an
165
+ Executable version available; and if made available via Electronic
166
+ Distribution Mechanism, must remain available for at least twelve (12)
167
+ months after the date it initially became available, or at least six
168
+ (6) months after a subsequent version of that particular Modification
169
+ has been made available to such recipients. You are responsible for
170
+ ensuring that the Source Code version remains available even if the
171
+ Electronic Distribution Mechanism is maintained by a third party.
172
+
173
+ 3.3. Description of Modifications.
174
+ You must cause all Covered Code to which You contribute to contain a
175
+ file documenting the changes You made to create that Covered Code and
176
+ the date of any change. You must include a prominent statement that
177
+ the Modification is derived, directly or indirectly, from Original
178
+ Code provided by the Initial Developer and including the name of the
179
+ Initial Developer in (a) the Source Code, and (b) in any notice in an
180
+ Executable version or related documentation in which You describe the
181
+ origin or ownership of the Covered Code.
182
+
183
+ 3.4. Intellectual Property Matters
184
+ (a) Third Party Claims.
185
+ If Contributor has knowledge that a license under a third party's
186
+ intellectual property rights is required to exercise the rights
187
+ granted by such Contributor under Sections 2.1 or 2.2,
188
+ Contributor must include a text file with the Source Code
189
+ distribution titled "LEGAL" which describes the claim and the
190
+ party making the claim in sufficient detail that a recipient will
191
+ know whom to contact. If Contributor obtains such knowledge after
192
+ the Modification is made available as described in Section 3.2,
193
+ Contributor shall promptly modify the LEGAL file in all copies
194
+ Contributor makes available thereafter and shall take other steps
195
+ (such as notifying appropriate mailing lists or newsgroups)
196
+ reasonably calculated to inform those who received the Covered
197
+ Code that new knowledge has been obtained.
198
+
199
+ (b) Contributor APIs.
200
+ If Contributor's Modifications include an application programming
201
+ interface and Contributor has knowledge of patent licenses which
202
+ are reasonably necessary to implement that API, Contributor must
203
+ also include this information in the LEGAL file.
204
+
205
+ (c) Representations.
206
+ Contributor represents that, except as disclosed pursuant to
207
+ Section 3.4(a) above, Contributor believes that Contributor's
208
+ Modifications are Contributor's original creation(s) and/or
209
+ Contributor has sufficient rights to grant the rights conveyed by
210
+ this License.
211
+
212
+ 3.5. Required Notices.
213
+ You must duplicate the notice in Exhibit A in each file of the Source
214
+ Code. If it is not possible to put such notice in a particular Source
215
+ Code file due to its structure, then You must include such notice in a
216
+ location (such as a relevant directory) where a user would be likely
217
+ to look for such a notice. If You created one or more Modification(s)
218
+ You may add your name as a Contributor to the notice described in
219
+ Exhibit A. You must also duplicate this License in any documentation
220
+ for the Source Code where You describe recipients' rights or ownership
221
+ rights relating to Covered Code. You may choose to offer, and to
222
+ charge a fee for, warranty, support, indemnity or liability
223
+ obligations to one or more recipients of Covered Code. However, You
224
+ may do so only on Your own behalf, and not on behalf of the Initial
225
+ Developer or any Contributor. You must make it absolutely clear than
226
+ any such warranty, support, indemnity or liability obligation is
227
+ offered by You alone, and You hereby agree to indemnify the Initial
228
+ Developer and every Contributor for any liability incurred by the
229
+ Initial Developer or such Contributor as a result of warranty,
230
+ support, indemnity or liability terms You offer.
231
+
232
+ 3.6. Distribution of Executable Versions.
233
+ You may distribute Covered Code in Executable form only if the
234
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
235
+ and if You include a notice stating that the Source Code version of
236
+ the Covered Code is available under the terms of this License,
237
+ including a description of how and where You have fulfilled the
238
+ obligations of Section 3.2. The notice must be conspicuously included
239
+ in any notice in an Executable version, related documentation or
240
+ collateral in which You describe recipients' rights relating to the
241
+ Covered Code. You may distribute the Executable version of Covered
242
+ Code or ownership rights under a license of Your choice, which may
243
+ contain terms different from this License, provided that You are in
244
+ compliance with the terms of this License and that the license for the
245
+ Executable version does not attempt to limit or alter the recipient's
246
+ rights in the Source Code version from the rights set forth in this
247
+ License. If You distribute the Executable version under a different
248
+ license You must make it absolutely clear that any terms which differ
249
+ from this License are offered by You alone, not by the Initial
250
+ Developer or any Contributor. You hereby agree to indemnify the
251
+ Initial Developer and every Contributor for any liability incurred by
252
+ the Initial Developer or such Contributor as a result of any such
253
+ terms You offer.
254
+
255
+ 3.7. Larger Works.
256
+ You may create a Larger Work by combining Covered Code with other code
257
+ not governed by the terms of this License and distribute the Larger
258
+ Work as a single product. In such a case, You must make sure the
259
+ requirements of this License are fulfilled for the Covered Code.
260
+
261
+ 4. Inability to Comply Due to Statute or Regulation.
262
+
263
+ If it is impossible for You to comply with any of the terms of this
264
+ License with respect to some or all of the Covered Code due to
265
+ statute, judicial order, or regulation then You must: (a) comply with
266
+ the terms of this License to the maximum extent possible; and (b)
267
+ describe the limitations and the code they affect. Such description
268
+ must be included in the LEGAL file described in Section 3.4 and must
269
+ be included with all distributions of the Source Code. Except to the
270
+ extent prohibited by statute or regulation, such description must be
271
+ sufficiently detailed for a recipient of ordinary skill to be able to
272
+ understand it.
273
+
274
+ 5. Application of this License.
275
+
276
+ This License applies to code to which the Initial Developer has
277
+ attached the notice in Exhibit A and to related Covered Code.
278
+
279
+ 6. Versions of the License.
280
+
281
+ 6.1. New Versions.
282
+ Netscape Communications Corporation ("Netscape") may publish revised
283
+ and/or new versions of the License from time to time. Each version
284
+ will be given a distinguishing version number.
285
+
286
+ 6.2. Effect of New Versions.
287
+ Once Covered Code has been published under a particular version of the
288
+ License, You may always continue to use it under the terms of that
289
+ version. You may also choose to use such Covered Code under the terms
290
+ of any subsequent version of the License published by Netscape. No one
291
+ other than Netscape has the right to modify the terms applicable to
292
+ Covered Code created under this License.
293
+
294
+ 6.3. Derivative Works.
295
+ If You create or use a modified version of this License (which you may
296
+ only do in order to apply it to code which is not already Covered Code
297
+ governed by this License), You must (a) rename Your license so that
298
+ the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
299
+ "MPL", "NPL" or any confusingly similar phrase do not appear in your
300
+ license (except to note that your license differs from this License)
301
+ and (b) otherwise make it clear that Your version of the license
302
+ contains terms which differ from the Mozilla Public License and
303
+ Netscape Public License. (Filling in the name of the Initial
304
+ Developer, Original Code or Contributor in the notice described in
305
+ Exhibit A shall not of themselves be deemed to be modifications of
306
+ this License.)
307
+
308
+ 7. DISCLAIMER OF WARRANTY.
309
+
310
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
311
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
312
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
313
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
314
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
315
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
316
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
317
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
318
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
319
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
320
+
321
+ 8. TERMINATION.
322
+
323
+ 8.1. This License and the rights granted hereunder will terminate
324
+ automatically if You fail to comply with terms herein and fail to cure
325
+ such breach within 30 days of becoming aware of the breach. All
326
+ sublicenses to the Covered Code which are properly granted shall
327
+ survive any termination of this License. Provisions which, by their
328
+ nature, must remain in effect beyond the termination of this License
329
+ shall survive.
330
+
331
+ 8.2. If You initiate litigation by asserting a patent infringement
332
+ claim (excluding declatory judgment actions) against Initial Developer
333
+ or a Contributor (the Initial Developer or Contributor against whom
334
+ You file such action is referred to as "Participant") alleging that:
335
+
336
+ (a) such Participant's Contributor Version directly or indirectly
337
+ infringes any patent, then any and all rights granted by such
338
+ Participant to You under Sections 2.1 and/or 2.2 of this License
339
+ shall, upon 60 days notice from Participant terminate prospectively,
340
+ unless if within 60 days after receipt of notice You either: (i)
341
+ agree in writing to pay Participant a mutually agreeable reasonable
342
+ royalty for Your past and future use of Modifications made by such
343
+ Participant, or (ii) withdraw Your litigation claim with respect to
344
+ the Contributor Version against such Participant. If within 60 days
345
+ of notice, a reasonable royalty and payment arrangement are not
346
+ mutually agreed upon in writing by the parties or the litigation claim
347
+ is not withdrawn, the rights granted by Participant to You under
348
+ Sections 2.1 and/or 2.2 automatically terminate at the expiration of
349
+ the 60 day notice period specified above.
350
+
351
+ (b) any software, hardware, or device, other than such Participant's
352
+ Contributor Version, directly or indirectly infringes any patent, then
353
+ any rights granted to You by such Participant under Sections 2.1(b)
354
+ and 2.2(b) are revoked effective as of the date You first made, used,
355
+ sold, distributed, or had made, Modifications made by that
356
+ Participant.
357
+
358
+ 8.3. If You assert a patent infringement claim against Participant
359
+ alleging that such Participant's Contributor Version directly or
360
+ indirectly infringes any patent where such claim is resolved (such as
361
+ by license or settlement) prior to the initiation of patent
362
+ infringement litigation, then the reasonable value of the licenses
363
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
364
+ into account in determining the amount or value of any payment or
365
+ license.
366
+
367
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above,
368
+ all end user license agreements (excluding distributors and resellers)
369
+ which have been validly granted by You or any distributor hereunder
370
+ prior to termination shall survive termination.
371
+
372
+ 9. LIMITATION OF LIABILITY.
373
+
374
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
375
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
376
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
377
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
378
+ ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
379
+ CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
380
+ WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
381
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
382
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
383
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
384
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
385
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
386
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
387
+ THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
388
+
389
+ 10. U.S. GOVERNMENT END USERS.
390
+
391
+ The Covered Code is a "commercial item," as that term is defined in
392
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
393
+ software" and "commercial computer software documentation," as such
394
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
395
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
396
+ all U.S. Government End Users acquire Covered Code with only those
397
+ rights set forth herein.
398
+
399
+ 11. MISCELLANEOUS.
400
+
401
+ This License represents the complete agreement concerning subject
402
+ matter hereof. If any provision of this License is held to be
403
+ unenforceable, such provision shall be reformed only to the extent
404
+ necessary to make it enforceable. This License shall be governed by
405
+ California law provisions (except to the extent applicable law, if
406
+ any, provides otherwise), excluding its conflict-of-law provisions.
407
+ With respect to disputes in which at least one party is a citizen of,
408
+ or an entity chartered or registered to do business in the United
409
+ States of America, any litigation relating to this License shall be
410
+ subject to the jurisdiction of the Federal Courts of the Northern
411
+ District of California, with venue lying in Santa Clara County,
412
+ California, with the losing party responsible for costs, including
413
+ without limitation, court costs and reasonable attorneys' fees and
414
+ expenses. The application of the United Nations Convention on
415
+ Contracts for the International Sale of Goods is expressly excluded.
416
+ Any law or regulation which provides that the language of a contract
417
+ shall be construed against the drafter shall not apply to this
418
+ License.
419
+
420
+ 12. RESPONSIBILITY FOR CLAIMS.
421
+
422
+ As between Initial Developer and the Contributors, each party is
423
+ responsible for claims and damages arising, directly or indirectly,
424
+ out of its utilization of rights under this License and You agree to
425
+ work with Initial Developer and Contributors to distribute such
426
+ responsibility on an equitable basis. Nothing herein is intended or
427
+ shall be deemed to constitute any admission of liability.
428
+
429
+ 13. MULTIPLE-LICENSED CODE.
430
+
431
+ Initial Developer may designate portions of the Covered Code as
432
+ "Multiple-Licensed". "Multiple-Licensed" means that the Initial
433
+ Developer permits you to utilize portions of the Covered Code under
434
+ Your choice of the NPL or the alternative licenses, if any, specified
435
+ by the Initial Developer in the file described in Exhibit A.
436
+
437
+ EXHIBIT A -Mozilla Public License.
438
+
439
+ ``The contents of this file are subject to the Mozilla Public License
440
+ Version 1.1 (the "License"); you may not use this file except in
441
+ compliance with the License. You may obtain a copy of the License at
442
+ http://www.mozilla.org/MPL/
443
+
444
+ Software distributed under the License is distributed on an "AS IS"
445
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
446
+ License for the specific language governing rights and limitations
447
+ under the License.
448
+
449
+ The Original Code is ______________________________________.
450
+
451
+ The Initial Developer of the Original Code is ________________________.
452
+ Portions created by ______________________ are Copyright (C) ______
453
+ _______________________. All Rights Reserved.
454
+
455
+ Contributor(s): ______________________________________.
456
+
457
+ Alternatively, the contents of this file may be used under the terms
458
+ of the _____ license (the "[___] License"), in which case the
459
+ provisions of [______] License are applicable instead of those
460
+ above. If you wish to allow use of your version of this file only
461
+ under the terms of the [____] License and not to allow others to use
462
+ your version of this file under the MPL, indicate your decision by
463
+ deleting the provisions above and replace them with the notice and
464
+ other provisions required by the [___] License. If you do not delete
465
+ the provisions above, a recipient may use your version of this file
466
+ under either the MPL or the [___] License."
467
+
468
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
469
+ the notices in the Source Code files of the Original Code. You should
470
+ use the text of this Exhibit A rather than the text found in the
471
+ Original Code Source Code for Your Modifications.]
472
+
473
+
474
+
475
+ GNU LESSER GENERAL PUBLIC LICENSE
476
+ Version 3, 29 June 2007#+STARTUP: showall
477
+ #+STYLE: <link rel="stylesheet" href="tutorial.css" />
478
+ #+TITLE: Introduction to Nitrogen
479
+
480
+ * Welcome
481
+ #+HTML: <div style="text-align:center; font-size: 400%; line-height: 1em;">
482
+ #+HTML: <br>
483
+ #+HTML: Introduction to Nitrogen
484
+ #+HTML: <hr>
485
+ #+HTML: </div>
486
+ #+HTML: <div style="text-align:center; font-size: 100%; line-height: 1.5em;">
487
+ #+HTML: A step-by-step introduction to the<br>
488
+ #+HTML: major features and concepts behind<br>
489
+ #+HTML: the Nitrogen Web Framework.
490
+ #+HTML: </div>
491
+
492
+ * Main Agenda Slide
493
+ ** Agenda
494
+ + Part 1: Install & Run Nitrogen
495
+ + Part 2: Nitrogen Pages
496
+ + Part 3: Nitrogen Elements
497
+ + Part 4: Nitrogen Actions
498
+ + Part 5: Nitrogen Postback Events
499
+ + Part 6: Session and Page State
500
+ + Part 7: Security
501
+ + Part 8: Validation
502
+ + Part 9: Comet
503
+ + Part 10: Extending Nitrogen
504
+ + Conclusion
505
+
506
+ * PART 1 AGENDA
507
+ ** Install & Run Nitrogen
508
+
509
+ + Install Nitrogen
510
+ + Run the Website
511
+ + A Tour Through the Files
512
+
513
+ * Install Nitrogen
514
+ ** Install Nitrogen
515
+
516
+ *** If you *don't* have Erlang Installed:
517
+
518
+ [[http://nitrogenproject.com/downloads][Download Nitrogen]], unzip and =cd nitrogen=.
519
+
520
+ *** If you *do* have Erlang installed:
521
+
522
+ Pull the [[http://github.com/nitrogen/nitrogen][Nitrogen Source Code]], then =make rel_inets; cd rel/nitrogen=.
523
+
524
+ * Start the Website in Console Mode
525
+ ** Install & Run Nitrogen
526
+ *** Start Up
527
+ : bin/nitrogen console
528
+ : open http://localhost:8000
529
+
530
+ * Stop the Website
531
+ ** Install & Run Nitrogen
532
+ *** Shut Down
533
+ /Press Control-C twice./
534
+
535
+ *** View the Directory
536
+ : ls -l
537
+
538
+ * Anatomy of a Nitrogen Project
539
+ ** Install & Run Nitrogen
540
+ *** Anatomy of a Nitrogen Project
541
+ + BuildInfo.txt :: From =uname=.
542
+ + Makefile :: Used by =make=.
543
+ + bin/ :: Commands to start and stop system, plus developer tools.
544
+ + etc/ :: Configuration settings.
545
+ + site/ :: Contains the website files, templates, and Erlang modules.
546
+ + log/ :: The logs.
547
+ + doc/ :: Contains Nitrogen documentation.
548
+ + erts-5.7.5/ :: Embedded Erlang.
549
+ + releases/ :: Tells Erlang how to start the system.
550
+ + lib/ :: Dependent libraries.
551
+
552
+ * Anatomy of the site/ Directory
553
+ ** Install & Run Nitrogen
554
+ *** The =site/= Directory
555
+ The site directory should go under source control, it contains all
556
+ of the information necessary to run the website.
557
+
558
+ + Emakefile :: Used by make.erl to compile the system.
559
+ + ebin/ :: Compiled Erlang modules.
560
+ + include/ :: Include files for your website.
561
+ + src/ :: Erlang source files for your website.
562
+ + static/ :: Static files for your website.
563
+ + templates/ :: Template files for your website.
564
+
565
+ * Anatomy of the site/src Directory
566
+ ** Install & Run Nitrogen
567
+ *** The =site/src/= Directory
568
+ Stores the Erlang source files for your application. By default it
569
+ contains:
570
+
571
+ + nitrogen\_init.erl :: Runs once on Nitrogen startup.
572
+ + nitrogen\_PLATFORM.erl :: Holds the request loop depending on
573
+ platform.
574
+ + index.erl :: The default web page.
575
+ + elements/ :: By convention, custom alements are placed here.
576
+ + actions/ :: By convention, custom actions are placed here.
577
+
578
+ * Exercise: Modify a Nitrogen Page
579
+ ** Install & Run Nitrogen
580
+ *** Exercise: Modify Your First Page
581
+ + Open =site/src/index.erl=
582
+ + Change "Welcome to Nitrogen" to "Welcome to My Website"
583
+ + From the Erlang Shell, run:
584
+ : sync:go()
585
+ + Reload the page
586
+
587
+ * Exercise: Compile in Different Ways
588
+ ** Install & Run Nitrogen
589
+ *** Exercise: Compile in a Different Way
590
+ + Change to "Welcome to my ERL-TASTIC WEBSITE!" (or, you know, whatever)
591
+ + From a different terminal, run:
592
+ : bin/dev compile
593
+ + Reload the page
594
+
595
+ * Exercise: Debugging
596
+ ** Install & Run Nitrogen
597
+ *** Debug Statements
598
+ + Add =?DEBUG= to =index.erl=. Then compile and
599
+ reload. What happens?
600
+ + Add =?PRINT(node())= to =index.erl=. Then compile and reload. What
601
+ happens?
602
+
603
+ * Emacs Mode
604
+ ** Install & Run Nitrogen
605
+ *** Emacs =nitrogen-mode=
606
+ #+BEGIN_SRC lisp
607
+ (add-to-list 'load-path "PATH/TO/NITROGEN/support/nitrogen-mode")
608
+ (require 'nitrogen-mode)
609
+ #+END_SRC
610
+
611
+ Without =nitrogen-mode=:
612
+ #+BEGIN_SRC erlang
613
+ #panel { id=my_panel, body=[
614
+ #panel { id=my_panel2, body=[
615
+ #label { text="Name" },
616
+ #textbox { id=my_textbox }
617
+ ]}
618
+ ]}
619
+ #+END_SRC
620
+
621
+ With =nitrogen-mode=:
622
+ #+BEGIN_SRC erlang
623
+ M-x nitrogen-mode
624
+ #panel { id=my_panel, body=[
625
+ #panel { id=my_panel2, body=[
626
+ #label { text="Name" },
627
+ #textbox { id=my_textbox }
628
+ ]}
629
+ ]}
630
+ #+END_SRC
631
+
632
+ * PART 2 AGENDA
633
+ ** Nitrogen Pages
634
+ + What is a Nitrogen Page?
635
+ + Dynamic Routing Explained
636
+ + Creating Your First Page
637
+ + How is a Page Rendered?
638
+ + Anatomy of a Template
639
+ + Experimenting With Templates
640
+
641
+ * What is a Nitrogen Page?
642
+ ** Nitrogen Pages
643
+ *** What is a Nitrogen Page
644
+ + A Page is an Erlang Module
645
+ + Each page should accomplish one store or piece of
646
+ functionality.
647
+
648
+ Some examples:
649
+ + Allow the user to log in (=user_login.erl=).
650
+ + Change the user's preferences. (=user_preferences.erl=)
651
+ + Display a list of items. (=items_view.erl=)
652
+ + Allow the user to edit an item. (=items_edit.erl=)
653
+
654
+ * Dynamic Routes Explained
655
+ ** Nitrogen Pages
656
+ *** Dynamic Routing Explained
657
+ Dynamic routing rules:
658
+ 1. If there is an extension, assume a static file.
659
+ : http://localhost:8000/routes/to/a/module
660
+ : http://localhost:8000/routes/to/a/static/file.html
661
+ 2. Root page maps to =index.erl=
662
+ 3. Replaces slashes with underscores.
663
+ : http://localhost:8000/routes/to/a/module ->
664
+ : routes_to_a_module.erl
665
+ 4. Try the longest matching module.
666
+ : http://localhost:8000/routes/to/a/module/foo/bar ->
667
+ : routes_to_a_module.erl
668
+ 5. Modules that aren't found go to =web\_404.erl= if it exists.
669
+ 6. Static files that aren't found are handled by the underlying
670
+ platform (not yet generalized.)
671
+
672
+ * Creating a New Page
673
+ ** Nitrogen Pages
674
+ *** Exercise: Create a New Page
675
+ + Generate the Page
676
+ : bin/dev page my\_page
677
+ : $EDIT site/src/my\_page.erl
678
+
679
+ + Replace the default body with:
680
+ #+BEGIN_SRC erlang
681
+ body() -> "Hello World!".
682
+ #+END_SRC
683
+
684
+ + Remove the =event/1= function.
685
+
686
+ + Compile the page and load =http://localhost:8080/my/page=
687
+
688
+ * How is a Page Rendered (Simple Version)
689
+ ** Nitrogen Pages
690
+ *** How is a Page Rendered?
691
+ 1. User hits a URL.
692
+ 2. URL is mapped to a module.
693
+ 3. Nitrogen framework calls =module:main()=
694
+ 4. =module:main()= calls a =#template=
695
+ 5. =#template= calls back into the page (or other modules)
696
+ 6. Nitrogen framework renders the output into HTML/Javascript.
697
+ (This is the simple version. Complex version will come later.)
698
+
699
+ * Anatomy of a Template
700
+ ** Nitrogen Pages
701
+ *** Anatomy of a Template
702
+ + HTML. The Page is slurped into the Template.
703
+ + Contains one or more callouts, ie:
704
+ : [[[module:body()]]]
705
+ + Contains a script callout for Javascript:
706
+ : [[[script]]]
707
+ + The callouts look like Erlang, but they are not. They can only be
708
+ of the form =module:function(Args)=. The 'page' module refers to
709
+ the current page.
710
+
711
+ * Experimenting With Templates
712
+ ** Nitrogen Pages
713
+ *** Experimenting With Templates
714
+ + Change the callout from =page:body()= to =page:body1()= in the
715
+ default template and reload the page. What happens?
716
+
717
+ + Create another callout. What happens?
718
+
719
+ + What happens when you change =page= to be a specific module?
720
+
721
+ + Replace the module call with some arbitrary Erlang code. What happens?
722
+
723
+ * PART 3 AGENDA
724
+ ** Nitrogen Elements
725
+ + What is a Nitrogen Element?
726
+ + Add Elements to Your Page
727
+ + Nested Elements
728
+ + Documentation
729
+ + Anatomy of a Nitrogen Element
730
+
731
+ * What is a Nitrogen Element?
732
+ ** Nitrogen Elements
733
+ *** What is a Nitrogen Element?
734
+ An element can be either HTML, or some record that renders into
735
+ HTML.
736
+
737
+ Change this:
738
+ #+BEGIN_SRC erlang
739
+ body() -> "Hello World!".
740
+ #+END_SRC
741
+
742
+ To this:
743
+ #+BEGIN_SRC erlang
744
+ body() -> #label { text="Hello World!" }.
745
+ #+END_SRC
746
+
747
+ * What is a Nitrogen Element?
748
+ ** Nitrogen Elements
749
+ *** What is a Nitrogen Element?
750
+ The =#label{}= element is rendered into:
751
+
752
+ #+BEGIN_SRC html
753
+ <label class="wfid_tempNNNNN label">Hello World!</label>
754
+ #+END_SRC
755
+
756
+ View the rendered page source in your browser and search for "Hello World".
757
+
758
+ * Nitrogen Element Properties
759
+ ** Nitrogen Elements
760
+ *** Why Nitrogen Elements?
761
+
762
+ Nitrogen elements serve two purposes:
763
+
764
+ 1. Allow you to generate HTML within Erlang:
765
+ + Avoid mixing languages == clearer code.
766
+ + Fewer characters to type.
767
+ + Checked at compile time.
768
+
769
+ 2. Abstraction layer:
770
+ + Avoid repeating common functionality.
771
+ + Hide complexity in a module.
772
+
773
+ * Nitrogen Element Examples
774
+ ** Nitrogen Elements
775
+ *** Nitrogen Element Examples
776
+
777
+ Try this on my\_page.erl:
778
+ #+BEGIN_SRC erlang
779
+ body() -> [
780
+ #h1 { text="My Simple Application" },
781
+ #label { text="What is your name?" },
782
+ #textbox { },
783
+ #button { text="Submit" }
784
+ ].
785
+ #+END_SRC
786
+
787
+ Then compile, reload, and view source.
788
+
789
+ * Nested Elements
790
+ ** Nitrogen Elements
791
+ *** Nested Elements
792
+
793
+ Try a nested element:
794
+
795
+ #+BEGIN_SRC erlang
796
+ body() ->
797
+ #panel { style="margin: 50px;", body=[
798
+ #h1 { text="My Page" },
799
+ #label { text="Enter Your Name:" },
800
+ #textbox { },
801
+ #button { text="Submit" }
802
+ ]}.
803
+ #+END_SRC
804
+
805
+ * PART 4 AGENDA
806
+ ** Nitrogen Actions
807
+ + What is a Nitrogen Action?
808
+ + Wiring an Action
809
+ + Conditional Actions with =#event{}=
810
+ + Postbacks
811
+
812
+ * What is a Nitrogen Action?
813
+ ** Nitrogen Actions
814
+ *** What is a Nitrogen Action?
815
+ An action can either be Javascript, or some record that renders
816
+ into Javascript.
817
+
818
+ Add a Javascript alert to the =#button{}= element. Then recompile
819
+ and run. What do you expect will happen?
820
+
821
+ #+BEGIN_SRC erlang
822
+ body() ->
823
+ [
824
+ #button { text="Submit", actions="alert('hello');" }
825
+ ].
826
+ #+END_SRC
827
+
828
+ * What is a Nitrogen Action?
829
+ ** Nitrogen Actions
830
+ *** What is a Nitrogen Action?
831
+ Do the same thing a different way.
832
+
833
+ #+BEGIN_SRC erlang
834
+ body() ->
835
+ [
836
+ #button {
837
+ text="Submit",
838
+ actions=#alert { text="Hello" }
839
+ }
840
+ ].
841
+ #+END_SRC
842
+
843
+ * Wiring an Action
844
+ ** Nitrogen Actions
845
+ *** Wiring an Action
846
+
847
+ Setting the =actions= property of an element can lead to messy
848
+ code. Another, cleaner way to wire an action is the =wf:wire/N=
849
+ function.
850
+
851
+ #+BEGIN_SRC erlang
852
+ body() ->
853
+ wf:wire(mybutton, #effect { effect=pulsate }),
854
+ [
855
+ #button { id=mybutton, text="Submit" }
856
+ ].
857
+ #+END_SRC
858
+
859
+ * Conditional Actions with =#event{}=
860
+ ** Nitrogen Actions
861
+ *** Conditional Actions with =#event{}=
862
+
863
+ Put the =#effect{}= action inside of an =#event{}= action. This
864
+ causes the effect to *only* get fired if the user clicks on
865
+ =mybutton=.
866
+
867
+ #+BEGIN_SRC erlang
868
+ body() ->
869
+ wf:wire(mybutton, #event {
870
+ type=click,
871
+ actions=#effect { effect=pulsate }
872
+ }),
873
+ [
874
+ #button { id=mybutton, text="Submit" }
875
+ ].
876
+ #+END_SRC
877
+
878
+ * Triggers and Targets
879
+ ** Nitrogen Actions
880
+ *** Triggers and Targets
881
+
882
+ All actions have a =target= property. The =target= specifies what
883
+ element(s) the action effects.
884
+
885
+ The event action also has a =trigger= property. The =trigger=
886
+ specifies what element(s) trigger the action.
887
+
888
+ Try this:
889
+
890
+ #+BEGIN_SRC erlang
891
+ body() ->
892
+ wf:wire(#event {
893
+ type=click, trigger=mybutton, target=mylabel,
894
+ actions=#effect { effect=pulsate }
895
+ }),
896
+ [
897
+ #label { id=mylabel, text="Make Me Blink!" },
898
+ #button { id=mybutton, text="Submit" }
899
+ ].
900
+ #+END_SRC
901
+
902
+ * Triggers and Targets
903
+ ** Nitrogen Actions
904
+ *** Triggers and Targets
905
+
906
+ You can also specify the *Trigger* and *Target* directly in =wf:wire/N=. It takes three forms:
907
+
908
+ #+BEGIN_SRC erlang
909
+ % Specify a trigger and target.
910
+ wf:wire(Trigger, Target, Actions)
911
+
912
+ % Use the same element for both trigger and target.
913
+ wf:wire(TriggerAndTarget, Actions)
914
+
915
+ % Assume the trigger and/or target is provided in the actions.
916
+ % If not, then wire the action directly to the page.
917
+ % (Useful for catching keystrokes.)
918
+ wf:wire(Actions)
919
+ #+END_SRC
920
+
921
+ * Quick Review
922
+ ** Nitrogen Actions
923
+ *** Quick Review
924
+
925
+ 1. Elements make HTML.
926
+ 2. Actions make Javascript.
927
+ 3. An action can be wired using the =actions= property, or wired
928
+ later with =wf:wire/N=. Both approaches can take a single
929
+ action or a list of actions.
930
+ 4. An action looks for =trigger= and =target= properties. These
931
+ can be specified in a few different ways.
932
+ 5. Everything we have seen so far happens on the client.
933
+
934
+ * PART 5 AGENDA
935
+ ** Nitrogen Events
936
+ + What is a Postback?
937
+ + Your First Postback
938
+ + Event Properties
939
+ + More Event Examples
940
+ + Postback Shortcuts
941
+ + Modifying Elements
942
+ * What is a Postback?
943
+ ** Nitrogen Events
944
+ *** What is a Postback?
945
+
946
+ A postback briefly transfers control from the browser to the
947
+ Nitrogen server. It is initiated when an event fires with the
948
+ =postback= property set. For example:
949
+
950
+ #+BEGIN_SRC erlang
951
+ #event { type=click, postback=my_click_event }
952
+ #+END_SRC
953
+
954
+ The postback tag can be any valid Erlang term. You use this to
955
+ differentiate incoming events.
956
+
957
+ * Your First Postback
958
+ ** Nitrogen Events
959
+ *** Your First Postback
960
+
961
+ First, let's use the postback to print out a debug message.
962
+
963
+ #+BEGIN_SRC erlang
964
+ body() ->
965
+ wf:wire(mybutton, #event { type=click, postback=myevent }),
966
+ [
967
+ #button { id=mybutton, text="Submit" }
968
+ ].
969
+
970
+ event(myevent) ->
971
+ ?PRINT({event, now()}).
972
+ #+END_SRC
973
+
974
+ * Postback Shortcuts
975
+ ** Nitrogen Events
976
+ *** Postback Shortcuts
977
+
978
+ A few elements allow you to set the =postback= property as a
979
+ shortcut to handle their most common events.
980
+
981
+ | Element | Shortcut Event |
982
+ | =#button{}= | click |
983
+ | =#textbox{}= | enter key |
984
+ | =#checkbox{}= | click |
985
+ | =#dropdown{}= | change |
986
+ | =#password{}= | enter key |
987
+
988
+ * Postback Shortcuts
989
+ ** Nitrogen Events
990
+ *** Postback Shortcuts
991
+
992
+ A few elements allow you to set the =postback= property as a
993
+ shortcut to handle their most common events.
994
+
995
+ The previous code, simplified:
996
+
997
+ #+BEGIN_SRC erlang
998
+ body() ->
999
+ [
1000
+ #button { id=mybutton, text="Submit", postback=myevent }