├── remote ├── .gitignore ├── public │ ├── _includes │ │ ├── img │ │ │ └── fav.ico │ │ ├── js │ │ │ └── site.js │ │ └── css │ │ │ └── screen.css │ ├── connection-type │ │ └── index.html │ └── index.html ├── package.json └── app.js ├── s5 ├── _ui │ ├── rainbow │ │ ├── .gitignore │ │ ├── themes │ │ │ ├── all-hallows-eve.css │ │ │ ├── zenburnesque.css │ │ │ ├── tricolore.css │ │ │ ├── tomorrow-night.css │ │ │ ├── blackboard.css │ │ │ ├── espresso-libre.css │ │ │ ├── obsidian.css │ │ │ ├── twilight.css │ │ │ ├── solarized-dark.css │ │ │ ├── solarized-light.css │ │ │ ├── sunburst.css │ │ │ ├── github.css │ │ │ └── pastie.css │ │ ├── demos │ │ │ ├── index.html │ │ │ ├── scheme.html │ │ │ ├── css.html │ │ │ ├── html.html │ │ │ ├── go.html │ │ │ ├── r.html │ │ │ ├── coffeescript.html │ │ │ ├── php.html │ │ │ ├── js.html │ │ │ ├── ruby-test.html │ │ │ ├── python.html │ │ │ ├── lua.html │ │ │ ├── c.html │ │ │ └── ruby.html │ │ ├── util │ │ │ ├── compile.py │ │ │ └── builder.py │ │ ├── js │ │ │ ├── language │ │ │ │ ├── smalltalk.js │ │ │ │ ├── sql.js │ │ │ │ ├── shell.js │ │ │ │ ├── lua.js │ │ │ │ ├── go.js │ │ │ │ ├── java.js │ │ │ │ ├── generic.js │ │ │ │ ├── c.js │ │ │ │ ├── html.js │ │ │ │ ├── css.js │ │ │ │ ├── python.js │ │ │ │ ├── r.js │ │ │ │ ├── javascript.js │ │ │ │ ├── coffeescript.js │ │ │ │ ├── csharp.js │ │ │ │ ├── scheme.js │ │ │ │ ├── php.js │ │ │ │ └── ruby.js │ │ │ └── rainbow.min.js │ │ ├── tests │ │ │ ├── index.html │ │ │ ├── tests.css │ │ │ ├── api.html │ │ │ ├── language │ │ │ │ ├── java-test.js │ │ │ │ ├── smalltalk-test.js │ │ │ │ ├── python-test.js │ │ │ │ ├── csharp-test.js │ │ │ │ ├── r-test.js │ │ │ │ ├── javascript-test.js │ │ │ │ └── css-test.js │ │ │ └── tests.js │ │ └── README.md │ ├── default │ │ ├── blank.gif │ │ ├── bodybg.gif │ │ ├── opera.css │ │ ├── slides.css │ │ ├── s5-core.css │ │ ├── outline.css │ │ ├── framing.css │ │ ├── iepngfix.htc │ │ ├── print.css │ │ └── pretty.css │ └── pg │ │ ├── icon_bracket-open.gif │ │ ├── array.js │ │ ├── slide-websockets.js │ │ └── printlinks.js └── index.html ├── .gitignore ├── README.md └── goog ├── assets └── slide-websockets.js └── index.html /remote/.gitignore: -------------------------------------------------------------------------------- 1 | deploy.sh 2 | node_modules -------------------------------------------------------------------------------- /s5/_ui/rainbow/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.sw? 3 | js/rainbow-custom.min.js 4 | .AppleDouble 5 | -------------------------------------------------------------------------------- /s5/_ui/default/blank.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orangespaceman/slide-controller/master/s5/_ui/default/blank.gif -------------------------------------------------------------------------------- /s5/_ui/default/bodybg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orangespaceman/slide-controller/master/s5/_ui/default/bodybg.gif -------------------------------------------------------------------------------- /s5/_ui/pg/icon_bracket-open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orangespaceman/slide-controller/master/s5/_ui/pg/icon_bracket-open.gif -------------------------------------------------------------------------------- /remote/public/_includes/img/fav.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orangespaceman/slide-controller/master/remote/public/_includes/img/fav.ico -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | -------------------------------------------------------------------------------- /s5/_ui/default/opera.css: -------------------------------------------------------------------------------- 1 | /* DO NOT CHANGE THESE unless you really want to break Opera Show */ 2 | .slide { 3 | visibility: visible !important; 4 | position: static !important; 5 | page-break-before: always; 6 | } 7 | #slide0 {page-break-before: avoid;} 8 | -------------------------------------------------------------------------------- /s5/_ui/default/slides.css: -------------------------------------------------------------------------------- 1 | @import url(s5-core.css); /* required to make the slide show run at all */ 2 | @import url(framing.css); /* sets basic placement and size of slide components */ 3 | @import url(pretty.css); /* stuff that makes the slides look better than blah */ -------------------------------------------------------------------------------- /s5/_ui/default/s5-core.css: -------------------------------------------------------------------------------- 1 | /* Do not edit or override these styles! The system will likely break if you do. */ 2 | 3 | div#header, div#footer, div#controls, .slide {position: absolute;} 4 | html>body div#header, html>body div#footer, 5 | html>body div#controls, html>body .slide {position: fixed;} 6 | .handout {display: none;} 7 | .layout {display: block;} 8 | .slide, .hideme, .incremental {visibility: hidden;} 9 | #slide0 {visibility: visible;} 10 | -------------------------------------------------------------------------------- /remote/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "slide-controller", 3 | "node":"0.10.x", 4 | "description": "Node.js-based remote control for HTML/JS slideshows", 5 | "version": "0.0.2", 6 | "repository": { "type" : "git", "url" : "http://github.com/orangespaceman/slide-controller.git" }, 7 | "keywords": ["slideshow"], 8 | "dependencies": { 9 | "express" : "2.5.x", 10 | "socket.io" : "0.9.x" 11 | }, 12 | "devDependencies": {}, 13 | "optionalDependencies": {}, 14 | "engines": { 15 | "node": "*" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /s5/_ui/default/outline.css: -------------------------------------------------------------------------------- 1 | /* don't change this unless you want the layout stuff to show up in the outline view! */ 2 | 3 | .layout div, #footer *, #controlForm * {display: none;} 4 | #footer, #controls, #controlForm, #navLinks, #toggle { 5 | display: block; visibility: visible; margin: 0; padding: 0;} 6 | #toggle {float: right; padding: 0.5em;} 7 | html>body #toggle {position: fixed; top: 0; right: 0;} 8 | 9 | /* making the outline look pretty-ish */ 10 | 11 | #slide0 h1, #slide0 h2, #slide0 h3, #slide0 h4 {border: none; margin: 0;} 12 | #slide0 h1 {padding-top: 1.5em;} 13 | .slide h1 {margin: 1.5em 0 0; padding-top: 0.25em; 14 | border-top: 1px solid #888; border-bottom: 1px solid #AAA;} 15 | #toggle {border: 1px solid; border-width: 0 0 1px 1px; background: #FFF;} 16 | -------------------------------------------------------------------------------- /remote/public/connection-type/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |Loading...
25 | 26 | -------------------------------------------------------------------------------- /remote/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |Slide of
19 |notes will appear here...
21 |11 | 12 | ;; Produces the union of two sets 13 | (define (set-union set1 set2) 14 | (let loop ((set1 set1) 15 | (set2 set2)) 16 | (if (null? set2) 17 | set1 18 | (let ((item (car set2))) 19 | (if (member item set1) 20 | (loop set1 (cdr set2)) 21 | (loop (cons item set1) (cdr set2))))))) 22 | 23 | (define (all? pred coll) 24 | (if (null? coll) 25 | #t 26 | (and (pred (car coll)) 27 | (all? pred (cdr coll))))) 28 | 29 | (define (filter pred coll) 30 | (let loop ((ret '()) 31 | (coll coll)) 32 | (if (null? coll) 33 | (reverse ret) 34 | (let ((a (car coll))) 35 | (if (pred a) 36 | (loop (cons a ret) (cdr coll)) 37 | (loop ret (cdr coll))))))) 38 | 39 |40 | 41 | 42 |
8 | /**
9 | * styles for blackboard theme
10 | */
11 | pre {
12 | background: #0B1022;
13 | white-space: pre-wrap;
14 | white-space: -moz-pre-wrap;
15 | white-space: -pre-wrap;
16 | white-space: -o-pre-wrap;
17 | word-wrap: break-word;
18 | margin: 0px;
19 | padding: 0px;
20 | padding: 10px;
21 | color: #fff;
22 | font-size: 14px;
23 | margin-bottom: 20px;
24 | }
25 |
26 | pre, code {
27 | font-family: 'Monaco', courier, monospace;
28 | }
29 |
30 | pre .comment {
31 | color: #727272;
32 | }
33 |
34 | pre .constant {
35 | color: #D8FA3C;
36 | }
37 |
38 | pre .storage {
39 | color: #FBDE2D;
40 | }
41 |
42 | pre .string {
43 | color: #61CE3C;
44 | }
45 |
46 | pre .keyword, pre .selector {
47 | color: #FBDE2D;
48 | }
49 |
50 | pre .parent {
51 | font-style: italic;
52 | }
53 |
54 | pre .entity {
55 | color: #FF6400;
56 | }
57 |
58 | pre .support {
59 | color: #8DA6CE;
60 | }
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/smalltalk.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Smalltalk patterns
3 | *
4 | * @author Frank Shearar
9 | <!-- inline styles! -->
10 | <style type="text/css">
11 | body span.blah {
12 | background: #000;
13 | color: #fff;
14 | }
15 | </style>
16 |
17 | <body>
18 | <span class="blah" width="200" height="200">test code goes here</span>
19 | </body>
20 |
21 | <!-- inline php! -->
22 | <?php
23 | $test = true;
24 |
25 | /**
26 | * test
27 | */
28 | function what($test) {
29 | return $test;
30 | }
31 | ?>
32 |
33 | <!-- inline javascript! -->
34 | <script type="text/javascript">
35 | function prettyCool() {
36 | doSomeJQueryOrWhatever();
37 | }
38 | </script>
39 |
40 | <article title="<?= $user->name ?>">test</article>
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/s5/_ui/default/print.css:
--------------------------------------------------------------------------------
1 | /* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */
.slide, ul {page-break-inside: avoid; visibility: visible !important;}
h1 {page-break-after: avoid;}
body {font-size: 12pt; background: white;}
* {color: black;}
#slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;}
#slide0 h3 {margin: 0; padding: 0;}
#slide0 h4 {margin: 0 0 0.5em; padding: 0;}
#slide0 {margin-bottom: 3em;}
h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;}
.extra {background: transparent !important;}
div.extra, pre.extra, .example {font-size: 10pt; color: #333;}
ul.extra a {font-weight: bold;}
p.example {display: none;}
#header {display: none;}
#footer h1 {margin: 0; border-bottom: 1px solid; color: gray; font-style: italic;}
#footer h2, #controls {display: none;}
/* The following rule keeps the layout stuff out of print. Remove at your own risk! */
.layout, .layout * {display: none !important;}
/* Pete additions */
h2.interstitial {
display:none;
padding:30px 50px;
background:#eee;
border:1px solid #ccc;
font: bold 150%/1em Helvetica, sans-serif;
text-transform: capitalize;
color: #333;
margin:100px 0;
border-bottom: 1px solid;
page-break-before: always;
}
.no-print, .no-print * {display: none !important;}
a {
/*text-decoration:none;*/
padding-right:10px;
}
a .printonly {
padding-left:4px;
font-size:60%;
vertical-align:top;
}
td, th {
border:1px solid #999;
padding:5px 10px;
}
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/sql.js:
--------------------------------------------------------------------------------
1 | /**
2 | * PL/SQL patterns
3 | *
4 | * @author Ray Myers
5 | * @version 1.0.0
6 | */
7 | Rainbow.extend( "sql", [
8 | {
9 | name: "constant",
10 | pattern: /\b(false|null|true)\b/gi
11 | },
12 | {
13 | // see http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
14 | name: "keyword",
15 | // An attempt at listing the most common keywords. Add to this as needed.
16 | pattern: /\b(select|from|insert|update|create|order|by|asc|desc|limit|or|database|show|describe|alter|add|change|drop|truncate|drop|use|package|as|procedure|xmltype|function|return|varchar|varchar2|char|number|long|float|double|integer|int|tinyint|datetime|text|date|timestamp|out|body|rowtype|values|into|nextval|begin|end|table|type|loop|constant|exception|pragma|exception_init|is|while|then|else|raise|others|when|delete|merge|union|commit|rollback|clob|if|elsif|join|using|set|values|sysdate|inner|outer|exists|distinct|sequence|on|matched|where|and|rownum|boolean|default|count|cursor|for|in)\b/gi
17 | },
18 | {
19 | name: "string",
20 | pattern: /'([^']|(''))*'/g
21 | },
22 | {
23 | name: "number",
24 | pattern: /\b[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\b/g
25 | },
26 | {
27 | name: "comment",
28 | pattern: /\/\*[\s\S]*?\*\/|(--).*?$/gm
29 | },
30 | {
31 | name: "operator",
32 | pattern: /(\+{1,2}|-{1,2}|~|!|\*|\/|%|(?:<){1,2}|(?:>){1,3}|(?:&){1,2}|\^|\|{1,2}|\?|:|(?:=|!|\+|-|\*|\/|%|\^|\||:=|(?:<){1,2}|(?:>){1,3})?=)/g
33 | }
34 | ], true );
--------------------------------------------------------------------------------
/s5/_ui/rainbow/themes/twilight.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Twilight theme
3 | *
4 | * Adapted from Michael Sheets' TextMate theme of the same name
5 | *
6 | * @author Michael Sheets
7 | * @author Jesse Farmer First example:
11 |// You can edit this code!
12 | // Click here and start typing.
13 | package main
14 |
15 | import "fmt"
16 |
17 | func main() {
18 | fmt.Println("Hello, world!")
19 | }
20 |
21 | package main
22 |
23 | // fib returns a function that returns
24 | // successive Fibonacci numbers.
25 | func fib() func() int {
26 | a, b := 0, 1
27 | return func() int {
28 | a, b = b, a+b
29 | c = 256
30 | return a
31 | }
32 | }
33 |
34 | func main() {
35 | f := fib()
36 | // Function calls are evaluated left-to-right.
37 | println(f(), f(), f(), f(), f())
38 | }
39 |
40 | Another Example:
41 | 42 |/*
43 | This is a long comment
44 | Second line.
45 | */
46 | package main
47 |
48 | import (
49 | "fmt"
50 | "github.com/hoisie/web.go"
51 | )
52 |
53 | type mytype struct {
54 | A string
55 | B string
56 | C int
57 | D int64
58 | E uint8
59 | F complex128
60 | G float32
61 | }
62 |
63 | var page = `
64 | This is a long string
65 | This is another string
66 | `
67 |
68 | func index() string { return page }
69 |
70 | func process(ctx *web.Context) string {
71 | var data mytype
72 | ctx.UnmarshalParams(&data)
73 | return fmt.Sprintf("%v\n", data)
74 | }
75 |
76 | func main() {
77 | web.Get("/", index)
78 | web.Post("/process", process)
79 | web.Run("0.0.0.0:9999")
80 | }
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/demos/r.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 | ## Probability density function for the Generalised Normal Laplace distribution
10 | dgnl <- function(x, mu = 0, sigma = 1, alpha = 1, beta = 1, rho = 1,
11 | param = c(mu, sigma, alpha, beta, rho)) {
12 |
13 | ## check parameters
14 | parResult <- gnlCheckPars(param)
15 | case <- parResult$case
16 | errMessage <- parResult$errMessage
17 |
18 | if (case == "error")
19 | stop(errMessage)
20 |
21 | mu <- param[1]
22 | sigma <- param[2]
23 | alpha <- param[3]
24 | beta <- param[4]
25 | rho <- param[5]
26 |
27 | ## Shifting by mu
28 | x <- x - mu
29 |
30 | ## Initialising result vector
31 | pdfValues <- rep(0, length(x))
32 |
33 | ## Because 'integrate' doesn't take vectors as input, we need to iterate over
34 | ## x to evaluate densities
35 | for (i in 1:length(x)) {
36 | ## Modified characteristic function. Includes minor calculation regarding
37 | ## complex numbers to ensure the function returns a real number
38 | chfn <- function(s) {
39 | result <- (alpha * beta * exp(-((sigma^2 * s^2) / 2))) /
40 | (complex(real = alpha, imaginary = -s) *
41 | complex(real = beta, imaginary = s))
42 | result <- result^rho ## Scaling result by rho
43 | r <- Mod(result)
44 | theta <- Arg(result)
45 | r * cos(theta - (s * x[i]))
46 | }
47 |
48 | ## Integrating modified characteristic function
49 | pdfValues[i] <- (1 / pi) * integrate(chfn, 0, Inf)$value
50 | }
51 |
52 | ## Returning vector of densities
53 | pdfValues
54 | }
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/tests/tests.css:
--------------------------------------------------------------------------------
1 | ul, li, h1, h2, h3, h4, h5, h6 {
2 | margin: 0px;
3 | padding: 0px;
4 | }
5 |
6 | h1 {
7 | margin-bottom: 15px;
8 | }
9 |
10 | body {
11 | font-family: helvetica;
12 | }
13 |
14 | a {
15 | text-decoration: none;
16 | color: #666;
17 | }
18 |
19 | select {
20 | width: 200px;
21 | height: 200px;
22 | font-size: 14px;
23 | }
24 |
25 | form label {
26 | display: block;
27 | margin-top: 10px;
28 | }
29 |
30 | form input {
31 | margin-top: 10px;
32 | }
33 |
34 | ul {
35 | padding-left: 20px;
36 | margin-left: 20px;
37 | }
38 |
39 | .global_toggle {
40 | position: relative;
41 | float: right;
42 | top: 15px;
43 | display: none;
44 | }
45 |
46 | h3 {
47 | margin-top: 30px;
48 | margin-bottom: 10px;
49 | }
50 |
51 | li {
52 | font-size: 30px;
53 | }
54 |
55 | .success a:hover, .failure a:hover, a:hover {
56 | color: #000;
57 | }
58 |
59 | a:active {
60 | color: #ff8009 !important;
61 | }
62 |
63 | pre {
64 | margin-bottom: 10px;
65 | }
66 |
67 | li h5 {
68 | font-size: 16px;
69 | color: #000;
70 | }
71 |
72 | .success, .success a {
73 | color: green;
74 | }
75 |
76 | .success .code, .failure .code {
77 | display: none;
78 | }
79 |
80 | .failure, .failure a {
81 | color: red;
82 | }
83 |
84 | .failure .code {
85 | margin-top: 5px;
86 | }
87 |
88 | h6 {
89 | font-size: 14px;
90 | color: #666;
91 | }
92 |
93 | table {
94 | margin-top: 25px;
95 | margin-bottom: 25px;
96 | /*border: 2px solid #000;*/
97 | border-collapse: collapse;
98 | }
99 |
100 | table th {
101 | text-align: left;
102 | padding: 5px 20px 5px 5px;
103 | }
104 |
105 | table td {
106 | border: 1px solid #999;
107 | padding: 4px;
108 | }
109 |
110 | table tr td:first-child {
111 | /*border: 0px;*/
112 | }
113 |
114 | table tr:last-child td:first-child {
115 | /*border-bottom: 0px;*/
116 | }
117 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/c.js:
--------------------------------------------------------------------------------
1 | /**
2 | * C patterns
3 | *
4 | * @author Daniel Holden
5 | * @author Craig Campbell
6 | * @version 1.0.6
7 | */
8 | Rainbow.extend('c', [
9 | {
10 | 'name': 'meta.preprocessor',
11 | 'matches': {
12 | 1: [
13 | {
14 | 'matches': {
15 | 1: 'keyword.define',
16 | 2: 'entity.name'
17 | },
18 | 'pattern': /(\w+)\s(\w+)\b/g
19 | },
20 | {
21 | 'name': 'keyword.define',
22 | 'pattern': /endif/g
23 | },
24 | {
25 | 'name': 'constant.numeric',
26 | 'pattern': /\d+/g
27 | },
28 | {
29 | 'matches': {
30 | 1: 'keyword.include',
31 | 2: 'string'
32 | },
33 | 'pattern': /(include)\s(.*?)$/g
34 | }
35 | ]
36 | },
37 | 'pattern': /\#([\S\s]*?)$/gm
38 | },
39 | {
40 | 'name': 'keyword',
41 | 'pattern': /\b(do|goto|continue|break|switch|case|typedef)\b/g
42 | },
43 | {
44 | 'name': 'entity.label',
45 | 'pattern': /\w+:/g
46 | },
47 | {
48 | 'matches': {
49 | 1: 'storage.type',
50 | 3: 'storage.type',
51 | 4: 'entity.name.function'
52 | },
53 | 'pattern': /\b((un)?signed|const)? ?(void|char|short|int|long|float|double)\*? +((\w+)(?= ?\())?/g
54 | },
55 | {
56 | 'matches': {
57 | 2: 'entity.name.function'
58 | },
59 | 'pattern': /(\w|\*) +((\w+)(?= ?\())/g
60 | },
61 | {
62 | 'name': 'storage.modifier',
63 | 'pattern': /\b(static|extern|auto|register|volatile|inline)\b/g
64 | },
65 | {
66 | 'name': 'support.type',
67 | 'pattern': /\b(struct|union|enum)\b/g
68 | }
69 | ]);
70 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/demos/coffeescript.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Assignment:
8 | number = 42
9 | opposite = true
10 |
11 | # Conditions:
12 | number = -42 if opposite
13 |
14 | # Functions:
15 | square = (x) -> x * x
16 |
17 | # Arrays:
18 | list = [1, 2, 3, 4, 5]
19 |
20 | # Objects:
21 | math =
22 | root: Math.sqrt
23 | square: square
24 | cube: (x) -> x * square x
25 |
26 | # Splats:
27 | race = (winner, runners...) ->
28 | print winner, runners
29 |
30 | # Existence:
31 | alert "I knew it!" if elvis?
32 |
33 | # Array comprehensions:
34 | cubes = (math.cube num for num in list)
35 |
36 | class Animal
37 | constructor: (@name) ->
38 |
39 | move: (meters) ->
40 | alert @name + " moved #{meters}m."
41 |
42 | class Snake extends Animal
43 | move: ->
44 | alert "Slithering..."
45 | super 5
46 |
47 | class Horse extends Animal
48 | move: ->
49 | alert "Galloping..."
50 | super 45
51 |
52 | sam = new Snake "Sammy the Python"
53 | tom = new Horse "Tommy the Palomino"
54 |
55 | sam.move()
56 | tom.move()
57 | weatherReport = (location) ->
58 | # Make an Ajax request to fetch the weather...
59 | [location, 72, "Mostly Sunny"]
60 |
61 | [city, temp, forecast] = weatherReport "Berkeley, CA"
62 |
63 | fs = require 'fs'
64 |
65 | option '-o', '--output [DIR]', 'directory for compiled code'
66 |
67 | task 'build:parser', 'rebuild the Jison parser', (options) ->
68 | require 'jison'
69 | code = require('./lib/grammar').parser.generate()
70 | dir = options.output or 'lib'
71 | fs.writeFile "#{dir}/parser.js", code
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/demos/php.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | // this is some sample php code
9 | $i = 0;
10 | for ($i = 0; $i < 25; ++$i) {
11 | echo $i;
12 | }
13 |
14 | # comment like this
15 | function customFunction()
16 | {
17 | return mt_rand(1, 100);
18 | }
19 |
20 | while ($test) {
21 | echo 'blah' . "\n";
22 | };
23 |
24 | $fruits = array('banana', 'strawberry', 'blueberry', 'apple', 'blackberry');
25 |
26 | asort($fruits);
27 |
28 | foreach ($fruits as $key => $value) {
29 | echo $value;
30 | }
31 |
32 |
33 |
34 | <?php
35 | namespace Sonic;
36 |
37 | /**
38 | * Util
39 | *
40 | * @category Sonic
41 | * @package Util
42 | * @author Craig Campbell
43 | */
44 | class Util
45 | {
46 | /**
47 | * deletes a directory recursively
48 | *
49 | * php's native rmdir() function only removes a directory if there is nothing in it
50 | *
51 | * @param string $path
52 | * @return void
53 | */
54 | public static function removeDir($path)
55 | {
56 | if (is_link($path)) {
57 | return unlink($path);
58 | }
59 |
60 | $files = new \RecursiveDirectoryIterator($path);
61 | foreach ($files as $file) {
62 | if (in_array($file->getFilename(), array('.', '..'))) {
63 | continue;
64 | }
65 |
66 | if ($file->isLink()) {
67 | unlink($file->getPathName());
68 | continue;
69 | }
70 |
71 | if ($file->isFile()) {
72 | unlink($file->getRealPath());
73 | continue;
74 | }
75 |
76 | if ($file->isDir()) {
77 | self::removeDir($file->getRealPath());
78 | }
79 | }
80 | return rmdir($path);
81 | }
82 | }
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/html.js:
--------------------------------------------------------------------------------
1 | /**
2 | * HTML patterns
3 | *
4 | * @author Craig Campbell
5 | * @version 1.0.7
6 | */
7 | Rainbow.extend('html', [
8 | {
9 | 'name': 'source.php.embedded',
10 | 'matches': {
11 | 2: {
12 | 'language': 'php'
13 | }
14 | },
15 | 'pattern': /<\?=?(?!xml)(php)?([\s\S]*?)(\?>)/gm
16 | },
17 | {
18 | 'name': 'source.css.embedded',
19 | 'matches': {
20 | 0: {
21 | 'language': 'css'
22 | }
23 | },
24 | 'pattern': /<style(.*?)>([\s\S]*?)<\/style>/gm
25 | },
26 | {
27 | 'name': 'source.js.embedded',
28 | 'matches': {
29 | 0: {
30 | 'language': 'javascript'
31 | }
32 | },
33 | 'pattern': /<script(?! src)(.*?)>([\s\S]*?)<\/script>/gm
34 | },
35 | {
36 | 'name': 'comment.html',
37 | 'pattern': /<\!--[\S\s]*?-->/g
38 | },
39 | {
40 | 'matches': {
41 | 1: 'support.tag.open',
42 | 2: 'support.tag.close'
43 | },
44 | 'pattern': /(<)|(\/?\??>)/g
45 | },
46 | {
47 | 'name': 'support.tag',
48 | 'matches': {
49 | 1: 'support.tag',
50 | 2: 'support.tag.special',
51 | 3: 'support.tag-name'
52 | },
53 | 'pattern': /(<\??)(\/|\!?)(\w+)/g
54 | },
55 | {
56 | 'matches': {
57 | 1: 'support.attribute'
58 | },
59 | 'pattern': /([a-z-]+)(?=\=)/gi
60 | },
61 | {
62 | 'matches': {
63 | 1: 'support.operator',
64 | 2: 'string.quote',
65 | 3: 'string.value',
66 | 4: 'string.quote'
67 | },
68 | 'pattern': /(=)('|")(.*?)(\2)/g
69 | },
70 | {
71 | 'matches': {
72 | 1: 'support.operator',
73 | 2: 'support.value'
74 | },
75 | 'pattern': /(=)([a-zA-Z\-0-9]*)\b/g
76 | },
77 | {
78 | 'matches': {
79 | 1: 'support.attribute'
80 | },
81 | 'pattern': /\s(\w+)(?=\s|>)(?![\s\S]*<)/g
82 | }
83 | ], true);
84 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/demos/js.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | /**
8 | * test function
9 | *
10 | * @param string
11 | * @return string
12 | */
13 | function blah(foo, blah) {
14 | var test = 25;
15 |
16 | console.log(test.length);
17 |
18 | // if foo is true then return this string
19 | if (foo === true) {
20 | return 'foo is true';
21 | }
22 | return 'foo is false';
23 | }
24 |
25 | $(document).ready(function() {
26 | $("table").on("click", "td", function() {
27 | console.log('td click');
28 | });
29 | });
30 |
31 |
32 |
33 |
34 | window.Rainbow = {
35 | whatever: function(param) {
36 |
37 | },
38 |
39 | another: function(param) {
40 |
41 | }
42 | };
43 |
44 |
45 |
46 | window.Rainbow = window.Rainbow || {};
47 |
48 | Rainbow.extend('javascript', [
49 | {
50 | 'name': 'selector',
51 | 'pattern': /\$(?=\.|\()/g
52 | }
53 | ]);
54 |
55 |
56 |
57 | /**
58 | * cross browser get attribute for an element
59 | *
60 | * @see http://stackoverflow.com/questions/3755227/cross-browser-javascript-getattribute-method
61 | *
62 | * @param {Element} el
63 | * @param {string} attr attribute you are trying to get
64 | * @returns {string}
65 | */
66 | function _attr(el, attr) {
67 | var result = (el.getAttribute && el.getAttribute(attr)) || null;
68 |
69 | if (!result) {
70 | var attrs = el.attributes,
71 | length = attrs.length,
72 | i;
73 |
74 | for (i = 0; i < length; ++i) {
75 | if (attr[i].nodeName === attr) {
76 | result = attr[i].nodeValue;
77 | }
78 | }
79 | }
80 |
81 | return result;
82 | }
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/themes/pastie.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Pastie theme
3 | *
4 | * @author pygments.org
5 | * @author pastie.org
6 | * @author Simon Potter
7 | * @version 1.0
8 | */
9 |
10 | pre {
11 | /* original is white background with no border */
12 | background-color: #F8F8FF;
13 | border: 1px solid #DEDEDE;
14 | word-wrap: break-word;
15 | margin: 0;
16 | padding: 0;
17 | color: #000;
18 | font-size: 13px;
19 | line-height: 16px;
20 | margin-bottom: 20px
21 | }
22 |
23 | pre, code {
24 | font-family: monospace;
25 | }
26 |
27 | pre .comment {
28 | color: #888;
29 | }
30 |
31 | pre .keyword, pre .selector, pre .storage.module, pre .storage.class, pre .storage.function {
32 | color: #080;
33 | font-weight: bold;
34 | }
35 |
36 | pre .keyword.operator {
37 | color: #000;
38 | font-weight: normal;
39 | }
40 |
41 | pre .constant.language {
42 | color: #038;
43 | font-weight:bold;
44 | }
45 |
46 | pre .constant.symbol, pre .class, pre .constant {
47 | color: #036;
48 | font-weight: bold;
49 | }
50 |
51 | pre .keyword.namespace, pre .entity.name.class {
52 | color: #B06;
53 | font-weight: bold;
54 | }
55 |
56 | pre .constant.numeric {
57 | color: #00D;
58 | font-weight: bold;
59 | }
60 |
61 | pre .string, pre .comment.docstring {
62 | color: #D20;
63 | background-color: #FFF0F0;
64 | }
65 |
66 | pre .string.regexp {
67 | background-color: #FFF0FF;
68 | color: #808;
69 | }
70 |
71 | pre .variable.instance {
72 | color: #33B;
73 | }
74 |
75 | pre .entity.name.function {
76 | color: #06B;
77 | font-weight: bold;
78 | }
79 |
80 | pre .support.tag-name, pre .entity.tag.script, pre .entity.tag.style {
81 | color: #070;
82 | }
83 |
84 | pre .support.attribute {
85 | color: #007;
86 | font-style: italic;
87 | }
88 |
89 | pre .entity.name.tag, pre .storage.type {
90 | color: #070;
91 | font-weight: bold;
92 | }
93 |
94 | pre .variable.self, pre .support.function {
95 | color: #038;
96 | font-weight: bold;
97 | }
98 |
99 | pre .entity.function, pre .support.magic, pre.support.method {
100 | color: #C00;
101 | font-weight: bold;
102 | }
103 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/tests/api.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | code on page to begin with
9 |var foo = false;10 |
9 | # Comments
10 | not_comment # comment
11 |
12 | =begin
13 | comment
14 | =end
15 |
16 | =begin
17 | not_comment
18 | =end
19 |
20 | # Strings
21 | 'string'
22 | "string"
23 | %q(string)
24 | %q[string]
25 | %q{string}
26 | %q<string>
27 | %q|string|
28 | %Q(string)
29 | %Q[string]
30 | %Q{string}
31 | %Q<string>
32 | %Q|string|
33 |
34 | foo('string', 'string')
35 |
36 | "unsupported\"string"
37 |
38 | # Heredocs
39 | if true
40 | DOC = foo(<<-DOC)
41 | heredoc
42 | xxx
43 | xxx
44 | DOC
45 | # ^heredoc ends here
46 | DOC
47 | end
48 |
49 | if true
50 | DOC = foo(<<DOC)
51 | heredoc
52 | xxx
53 | xxx
54 | DOC
55 | DOC
56 | # ^heredoc ends here
57 | end
58 |
59 | # Symbols
60 | :symbol
61 | :'long symbol'
62 | :"long symbol"
63 |
64 | # Regular Expressions
65 | /regex/xxx
66 | %r(regex)xxx
67 | %r[regex]xxx
68 | %r{regex}xxx
69 | %r<regex>xxx
70 | %r|regex|xxx
71 |
72 | foo(/regex/xxx, /regex/xxx)
73 | @path.sub(/^#{@root}/, '')
74 |
75 | /unsupported\/regex/
76 |
77 | # Classes
78 | class Test < Object
79 | attr_accessor :z
80 | end
81 |
82 | x = Test.method(1, 2)
83 | x = Test::method(1, 2)
84 | x = Test::CONSTANT
85 |
86 | # Methods
87 | def method(x, y)
88 | z = 3
89 | end
90 |
91 | def self.method(x, y)
92 | z = 3
93 | end
94 |
95 | # Sigils
96 | $stderr.puts 3
97 | @@foo = 3
98 | @foo = 3
99 |
100 | # Data Structures
101 | [:value]
102 | ['value']
103 | {:key=>'value'}
104 | {:key => 'value'}
105 | {'key' => 'value'}
106 | {key: 'value'}
107 | foo(:key => 'value')
108 | foo(key: 'value')
109 |
110 | # Classes, modules, etc.
111 | module Foo
112 | CONSTANT = 'An \'escaped\' string'
113 | class Bar
114 | def self.something
115 | begin
116 | 1 + 1
117 | rescue StandardError => e
118 | puts "Whoa buddy!"
119 | end
120 |
121 | class << self
122 | def something
123 | 1 + 1
124 | end
125 | end
126 |
127 | def something
128 | end
129 | end
130 | end
131 |
132 | class MyClass < ::Foo::Bar
133 | end
134 |
135 | foo(::Foo::Bar.something)
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/remote/public/_includes/js/site.js:
--------------------------------------------------------------------------------
1 | /*
2 | * S5 Controller
3 | */
4 | (function(doc, $) {
5 |
6 | var $notes, $slideCount, $totalSlides;
7 |
8 | // init on dom load
9 | $.domReady(function(){
10 | detectClicks();
11 | $notes = $(".notes");
12 | $currentSlide = $(".current-slide");
13 | $totalSlides = $(".total-slides");
14 | });
15 |
16 | // set up websockets
17 | var socket = io.connect();
18 |
19 | // connection established
20 | socket.on('open', function (data) {
21 | log("remote", data);
22 | });
23 |
24 | // message received
25 | socket.on('message', function (data) {
26 | log("remote", data);
27 | });
28 |
29 | // update notes
30 | socket.on('notes', function (data){
31 | $notes.html(data.notes);
32 | $currentSlide.html(data.currentSlide);
33 | $totalSlides.html(data.totalSlides);
34 | log("updated notes", data);
35 | });
36 |
37 | // connection closed
38 | socket.on('close', function (data) {
39 | log("remote", data);
40 | });
41 |
42 |
43 | // detect previous/next clicks
44 | function detectClicks() {
45 | var $prev = $("a.prev"),
46 | $next = $("a.next");
47 |
48 | $prev.on('click', function(e){
49 | this.blur();
50 | e.preventDefault();
51 | send("prev");
52 | });
53 |
54 | $next.on('click', function(e){
55 | this.blur();
56 | e.preventDefault();
57 | send("next");
58 | });
59 | }
60 |
61 |
62 | // send (and log) a message
63 | function send(message) {
64 | socket.emit("move", {message:message});
65 | log("local", message);
66 | }
67 |
68 |
69 | // log recieved messages
70 | function log(source, message) {
71 | console.log(source, " message received: ", message);
72 | }
73 |
74 |
75 | /*
76 | * iOS viewport fix
77 | * https://raw.github.com/gist/901295/bf9a44b636a522e608bba11a91b8298acd081f50/ios-viewport-scaling-bug-fix.js
78 | * By @mathias, @cheeaun and @jdalton
79 | */
80 | (function(){
81 | var addEvent = 'addEventListener',
82 | type = 'gesturestart',
83 | qsa = 'querySelectorAll',
84 | scales = [1, 1],
85 | meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
86 |
87 | function fix() {
88 | meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
89 | doc.removeEventListener(type, fix, true);
90 | }
91 |
92 | if ((meta = meta[meta.length - 1]) && addEvent in doc) {
93 | fix();
94 | scales = [0.25, 1.6];
95 | doc[addEvent](type, fix, true);
96 | }
97 | })();
98 |
99 | }(document, $));
100 |
101 |
102 | // hide address bar
103 | window.addEventListener('load', function(e) {
104 | setTimeout(function() { window.scrollTo(0, 1); }, 1);
105 | }, false);
--------------------------------------------------------------------------------
/s5/_ui/rainbow/demos/python.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | #!/usr/bin/env python
9 | # Copyright 2012 Craig Campbell
10 | #
11 | # Licensed under the Apache License, Version 2.0 (the "License");
12 | # you may not use this file except in compliance with the License.
13 | # You may obtain a copy of the License at
14 | #
15 | # http://www.apache.org/licenses/LICENSE-2.0
16 | #
17 | # Unless required by applicable law or agreed to in writing, software
18 | # distributed under the License is distributed on an "AS IS" BASIS,
19 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | # See the License for the specific language governing permissions and
21 | # limitations under the License.
22 | import re, os, math
23 | from util import Util
24 | from instrument import Instrument
25 |
26 | class WarpWhistle(object):
27 | TEMPO = 'tempo'
28 | VOLUME = 'volume'
29 | TIMBRE = 'timbre'
30 | ARPEGGIO = 'arpeggio'
31 | INSTRUMENT = 'instrument'
32 | PITCH = 'pitch'
33 | OCTAVE = 'octave'
34 | SLIDE = 'slide'
35 | Q = 'q'
36 |
37 | ABSOLUTE_NOTES = 'X-ABSOLUTE-NOTES'
38 | TRANSPOSE = 'X-TRANSPOSE'
39 | COUNTER = 'X-COUNTER'
40 | X_TEMPO = 'X-TEMPO'
41 | SMOOTH = 'X-SMOOTH'
42 | N106 = 'EX-NAMCO106'
43 | FDS = 'EX-DISKFM'
44 | VRC6 = 'EX-VRC6'
45 | PITCH_CORRECTION = 'PITCH-CORRECTION'
46 |
47 | CHIP_N106 = 'N106'
48 | CHIP_FDS = 'FDS'
49 | CHIP_VRC6 = 'VRC6'
50 |
51 | def __init__(self, content, logger, options):
52 | self.first_run = True
53 |
54 | # current voice we are processing if we are processing voices separately
55 | self.process_voice = None
56 |
57 | # list of voices to process
58 | self.voices_to_process = None
59 |
60 | # list of voices
61 | self.voices = None
62 |
63 | self.content = content
64 | self.logger = logger
65 | self.options = options
66 | self.reset()
67 |
68 | def reset(self):
69 | """
70 | This method resets the properties of the instance.
71 | """
72 | self.current_voices = []
73 | self.global_vars = {}
74 | self.vars = {}
75 | self.instruments = {}
76 | self.data = {}
77 | self.global_lines = []
78 |
79 | def getDataForVoice(self, voice, key):
80 | if not voice in self.data:
81 | return None
82 |
83 | if not key in self.data[voice]:
84 | return None
85 |
86 | return self.data[voice][key]
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/s5/_ui/pg/slide-websockets.js:
--------------------------------------------------------------------------------
1 | // Slide websockets
2 |
3 | /*
4 | * Init on load
5 | */
6 | (function(){
7 |
8 | // only start the sockets once...
9 | var socketOn = false;
10 |
11 |
12 | // add load event
13 | if (window.addEventListener) {
14 | window.addEventListener("load", init, false);
15 | }
16 |
17 |
18 | /*
19 | * init web sockets
20 | */
21 | function init() {
22 |
23 | // enter the password to activate bonus mode
24 | var
25 | kkeys = [],
26 | password = "71,79"; //this spells guns
27 |
28 | if (window.addEventListener) {
29 | window.addEventListener('keydown', function(e){
30 | kkeys.push( e.keyCode );
31 | if ( kkeys.toString().indexOf( password ) >= 0 ) {
32 | console.log("starting controller");
33 | startController();
34 | kkeys = [];
35 | }
36 | });
37 | }
38 | }
39 |
40 |
41 |
42 | function startController() {
43 |
44 | var socket, note;
45 |
46 | // only start sockets once
47 | if (!!socketOn) {
48 | return;
49 | }
50 | socketOn = true;
51 |
52 | console.log("web sockets activated");
53 |
54 | // set up websockets
55 | socket = io.connect(websocketUrl);
56 |
57 | // connection established
58 | socket.on('connect', function () {
59 | console.log("socket connected");
60 | socket.emit("slide-notes",{
61 | currentSlide: snum+1,
62 | totalSlides : smax,
63 | notes : getNote()
64 | });
65 | });
66 |
67 | // move received
68 | socket.on('shift', function (data) {
69 |
70 | console.log("shift", data);
71 |
72 | note = getNote(data.dir);
73 |
74 | // trigger 'left' keypress for s5
75 | if (data.dir === "prev") {
76 | keys({which:37});
77 | socket.emit("slide-notes",{
78 | currentSlide: snum+1,
79 | totalSlides : smax,
80 | notes : note
81 | });
82 | }
83 |
84 | // trigger 'right' keypress for s5
85 | if (data.dir === "next") {
86 | keys({which:39});
87 | socket.emit("slide-notes",{
88 | currentSlide: snum+1,
89 | totalSlides : smax,
90 | notes : note
91 | });
92 | }
93 | });
94 | }
95 |
96 |
97 | function getNote(dir) {
98 | var notesEl, notes, slideNo;
99 |
100 | if (dir === "next") {
101 | slideNo = snum + 1;
102 | } else if (dir === "prev") {
103 | slideNo = snum - 1;
104 | } else {
105 | slideNo = snum;
106 | }
107 |
108 | notesEl = document.querySelectorAll('.slide')[slideNo].querySelector('.notes');
109 | if (notesEl) {
110 | notes = notesEl.innerHTML;
111 | } else {
112 | notes = "[no notes]";
113 | }
114 |
115 | return notes;
116 | }
117 | })();
--------------------------------------------------------------------------------
/goog/assets/slide-websockets.js:
--------------------------------------------------------------------------------
1 | // Slide websockets
2 |
3 | /*
4 | * Init on load
5 | */
6 | (function(){
7 |
8 | // only start the sockets once...
9 | var socketOn = false;
10 |
11 |
12 | // add load event
13 | if (window.addEventListener) {
14 | window.addEventListener("load", init, false);
15 | }
16 |
17 |
18 | /*
19 | * init web sockets
20 | */
21 | function init() {
22 |
23 | // enter the password to activate web sockets
24 | var
25 | kkeys = [],
26 | password = "71,79"; //this spells go
27 |
28 | if (window.addEventListener) {
29 | window.addEventListener('keydown', function(e){
30 | kkeys.push( e.keyCode );
31 | if ( kkeys.toString().indexOf( password ) >= 0 ) {
32 | console.log("starting controller");
33 | startController();
34 | kkeys = [];
35 | }
36 | });
37 | }
38 | }
39 |
40 |
41 |
42 | function startController() {
43 |
44 | var socket, note;
45 |
46 | // only start sockets once
47 | if (!!socketOn) {
48 | return;
49 | }
50 | socketOn = true;
51 |
52 | console.log("web sockets activated");
53 |
54 | // set up websockets
55 | socket = io.connect(websocketUrl);
56 |
57 | // connection established
58 | socket.on('connect', function () {
59 | console.log("socket connected");
60 | socket.emit("slide-notes",{
61 | currentSlide: curSlide+1,
62 | totalSlides : slideEls.length,
63 | notes : getNote()
64 | });
65 | });
66 |
67 | // move received
68 | socket.on('shift', function (data) {
69 |
70 | console.log("shift", data);
71 |
72 | note = getNote(data.dir);
73 |
74 | // trigger 'left' keypress for s5
75 | if (data.dir === "prev") {
76 | prevSlide();
77 | socket.emit("slide-notes",{
78 | currentSlide: curSlide+1,
79 | totalSlides : slideEls.length,
80 | notes : note
81 | });
82 | }
83 |
84 | // trigger 'right' keypress for s5
85 | if (data.dir === "next") {
86 | nextSlide();
87 | socket.emit("slide-notes",{
88 | currentSlide: curSlide+1,
89 | totalSlides : slideEls.length,
90 | notes : note
91 | });
92 | }
93 | });
94 | }
95 |
96 |
97 | function getNote(dir) {
98 | var notesEl, notes, slideNo;
99 |
100 | if (dir === "next") {
101 | slideNo = curSlide + 1;
102 | } else if (dir === "prev") {
103 | slideNo = curSlide - 1;
104 | } else {
105 | slideNo = curSlide;
106 | }
107 |
108 | notesEl = document.querySelectorAll('article')[slideNo].querySelector('.notes');
109 | if (notesEl) {
110 | notes = notesEl.innerHTML;
111 | } else {
112 | notes = "[no notes]";
113 | }
114 |
115 | return notes;
116 | }
117 | })();
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/r.js:
--------------------------------------------------------------------------------
1 | /**
2 | * R language patterns
3 | *
4 | * @author Simon Potter
5 | * @version 1.0
6 | */
7 | Rainbow.extend('r', [
8 | /**
9 | * Note that a valid variable name is of the form:
10 | * [.a-zA-Z][0-9a-zA-Z._]*
11 | */
12 | {
13 | 'matches': {
14 | 1: {
15 | 'name': 'keyword.operator',
16 | 'pattern': /\=|<\-|<-/g
17 | },
18 | 2: {
19 | 'name': 'string',
20 | 'matches': {
21 | 'name': 'constant.character.escape',
22 | 'pattern': /\\('|"){1}/g
23 | }
24 | }
25 | },
26 | 'pattern': /(\(|\s|\[|\=|:)(('|")([^\\\1]|\\.)*?(\3))/gm
27 | },
28 |
29 | /**
30 | * Most of these are known via the Language Reference.
31 | * The built-in constant symbols are known via ?Constants.
32 | */
33 | {
34 | 'matches': {
35 | 1: 'constant.language'
36 | },
37 | 'pattern': /\b(NULL|NA|TRUE|FALSE|T|F|NaN|Inf|NA_integer_|NA_real_|NA_complex_|NA_character_)\b/g
38 | },
39 | {
40 | 'matches': {
41 | 1: 'constant.symbol'
42 | },
43 | 'pattern': /[^0-9a-zA-Z\._](LETTERS|letters|month\.(abb|name)|pi)/g
44 | },
45 |
46 | /**
47 | * @todo: The list subsetting operator isn't quite working properly.
48 | * It includes the previous variable when it should only match [[
49 | */
50 | {
51 | 'name': 'keyword.operator',
52 | 'pattern': /<-|<-|-|==|<=|<=|>>|>=|<|>|&&|&&|&|&|!=|\|\|?|\*|\+|\^|\/|%%|%\/%|\=|%in%|%\*%|%o%|%x%|\$|:|~|\[{1,2}|\]{1,2}/g
53 | },
54 | {
55 | 'matches': {
56 | 1: 'storage',
57 | 3: 'entity.function'
58 | },
59 | 'pattern': /(\s|^)(.*)(?=\s?=\s?function\s\()/g
60 | },
61 | {
62 | 'matches': {
63 | 1: 'storage.function'
64 | },
65 | 'pattern': /[^a-zA-Z0-9._](function)(?=\s*\()/g
66 | },
67 | {
68 | 'matches': {
69 | 1: 'namespace',
70 | 2: 'keyword.operator',
71 | 3: 'function.call'
72 | },
73 | 'pattern': /([a-zA-Z][a-zA-Z0-9._]+)([:]{2,3})([.a-zA-Z][a-zA-Z0-9._]*(?=\s*\())\b/g
74 | },
75 |
76 | /*
77 | * Note that we would perhaps match more builtin functions and
78 | * variables, but there are so many that most are ommitted for now.
79 | * See ?builtins for more info.
80 | *
81 | * @todo: Fix the case where we have a function like tmp.logical().
82 | * This should just be a function call, at the moment it's
83 | * only partly a function all.
84 | */
85 | {
86 | 'name': 'support.function',
87 | 'pattern': /(^|[^0-9a-zA-Z\._])(array|character|complex|data\.frame|double|integer|list|logical|matrix|numeric|vector)(?=\s*\()/g
88 | }
89 | ]);
90 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/rainbow.min.js:
--------------------------------------------------------------------------------
1 | /* Rainbow v1.1.8 rainbowco.de */
2 | window.Rainbow=function(){function q(a){var b,c=a.getAttribute&&a.getAttribute("data-language")||0;if(!c){a=a.attributes;for(b=0;bdef openFile(path):
17 | file = open(path, "r")
18 | content = file.read()
19 | file.close()
20 | return content
21 | ```
22 |
23 | 2. Include a CSS theme file in the ````:
24 |
25 | ```html
26 |
27 | ```
28 |
29 | 3. Include rainbow.js and whatever languages you want before the closing ````:
30 |
31 | ```html
32 |
33 |
34 |
35 | ```
36 |
37 | ## Extending Rainbow
38 | If you have a language specific pattern that you want highlighted, but it does not exist in the language syntax rules you can add a rule on your page.
39 |
40 | Let's say for example you want to reference PHP's apc functions.
41 | You can include the php language then in the markup on your page add:
42 |
43 | ```html
44 |
54 | ```
55 |
56 | ## Supported Languages
57 |
58 | Currently supported languages are:
59 | - C
60 | - C#
61 | - Coffeescript
62 | - CSS
63 | - Go
64 | - HTML
65 | - Java
66 | - Javascript
67 | - Lua
68 | - PHP
69 | - Python
70 | - R
71 | - Ruby
72 | - Scheme
73 | - Shell
74 | - Smalltalk
75 |
76 | ## Building
77 |
78 | Rainbow gets minified with the closure compiler. You can install it on OS X via Homebrew:
79 |
80 | brew install closure-compiler
81 |
82 | To build a minified version of your changes, you can run the compile script:
83 |
84 | ./util/compile.py --core
85 |
86 | In case the compiler cannot be found (which is the case if you installed via Homebrew),
87 | you will have to specify the path to the compiler.jar (see `brew info closure-compiler`) -
88 | here's an example:
89 |
90 | CLOSURE_COMPILER=/usr/local/Cellar/closure-compiler/20120710/libexec/build/compiler.jar util/compile.py --core
91 |
92 | If you want to build a custom version, list the languages you would like to include as
93 | command line arguments:
94 |
95 | util/compile.py ruby javascript
96 |
97 | ## More Info
98 |
99 | If you are looking for line number support you can try one of the following:
100 | - https://github.com/Blender3D/rainbow.linenumbers.js
101 | - https://github.com/Sjeiti/rainbow.linenumbers
102 |
103 | You can check out additional documentation and build custom packages at [rainbowco.de](http://rainbowco.de).
104 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/coffeescript.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Coffeescript patterns
3 | *
4 | * @author Craig Campbell
5 | * @version 1.0
6 | */
7 | Rainbow.extend('coffeescript', [
8 | {
9 | 'name': 'comment.block',
10 | 'pattern': /(\#{3})[\s\S]*\1/gm
11 | },
12 | {
13 | 'name': 'string.block',
14 | 'pattern': /('{3}|"{3})[\s\S]*\1/gm
15 | },
16 |
17 | /**
18 | * multiline regex with comments
19 | */
20 | {
21 | 'name': 'string.regex',
22 | 'matches': {
23 | 2: {
24 | 'name': 'comment',
25 | 'pattern': /\#(.*?)\n/g
26 | }
27 | },
28 | 'pattern': /(\/{3})([\s\S]*)\1/gm
29 | },
30 | {
31 | 'matches': {
32 | 1: 'keyword'
33 | },
34 | 'pattern': /\b(in|when|is|isnt|of|not|unless|until|super)(?=\b)/gi
35 | },
36 | {
37 | 'name': 'keyword.operator',
38 | 'pattern': /\?/g
39 | },
40 | {
41 | 'name': 'constant.language',
42 | 'pattern': /\b(undefined|yes|on|no|off)\b/g
43 | },
44 | {
45 | 'name': 'keyword.variable.coffee',
46 | 'pattern': /@(\w+)/gi
47 | },
48 |
49 | /**
50 | * reset global keywards from generic
51 | */
52 | {
53 | 'name': 'reset',
54 | 'pattern': /object|class|print/gi
55 | },
56 |
57 | /**
58 | * named function
59 | */
60 | {
61 | 'matches' : {
62 | 1: 'entity.name.function',
63 | 2: 'keyword.operator',
64 | 3: {
65 | 'name': 'function.argument.coffee',
66 | 'pattern': /([\@\w]+)/g
67 | },
68 | 4: 'keyword.function'
69 | },
70 | 'pattern': /(\w+)\s{0,}(=|:)\s{0,}\((.*?)((-|=)>)/gi
71 | },
72 |
73 | /**
74 | * anonymous function
75 | */
76 | {
77 | 'matches': {
78 | 1: {
79 | 'name': 'function.argument.coffee',
80 | 'pattern': /([\@\w]+)/g
81 | },
82 | 2: 'keyword.function'
83 | },
84 | 'pattern': /\s\((.*?)\)\s{0,}((-|=)>)/gi
85 | },
86 |
87 | /**
88 | * direct function no arguments
89 | */
90 | {
91 | 'matches' : {
92 | 1: 'entity.name.function',
93 | 2: 'keyword.operator',
94 | 3: 'keyword.function'
95 | },
96 | 'pattern': /(\w+)\s{0,}(=|:)\s{0,}((-|=)>)/gi
97 | },
98 |
99 | /**
100 | * class definitions
101 | */
102 | {
103 | 'matches': {
104 | 1: 'storage.class',
105 | 2: 'entity.name.class',
106 | 3: 'storage.modifier.extends',
107 | 4: 'entity.other.inherited-class'
108 | },
109 | 'pattern': /\b(class)\s(\w+)(\sextends\s)?([\w\\]*)?\b/g
110 | },
111 |
112 | /**
113 | * object instantiation
114 | */
115 | {
116 | 'matches': {
117 | 1: 'keyword.new',
118 | 2: {
119 | 'name': 'support.class',
120 | 'pattern': /\w+/g
121 | }
122 | },
123 | 'pattern': /\b(new)\s(.*?)(?=\s)/g
124 | }
125 | ]);
126 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/csharp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * C# patterns
3 | *
4 | * @author Dan Stewart
5 | * @version 1.0.1
6 | */
7 | Rainbow.extend('csharp', [
8 | {
9 | // @see http://msdn.microsoft.com/en-us/library/23954zh5.aspx
10 | 'name': 'constant',
11 | 'pattern': /\b(false|null|true)\b/g
12 | },
13 | {
14 | // @see http://msdn.microsoft.com/en-us/library/x53a06bb%28v=vs.100%29.aspx
15 | // Does not support putting an @ in front of a keyword which makes it not a keyword anymore.
16 | 'name': 'keyword',
17 | 'pattern': /\b(abstract|add|alias|ascending|as|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|descending|double|do|dynamic|else|enum|event|explicit|extern|false|finally|fixed|float|foreach|for|from|get|global|goto|group|if|implicit|int|interface|internal|into|in|is|join|let|lock|long|namespace|new|object|operator|orderby|out|override|params|partial|private|protected|public|readonly|ref|remove|return|sbyte|sealed|select|set|short|sizeof|stackalloc|static|string|struct|switch|this|throw|try|typeof|uint|unchecked|ulong|unsafe|ushort|using|value|var|virtual|void|volatile|where|while|yield)\b/g
18 | },
19 | {
20 | 'matches': {
21 | 1: 'keyword',
22 | 2: {
23 | 'name': 'support.class',
24 | 'pattern': /\w+/g
25 | }
26 | },
27 | 'pattern': /(typeof)\s([^\$].*?)(\)|;)/g
28 | },
29 | {
30 | 'matches': {
31 | 1: 'keyword.namespace',
32 | 2: {
33 | 'name': 'support.namespace',
34 | 'pattern': /\w+/g
35 | }
36 | },
37 | 'pattern': /\b(namespace)\s(.*?);/g
38 | },
39 | {
40 | 'matches': {
41 | 1: 'storage.modifier',
42 | 2: 'storage.class',
43 | 3: 'entity.name.class',
44 | 4: 'storage.modifier.extends',
45 | 5: 'entity.other.inherited-class'
46 | },
47 | 'pattern': /\b(abstract|sealed)?\s?(class)\s(\w+)(\sextends\s)?([\w\\]*)?\s?\{?(\n|\})/g
48 | },
49 | {
50 | 'name': 'keyword.static',
51 | 'pattern': /\b(static)\b/g
52 | },
53 | {
54 | 'matches': {
55 | 1: 'keyword.new',
56 | 2: {
57 | 'name': 'support.class',
58 | 'pattern': /\w+/g
59 | }
60 |
61 | },
62 | 'pattern': /\b(new)\s([^\$].*?)(?=\)|\(|;|&)/g
63 | },
64 | {
65 | 'name': 'string',
66 | 'pattern': /(")(.*?)\1/g
67 | },
68 | {
69 | 'name': 'integer',
70 | 'pattern': /\b(0x[\da-f]+|\d+)\b/g
71 | },
72 | {
73 | 'name': 'comment',
74 | 'pattern': /\/\*[\s\S]*?\*\/|(\/\/)[\s\S]*?$/gm
75 | },
76 | {
77 | 'name': 'operator',
78 | // @see http://msdn.microsoft.com/en-us/library/6a71f45d%28v=vs.100%29.aspx
79 | // ++ += + -- -= - <<= << <= => >>= >> >= != ! ~ ^ || && &= & ?? :: : *= * |= %= |= == =
80 | 'pattern': /(\+\+|\+=|\+|--|-=|-|<<=|<<|<=|=>|>>=|>>|>=|!=|!|~|\^|\|\||&&|&=|&|\?\?|::|:|\*=|\*|\/=|%=|\|=|==|=)/g
81 | },
82 | {
83 | // @see http://msdn.microsoft.com/en-us/library/ed8yd1ha%28v=vs.100%29.aspx
84 | 'name': 'preprocessor',
85 | 'pattern': /(\#if|\#else|\#elif|\#endif|\#define|\#undef|\#warning|\#error|\#line|\#region|\#endregion|\#pragma)[\s\S]*?$/gm
86 | }
87 | ], true);
88 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/scheme.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Scheme patterns
3 | *
4 | * @author Alex Queiroz
11 |
12 | function get_all_factors(number)
13 | --[[--
14 | Gets all of the factors of a given number
15 |
16 | @Parameter: number
17 | The number to find the factors of
18 |
19 | @Returns: A table of factors of the number
20 | --]]--
21 | local factors = {}
22 | for possible_factor=1, math.sqrt(number), 1 do
23 | local remainder = number%possible_factor
24 |
25 | if remainder == 0 then
26 | local factor, factor_pair = possible_factor, number/possible_factor
27 | table.insert(factors, factor)
28 |
29 | if factor ~= factor_pair then
30 | table.insert(factors, factor_pair)
31 | end
32 | end
33 | end
34 |
35 | hello = nil -- This is it!
36 | hello = 3%2
37 | print("I haz "..#bag_of_stuff.." things")
38 | table.sort(factors)
39 | return factors
40 | end
41 |
42 | --The Meaning of the Universe is 42. Let's find all of the factors driving the Universe.
43 |
44 | the_universe = 42
45 | factors_of_the_universe = get_all_factors(the_universe)
46 |
47 | --Print out each factor
48 |
49 | print("Count", "The Factors of Life, the Universe, and Everything")
50 | table.foreach(factors_of_the_universe, print)
51 |
52 |
53 | -- Other example
54 | -------------------------------------------------
55 | -- PUBLIC FUNCTIONS
56 | -------------------------------------------------
57 |
58 | function gameminion.init(accessKey, secretKey) -- constructor
59 | -- initialize GM connection
60 |
61 | GM_ACCESS_KEY = accessKey
62 | GM_SECRET_KEY = secretKey
63 |
64 | local newGameminion = {
65 | authToken = authToken,
66 | accessKey = GM_ACCESS_KEY,
67 | secretKey = GM_SECRET_KEY,
68 | gameID = "4f6f1e456b789d0001000002",
69 | cloudStorageBox = cloudStorageBox,
70 | gameminion = gameminion
71 | }
72 |
73 | return setmetatable( newGameminion, gameminion_mt )
74 | end
75 |
76 | -------------------------------------------------
77 | -- User
78 | -------------------------------------------------
79 |
80 | function gameminion:loginWeb()
81 | local authToken
82 |
83 | return authToken
84 | end
85 |
86 | -------------------------------------------------
87 |
88 | function gameminion:loginAPI(username, password)
89 | local params = "login="..username.."&password="..password"
90 |
91 | local path = "user_sessions/user_login.json"
92 |
93 | -- set AuthToken when it gets it
94 | local function networkListener(event)
95 | if (event.isError) then
96 | print("Network Error")
97 | print("Error: "..event.response)
98 | return false
99 | else
100 | self.authToken = json.decode(event.response).auth_token
101 | print("User Logged In!")
102 | print("Auth Token: "..self.authToken)
103 | return true
104 | end
105 | end
106 |
107 | postGM(path, params, networkListener)
108 |
109 | return true
110 | end
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/remote/public/_includes/css/screen.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Slide Controller
3 | */
4 |
5 | /* normalise */
6 | html { font-size: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
7 | html, button, input, select, textarea { font-family: sans-serif; color: #222; }
8 | body { margin: 0; font-size: 1em; line-height: 1.4; }
9 |
10 | ::-moz-selection { background: #fe57a1; color: #fff; text-shadow: none; }
11 | ::selection { background: #fe57a1; color: #fff; text-shadow: none; }
12 |
13 | a:focus { outline: thin dotted; }
14 | a:hover, a:active { outline: 0; }
15 |
16 | ul, ol, li { margin:0; padding:0; }
17 |
18 | html, body { height:100%; }
19 |
20 | /* site */
21 | body {
22 | background:#aaa;
23 | font-size:16px;
24 | }
25 |
26 | h1, .controls, .controls li {
27 | -webkit-box-sizing: border-box;
28 | -moz-box-sizing: border-box;
29 | box-sizing: border-box;
30 | }
31 |
32 | h1 {
33 | position: fixed;
34 | top:0;
35 | width:100%;
36 | height:10%;
37 | text-align:center;
38 | background:#f60;
39 | color:#fff;
40 | font-size:2em;
41 | padding:0.4em 0;
42 | margin:0;
43 | border-bottom:1px solid #fff;
44 | }
45 |
46 | /* controls */
47 | .controls {
48 | position:fixed;
49 | top:10%;
50 | left:0;
51 | right:0;
52 | height:50%;
53 | }
54 |
55 | .controls ul,
56 | .controls li {
57 | height:100%;
58 | }
59 |
60 | .controls li {
61 | display:table;
62 | width:50%;
63 | float:left;
64 | list-style:none;
65 | border-bottom:1px solid #fff;
66 | }
67 |
68 | .controls li:first-child {
69 | border-right:1px solid #fff;
70 | }
71 |
72 | .controls a {
73 | display:table-cell;
74 | width:100%;
75 | height:100%;
76 | background-color:#f90;
77 | color:#fff;
78 | text-align:center;
79 | text-decoration:none;
80 | font-size:3.75em;
81 | vertical-align:middle;
82 | }
83 |
84 | .controls a:hover {
85 | background-color:#f60;
86 | color:#fff;
87 | }
88 |
89 | .controls a,
90 | .controls h1 {
91 | -webkit-transition : all 0.25s ease-out;
92 | -moz-transition : all 0.25s ease-out;
93 | -ms-transition : all 0.25s ease-out;
94 | -o-transition : all 0.25s ease-out;
95 | transition : all 0.25s ease-out;
96 | }
97 |
98 | /* notes */
99 | .note-container {
100 | position:fixed;
101 | top:60%;
102 | height:40%;
103 | left:0;
104 | right:0;
105 | padding:20px;
106 | background:#fff;
107 | overflow: auto;
108 | -webkit-overflow-scrolling: touch;
109 | }
110 |
111 |
112 | /*
113 | * mobile, landscape
114 | */
115 | @media only screen and (max-height: 400px) {
116 | h1 {
117 | height:20%;
118 | font-size:1em;
119 | }
120 | .controls {
121 | top:20%;
122 | height:40%;
123 | }
124 | }
125 |
126 | @media only screen and (max-height: 600px) {
127 | h1 {
128 | height:15%;
129 | }
130 | .controls {
131 | top:15%;
132 | height:45%;
133 | }
134 | }
135 |
136 |
137 | /* boilerplate */
138 | .hidden { display: none !important; visibility: hidden; }
139 | .visuallyhidden { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; }
140 | .visuallyhidden.focusable:active, .visuallyhidden.focusable:focus { clip: auto; height: auto; margin: 0; overflow: visible; position: static; width: auto; }
141 | .invisible { visibility: hidden; }
142 | .clearfix:before, .clearfix:after { content: ""; display: table; }
143 | .clearfix:after { clear: both; }
144 | .clearfix { *zoom: 1; }
145 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/js/language/php.js:
--------------------------------------------------------------------------------
1 | /**
2 | * PHP patterns
3 | *
4 | * @author Craig Campbell
5 | * @version 1.0.7
6 | */
7 | Rainbow.extend('php', [
8 | {
9 | 'name': 'support',
10 | 'pattern': /\becho\b/g
11 | },
12 | {
13 | 'matches': {
14 | 1: 'variable.dollar-sign',
15 | 2: 'variable'
16 | },
17 | 'pattern': /(\$)(\w+)\b/g
18 | },
19 | {
20 | 'name': 'constant.language',
21 | 'pattern': /true|false|null/ig
22 | },
23 | {
24 | 'name': 'constant',
25 | 'pattern': /\b[A-Z0-9_]{2,}\b/g
26 | },
27 | {
28 | 'name': 'keyword.dot',
29 | 'pattern': /\./g
30 | },
31 | {
32 | 'name': 'keyword',
33 | 'pattern': /\b(continue|break|die|end(for(each)?|switch|if)|case|require(_once)?|include(_once)?)(?=\(|\b)/g
34 | },
35 | {
36 | 'matches': {
37 | 1: 'keyword',
38 | 2: {
39 | 'name': 'support.class',
40 | 'pattern': /\w+/g
41 | }
42 | },
43 | 'pattern': /(instanceof)\s([^\$].*?)(\)|;)/g
44 | },
45 |
46 | /**
47 | * these are the top 50 most used PHP functions
48 | * found from running a script and checking the frequency of each function
49 | * over a bunch of popular PHP frameworks then combining the results
50 | */
51 | {
52 | 'matches': {
53 | 1: 'support.function'
54 | },
55 | 'pattern': /\b(array(_key_exists|_merge|_keys|_shift)?|isset|count|empty|unset|printf|is_(array|string|numeric|object)|sprintf|each|date|time|substr|pos|str(len|pos|tolower|_replace|totime)?|ord|trim|in_array|implode|end|preg_match|explode|fmod|define|link|list|get_class|serialize|file|sort|mail|dir|idate|log|intval|header|chr|function_exists|dirname|preg_replace|file_exists)(?=\()/g
56 | },
57 | {
58 | 'name': 'variable.language.php-tag',
59 | 'pattern': /(<\?(php)?|\?>)/g
60 | },
61 | {
62 | 'matches': {
63 | 1: 'keyword.namespace',
64 | 2: {
65 | 'name': 'support.namespace',
66 | 'pattern': /\w+/g
67 | }
68 | },
69 | 'pattern': /\b(namespace|use)\s(.*?);/g
70 | },
71 | {
72 | 'matches': {
73 | 1: 'storage.modifier',
74 | 2: 'storage.class',
75 | 3: 'entity.name.class',
76 | 4: 'storage.modifier.extends',
77 | 5: 'entity.other.inherited-class',
78 | 6: 'storage.modifier.extends',
79 | 7: 'entity.other.inherited-class'
80 | },
81 | 'pattern': /\b(abstract|final)?\s?(class|interface|trait)\s(\w+)(\sextends\s)?([\w\\]*)?(\simplements\s)?([\w\\]*)?\s?\{?(\n|\})/g
82 | },
83 | {
84 | 'name': 'keyword.static',
85 | 'pattern': /self::|static::/g
86 | },
87 | {
88 | 'matches': {
89 | 1: 'storage.function',
90 | 2: 'support.magic'
91 | },
92 | 'pattern': /(function)\s(__.*?)(?=\()/g
93 | },
94 | {
95 | 'matches': {
96 | 1: 'keyword.new',
97 | 2: {
98 | 'name': 'support.class',
99 | 'pattern': /\w+/g
100 | }
101 | },
102 | 'pattern': /\b(new)\s([^\$].*?)(?=\)|\(|;)/g
103 | },
104 | {
105 | 'matches': {
106 | 1: {
107 | 'name': 'support.class',
108 | 'pattern': /\w+/g
109 | },
110 | 2: 'keyword.static'
111 | },
112 | 'pattern': /([\w\\]*?)(::)(?=\b|\$)/g
113 | },
114 | {
115 | 'matches': {
116 | 2: {
117 | 'name': 'support.class',
118 | 'pattern': /\w+/g
119 | }
120 | },
121 | 'pattern': /(\(|,\s?)([\w\\]*?)(?=\s\$)/g
122 | }
123 | ]);
124 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/tests/language/java-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Java tests
3 | *
4 | * @author Leo Accend
5 | */
6 | RainbowTester.startTest("java");
7 |
8 | RainbowTester.run(
9 | "package declaration",
10 | 'package com.example.rainbow;',
11 | 'package com.example.rainbow;'
12 | );
13 |
14 | RainbowTester.run(
15 | "import statement",
16 | 'import com.example.rainbow.util.RainbowUtil;',
17 | 'import com.example.rainbow.util.RainbowUtil;'
18 | );
19 |
20 | RainbowTester.run(
21 | "multi-line comment",
22 | '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */',
23 | '/**\n * This is a Javadoc style comment. It is pretty awesome.\n */'
24 | );
25 |
26 | RainbowTester.run(
27 | "single-line comment",
28 | '// This is a good comment.',
29 | '// This is a good comment.'
30 | );
31 |
32 | RainbowTester.run(
33 | "complicated class declaration",
34 | 'public class Rainbow
8 |
9 | /* variable names that match a keyword or type at the beginning */
10 | char charcoal;
11 | float interval;
12 | char *floating;
13 | double short_stuff, voider;
14 |
15 | void floater(int x, int y)
16 | {
17 | return;
18 | }
19 |
20 |
21 |
22 |
23 |
24 | #include <stdio.h>
25 | #include <stdarg.h>
26 | #include <sys/types.h>
27 | #include <sys/stat.h>
28 | #include <fcntl.h>
29 | #include <unistd.h>
30 |
31 | #ifndef BUF_SIZE
32 | #define BUF_SIZE 1024
33 | #endif
34 |
35 | static void die (const char * format, ...)
36 | {
37 | va_list vargs;
38 | va_start(vargs, format);
39 | vfprintf(stderr, format, vargs);
40 | fprintf(stderr, ".\n");
41 | va_end(vargs);
42 | _exit(1);
43 | }
44 |
45 | int main (int argc, char *argv[])
46 | {
47 | static int x;
48 | const float y;
49 | unsigned int n;
50 | unsigned short int g;
51 | char* test;
52 |
53 | int outFD, opt, openFlags = O_WRONLY;
54 | char buf[BUF_SIZE];
55 | ssize_t charCount;
56 |
57 | while ((opt = getopt(argc, argv, ":a")) != -1) {
58 | switch (opt) {
59 | case 'a':
60 | openFlags |= O_APPEND;
61 | default:
62 | die("Unrecognized option");
63 | }
64 | }
65 |
66 | outFD = open(argv[1], O_WRONLY);
67 | while ((charCount = read(STDIN_FILENO, buf, BUF_SIZE) > 0)) {
68 | if (charCount != write(STDOUT_FILENO, buf, BUF_SIZE))
69 | die("Couldn't write same number of bytes to stdout");
70 | if (charCount != write(outFD, buf, BUF_SIZE))
71 | die("Couldn't write same number of bytes to output file");
72 | }
73 | close(outFD);
74 |
75 | return 0;
76 | }
77 |
78 |
79 |
80 |
81 |
82 | #ifndef type_h
83 | #define type_h
84 |
85 | typedef int type_id;
86 |
87 | #define typeid(TYPE) type_find(#TYPE)
88 | #define type_name(TYPE) #TYPE
89 |
90 | type_id type_find(const char* type);
91 | const char* type_id_name(int id);
92 |
93 | #endif
94 |
95 |
96 |
97 |
98 |
99 |
100 | #include <string.h>
101 | #include <stdio.h>
102 | #include <stdlib.h>
103 |
104 | #include "error.h"
105 |
106 | #include "type.h"
107 |
108 | #define MAX_TYPE_LEN 512
109 | #define MAX_NUM_TYPES 1024
110 |
111 | /* Store Table of type names */
112 | typedef char type_string[MAX_TYPE_LEN];
113 | type_string type_table[MAX_NUM_TYPES];
114 | int type_index = 0;
115 |
116 | /* Dynamically enter types into table */
117 | int type_find(const char* type) {
118 |
119 | if (strlen(type) >= MAX_TYPE_LEN) {
120 | error("Type name %s is too long to index into type table.", type);
121 | }
122 | if (type_index >= MAX_NUM_TYPES) {
123 | error("Too many types in type table already. Cannot add %s.", type);
124 | }
125 |
126 | for (int i = 0; i < type_index; i++) {
127 | // Return type index if found
128 | if (strcmp(type, type_table[i]) == 0) {
129 | return i;
130 | }
131 | }
132 |
133 | // If not found add to table and return
134 | strcpy(type_table[type_index], type);
135 | type_index++;
136 |
137 | return type_index-1;
138 | }
139 |
140 | const char* type_id_name(int id) {
141 | return type_table[id];
142 | }
143 |
144 |
145 |
146 |
147 |
148 | #ifndef sound_h
149 | #define sound_h
150 |
151 | #include "SDL/SDL.h"
152 |
153 | typedef struct {
154 | char* data;
155 | int length;
156 | } sound;
157 |
158 | sound* wav_load_file(char* filename);
159 | void sound_delete(sound* s);
160 |
161 | #endif
162 |
163 |
164 |
165 |
166 |
167 | #include "error.h"
168 |
169 | #include "assets/sound.h"
170 |
171 | static void flip_endian(char* data, int length) {
172 | for(int i = 0; i < length; i += 2) {
173 | int x = data[i];
174 | data[i] = data[i + 1];
175 | data[i + 1] = x;
176 | }
177 | }
178 |
179 | sound* wav_load_file(char* filename) {
180 |
181 | sound* s = malloc(sizeof(sound));
182 |
183 | SDL_AudioSpec spec;
184 |
185 | if( SDL_LoadWAV(filename, &spec, (Uint8**)&s->data, (Uint32*)&s->length) == NULL) {
186 | error("Unable to load sound file %s", filename);
187 | }
188 |
189 | if ((spec.format != AUDIO_S16LSB) &&
190 | (spec.format != AUDIO_S16MSB)) {
191 | error("Unsupported sound format for file %s, id %i.", filename, spec.format);
192 | }
193 |
194 | if (spec.format != AUDIO_S16SYS) {
195 | flip_endian(s->data, s->length);
196 | }
197 |
198 | return s;
199 | }
200 |
201 | void sound_delete(sound* s) {
202 | SDL_FreeWAV((Uint8*)s->data);
203 | free(s);
204 | }
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/tests/language/smalltalk-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Smalltalk tests
3 | *
4 | * @author Frank Shearar
5 | */
6 | RainbowTester.startTest('smalltalk');
7 |
8 | RainbowTester.run(
9 | 'constant true',
10 |
11 | 'true',
12 |
13 | 'true'
14 | );
15 |
16 | RainbowTester.run(
17 | 'constant false',
18 |
19 | 'false',
20 |
21 | 'false'
22 | );
23 |
24 | RainbowTester.run(
25 | 'constant nil',
26 |
27 | 'nil',
28 |
29 | 'nil'
30 | );
31 |
32 | RainbowTester.run(
33 | 'self pseudovariable',
34 |
35 | 'self',
36 |
37 | 'self'
38 | );
39 |
40 | RainbowTester.run(
41 | 'thisContext pseudovariable',
42 |
43 | 'thisContext',
44 |
45 | 'thisContext'
46 | );
47 |
48 | RainbowTester.run(
49 | 'two-character operator !!',
50 |
51 | '!!',
52 |
53 | '!!'
54 | );
55 |
56 | RainbowTester.run(
57 | 'two-character operator //',
58 |
59 | '//',
60 |
61 | '//'
62 | );
63 |
64 | RainbowTester.run(
65 | '| delimiter',
66 |
67 | '|',
68 |
69 | '|'
70 | );
71 |
72 | RainbowTester.run(
73 | '|| binary selector',
74 |
75 | '||',
76 |
77 | '||'
78 | );
79 |
80 | RainbowTester.run(
81 | 'HTML-unfriendly operator',
82 |
83 | '&',
84 |
85 | '&'
86 | );
87 |
88 | RainbowTester.run(
89 | 'three-character operator',
90 |
91 | '>>=',
92 |
93 | '>>='
94 | );
95 |
96 | RainbowTester.run(
97 | 'String-like Symbol',
98 |
99 | "#'this is a symbol'",
100 |
101 | "#'this is a symbol'"
102 | );
103 |
104 | RainbowTester.run(
105 | 'Symbol',
106 |
107 | "#thisIsaSymbol0",
108 |
109 | "#thisIsaSymbol0"
110 | );
111 |
112 | RainbowTester.run(
113 | 'String',
114 |
115 | "'This is a string'",
116 |
117 | '\'This is a string\''
118 | );
119 |
120 | RainbowTester.run(
121 | 'Comment',
122 |
123 | '"This is a comment"',
124 |
125 | '"This is a comment"'
126 | );
127 |
128 | RainbowTester.run(
129 | 'Comment in between message sends',
130 |
131 | 'self "this is a comment" foo',
132 |
133 | 'self "this is a comment" foo'
134 | );
135 |
136 | RainbowTester.run(
137 | 'Integer',
138 |
139 | '987654321',
140 |
141 | '987654321'
142 | );
143 |
144 | RainbowTester.run(
145 | 'Negative integer',
146 |
147 | '-987654321',
148 |
149 | '-987654321'
150 | );
151 |
152 | RainbowTester.run(
153 | 'Exponent integer',
154 |
155 | '987654321e10',
156 |
157 | '987654321e10'
158 | );
159 |
160 | RainbowTester.run(
161 | 'Negative exponent integer',
162 |
163 | '-987654321e10',
164 |
165 | '-987654321e10'
166 | );
167 |
168 | RainbowTester.run(
169 | 'Radix Integer',
170 |
171 | '16r987654321deadbeef',
172 |
173 | '16r987654321deadbeef'
174 | );
175 |
176 | RainbowTester.run(
177 | 'Negative radix Integer',
178 |
179 | '16r-987654321deadbeef',
180 |
181 | '16r-987654321deadbeef'
182 | );
183 |
184 | RainbowTester.run(
185 | 'Float',
186 |
187 | '987654321.0',
188 |
189 | '987654321.0'
190 | );
191 |
192 | RainbowTester.run(
193 | 'Negative float',
194 |
195 | '-987654321.0',
196 |
197 | '-987654321.0'
198 | );
199 |
200 | RainbowTester.run(
201 | 'Exponent float',
202 |
203 | '1.0e10',
204 |
205 | '1.0e10'
206 | );
207 |
208 | RainbowTester.run(
209 | 'Negative exponent float',
210 |
211 | '1.0e-10',
212 |
213 | '1.0e-10'
214 | );
215 |
216 | RainbowTester.run(
217 | 'Negative exponent negative float',
218 |
219 | '-1.0e-10',
220 |
221 | '-1.0e-10'
222 | );
223 |
224 | RainbowTester.run(
225 | 'Scaled decimal',
226 |
227 | '1.0s10',
228 |
229 | '1.0s10'
230 | );
231 |
232 | RainbowTester.run(
233 | 'Class name, normal',
234 |
235 | 'Class',
236 |
237 | 'Class'
238 | );
239 |
240 | RainbowTester.run(
241 | 'Class name, with digits',
242 |
243 | 'Class0zero',
244 |
245 | 'Class0zero'
246 | );
247 |
248 | RainbowTester.endTest('smalltalk');
249 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/util/builder.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 | import zipfile
4 | import hashlib
5 | import re
6 | import glob
7 | from zipfile import ZipFile
8 | from StringIO import StringIO
9 |
10 |
11 | class RainbowBuilder(object):
12 |
13 | def __init__(self, js_path, closure_path, theme_path=None):
14 |
15 | self.versions = {
16 | 'c': '1.0.6',
17 | 'csharp': '1.0.1',
18 | 'coffeescript': '1.0',
19 | 'css': '1.0.7',
20 | 'generic': '1.0.9',
21 | 'go': '1.0',
22 | 'html': '1.0.7',
23 | 'java': '1.0',
24 | 'javascript': '1.0.7',
25 | 'lua': '1.0',
26 | 'php': '1.0.7',
27 | 'python': '1.0.7',
28 | 'r': '1.0',
29 | 'ruby': '1.0.5',
30 | 'scheme': '1.0',
31 | 'shell': '1.0.3',
32 | 'smalltalk': '1.0'
33 | }
34 |
35 | self.js_path = js_path
36 | self.closure_path = closure_path
37 | self.js_files_to_include = []
38 | self.file_name = ""
39 | self.theme_path = theme_path
40 |
41 | def getPathForLanguage(self, language):
42 | return os.path.join(self.js_path, 'language/' + language + '.js')
43 |
44 | def getRainbowPath(self):
45 | return os.path.join(self.js_path, 'rainbow.js')
46 |
47 | def verifyPaths(self):
48 | if not os.path.exists(self.js_path):
49 | raise Exception('directory does not exist at: %s' % self.js_path)
50 |
51 | if not os.path.isfile(self.closure_path):
52 | raise Exception('closure compiler does not exist at: %s' % self.closure_path)
53 |
54 | def getZipForLanguages(self, languages, path=None):
55 | self.verifyPaths()
56 |
57 | # strip out any duplicates
58 | languages = list(set(languages))
59 |
60 | write_to = StringIO() if path is None else path
61 | zip_file = ZipFile(write_to, 'w')
62 | zip_file.write(self.getRainbowPath(), 'rainbow.js', zipfile.ZIP_DEFLATED)
63 |
64 | # include minimized version even when downloading the dev version
65 | zip_file.write(self.getRainbowPath().replace('.js', '.min.js'), 'rainbow.min.js', zipfile.ZIP_DEFLATED)
66 |
67 | # include themes as well
68 | if self.theme_path:
69 | files = glob.glob(self.theme_path + '/*.css')
70 | for file_name in files:
71 | zip_file.write(file_name, os.path.join('themes', os.path.basename(file_name)), zipfile.ZIP_DEFLATED)
72 |
73 | for language in languages:
74 | zip_file.write(self.getPathForLanguage(language), os.path.join('language', language + '.js'), zipfile.ZIP_DEFLATED)
75 |
76 | zip_file.close()
77 |
78 | return write_to
79 |
80 | def openFile(self, path):
81 | file = open(path, "r")
82 | content = file.read()
83 | file.close()
84 | return content
85 |
86 | def writeFile(self, path, content):
87 | file = open(path, "w")
88 | file.write(content)
89 | file.close()
90 |
91 | def getVersion(self):
92 | contents = self.openFile(self.getRainbowPath())
93 | match = re.search(r'@version\s(.*)\s+?', contents)
94 | return match.group(1)
95 |
96 | def getLanguageVersions(self, languages):
97 | groups = []
98 | for language in languages:
99 | if language in self.versions:
100 | groups.append(language + ' v' + self.versions[language])
101 |
102 | return ', '.join(groups)
103 |
104 | def getFileForLanguages(self, languages, cache=None):
105 | self.verifyPaths()
106 |
107 | # strip out any duplicates
108 | languages = list(set(languages))
109 |
110 | self.js_files_to_include = [self.getRainbowPath()]
111 | for language in languages:
112 | path = self.getPathForLanguage(language)
113 | if not os.path.exists(path):
114 | continue
115 |
116 | self.js_files_to_include.append(path)
117 |
118 | self.file_name = 'rainbow' + ('-custom' if len(languages) else '') + '.min.js'
119 |
120 | if cache is not None:
121 | version = self.getVersion()
122 | cache_key = 'rainbow_' + hashlib.md5(self.getLanguageVersions(languages)).hexdigest() + '_' + version
123 | cached_version = cache.get(cache_key)
124 | if cached_version:
125 | return cached_version
126 |
127 | command = ['java', '-jar', self.closure_path, '--compilation_level', 'ADVANCED_OPTIMIZATIONS'] + self.js_files_to_include
128 | proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
129 | output, err = proc.communicate()
130 |
131 | lines = output.splitlines()
132 | comments = lines[0:4]
133 | version = comments[1].replace(' @version ', '')
134 | url = comments[2].replace(' @url ', '')
135 | new_comment = '/* Rainbow v' + version + ' ' + url
136 |
137 | if len(languages):
138 | new_comment += ' | included languages: ' + ', '.join(languages)
139 |
140 | new_comment += ' */'
141 |
142 | output = new_comment + '\n' + '\n'.join(lines[4:])
143 |
144 | if cache is not None:
145 | cache.set(cache_key, output, 14400) # 4 hours
146 |
147 | return output
148 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/tests/language/python-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Python tests
3 | *
4 | * @author Craig Campbell
5 | */
6 | RainbowTester.startTest('python');
7 |
8 | RainbowTester.run(
9 | 'no self',
10 |
11 | 'print self.something',
12 |
13 | 'print self.something'
14 | );
15 |
16 | RainbowTester.run(
17 | 'comment',
18 |
19 | '# this is a comment',
20 |
21 | '# this is a comment'
22 | );
23 |
24 | RainbowTester.run(
25 | 'language constants',
26 |
27 | 'var1 = None\n' +
28 | 'var2 = True\n' +
29 | 'someFunction(var3=False)',
30 |
31 | 'var1 = None\n' +
32 | 'var2 = True\n' +
33 | 'someFunction(var3=False)'
34 | );
35 |
36 | RainbowTester.run(
37 | 'object',
38 |
39 | 'object',
40 |
41 | 'object'
42 | );
43 |
44 | RainbowTester.run(
45 | 'import',
46 |
47 | 'from SomePackage import SomeThing',
48 |
49 | 'from SomePackage import SomeThing'
50 | );
51 |
52 | RainbowTester.run(
53 | 'class',
54 |
55 | 'class Something(object):\n' +
56 | ' pass',
57 |
58 | 'class Something(object):\n' +
59 | ' pass'
60 | );
61 |
62 | RainbowTester.run(
63 | 'special method',
64 |
65 | 'def __init__(self, some_var):\n' +
66 | ' pass',
67 |
68 | 'def __init__(self, some_var):\n' +
69 | ' pass'
70 | );
71 |
72 | RainbowTester.run(
73 | 'function',
74 |
75 | 'def openFile(path):\n' +
76 | ' file = open(path, "r")\n' +
77 | ' content = file.read()\n' +
78 | ' file.close()\n' +
79 | ' return content',
80 |
81 | 'def openFile(path):\n' +
82 | ' file = open(path, "r")\n' +
83 | ' content = file.read()\n' +
84 | ' file.close()\n' +
85 | ' return content'
86 | );
87 |
88 | RainbowTester.run(
89 | 'decorator',
90 |
91 | '@makebold\n' +
92 | '@makeitalic\n' +
93 | 'def hello():\n' +
94 | ' return "hello world"',
95 |
96 | '@makebold\n' +
97 | '@makeitalic\n' +
98 | 'def hello():\n' +
99 | ' return "hello world"'
100 | );
101 |
102 | RainbowTester.run(
103 | '__main__',
104 |
105 | 'if __name__ == \'__main__\':\n' +
106 | ' pass',
107 |
108 | 'if __name__ == \'__main__\':\n' +
109 | ' pass'
110 | );
111 |
112 | RainbowTester.run(
113 | 'try catch',
114 |
115 | 'try:\n' +
116 | ' import cPickle as pickle\n' +
117 | 'except ImportError:\n' +
118 | ' import pickle',
119 |
120 | 'try:\n' +
121 | ' import cPickle as pickle\n' +
122 | 'except ImportError:\n' +
123 | ' import pickle'
124 | );
125 |
126 | RainbowTester.run(
127 | 'docstring single line double quotes',
128 |
129 | '"""docstring test"""',
130 |
131 | '"""docstring test"""'
132 | );
133 |
134 | RainbowTester.run(
135 | 'docstring single line single quotes',
136 |
137 | "'''docstring test'''",
138 |
139 | '\'\'\'docstring test\'\'\''
140 | );
141 |
142 | RainbowTester.run(
143 | 'docstring multiline',
144 |
145 | '"""test\n' +
146 | 'multiline\n' +
147 | 'yes"""',
148 |
149 | '"""test\n' +
150 | 'multiline\n' +
151 | 'yes"""'
152 | );
153 |
154 | RainbowTester.run(
155 | 'multiple docstrings',
156 |
157 | '"""\n' +
158 | 'x\n' +
159 | '"""\n' +
160 | '2 + 2\n' +
161 | '"""\n' +
162 | 'y\n' +
163 | '"""',
164 |
165 | '"""\n' +
166 | 'x\n' +
167 | '"""\n' +
168 | '2 + 2\n' +
169 | '"""\n' +
170 | 'y\n' +
171 | '"""'
172 | );
173 |
174 | RainbowTester.endTest('python');
175 |
--------------------------------------------------------------------------------
/s5/_ui/rainbow/tests/language/csharp-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * C# tests
3 | *
4 | * @author Dan Stewart
5 | * The csharp.js file is configured to not load generic.js
6 | */
7 | RainbowTester.startTest('csharp');
8 |
9 | RainbowTester.run(
10 | 'echo',
11 |
12 | 'Console.WriteLine("hello world");',
13 |
14 | 'Console.WriteLine("hello world");'
15 | );
16 |
17 | RainbowTester.run(
18 | 'variable',
19 |
20 | 'var foo = true;',
21 |
22 | 'var foo = true;'
23 | );
24 |
25 | RainbowTester.run(
26 | 'string concatenation',
27 |
28 | 'string foo = "test " + "string " + "concatenation";',
29 |
30 | 'string foo = "test " + "string " + "concatenation";'
31 | );
32 |
33 | RainbowTester.run(
34 | 'typeof',
35 |
36 | "var is_array_object = typeof(System.Array);",
37 |
38 | 'var is_array_object = typeof(System.Array);'
39 | );
40 |
41 | RainbowTester.run(
42 | 'array stuff',
43 |
44 | 'string[] turtles = new string[] {\n' +
45 | ' "leonardo",\n' +
46 | ' "michaelangelo",\n' +
47 | ' "donatello",\n' +
48 | ' "raphael"\n' +
49 | '};\n' +
50 | '\n' +
51 | 'bool exists = turtles[0] == "leonardo";',
52 |
53 | 'string[] turtles = new string[] {\n' +
54 | ' "leonardo",\n' +
55 | ' "michaelangelo",\n' +
56 | ' "donatello",\n' +
57 | ' "raphael"\n' +
58 | '};\n' +
59 | '\n' +
60 | 'bool exists = turtles[0] == "leonardo";'
61 | );
62 |
63 | RainbowTester.run(
64 | 'namespace declaration',
65 |
66 | 'namespace Sonic.Database {',
67 |
68 | 'namespace Sonic.Database {'
69 | );
70 |
71 | RainbowTester.run(
72 | 'class declaration',
73 |
74 | 'class MyClass {}',
75 |
76 | 'class MyClass {}'
77 | );
78 |
79 | RainbowTester.run(
80 | 'abstract class declaration',
81 |
82 | 'abstract class MyClass {}',
83 |
84 | 'abstract class MyClass {}'
85 | );
86 |
87 | RainbowTester.run(
88 | 'sealed class declaration',
89 |
90 | 'sealed class TestClass\n' +
91 | '{\n' +
92 | '}',
93 |
94 | 'sealed class TestClass\n' +
95 | '{\n' +
96 | '}'
97 | );
98 |
99 | RainbowTester.run(
100 | 'child class declaration',
101 |
102 | 'class MyCollection : ICollection {}',
103 |
104 | 'class MyCollection : ICollection {}'
105 | );
106 |
107 | RainbowTester.run(
108 | 'test static',
109 |
110 | 'static void doSomethingElse() {}',
111 |
112 | 'static void doSomethingElse() {}'
113 | );
114 |
115 | RainbowTester.run(
116 | 'test magic function',
117 |
118 | 'protected void Page_Load(object sender, EventArgs e)\n' +
119 | '{\n' +
120 | ' // do whatever\n' +
121 | '}',
122 |
123 | 'protected void Page_Load(object sender, EventArgs e)\n' +
124 | '{\n' +
125 | ' // do whatever\n' +
126 | '}'
127 | );
128 |
129 | RainbowTester.run(
130 | 'test new class',
131 |
132 | 'new SomeClass();',
133 |
134 | 'new SomeClass();'
135 | );
136 |
137 | RainbowTester.run(
138 | 'test new namespace class',
139 |
140 | 'var s = new Sonic.Database.Query();',
141 |
142 | 'var s = new Sonic.Database.Query();'
143 | );
144 |
145 | RainbowTester.run(
146 | 'test static class call',
147 |
148 | 'var path = Sonic.App.getInstance();',
149 |
150 | 'var path = Sonic.App.getInstance();'
151 | );
152 |
153 | RainbowTester.run(
154 | 'type hint',
155 |
156 | 'public static string getForUser(User user, Sort sort) {}',
157 |
158 | 'public static string getForUser(User user, Sort sort) {}'
159 | );
160 |
161 | RainbowTester.run(
162 | 'generics',
163 |
164 | 'public IList<string> firstNames = new List<string>()',
165 |
166 | 'public IList<string> firstNames = new List<string>()'
167 | );
168 |
169 | RainbowTester.endTest('csharp');
--------------------------------------------------------------------------------
/s5/_ui/rainbow/tests/language/r-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * R tests
3 | *
4 | * @author Simon Potter
5 | */
6 | RainbowTester.startTest('r');
7 |
8 | RainbowTester.run(
9 | 'comments',
10 |
11 | '# A comment\n' +
12 | 'a <- "b" # Another comment',
13 |
14 | '# A comment\n' +
15 | 'a <- "b" # Another comment'
16 | );
17 |
18 | RainbowTester.run(
19 | 'assignment',
20 |
21 | 'foo.bar <- "foo"\n' +
22 | 'baz1 = 1.62e-4',
23 |
24 | 'foo.bar <- "foo"\n' +
25 | 'baz1 = 1.62e-4'
26 | );
27 |
28 | RainbowTester.run(
29 | 'constants',
30 |
31 | 'baz <- NA\n' +
32 | 'my.pi <- pi\n' +
33 | 'all.letters <- c(LETTERS, letters)\n' +
34 | 'xrange <- c(-Inf, TRUE)',
35 |
36 | 'baz <- NA\n' +
37 | 'my.pi <- pi\n' +
38 | 'all.letters <- c(LETTERS, letters)\n' +
39 | 'xrange <- c(-Inf, TRUE)'
40 | );
41 |
42 | RainbowTester.run(
43 | 'operators',
44 |
45 | 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' +
46 | 'bound.rect <- grid::rectGrob()\n' +
47 | 'my_seq <- 1:10\n' +
48 | 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' +
49 | 'plot(y ~ x, type = "l")',
50 |
51 | 'beta.hat <- solve(t(X) %*% X) %*% t(X) %*% y\n' +
52 | 'bound.rect <- grid::rectGrob()\n' +
53 | 'my_seq <- 1:10\n' +
54 | 'is_in_seq <- c(2, 7, 23) %in% my_seq\n' +
55 | 'plot(y ~ x, type = "l")'
56 | );
57 |
58 | /**
59 | * Note that the second function is intentionally not a function call,
60 | * just testing that the regex is matching only 'function' and not .+function
61 | */
62 | RainbowTester.run(
63 | 'function creation',
64 |
65 | 'square <- function(x) x * x\n' +
66 | 'square2 <- testfunction(x) x * x\n' +
67 | 'area <- function (r) {\n' +
68 | ' pi * r^2\n' +
69 | '}',
70 |
71 | 'square <- function(x) x * x\n' +
72 | 'square2 <- testfunction(x) x * x\n' +
73 | 'area <- function (r) {\n' +
74 | ' pi * r^2\n' +
75 | '}'
76 | );
77 |
78 | RainbowTester.run(
79 | 'variable',
80 |
81 | 'tmp <- 1\n' +
82 | 'another.tmp <- 2\n' +
83 | 'this.is.a.var <- 3',
84 |
85 | 'tmp <- 1\n' +
86 | 'another.tmp <- 2\n' +
87 | 'this.is.a.var <- 3'
88 | );
89 |
90 | RainbowTester.run(
91 | 'subsetting',
92 |
93 | 'tmp[1]\n' +
94 | 'tmp[["test"]]',
95 |
96 | 'tmp[1]\n' +
97 | 'tmp[["test"]]'
98 | );
99 |
100 | RainbowTester.run(
101 | 'support functions',
102 |
103 | 'logical(10)\n' +
104 | 'test.logical(10)\n' +
105 | 'data.frame(a = 1:10, b = 15:24)\n' +
106 | 'complex(real = 1, imaginary = 0.5)',
107 |
108 | 'logical(10)\n' +
109 | 'test.logical(10)\n' +
110 | 'data.frame(a = 1:10, b = 15:24)\n' +
111 | 'complex(real = 1, imaginary = 0.5)'
112 | );
113 |
114 | RainbowTester.endTest('r');
115 |
--------------------------------------------------------------------------------
/s5/_ui/pg/printlinks.js:
--------------------------------------------------------------------------------
1 | /*
2 | * footnote links cycles through the links from an html page,
3 | * and puts these at the foot of the printed page
4 | *
5 | */
6 | var printFootnoteLinks = {
7 |
8 | /*
9 | * function runs on page load, collecting links and running sub-functions to check validity
10 | *
11 | * @param string containerID Id of the container within which to collect all links
12 | * @param string targetID Id of the container to append complete link list to
13 | *
14 | * @return void
15 | */
16 | init: function(containerID,targetID) {
17 |
18 | //check to see if variables passed to function are contained in the html document
19 | if (!document.getElementById(containerID) || !document.getElementById(targetID)) return false;
20 |
21 | //get container object
22 | var container = document.getElementById(containerID);
23 |
24 | //get all link tags from the container
25 | var linkArray = container.getElementsByTagName('a');
26 |
27 | //create an array to contain all unique links
28 | var uniqueLinkArray = [];
29 |
30 | //create an ordered list to display all unique links
31 | var ol = document.createElement('ol');
32 |
33 |
34 | //cycle through all links
35 | for (var i=0; i| Language | Failed | Passed |
|---|
' + actual + '' +
135 | '' + expected + '' +
155 | '' + actual + '' +
157 | '
9 | # Copyright (c) 2007, 2008, 2009, 2010 Christian Neukirchen <purl.org/net/chneukirchen>
10 | #
11 | # Permission is hereby granted, free of charge, to any person obtaining a copy
12 | # of this software and associated documentation files (the "Software"), to
13 | # deal in the Software without restriction, including without limitation the
14 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15 | # sell copies of the Software, and to permit persons to whom the Software is
16 | # furnished to do so, subject to the following conditions:
17 | #
18 | # The above copyright notice and this permission notice shall be included in
19 | # all copies or substantial portions of the Software.
20 | #
21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 | # THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
25 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 |
28 | require 'time'
29 | require 'rack/utils'
30 | require 'rack/mime'
31 |
32 | module Rack
33 | # Rack::Directory serves entries below the +root+ given, according to the
34 | # path info of the Rack request. If a directory is found, the file's contents
35 | # will be presented in an html based index. If a file is found, the env will
36 | # be passed to the specified +app+.
37 | #
38 | # If +app+ is not specified, a Rack::File of the same +root+ will be used.
39 |
40 | class Directory
41 | DIR_FILE = "<tr><td class='name'><a href='%s'>%s</a></td><td class='size'>%s</td><td class='type'>%s</td><td class='mtime'>%s</td></tr>"
42 | DIR_PAGE = <<-PAGE
43 | <html><head>
44 | <title>%s</title>
45 | <meta http-equiv="content-type" content="text/html; charset=utf-8" />
46 | <style type='text/css'>
47 | table { width:100%%; }
48 | .name { text-align:left; }
49 | .size, .mtime { text-align:right; }
50 | .type { width:11em; }
51 | .mtime { width:15em; }
52 | </style>
53 | </head><body>
54 | <h1>%s</h1>
55 | <hr />
56 | <table>
57 | <tr>
58 | <th class='name'>Name</th>
59 | <th class='size'>Size</th>
60 | <th class='type'>Type</th>
61 | <th class='mtime'>Last Modified</th>
62 | </tr>
63 | %s
64 | </table>
65 | <hr />
66 | </body></html>
67 | PAGE
68 |
69 | attr_reader :files
70 | attr_accessor :root, :path
71 |
72 | def initialize(root, app=nil)
73 | @root = F.expand_path(root)
74 | @app = app || Rack::File.new(@root)
75 | end
76 |
77 | def call(env)
78 | dup._call(env)
79 | end
80 |
81 | F = ::File
82 |
83 | def _call(env)
84 | @env = env
85 | @script_name = env['SCRIPT_NAME']
86 | @path_info = Utils.unescape(env['PATH_INFO'])
87 |
88 | if forbidden = check_forbidden
89 | forbidden
90 | else
91 | @path = F.join(@root, @path_info)
92 | list_path
93 | end
94 | end
95 |
96 | def check_forbidden
97 | return unless @path_info.include? ".."
98 |
99 | body = "Forbidden\n"
100 | size = Rack::Utils.bytesize(body)
101 | return [403, {"Content-Type" => "text/plain",
102 | "Content-Length" => size.to_s,
103 | "X-Cascade" => "pass"}, [body]]
104 | end
105 |
106 | def list_directory
107 | @files = [['../','Parent Directory','','','']]
108 | glob = F.join(@path, '*')
109 |
110 | url_head = ([@script_name] + @path_info.split('/')).map do |part|
111 | Rack::Utils.escape part
112 | end
113 |
114 | Dir[glob].sort.each do |node|
115 | stat = stat(node)
116 | next unless stat
117 | basename = F.basename(node)
118 | ext = F.extname(node)
119 |
120 | url = F.join(*url_head + [Rack::Utils.escape(basename)])
121 | size = stat.size
122 | type = stat.directory? ? 'directory' : Mime.mime_type(ext)
123 | size = stat.directory? ? '-' : filesize_format(size)
124 | mtime = stat.mtime.httpdate
125 | url << '/' if stat.directory?
126 | basename << '/' if stat.directory?
127 |
128 | @files << [ url, basename, size, type, mtime ]
129 | end
130 |
131 | return [ 200, {'Content-Type'=>'text/html; charset=utf-8'}, self ]
132 | end
133 |
134 | def stat(node, max = 10)
135 | F.stat(node)
136 | rescue Errno::ENOENT, Errno::ELOOP
137 | return nil
138 | end
139 |
140 | # TODO: add correct response if not readable, not sure if 404 is the best
141 | # option
142 | def list_path
143 | @stat = F.stat(@path)
144 |
145 | if @stat.readable?
146 | return @app.call(@env) if @stat.file?
147 | return list_directory if @stat.directory?
148 | else
149 | raise Errno::ENOENT, 'No such file or directory'
150 | end
151 |
152 | rescue Errno::ENOENT, Errno::ELOOP
153 | return entity_not_found
154 | end
155 |
156 | def entity_not_found
157 | body = "Entity not found: #{@path_info}\n"
158 | size = Rack::Utils.bytesize(body)
159 | return [404, {"Content-Type" => "text/plain",
160 | "Content-Length" => size.to_s,
161 | "X-Cascade" => "pass"}, [body]]
162 | end
163 |
164 | def each
165 | show_path = @path.sub(/^#{@root}/,'')
166 | files = @files.map{|f| DIR_FILE % f }*"\n"
167 | page = DIR_PAGE % [ show_path, show_path , files ]
168 | page.each_line{|l| yield l }
169 | end
170 |
171 | # Stolen from Ramaze
172 |
173 | FILESIZE_FORMAT = [
174 | ['%.1fT', 1 << 40],
175 | ['%.1fG', 1 << 30],
176 | ['%.1fM', 1 << 20],
177 | ['%.1fK', 1 << 10],
178 | ]
179 |
180 | def filesize_format(int)
181 | FILESIZE_FORMAT.each do |format, size|
182 | return format % (int.to_f / size) if int >= size
183 | end
184 |
185 | int.to_s + 'B'
186 | end
187 | end
188 | end
189 |
190 |
191 |
192 |
193 |
194 |
195 |
--------------------------------------------------------------------------------
/s5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |