swagr 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/swagr +15 -0
- data/examples/examples01/app.rb +6 -2
- data/examples/examples01/coffee/data_port.coffee +2 -0
- data/examples/examples01/static/css/codemirror.css +1247 -0
- data/examples/examples01/static/js/codemirror-compressed-3-0.js +5 -0
- data/examples/examples01/static/js/codemirror/keymap/emacs.js +30 -0
- data/examples/examples01/static/js/codemirror/keymap/vim.js +2298 -0
- data/examples/examples01/static/js/codemirror/lib/codemirror.css +239 -0
- data/examples/examples01/static/js/codemirror/lib/codemirror.js +4553 -0
- data/examples/examples01/static/js/codemirror/lib/util/closetag.js +85 -0
- data/examples/examples01/static/js/codemirror/lib/util/colorize.js +29 -0
- data/examples/examples01/static/js/codemirror/lib/util/continuecomment.js +36 -0
- data/examples/examples01/static/js/codemirror/lib/util/continuelist.js +28 -0
- data/examples/examples01/static/js/codemirror/lib/util/dialog.css +32 -0
- data/examples/examples01/static/js/codemirror/lib/util/dialog.js +75 -0
- data/examples/examples01/static/js/codemirror/lib/util/foldcode.js +182 -0
- data/examples/examples01/static/js/codemirror/lib/util/formatting.js +108 -0
- data/examples/examples01/static/js/codemirror/lib/util/javascript-hint.js +137 -0
- data/examples/examples01/static/js/codemirror/lib/util/loadmode.js +51 -0
- data/examples/examples01/static/js/codemirror/lib/util/match-highlighter.js +46 -0
- data/examples/examples01/static/js/codemirror/lib/util/matchbrackets.js +63 -0
- data/examples/examples01/static/js/codemirror/lib/util/multiplex.js +95 -0
- data/examples/examples01/static/js/codemirror/lib/util/overlay.js +59 -0
- data/examples/examples01/static/js/codemirror/lib/util/pig-hint.js +117 -0
- data/examples/examples01/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
- data/examples/examples01/static/js/codemirror/lib/util/runmode.js +52 -0
- data/examples/examples01/static/js/codemirror/lib/util/search.js +119 -0
- data/examples/examples01/static/js/codemirror/lib/util/searchcursor.js +119 -0
- data/examples/examples01/static/js/codemirror/lib/util/simple-hint.css +16 -0
- data/examples/examples01/static/js/codemirror/lib/util/simple-hint.js +102 -0
- data/examples/examples01/static/js/codemirror/lib/util/xml-hint.js +131 -0
- data/examples/examples01/static/js/codemirror/mode/clike/clike.js +300 -0
- data/examples/examples01/static/js/codemirror/mode/clike/index.html +103 -0
- data/examples/examples01/static/js/codemirror/mode/clike/scala.html +767 -0
- data/examples/examples01/static/js/codemirror/mode/clojure/clojure.js +206 -0
- data/examples/examples01/static/js/codemirror/mode/clojure/index.html +67 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/index.html +728 -0
- data/examples/examples01/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/examples/examples01/static/js/codemirror/mode/commonlisp/index.html +165 -0
- data/examples/examples01/static/js/codemirror/mode/css/css.js +465 -0
- data/examples/examples01/static/js/codemirror/mode/css/index.html +58 -0
- data/examples/examples01/static/js/codemirror/mode/css/test.js +501 -0
- data/examples/examples01/static/js/codemirror/mode/diff/diff.js +32 -0
- data/examples/examples01/static/js/codemirror/mode/diff/index.html +105 -0
- data/examples/examples01/static/js/codemirror/mode/ecl/ecl.js +192 -0
- data/examples/examples01/static/js/codemirror/mode/ecl/index.html +39 -0
- data/examples/examples01/static/js/codemirror/mode/erlang/erlang.js +463 -0
- data/examples/examples01/static/js/codemirror/mode/erlang/index.html +64 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/gfm.js +94 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/index.html +70 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/test.js +225 -0
- data/examples/examples01/static/js/codemirror/mode/go/go.js +165 -0
- data/examples/examples01/static/js/codemirror/mode/go/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/groovy/groovy.js +210 -0
- data/examples/examples01/static/js/codemirror/mode/groovy/index.html +73 -0
- data/examples/examples01/static/js/codemirror/mode/haskell/haskell.js +242 -0
- data/examples/examples01/static/js/codemirror/mode/haskell/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/haxe/haxe.js +429 -0
- data/examples/examples01/static/js/codemirror/mode/haxe/index.html +90 -0
- data/examples/examples01/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/examples/examples01/static/js/codemirror/mode/htmlembedded/index.html +49 -0
- data/examples/examples01/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
- data/examples/examples01/static/js/codemirror/mode/htmlmixed/index.html +52 -0
- data/examples/examples01/static/js/codemirror/mode/http/http.js +98 -0
- data/examples/examples01/static/js/codemirror/mode/http/index.html +32 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/index.html +88 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/javascript.js +411 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/typescript.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/jinja2/index.html +38 -0
- data/examples/examples01/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
- data/examples/examples01/static/js/codemirror/mode/less/index.html +741 -0
- data/examples/examples01/static/js/codemirror/mode/less/less.js +266 -0
- data/examples/examples01/static/js/codemirror/mode/lua/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/lua/lua.js +140 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/index.html +344 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/markdown.js +474 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/test.js +1266 -0
- data/examples/examples01/static/js/codemirror/mode/mysql/index.html +41 -0
- data/examples/examples01/static/js/codemirror/mode/mysql/mysql.js +203 -0
- data/examples/examples01/static/js/codemirror/mode/ntriples/index.html +33 -0
- data/examples/examples01/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
- data/examples/examples01/static/js/codemirror/mode/ocaml/index.html +131 -0
- data/examples/examples01/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/LICENSE +7 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/index.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/pascal.js +94 -0
- data/examples/examples01/static/js/codemirror/mode/perl/LICENSE +19 -0
- data/examples/examples01/static/js/codemirror/mode/perl/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/perl/perl.js +816 -0
- data/examples/examples01/static/js/codemirror/mode/php/index.html +51 -0
- data/examples/examples01/static/js/codemirror/mode/php/php.js +129 -0
- data/examples/examples01/static/js/codemirror/mode/pig/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/pig/pig.js +171 -0
- data/examples/examples01/static/js/codemirror/mode/plsql/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/plsql/plsql.js +216 -0
- data/examples/examples01/static/js/codemirror/mode/properties/index.html +41 -0
- data/examples/examples01/static/js/codemirror/mode/properties/properties.js +63 -0
- data/examples/examples01/static/js/codemirror/mode/python/LICENSE.txt +21 -0
- data/examples/examples01/static/js/codemirror/mode/python/index.html +124 -0
- data/examples/examples01/static/js/codemirror/mode/python/python.js +340 -0
- data/examples/examples01/static/js/codemirror/mode/r/LICENSE +24 -0
- data/examples/examples01/static/js/codemirror/mode/r/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/r/r.js +141 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/changes/index.html +53 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/index.html +99 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
- data/examples/examples01/static/js/codemirror/mode/rst/index.html +526 -0
- data/examples/examples01/static/js/codemirror/mode/rst/rst.js +314 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/LICENSE +24 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/index.html +173 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/ruby.js +195 -0
- data/examples/examples01/static/js/codemirror/mode/rust/index.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/rust/rust.js +432 -0
- data/examples/examples01/static/js/codemirror/mode/scheme/index.html +65 -0
- data/examples/examples01/static/js/codemirror/mode/scheme/scheme.js +230 -0
- data/examples/examples01/static/js/codemirror/mode/shell/index.html +51 -0
- data/examples/examples01/static/js/codemirror/mode/shell/shell.js +118 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/LICENSE +23 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/index.html +81 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/sieve.js +156 -0
- data/examples/examples01/static/js/codemirror/mode/smalltalk/index.html +57 -0
- data/examples/examples01/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
- data/examples/examples01/static/js/codemirror/mode/smarty/index.html +83 -0
- data/examples/examples01/static/js/codemirror/mode/smarty/smarty.js +148 -0
- data/examples/examples01/static/js/codemirror/mode/sparql/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/sparql/sparql.js +143 -0
- data/examples/examples01/static/js/codemirror/mode/stex/index.html +98 -0
- data/examples/examples01/static/js/codemirror/mode/stex/stex.js +175 -0
- data/examples/examples01/static/js/codemirror/mode/stex/test.js +343 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/index.html +81 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/tiki.css +26 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/tiki.js +309 -0
- data/examples/examples01/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
- data/examples/examples01/static/js/codemirror/mode/vb/index.html +88 -0
- data/examples/examples01/static/js/codemirror/mode/vb/vb.js +260 -0
- data/examples/examples01/static/js/codemirror/mode/vbscript/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
- data/examples/examples01/static/js/codemirror/mode/velocity/index.html +103 -0
- data/examples/examples01/static/js/codemirror/mode/velocity/velocity.js +144 -0
- data/examples/examples01/static/js/codemirror/mode/verilog/index.html +210 -0
- data/examples/examples01/static/js/codemirror/mode/verilog/verilog.js +182 -0
- data/examples/examples01/static/js/codemirror/mode/xml/index.html +45 -0
- data/examples/examples01/static/js/codemirror/mode/xml/xml.js +324 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/LICENSE +20 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/index.html +221 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/test.js +77 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/xquery.js +450 -0
- data/examples/examples01/static/js/codemirror/mode/yaml/index.html +68 -0
- data/examples/examples01/static/js/codemirror/mode/yaml/yaml.js +95 -0
- data/examples/examples01/static/js/codemirror/mode/z80/index.html +39 -0
- data/examples/examples01/static/js/codemirror/mode/z80/z80.js +113 -0
- data/examples/examples01/static/js/codemirror/theme/ambiance-mobile.css +6 -0
- data/examples/examples01/static/js/codemirror/theme/ambiance.css +76 -0
- data/examples/examples01/static/js/codemirror/theme/blackboard.css +25 -0
- data/examples/examples01/static/js/codemirror/theme/cobalt.css +18 -0
- data/examples/examples01/static/js/codemirror/theme/eclipse.css +25 -0
- data/examples/examples01/static/js/codemirror/theme/elegant.css +10 -0
- data/examples/examples01/static/js/codemirror/theme/erlang-dark.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/lesser-dark.css +44 -0
- data/examples/examples01/static/js/codemirror/theme/monokai.css +28 -0
- data/examples/examples01/static/js/codemirror/theme/neat.css +9 -0
- data/examples/examples01/static/js/codemirror/theme/night.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/rubyblue.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/solarized.css +207 -0
- data/examples/examples01/static/js/codemirror/theme/twilight.css +26 -0
- data/examples/examples01/static/js/codemirror/theme/vibrant-ink.css +27 -0
- data/examples/examples01/static/js/codemirror/theme/xq-dark.css +46 -0
- data/examples/examples01/static/js/d3.v3.min.js +2 -2
- data/examples/examples01/static/test/cm.html +33 -0
- data/examples/examples01/views/about.slim +15 -0
- data/examples/examples01/views/index.slim +1 -1
- data/examples/examples01/views/layout.slim +1 -0
- data/examples/examples01/views/layout_cm.slim +17 -0
- data/examples/examples01/views/navbar.slim +4 -4
- data/lib/swagr/version.rb +1 -1
- data/templates/app.rb +4 -0
- data/templates/static/js/codemirror/keymap/emacs.js +30 -0
- data/templates/static/js/codemirror/keymap/vim.js +2298 -0
- data/templates/static/js/codemirror/lib/codemirror.css +239 -0
- data/templates/static/js/codemirror/lib/codemirror.js +4553 -0
- data/templates/static/js/codemirror/lib/util/closetag.js +85 -0
- data/templates/static/js/codemirror/lib/util/colorize.js +29 -0
- data/templates/static/js/codemirror/lib/util/continuecomment.js +36 -0
- data/templates/static/js/codemirror/lib/util/continuelist.js +28 -0
- data/templates/static/js/codemirror/lib/util/dialog.css +32 -0
- data/templates/static/js/codemirror/lib/util/dialog.js +75 -0
- data/templates/static/js/codemirror/lib/util/foldcode.js +182 -0
- data/templates/static/js/codemirror/lib/util/formatting.js +108 -0
- data/templates/static/js/codemirror/lib/util/javascript-hint.js +137 -0
- data/templates/static/js/codemirror/lib/util/loadmode.js +51 -0
- data/templates/static/js/codemirror/lib/util/match-highlighter.js +46 -0
- data/templates/static/js/codemirror/lib/util/matchbrackets.js +63 -0
- data/templates/static/js/codemirror/lib/util/multiplex.js +95 -0
- data/templates/static/js/codemirror/lib/util/overlay.js +59 -0
- data/templates/static/js/codemirror/lib/util/pig-hint.js +117 -0
- data/templates/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
- data/templates/static/js/codemirror/lib/util/runmode.js +52 -0
- data/templates/static/js/codemirror/lib/util/search.js +119 -0
- data/templates/static/js/codemirror/lib/util/searchcursor.js +119 -0
- data/templates/static/js/codemirror/lib/util/simple-hint.css +16 -0
- data/templates/static/js/codemirror/lib/util/simple-hint.js +102 -0
- data/templates/static/js/codemirror/lib/util/xml-hint.js +131 -0
- data/templates/static/js/codemirror/mode/clike/clike.js +300 -0
- data/templates/static/js/codemirror/mode/clike/index.html +103 -0
- data/templates/static/js/codemirror/mode/clike/scala.html +767 -0
- data/templates/static/js/codemirror/mode/clojure/clojure.js +206 -0
- data/templates/static/js/codemirror/mode/clojure/index.html +67 -0
- data/templates/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
- data/templates/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/templates/static/js/codemirror/mode/coffeescript/index.html +728 -0
- data/templates/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/templates/static/js/codemirror/mode/commonlisp/index.html +165 -0
- data/templates/static/js/codemirror/mode/css/css.js +465 -0
- data/templates/static/js/codemirror/mode/css/index.html +58 -0
- data/templates/static/js/codemirror/mode/css/test.js +501 -0
- data/templates/static/js/codemirror/mode/diff/diff.js +32 -0
- data/templates/static/js/codemirror/mode/diff/index.html +105 -0
- data/templates/static/js/codemirror/mode/ecl/ecl.js +192 -0
- data/templates/static/js/codemirror/mode/ecl/index.html +39 -0
- data/templates/static/js/codemirror/mode/erlang/erlang.js +463 -0
- data/templates/static/js/codemirror/mode/erlang/index.html +64 -0
- data/templates/static/js/codemirror/mode/gfm/gfm.js +94 -0
- data/templates/static/js/codemirror/mode/gfm/index.html +70 -0
- data/templates/static/js/codemirror/mode/gfm/test.js +225 -0
- data/templates/static/js/codemirror/mode/go/go.js +165 -0
- data/templates/static/js/codemirror/mode/go/index.html +74 -0
- data/templates/static/js/codemirror/mode/groovy/groovy.js +210 -0
- data/templates/static/js/codemirror/mode/groovy/index.html +73 -0
- data/templates/static/js/codemirror/mode/haskell/haskell.js +242 -0
- data/templates/static/js/codemirror/mode/haskell/index.html +62 -0
- data/templates/static/js/codemirror/mode/haxe/haxe.js +429 -0
- data/templates/static/js/codemirror/mode/haxe/index.html +90 -0
- data/templates/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/templates/static/js/codemirror/mode/htmlembedded/index.html +49 -0
- data/templates/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
- data/templates/static/js/codemirror/mode/htmlmixed/index.html +52 -0
- data/templates/static/js/codemirror/mode/http/http.js +98 -0
- data/templates/static/js/codemirror/mode/http/index.html +32 -0
- data/templates/static/js/codemirror/mode/javascript/index.html +88 -0
- data/templates/static/js/codemirror/mode/javascript/javascript.js +411 -0
- data/templates/static/js/codemirror/mode/javascript/typescript.html +48 -0
- data/templates/static/js/codemirror/mode/jinja2/index.html +38 -0
- data/templates/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
- data/templates/static/js/codemirror/mode/less/index.html +741 -0
- data/templates/static/js/codemirror/mode/less/less.js +266 -0
- data/templates/static/js/codemirror/mode/lua/index.html +74 -0
- data/templates/static/js/codemirror/mode/lua/lua.js +140 -0
- data/templates/static/js/codemirror/mode/markdown/index.html +344 -0
- data/templates/static/js/codemirror/mode/markdown/markdown.js +474 -0
- data/templates/static/js/codemirror/mode/markdown/test.js +1266 -0
- data/templates/static/js/codemirror/mode/mysql/index.html +41 -0
- data/templates/static/js/codemirror/mode/mysql/mysql.js +203 -0
- data/templates/static/js/codemirror/mode/ntriples/index.html +33 -0
- data/templates/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
- data/templates/static/js/codemirror/mode/ocaml/index.html +131 -0
- data/templates/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
- data/templates/static/js/codemirror/mode/pascal/LICENSE +7 -0
- data/templates/static/js/codemirror/mode/pascal/index.html +48 -0
- data/templates/static/js/codemirror/mode/pascal/pascal.js +94 -0
- data/templates/static/js/codemirror/mode/perl/LICENSE +19 -0
- data/templates/static/js/codemirror/mode/perl/index.html +62 -0
- data/templates/static/js/codemirror/mode/perl/perl.js +816 -0
- data/templates/static/js/codemirror/mode/php/index.html +51 -0
- data/templates/static/js/codemirror/mode/php/php.js +129 -0
- data/templates/static/js/codemirror/mode/pig/index.html +42 -0
- data/templates/static/js/codemirror/mode/pig/pig.js +171 -0
- data/templates/static/js/codemirror/mode/plsql/index.html +62 -0
- data/templates/static/js/codemirror/mode/plsql/plsql.js +216 -0
- data/templates/static/js/codemirror/mode/properties/index.html +41 -0
- data/templates/static/js/codemirror/mode/properties/properties.js +63 -0
- data/templates/static/js/codemirror/mode/python/LICENSE.txt +21 -0
- data/templates/static/js/codemirror/mode/python/index.html +124 -0
- data/templates/static/js/codemirror/mode/python/python.js +340 -0
- data/templates/static/js/codemirror/mode/r/LICENSE +24 -0
- data/templates/static/js/codemirror/mode/r/index.html +74 -0
- data/templates/static/js/codemirror/mode/r/r.js +141 -0
- data/templates/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
- data/templates/static/js/codemirror/mode/rpm/changes/index.html +53 -0
- data/templates/static/js/codemirror/mode/rpm/spec/index.html +99 -0
- data/templates/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
- data/templates/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
- data/templates/static/js/codemirror/mode/rst/index.html +526 -0
- data/templates/static/js/codemirror/mode/rst/rst.js +314 -0
- data/templates/static/js/codemirror/mode/ruby/LICENSE +24 -0
- data/templates/static/js/codemirror/mode/ruby/index.html +173 -0
- data/templates/static/js/codemirror/mode/ruby/ruby.js +195 -0
- data/templates/static/js/codemirror/mode/rust/index.html +48 -0
- data/templates/static/js/codemirror/mode/rust/rust.js +432 -0
- data/templates/static/js/codemirror/mode/scheme/index.html +65 -0
- data/templates/static/js/codemirror/mode/scheme/scheme.js +230 -0
- data/templates/static/js/codemirror/mode/shell/index.html +51 -0
- data/templates/static/js/codemirror/mode/shell/shell.js +118 -0
- data/templates/static/js/codemirror/mode/sieve/LICENSE +23 -0
- data/templates/static/js/codemirror/mode/sieve/index.html +81 -0
- data/templates/static/js/codemirror/mode/sieve/sieve.js +156 -0
- data/templates/static/js/codemirror/mode/smalltalk/index.html +57 -0
- data/templates/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
- data/templates/static/js/codemirror/mode/smarty/index.html +83 -0
- data/templates/static/js/codemirror/mode/smarty/smarty.js +148 -0
- data/templates/static/js/codemirror/mode/sparql/index.html +42 -0
- data/templates/static/js/codemirror/mode/sparql/sparql.js +143 -0
- data/templates/static/js/codemirror/mode/stex/index.html +98 -0
- data/templates/static/js/codemirror/mode/stex/stex.js +175 -0
- data/templates/static/js/codemirror/mode/stex/test.js +343 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/templates/static/js/codemirror/mode/tiki/index.html +81 -0
- data/templates/static/js/codemirror/mode/tiki/tiki.css +26 -0
- data/templates/static/js/codemirror/mode/tiki/tiki.js +309 -0
- data/templates/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
- data/templates/static/js/codemirror/mode/vb/index.html +88 -0
- data/templates/static/js/codemirror/mode/vb/vb.js +260 -0
- data/templates/static/js/codemirror/mode/vbscript/index.html +42 -0
- data/templates/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
- data/templates/static/js/codemirror/mode/velocity/index.html +103 -0
- data/templates/static/js/codemirror/mode/velocity/velocity.js +144 -0
- data/templates/static/js/codemirror/mode/verilog/index.html +210 -0
- data/templates/static/js/codemirror/mode/verilog/verilog.js +182 -0
- data/templates/static/js/codemirror/mode/xml/index.html +45 -0
- data/templates/static/js/codemirror/mode/xml/xml.js +324 -0
- data/templates/static/js/codemirror/mode/xquery/LICENSE +20 -0
- data/templates/static/js/codemirror/mode/xquery/index.html +221 -0
- data/templates/static/js/codemirror/mode/xquery/test.js +77 -0
- data/templates/static/js/codemirror/mode/xquery/xquery.js +450 -0
- data/templates/static/js/codemirror/mode/yaml/index.html +68 -0
- data/templates/static/js/codemirror/mode/yaml/yaml.js +95 -0
- data/templates/static/js/codemirror/mode/z80/index.html +39 -0
- data/templates/static/js/codemirror/mode/z80/z80.js +113 -0
- data/templates/static/js/codemirror/theme/ambiance-mobile.css +6 -0
- data/templates/static/js/codemirror/theme/ambiance.css +76 -0
- data/templates/static/js/codemirror/theme/blackboard.css +25 -0
- data/templates/static/js/codemirror/theme/cobalt.css +18 -0
- data/templates/static/js/codemirror/theme/eclipse.css +25 -0
- data/templates/static/js/codemirror/theme/elegant.css +10 -0
- data/templates/static/js/codemirror/theme/erlang-dark.css +21 -0
- data/templates/static/js/codemirror/theme/lesser-dark.css +44 -0
- data/templates/static/js/codemirror/theme/monokai.css +28 -0
- data/templates/static/js/codemirror/theme/neat.css +9 -0
- data/templates/static/js/codemirror/theme/night.css +21 -0
- data/templates/static/js/codemirror/theme/rubyblue.css +21 -0
- data/templates/static/js/codemirror/theme/solarized.css +207 -0
- data/templates/static/js/codemirror/theme/twilight.css +26 -0
- data/templates/static/js/codemirror/theme/vibrant-ink.css +27 -0
- data/templates/static/js/codemirror/theme/xq-dark.css +46 -0
- data/templates/static/js/d3.v3.min.js +2 -2
- data/templates/static/test/cm.html +33 -0
- data/templates/views/about.slim +15 -0
- data/templates/views/index.slim +1 -1
- data/templates/views/layout.slim +1 -0
- data/templates/views/navbar.slim +4 -4
- metadata +347 -2
@@ -0,0 +1,728 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>CodeMirror: CoffeeScript mode</title>
|
6
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
|
+
<script src="../../lib/codemirror.js"></script>
|
8
|
+
<script src="coffeescript.js"></script>
|
9
|
+
<style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
|
10
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>CodeMirror: CoffeeScript mode</h1>
|
14
|
+
<form><textarea id="code" name="code">
|
15
|
+
# CoffeeScript mode for CodeMirror
|
16
|
+
# Copyright (c) 2011 Jeff Pickhardt, released under
|
17
|
+
# the MIT License.
|
18
|
+
#
|
19
|
+
# Modified from the Python CodeMirror mode, which also is
|
20
|
+
# under the MIT License Copyright (c) 2010 Timothy Farrell.
|
21
|
+
#
|
22
|
+
# The following script, Underscore.coffee, is used to
|
23
|
+
# demonstrate CoffeeScript mode for CodeMirror.
|
24
|
+
#
|
25
|
+
# To download CoffeeScript mode for CodeMirror, go to:
|
26
|
+
# https://github.com/pickhardt/coffeescript-codemirror-mode
|
27
|
+
|
28
|
+
# **Underscore.coffee
|
29
|
+
# (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.**
|
30
|
+
# Underscore is freely distributable under the terms of the
|
31
|
+
# [MIT license](http://en.wikipedia.org/wiki/MIT_License).
|
32
|
+
# Portions of Underscore are inspired by or borrowed from
|
33
|
+
# [Prototype.js](http://prototypejs.org/api), Oliver Steele's
|
34
|
+
# [Functional](http://osteele.com), and John Resig's
|
35
|
+
# [Micro-Templating](http://ejohn.org).
|
36
|
+
# For all details and documentation:
|
37
|
+
# http://documentcloud.github.com/underscore/
|
38
|
+
|
39
|
+
|
40
|
+
# Baseline setup
|
41
|
+
# --------------
|
42
|
+
|
43
|
+
# Establish the root object, `window` in the browser, or `global` on the server.
|
44
|
+
root = this
|
45
|
+
|
46
|
+
|
47
|
+
# Save the previous value of the `_` variable.
|
48
|
+
previousUnderscore = root._
|
49
|
+
|
50
|
+
### Multiline
|
51
|
+
comment
|
52
|
+
###
|
53
|
+
|
54
|
+
# Establish the object that gets thrown to break out of a loop iteration.
|
55
|
+
# `StopIteration` is SOP on Mozilla.
|
56
|
+
breaker = if typeof(StopIteration) is 'undefined' then '__break__' else StopIteration
|
57
|
+
|
58
|
+
|
59
|
+
#### Docco style single line comment (title)
|
60
|
+
|
61
|
+
|
62
|
+
# Helper function to escape **RegExp** contents, because JS doesn't have one.
|
63
|
+
escapeRegExp = (string) -> string.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1')
|
64
|
+
|
65
|
+
|
66
|
+
# Save bytes in the minified (but not gzipped) version:
|
67
|
+
ArrayProto = Array.prototype
|
68
|
+
ObjProto = Object.prototype
|
69
|
+
|
70
|
+
|
71
|
+
# Create quick reference variables for speed access to core prototypes.
|
72
|
+
slice = ArrayProto.slice
|
73
|
+
unshift = ArrayProto.unshift
|
74
|
+
toString = ObjProto.toString
|
75
|
+
hasOwnProperty = ObjProto.hasOwnProperty
|
76
|
+
propertyIsEnumerable = ObjProto.propertyIsEnumerable
|
77
|
+
|
78
|
+
|
79
|
+
# All **ECMA5** native implementations we hope to use are declared here.
|
80
|
+
nativeForEach = ArrayProto.forEach
|
81
|
+
nativeMap = ArrayProto.map
|
82
|
+
nativeReduce = ArrayProto.reduce
|
83
|
+
nativeReduceRight = ArrayProto.reduceRight
|
84
|
+
nativeFilter = ArrayProto.filter
|
85
|
+
nativeEvery = ArrayProto.every
|
86
|
+
nativeSome = ArrayProto.some
|
87
|
+
nativeIndexOf = ArrayProto.indexOf
|
88
|
+
nativeLastIndexOf = ArrayProto.lastIndexOf
|
89
|
+
nativeIsArray = Array.isArray
|
90
|
+
nativeKeys = Object.keys
|
91
|
+
|
92
|
+
|
93
|
+
# Create a safe reference to the Underscore object for use below.
|
94
|
+
_ = (obj) -> new wrapper(obj)
|
95
|
+
|
96
|
+
|
97
|
+
# Export the Underscore object for **CommonJS**.
|
98
|
+
if typeof(exports) != 'undefined' then exports._ = _
|
99
|
+
|
100
|
+
|
101
|
+
# Export Underscore to global scope.
|
102
|
+
root._ = _
|
103
|
+
|
104
|
+
|
105
|
+
# Current version.
|
106
|
+
_.VERSION = '1.1.0'
|
107
|
+
|
108
|
+
|
109
|
+
# Collection Functions
|
110
|
+
# --------------------
|
111
|
+
|
112
|
+
# The cornerstone, an **each** implementation.
|
113
|
+
# Handles objects implementing **forEach**, arrays, and raw objects.
|
114
|
+
_.each = (obj, iterator, context) ->
|
115
|
+
try
|
116
|
+
if nativeForEach and obj.forEach is nativeForEach
|
117
|
+
obj.forEach iterator, context
|
118
|
+
else if _.isNumber obj.length
|
119
|
+
iterator.call context, obj[i], i, obj for i in [0...obj.length]
|
120
|
+
else
|
121
|
+
iterator.call context, val, key, obj for own key, val of obj
|
122
|
+
catch e
|
123
|
+
throw e if e isnt breaker
|
124
|
+
obj
|
125
|
+
|
126
|
+
|
127
|
+
# Return the results of applying the iterator to each element. Use JavaScript
|
128
|
+
# 1.6's version of **map**, if possible.
|
129
|
+
_.map = (obj, iterator, context) ->
|
130
|
+
return obj.map(iterator, context) if nativeMap and obj.map is nativeMap
|
131
|
+
results = []
|
132
|
+
_.each obj, (value, index, list) ->
|
133
|
+
results.push iterator.call context, value, index, list
|
134
|
+
results
|
135
|
+
|
136
|
+
|
137
|
+
# **Reduce** builds up a single result from a list of values. Also known as
|
138
|
+
# **inject**, or **foldl**. Uses JavaScript 1.8's version of **reduce**, if possible.
|
139
|
+
_.reduce = (obj, iterator, memo, context) ->
|
140
|
+
if nativeReduce and obj.reduce is nativeReduce
|
141
|
+
iterator = _.bind iterator, context if context
|
142
|
+
return obj.reduce iterator, memo
|
143
|
+
_.each obj, (value, index, list) ->
|
144
|
+
memo = iterator.call context, memo, value, index, list
|
145
|
+
memo
|
146
|
+
|
147
|
+
|
148
|
+
# The right-associative version of **reduce**, also known as **foldr**. Uses
|
149
|
+
# JavaScript 1.8's version of **reduceRight**, if available.
|
150
|
+
_.reduceRight = (obj, iterator, memo, context) ->
|
151
|
+
if nativeReduceRight and obj.reduceRight is nativeReduceRight
|
152
|
+
iterator = _.bind iterator, context if context
|
153
|
+
return obj.reduceRight iterator, memo
|
154
|
+
reversed = _.clone(_.toArray(obj)).reverse()
|
155
|
+
_.reduce reversed, iterator, memo, context
|
156
|
+
|
157
|
+
|
158
|
+
# Return the first value which passes a truth test.
|
159
|
+
_.detect = (obj, iterator, context) ->
|
160
|
+
result = null
|
161
|
+
_.each obj, (value, index, list) ->
|
162
|
+
if iterator.call context, value, index, list
|
163
|
+
result = value
|
164
|
+
_.breakLoop()
|
165
|
+
result
|
166
|
+
|
167
|
+
|
168
|
+
# Return all the elements that pass a truth test. Use JavaScript 1.6's
|
169
|
+
# **filter**, if it exists.
|
170
|
+
_.filter = (obj, iterator, context) ->
|
171
|
+
return obj.filter iterator, context if nativeFilter and obj.filter is nativeFilter
|
172
|
+
results = []
|
173
|
+
_.each obj, (value, index, list) ->
|
174
|
+
results.push value if iterator.call context, value, index, list
|
175
|
+
results
|
176
|
+
|
177
|
+
|
178
|
+
# Return all the elements for which a truth test fails.
|
179
|
+
_.reject = (obj, iterator, context) ->
|
180
|
+
results = []
|
181
|
+
_.each obj, (value, index, list) ->
|
182
|
+
results.push value if not iterator.call context, value, index, list
|
183
|
+
results
|
184
|
+
|
185
|
+
|
186
|
+
# Determine whether all of the elements match a truth test. Delegate to
|
187
|
+
# JavaScript 1.6's **every**, if it is present.
|
188
|
+
_.every = (obj, iterator, context) ->
|
189
|
+
iterator ||= _.identity
|
190
|
+
return obj.every iterator, context if nativeEvery and obj.every is nativeEvery
|
191
|
+
result = true
|
192
|
+
_.each obj, (value, index, list) ->
|
193
|
+
_.breakLoop() unless (result = result and iterator.call(context, value, index, list))
|
194
|
+
result
|
195
|
+
|
196
|
+
|
197
|
+
# Determine if at least one element in the object matches a truth test. Use
|
198
|
+
# JavaScript 1.6's **some**, if it exists.
|
199
|
+
_.some = (obj, iterator, context) ->
|
200
|
+
iterator ||= _.identity
|
201
|
+
return obj.some iterator, context if nativeSome and obj.some is nativeSome
|
202
|
+
result = false
|
203
|
+
_.each obj, (value, index, list) ->
|
204
|
+
_.breakLoop() if (result = iterator.call(context, value, index, list))
|
205
|
+
result
|
206
|
+
|
207
|
+
|
208
|
+
# Determine if a given value is included in the array or object,
|
209
|
+
# based on `===`.
|
210
|
+
_.include = (obj, target) ->
|
211
|
+
return _.indexOf(obj, target) isnt -1 if nativeIndexOf and obj.indexOf is nativeIndexOf
|
212
|
+
return true for own key, val of obj when val is target
|
213
|
+
false
|
214
|
+
|
215
|
+
|
216
|
+
# Invoke a method with arguments on every item in a collection.
|
217
|
+
_.invoke = (obj, method) ->
|
218
|
+
args = _.rest arguments, 2
|
219
|
+
(if method then val[method] else val).apply(val, args) for val in obj
|
220
|
+
|
221
|
+
|
222
|
+
# Convenience version of a common use case of **map**: fetching a property.
|
223
|
+
_.pluck = (obj, key) ->
|
224
|
+
_.map(obj, (val) -> val[key])
|
225
|
+
|
226
|
+
|
227
|
+
# Return the maximum item or (item-based computation).
|
228
|
+
_.max = (obj, iterator, context) ->
|
229
|
+
return Math.max.apply(Math, obj) if not iterator and _.isArray(obj)
|
230
|
+
result = computed: -Infinity
|
231
|
+
_.each obj, (value, index, list) ->
|
232
|
+
computed = if iterator then iterator.call(context, value, index, list) else value
|
233
|
+
computed >= result.computed and (result = {value: value, computed: computed})
|
234
|
+
result.value
|
235
|
+
|
236
|
+
|
237
|
+
# Return the minimum element (or element-based computation).
|
238
|
+
_.min = (obj, iterator, context) ->
|
239
|
+
return Math.min.apply(Math, obj) if not iterator and _.isArray(obj)
|
240
|
+
result = computed: Infinity
|
241
|
+
_.each obj, (value, index, list) ->
|
242
|
+
computed = if iterator then iterator.call(context, value, index, list) else value
|
243
|
+
computed < result.computed and (result = {value: value, computed: computed})
|
244
|
+
result.value
|
245
|
+
|
246
|
+
|
247
|
+
# Sort the object's values by a criterion produced by an iterator.
|
248
|
+
_.sortBy = (obj, iterator, context) ->
|
249
|
+
_.pluck(((_.map obj, (value, index, list) ->
|
250
|
+
{value: value, criteria: iterator.call(context, value, index, list)}
|
251
|
+
).sort((left, right) ->
|
252
|
+
a = left.criteria; b = right.criteria
|
253
|
+
if a < b then -1 else if a > b then 1 else 0
|
254
|
+
)), 'value')
|
255
|
+
|
256
|
+
|
257
|
+
# Use a comparator function to figure out at what index an object should
|
258
|
+
# be inserted so as to maintain order. Uses binary search.
|
259
|
+
_.sortedIndex = (array, obj, iterator) ->
|
260
|
+
iterator ||= _.identity
|
261
|
+
low = 0
|
262
|
+
high = array.length
|
263
|
+
while low < high
|
264
|
+
mid = (low + high) >> 1
|
265
|
+
if iterator(array[mid]) < iterator(obj) then low = mid + 1 else high = mid
|
266
|
+
low
|
267
|
+
|
268
|
+
|
269
|
+
# Convert anything iterable into a real, live array.
|
270
|
+
_.toArray = (iterable) ->
|
271
|
+
return [] if (!iterable)
|
272
|
+
return iterable.toArray() if (iterable.toArray)
|
273
|
+
return iterable if (_.isArray(iterable))
|
274
|
+
return slice.call(iterable) if (_.isArguments(iterable))
|
275
|
+
_.values(iterable)
|
276
|
+
|
277
|
+
|
278
|
+
# Return the number of elements in an object.
|
279
|
+
_.size = (obj) -> _.toArray(obj).length
|
280
|
+
|
281
|
+
|
282
|
+
# Array Functions
|
283
|
+
# ---------------
|
284
|
+
|
285
|
+
# Get the first element of an array. Passing `n` will return the first N
|
286
|
+
# values in the array. Aliased as **head**. The `guard` check allows it to work
|
287
|
+
# with **map**.
|
288
|
+
_.first = (array, n, guard) ->
|
289
|
+
if n and not guard then slice.call(array, 0, n) else array[0]
|
290
|
+
|
291
|
+
|
292
|
+
# Returns everything but the first entry of the array. Aliased as **tail**.
|
293
|
+
# Especially useful on the arguments object. Passing an `index` will return
|
294
|
+
# the rest of the values in the array from that index onward. The `guard`
|
295
|
+
# check allows it to work with **map**.
|
296
|
+
_.rest = (array, index, guard) ->
|
297
|
+
slice.call(array, if _.isUndefined(index) or guard then 1 else index)
|
298
|
+
|
299
|
+
|
300
|
+
# Get the last element of an array.
|
301
|
+
_.last = (array) -> array[array.length - 1]
|
302
|
+
|
303
|
+
|
304
|
+
# Trim out all falsy values from an array.
|
305
|
+
_.compact = (array) -> item for item in array when item
|
306
|
+
|
307
|
+
|
308
|
+
# Return a completely flattened version of an array.
|
309
|
+
_.flatten = (array) ->
|
310
|
+
_.reduce array, (memo, value) ->
|
311
|
+
return memo.concat(_.flatten(value)) if _.isArray value
|
312
|
+
memo.push value
|
313
|
+
memo
|
314
|
+
, []
|
315
|
+
|
316
|
+
|
317
|
+
# Return a version of the array that does not contain the specified value(s).
|
318
|
+
_.without = (array) ->
|
319
|
+
values = _.rest arguments
|
320
|
+
val for val in _.toArray(array) when not _.include values, val
|
321
|
+
|
322
|
+
|
323
|
+
# Produce a duplicate-free version of the array. If the array has already
|
324
|
+
# been sorted, you have the option of using a faster algorithm.
|
325
|
+
_.uniq = (array, isSorted) ->
|
326
|
+
memo = []
|
327
|
+
for el, i in _.toArray array
|
328
|
+
memo.push el if i is 0 || (if isSorted is true then _.last(memo) isnt el else not _.include(memo, el))
|
329
|
+
memo
|
330
|
+
|
331
|
+
|
332
|
+
# Produce an array that contains every item shared between all the
|
333
|
+
# passed-in arrays.
|
334
|
+
_.intersect = (array) ->
|
335
|
+
rest = _.rest arguments
|
336
|
+
_.select _.uniq(array), (item) ->
|
337
|
+
_.all rest, (other) ->
|
338
|
+
_.indexOf(other, item) >= 0
|
339
|
+
|
340
|
+
|
341
|
+
# Zip together multiple lists into a single array -- elements that share
|
342
|
+
# an index go together.
|
343
|
+
_.zip = ->
|
344
|
+
length = _.max _.pluck arguments, 'length'
|
345
|
+
results = new Array length
|
346
|
+
for i in [0...length]
|
347
|
+
results[i] = _.pluck arguments, String i
|
348
|
+
results
|
349
|
+
|
350
|
+
|
351
|
+
# If the browser doesn't supply us with **indexOf** (I'm looking at you, MSIE),
|
352
|
+
# we need this function. Return the position of the first occurrence of an
|
353
|
+
# item in an array, or -1 if the item is not included in the array.
|
354
|
+
_.indexOf = (array, item) ->
|
355
|
+
return array.indexOf item if nativeIndexOf and array.indexOf is nativeIndexOf
|
356
|
+
i = 0; l = array.length
|
357
|
+
while l - i
|
358
|
+
if array[i] is item then return i else i++
|
359
|
+
-1
|
360
|
+
|
361
|
+
|
362
|
+
# Provide JavaScript 1.6's **lastIndexOf**, delegating to the native function,
|
363
|
+
# if possible.
|
364
|
+
_.lastIndexOf = (array, item) ->
|
365
|
+
return array.lastIndexOf(item) if nativeLastIndexOf and array.lastIndexOf is nativeLastIndexOf
|
366
|
+
i = array.length
|
367
|
+
while i
|
368
|
+
if array[i] is item then return i else i--
|
369
|
+
-1
|
370
|
+
|
371
|
+
|
372
|
+
# Generate an integer Array containing an arithmetic progression. A port of
|
373
|
+
# [the native Python **range** function](http://docs.python.org/library/functions.html#range).
|
374
|
+
_.range = (start, stop, step) ->
|
375
|
+
a = arguments
|
376
|
+
solo = a.length <= 1
|
377
|
+
i = start = if solo then 0 else a[0]
|
378
|
+
stop = if solo then a[0] else a[1]
|
379
|
+
step = a[2] or 1
|
380
|
+
len = Math.ceil((stop - start) / step)
|
381
|
+
return [] if len <= 0
|
382
|
+
range = new Array len
|
383
|
+
idx = 0
|
384
|
+
loop
|
385
|
+
return range if (if step > 0 then i - stop else stop - i) >= 0
|
386
|
+
range[idx] = i
|
387
|
+
idx++
|
388
|
+
i+= step
|
389
|
+
|
390
|
+
|
391
|
+
# Function Functions
|
392
|
+
# ------------------
|
393
|
+
|
394
|
+
# Create a function bound to a given object (assigning `this`, and arguments,
|
395
|
+
# optionally). Binding with arguments is also known as **curry**.
|
396
|
+
_.bind = (func, obj) ->
|
397
|
+
args = _.rest arguments, 2
|
398
|
+
-> func.apply obj or root, args.concat arguments
|
399
|
+
|
400
|
+
|
401
|
+
# Bind all of an object's methods to that object. Useful for ensuring that
|
402
|
+
# all callbacks defined on an object belong to it.
|
403
|
+
_.bindAll = (obj) ->
|
404
|
+
funcs = if arguments.length > 1 then _.rest(arguments) else _.functions(obj)
|
405
|
+
_.each funcs, (f) -> obj[f] = _.bind obj[f], obj
|
406
|
+
obj
|
407
|
+
|
408
|
+
|
409
|
+
# Delays a function for the given number of milliseconds, and then calls
|
410
|
+
# it with the arguments supplied.
|
411
|
+
_.delay = (func, wait) ->
|
412
|
+
args = _.rest arguments, 2
|
413
|
+
setTimeout((-> func.apply(func, args)), wait)
|
414
|
+
|
415
|
+
|
416
|
+
# Memoize an expensive function by storing its results.
|
417
|
+
_.memoize = (func, hasher) ->
|
418
|
+
memo = {}
|
419
|
+
hasher or= _.identity
|
420
|
+
->
|
421
|
+
key = hasher.apply this, arguments
|
422
|
+
return memo[key] if key of memo
|
423
|
+
memo[key] = func.apply this, arguments
|
424
|
+
|
425
|
+
|
426
|
+
# Defers a function, scheduling it to run after the current call stack has
|
427
|
+
# cleared.
|
428
|
+
_.defer = (func) ->
|
429
|
+
_.delay.apply _, [func, 1].concat _.rest arguments
|
430
|
+
|
431
|
+
|
432
|
+
# Returns the first function passed as an argument to the second,
|
433
|
+
# allowing you to adjust arguments, run code before and after, and
|
434
|
+
# conditionally execute the original function.
|
435
|
+
_.wrap = (func, wrapper) ->
|
436
|
+
-> wrapper.apply wrapper, [func].concat arguments
|
437
|
+
|
438
|
+
|
439
|
+
# Returns a function that is the composition of a list of functions, each
|
440
|
+
# consuming the return value of the function that follows.
|
441
|
+
_.compose = ->
|
442
|
+
funcs = arguments
|
443
|
+
->
|
444
|
+
args = arguments
|
445
|
+
for i in [funcs.length - 1..0] by -1
|
446
|
+
args = [funcs[i].apply(this, args)]
|
447
|
+
args[0]
|
448
|
+
|
449
|
+
|
450
|
+
# Object Functions
|
451
|
+
# ----------------
|
452
|
+
|
453
|
+
# Retrieve the names of an object's properties.
|
454
|
+
_.keys = nativeKeys or (obj) ->
|
455
|
+
return _.range 0, obj.length if _.isArray(obj)
|
456
|
+
key for key, val of obj
|
457
|
+
|
458
|
+
|
459
|
+
# Retrieve the values of an object's properties.
|
460
|
+
_.values = (obj) ->
|
461
|
+
_.map obj, _.identity
|
462
|
+
|
463
|
+
|
464
|
+
# Return a sorted list of the function names available in Underscore.
|
465
|
+
_.functions = (obj) ->
|
466
|
+
_.filter(_.keys(obj), (key) -> _.isFunction(obj[key])).sort()
|
467
|
+
|
468
|
+
|
469
|
+
# Extend a given object with all of the properties in a source object.
|
470
|
+
_.extend = (obj) ->
|
471
|
+
for source in _.rest(arguments)
|
472
|
+
obj[key] = val for key, val of source
|
473
|
+
obj
|
474
|
+
|
475
|
+
|
476
|
+
# Create a (shallow-cloned) duplicate of an object.
|
477
|
+
_.clone = (obj) ->
|
478
|
+
return obj.slice 0 if _.isArray obj
|
479
|
+
_.extend {}, obj
|
480
|
+
|
481
|
+
|
482
|
+
# Invokes interceptor with the obj, and then returns obj.
|
483
|
+
# The primary purpose of this method is to "tap into" a method chain,
|
484
|
+
# in order to perform operations on intermediate results within
|
485
|
+
the chain.
|
486
|
+
_.tap = (obj, interceptor) ->
|
487
|
+
interceptor obj
|
488
|
+
obj
|
489
|
+
|
490
|
+
|
491
|
+
# Perform a deep comparison to check if two objects are equal.
|
492
|
+
_.isEqual = (a, b) ->
|
493
|
+
# Check object identity.
|
494
|
+
return true if a is b
|
495
|
+
# Different types?
|
496
|
+
atype = typeof(a); btype = typeof(b)
|
497
|
+
return false if atype isnt btype
|
498
|
+
# Basic equality test (watch out for coercions).
|
499
|
+
return true if `a == b`
|
500
|
+
# One is falsy and the other truthy.
|
501
|
+
return false if (!a and b) or (a and !b)
|
502
|
+
# One of them implements an `isEqual()`?
|
503
|
+
return a.isEqual(b) if a.isEqual
|
504
|
+
# Check dates' integer values.
|
505
|
+
return a.getTime() is b.getTime() if _.isDate(a) and _.isDate(b)
|
506
|
+
# Both are NaN?
|
507
|
+
return false if _.isNaN(a) and _.isNaN(b)
|
508
|
+
# Compare regular expressions.
|
509
|
+
if _.isRegExp(a) and _.isRegExp(b)
|
510
|
+
return a.source is b.source and
|
511
|
+
a.global is b.global and
|
512
|
+
a.ignoreCase is b.ignoreCase and
|
513
|
+
a.multiline is b.multiline
|
514
|
+
# If a is not an object by this point, we can't handle it.
|
515
|
+
return false if atype isnt 'object'
|
516
|
+
# Check for different array lengths before comparing contents.
|
517
|
+
return false if a.length and (a.length isnt b.length)
|
518
|
+
# Nothing else worked, deep compare the contents.
|
519
|
+
aKeys = _.keys(a); bKeys = _.keys(b)
|
520
|
+
# Different object sizes?
|
521
|
+
return false if aKeys.length isnt bKeys.length
|
522
|
+
# Recursive comparison of contents.
|
523
|
+
return false for key, val of a when !(key of b) or !_.isEqual(val, b[key])
|
524
|
+
true
|
525
|
+
|
526
|
+
|
527
|
+
# Is a given array or object empty?
|
528
|
+
_.isEmpty = (obj) ->
|
529
|
+
return obj.length is 0 if _.isArray(obj) or _.isString(obj)
|
530
|
+
return false for own key of obj
|
531
|
+
true
|
532
|
+
|
533
|
+
|
534
|
+
# Is a given value a DOM element?
|
535
|
+
_.isElement = (obj) -> obj and obj.nodeType is 1
|
536
|
+
|
537
|
+
|
538
|
+
# Is a given value an array?
|
539
|
+
_.isArray = nativeIsArray or (obj) -> !!(obj and obj.concat and obj.unshift and not obj.callee)
|
540
|
+
|
541
|
+
|
542
|
+
# Is a given variable an arguments object?
|
543
|
+
_.isArguments = (obj) -> obj and obj.callee
|
544
|
+
|
545
|
+
|
546
|
+
# Is the given value a function?
|
547
|
+
_.isFunction = (obj) -> !!(obj and obj.constructor and obj.call and obj.apply)
|
548
|
+
|
549
|
+
|
550
|
+
# Is the given value a string?
|
551
|
+
_.isString = (obj) -> !!(obj is '' or (obj and obj.charCodeAt and obj.substr))
|
552
|
+
|
553
|
+
|
554
|
+
# Is a given value a number?
|
555
|
+
_.isNumber = (obj) -> (obj is +obj) or toString.call(obj) is '[object Number]'
|
556
|
+
|
557
|
+
|
558
|
+
# Is a given value a boolean?
|
559
|
+
_.isBoolean = (obj) -> obj is true or obj is false
|
560
|
+
|
561
|
+
|
562
|
+
# Is a given value a Date?
|
563
|
+
_.isDate = (obj) -> !!(obj and obj.getTimezoneOffset and obj.setUTCFullYear)
|
564
|
+
|
565
|
+
|
566
|
+
# Is the given value a regular expression?
|
567
|
+
_.isRegExp = (obj) -> !!(obj and obj.exec and (obj.ignoreCase or obj.ignoreCase is false))
|
568
|
+
|
569
|
+
|
570
|
+
# Is the given value NaN -- this one is interesting. `NaN != NaN`, and
|
571
|
+
# `isNaN(undefined) == true`, so we make sure it's a number first.
|
572
|
+
_.isNaN = (obj) -> _.isNumber(obj) and window.isNaN(obj)
|
573
|
+
|
574
|
+
|
575
|
+
# Is a given value equal to null?
|
576
|
+
_.isNull = (obj) -> obj is null
|
577
|
+
|
578
|
+
|
579
|
+
# Is a given variable undefined?
|
580
|
+
_.isUndefined = (obj) -> typeof obj is 'undefined'
|
581
|
+
|
582
|
+
|
583
|
+
# Utility Functions
|
584
|
+
# -----------------
|
585
|
+
|
586
|
+
# Run Underscore.js in noConflict mode, returning the `_` variable to its
|
587
|
+
# previous owner. Returns a reference to the Underscore object.
|
588
|
+
_.noConflict = ->
|
589
|
+
root._ = previousUnderscore
|
590
|
+
this
|
591
|
+
|
592
|
+
|
593
|
+
# Keep the identity function around for default iterators.
|
594
|
+
_.identity = (value) -> value
|
595
|
+
|
596
|
+
|
597
|
+
# Run a function `n` times.
|
598
|
+
_.times = (n, iterator, context) ->
|
599
|
+
iterator.call context, i for i in [0...n]
|
600
|
+
|
601
|
+
|
602
|
+
# Break out of the middle of an iteration.
|
603
|
+
_.breakLoop = -> throw breaker
|
604
|
+
|
605
|
+
|
606
|
+
# Add your own custom functions to the Underscore object, ensuring that
|
607
|
+
# they're correctly added to the OOP wrapper as well.
|
608
|
+
_.mixin = (obj) ->
|
609
|
+
for name in _.functions(obj)
|
610
|
+
addToWrapper name, _[name] = obj[name]
|
611
|
+
|
612
|
+
|
613
|
+
# Generate a unique integer id (unique within the entire client session).
|
614
|
+
# Useful for temporary DOM ids.
|
615
|
+
idCounter = 0
|
616
|
+
_.uniqueId = (prefix) ->
|
617
|
+
(prefix or '') + idCounter++
|
618
|
+
|
619
|
+
|
620
|
+
# By default, Underscore uses **ERB**-style template delimiters, change the
|
621
|
+
# following template settings to use alternative delimiters.
|
622
|
+
_.templateSettings = {
|
623
|
+
start: '<%'
|
624
|
+
end: '%>'
|
625
|
+
interpolate: /<%=(.+?)%>/g
|
626
|
+
}
|
627
|
+
|
628
|
+
|
629
|
+
# JavaScript templating a-la **ERB**, pilfered from John Resig's
|
630
|
+
# *Secrets of the JavaScript Ninja*, page 83.
|
631
|
+
# Single-quote fix from Rick Strahl.
|
632
|
+
# With alterations for arbitrary delimiters, and to preserve whitespace.
|
633
|
+
_.template = (str, data) ->
|
634
|
+
c = _.templateSettings
|
635
|
+
endMatch = new RegExp("'(?=[^"+c.end.substr(0, 1)+"]*"+escapeRegExp(c.end)+")","g")
|
636
|
+
fn = new Function 'obj',
|
637
|
+
'var p=[],print=function(){p.push.apply(p,arguments);};' +
|
638
|
+
'with(obj||{}){p.push(\'' +
|
639
|
+
str.replace(/\r/g, '\\r')
|
640
|
+
.replace(/\n/g, '\\n')
|
641
|
+
.replace(/\t/g, '\\t')
|
642
|
+
.replace(endMatch,"���")
|
643
|
+
.split("'").join("\\'")
|
644
|
+
.split("���").join("'")
|
645
|
+
.replace(c.interpolate, "',$1,'")
|
646
|
+
.split(c.start).join("');")
|
647
|
+
.split(c.end).join("p.push('") +
|
648
|
+
"');}return p.join('');"
|
649
|
+
if data then fn(data) else fn
|
650
|
+
|
651
|
+
|
652
|
+
# Aliases
|
653
|
+
# -------
|
654
|
+
|
655
|
+
_.forEach = _.each
|
656
|
+
_.foldl = _.inject = _.reduce
|
657
|
+
_.foldr = _.reduceRight
|
658
|
+
_.select = _.filter
|
659
|
+
_.all = _.every
|
660
|
+
_.any = _.some
|
661
|
+
_.contains = _.include
|
662
|
+
_.head = _.first
|
663
|
+
_.tail = _.rest
|
664
|
+
_.methods = _.functions
|
665
|
+
|
666
|
+
|
667
|
+
# Setup the OOP Wrapper
|
668
|
+
# ---------------------
|
669
|
+
|
670
|
+
# If Underscore is called as a function, it returns a wrapped object that
|
671
|
+
# can be used OO-style. This wrapper holds altered versions of all the
|
672
|
+
# underscore functions. Wrapped objects may be chained.
|
673
|
+
wrapper = (obj) ->
|
674
|
+
this._wrapped = obj
|
675
|
+
this
|
676
|
+
|
677
|
+
|
678
|
+
# Helper function to continue chaining intermediate results.
|
679
|
+
result = (obj, chain) ->
|
680
|
+
if chain then _(obj).chain() else obj
|
681
|
+
|
682
|
+
|
683
|
+
# A method to easily add functions to the OOP wrapper.
|
684
|
+
addToWrapper = (name, func) ->
|
685
|
+
wrapper.prototype[name] = ->
|
686
|
+
args = _.toArray arguments
|
687
|
+
unshift.call args, this._wrapped
|
688
|
+
result func.apply(_, args), this._chain
|
689
|
+
|
690
|
+
|
691
|
+
# Add all ofthe Underscore functions to the wrapper object.
|
692
|
+
_.mixin _
|
693
|
+
|
694
|
+
|
695
|
+
# Add all mutator Array functions to the wrapper.
|
696
|
+
_.each ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], (name) ->
|
697
|
+
method = Array.prototype[name]
|
698
|
+
wrapper.prototype[name] = ->
|
699
|
+
method.apply(this._wrapped, arguments)
|
700
|
+
result(this._wrapped, this._chain)
|
701
|
+
|
702
|
+
|
703
|
+
# Add all accessor Array functions to the wrapper.
|
704
|
+
_.each ['concat', 'join', 'slice'], (name) ->
|
705
|
+
method = Array.prototype[name]
|
706
|
+
wrapper.prototype[name] = ->
|
707
|
+
result(method.apply(this._wrapped, arguments), this._chain)
|
708
|
+
|
709
|
+
|
710
|
+
# Start chaining a wrapped Underscore object.
|
711
|
+
wrapper::chain = ->
|
712
|
+
this._chain = true
|
713
|
+
this
|
714
|
+
|
715
|
+
|
716
|
+
# Extracts the result from a wrapped and chained object.
|
717
|
+
wrapper::value = -> this._wrapped
|
718
|
+
</textarea></form>
|
719
|
+
<script>
|
720
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
721
|
+
</script>
|
722
|
+
|
723
|
+
<p><strong>MIME types defined:</strong> <code>text/x-coffeescript</code>.</p>
|
724
|
+
|
725
|
+
<p>The CoffeeScript mode was written by Jeff Pickhardt (<a href="LICENSE">license</a>).</p>
|
726
|
+
|
727
|
+
</body>
|
728
|
+
</html>
|