├── .gitattributes
├── .gitignore
├── Bridge
└── CRBridge.go
├── Judge
├── Compile.go
├── CompileRunManager.go
├── Listener.go
├── Run.go
└── lxcmain.go
├── LICENSE.md
├── README.md
├── conf
├── app.conf
└── db.sql
├── controllers
├── Admin.go
├── BaseController.go
├── ContestController.go
├── ProblemController.go
└── UserController.go
├── firstSetup.bash
├── lxcSetup.bash
├── lxcWebPanel.bash
├── main.go
├── models
├── ContestScore.go
├── Exec.go
├── Models.go
├── Problem.go
├── ProblemLogs.go
├── Score.go
├── TestCases.go
├── User.go
├── Verify.go
└── contest.go
├── restart.bash
├── routers
└── router.go
├── startJudge.bash
├── static
├── CodeMirror
│ ├── addon
│ │ ├── comment
│ │ │ ├── comment.js
│ │ │ └── continuecomment.js
│ │ ├── dialog
│ │ │ ├── dialog.css
│ │ │ └── dialog.js
│ │ ├── display
│ │ │ ├── fullscreen.css
│ │ │ ├── fullscreen.js
│ │ │ ├── panel.js
│ │ │ ├── placeholder.js
│ │ │ └── rulers.js
│ │ ├── edit
│ │ │ ├── closebrackets.js
│ │ │ ├── closetag.js
│ │ │ ├── continuelist.js
│ │ │ ├── matchbrackets.js
│ │ │ ├── matchtags.js
│ │ │ └── trailingspace.js
│ │ ├── fold
│ │ │ ├── brace-fold.js
│ │ │ ├── comment-fold.js
│ │ │ ├── foldcode.js
│ │ │ ├── foldgutter.css
│ │ │ ├── foldgutter.js
│ │ │ ├── indent-fold.js
│ │ │ ├── markdown-fold.js
│ │ │ └── xml-fold.js
│ │ ├── hint
│ │ │ ├── anyword-hint.js
│ │ │ ├── css-hint.js
│ │ │ ├── html-hint.js
│ │ │ ├── javascript-hint.js
│ │ │ ├── show-hint.css
│ │ │ ├── show-hint.js
│ │ │ ├── sql-hint.js
│ │ │ └── xml-hint.js
│ │ ├── lint
│ │ │ ├── coffeescript-lint.js
│ │ │ ├── css-lint.js
│ │ │ ├── javascript-lint.js
│ │ │ ├── json-lint.js
│ │ │ ├── lint.css
│ │ │ ├── lint.js
│ │ │ └── yaml-lint.js
│ │ ├── merge
│ │ │ ├── merge.css
│ │ │ └── merge.js
│ │ ├── mode
│ │ │ ├── loadmode.js
│ │ │ ├── multiplex.js
│ │ │ ├── multiplex_test.js
│ │ │ ├── overlay.js
│ │ │ └── simple.js
│ │ ├── runmode
│ │ │ ├── colorize.js
│ │ │ ├── runmode-standalone.js
│ │ │ ├── runmode.js
│ │ │ └── runmode.node.js
│ │ ├── scroll
│ │ │ ├── annotatescrollbar.js
│ │ │ ├── scrollpastend.js
│ │ │ ├── simplescrollbars.css
│ │ │ └── simplescrollbars.js
│ │ ├── search
│ │ │ ├── match-highlighter.js
│ │ │ ├── matchesonscrollbar.css
│ │ │ ├── matchesonscrollbar.js
│ │ │ ├── search.js
│ │ │ └── searchcursor.js
│ │ ├── selection
│ │ │ ├── active-line.js
│ │ │ ├── mark-selection.js
│ │ │ └── selection-pointer.js
│ │ ├── tern
│ │ │ ├── tern.css
│ │ │ ├── tern.js
│ │ │ └── worker.js
│ │ └── wrap
│ │ │ └── hardwrap.js
│ ├── doc
│ │ ├── activebookmark.js
│ │ ├── compress.html
│ │ ├── docs.css
│ │ ├── internals.html
│ │ ├── logo.png
│ │ ├── logo.svg
│ │ ├── manual.html
│ │ ├── realworld.html
│ │ ├── releases.html
│ │ ├── reporting.html
│ │ ├── upgrade_v2.2.html
│ │ ├── upgrade_v3.html
│ │ ├── upgrade_v4.html
│ │ └── yinyang.png
│ ├── keymap
│ │ ├── emacs.js
│ │ ├── sublime.js
│ │ └── vim.js
│ ├── lib
│ │ ├── codemirror.css
│ │ └── codemirror.js
│ ├── mode
│ │ ├── apl
│ │ │ ├── apl.js
│ │ │ └── index.html
│ │ ├── asciiarmor
│ │ │ ├── asciiarmor.js
│ │ │ └── index.html
│ │ ├── asn.1
│ │ │ ├── asn.1.js
│ │ │ └── index.html
│ │ ├── asterisk
│ │ │ ├── asterisk.js
│ │ │ └── index.html
│ │ ├── brainfuck
│ │ │ ├── brainfuck.js
│ │ │ └── index.html
│ │ ├── clike
│ │ │ ├── clike.js
│ │ │ ├── index.html
│ │ │ ├── scala.html
│ │ │ └── test.js
│ │ ├── clojure
│ │ │ ├── clojure.js
│ │ │ └── index.html
│ │ ├── cmake
│ │ │ ├── cmake.js
│ │ │ └── index.html
│ │ ├── cobol
│ │ │ ├── cobol.js
│ │ │ └── index.html
│ │ ├── coffeescript
│ │ │ ├── coffeescript.js
│ │ │ └── index.html
│ │ ├── commonlisp
│ │ │ ├── commonlisp.js
│ │ │ └── index.html
│ │ ├── css
│ │ │ ├── css.js
│ │ │ ├── index.html
│ │ │ ├── less.html
│ │ │ ├── less_test.js
│ │ │ ├── scss.html
│ │ │ ├── scss_test.js
│ │ │ └── test.js
│ │ ├── cypher
│ │ │ ├── cypher.js
│ │ │ └── index.html
│ │ ├── d
│ │ │ ├── d.js
│ │ │ └── index.html
│ │ ├── dart
│ │ │ ├── dart.js
│ │ │ └── index.html
│ │ ├── diff
│ │ │ ├── diff.js
│ │ │ └── index.html
│ │ ├── django
│ │ │ ├── django.js
│ │ │ └── index.html
│ │ ├── dockerfile
│ │ │ ├── dockerfile.js
│ │ │ └── index.html
│ │ ├── dtd
│ │ │ ├── dtd.js
│ │ │ └── index.html
│ │ ├── dylan
│ │ │ ├── dylan.js
│ │ │ └── index.html
│ │ ├── ebnf
│ │ │ ├── ebnf.js
│ │ │ └── index.html
│ │ ├── ecl
│ │ │ ├── ecl.js
│ │ │ └── index.html
│ │ ├── eiffel
│ │ │ ├── eiffel.js
│ │ │ └── index.html
│ │ ├── elm
│ │ │ ├── elm.js
│ │ │ └── index.html
│ │ ├── erlang
│ │ │ ├── erlang.js
│ │ │ └── index.html
│ │ ├── factor
│ │ │ ├── factor.js
│ │ │ └── index.html
│ │ ├── forth
│ │ │ ├── forth.js
│ │ │ └── index.html
│ │ ├── fortran
│ │ │ ├── fortran.js
│ │ │ └── index.html
│ │ ├── gas
│ │ │ ├── gas.js
│ │ │ └── index.html
│ │ ├── gfm
│ │ │ ├── gfm.js
│ │ │ ├── index.html
│ │ │ └── test.js
│ │ ├── gherkin
│ │ │ ├── gherkin.js
│ │ │ └── index.html
│ │ ├── go
│ │ │ ├── go.js
│ │ │ └── index.html
│ │ ├── groovy
│ │ │ ├── groovy.js
│ │ │ └── index.html
│ │ ├── haml
│ │ │ ├── haml.js
│ │ │ ├── index.html
│ │ │ └── test.js
│ │ ├── handlebars
│ │ │ ├── handlebars.js
│ │ │ └── index.html
│ │ ├── haskell
│ │ │ ├── haskell.js
│ │ │ └── index.html
│ │ ├── haxe
│ │ │ ├── haxe.js
│ │ │ └── index.html
│ │ ├── htmlembedded
│ │ │ ├── htmlembedded.js
│ │ │ └── index.html
│ │ ├── htmlmixed
│ │ │ ├── htmlmixed.js
│ │ │ └── index.html
│ │ ├── http
│ │ │ ├── http.js
│ │ │ └── index.html
│ │ ├── idl
│ │ │ ├── idl.js
│ │ │ └── index.html
│ │ ├── index.html
│ │ ├── jade
│ │ │ ├── index.html
│ │ │ └── jade.js
│ │ ├── javascript
│ │ │ ├── index.html
│ │ │ ├── javascript.js
│ │ │ ├── json-ld.html
│ │ │ ├── test.js
│ │ │ └── typescript.html
│ │ ├── jinja2
│ │ │ ├── index.html
│ │ │ └── jinja2.js
│ │ ├── julia
│ │ │ ├── index.html
│ │ │ └── julia.js
│ │ ├── kotlin
│ │ │ ├── index.html
│ │ │ └── kotlin.js
│ │ ├── livescript
│ │ │ ├── index.html
│ │ │ └── livescript.js
│ │ ├── lua
│ │ │ ├── index.html
│ │ │ └── lua.js
│ │ ├── markdown
│ │ │ ├── index.html
│ │ │ ├── markdown.js
│ │ │ └── test.js
│ │ ├── mathematica
│ │ │ ├── index.html
│ │ │ └── mathematica.js
│ │ ├── meta.js
│ │ ├── mirc
│ │ │ ├── index.html
│ │ │ └── mirc.js
│ │ ├── mllike
│ │ │ ├── index.html
│ │ │ └── mllike.js
│ │ ├── modelica
│ │ │ ├── index.html
│ │ │ └── modelica.js
│ │ ├── mumps
│ │ │ ├── index.html
│ │ │ └── mumps.js
│ │ ├── nginx
│ │ │ ├── index.html
│ │ │ └── nginx.js
│ │ ├── ntriples
│ │ │ ├── index.html
│ │ │ └── ntriples.js
│ │ ├── octave
│ │ │ ├── index.html
│ │ │ └── octave.js
│ │ ├── pascal
│ │ │ ├── index.html
│ │ │ └── pascal.js
│ │ ├── pegjs
│ │ │ ├── index.html
│ │ │ └── pegjs.js
│ │ ├── perl
│ │ │ ├── index.html
│ │ │ └── perl.js
│ │ ├── php
│ │ │ ├── index.html
│ │ │ ├── php.js
│ │ │ └── test.js
│ │ ├── pig
│ │ │ ├── index.html
│ │ │ └── pig.js
│ │ ├── properties
│ │ │ ├── index.html
│ │ │ └── properties.js
│ │ ├── puppet
│ │ │ ├── index.html
│ │ │ └── puppet.js
│ │ ├── python
│ │ │ ├── index.html
│ │ │ └── python.js
│ │ ├── q
│ │ │ ├── index.html
│ │ │ └── q.js
│ │ ├── r
│ │ │ ├── index.html
│ │ │ └── r.js
│ │ ├── rpm
│ │ │ ├── changes
│ │ │ │ └── index.html
│ │ │ ├── index.html
│ │ │ └── rpm.js
│ │ ├── rst
│ │ │ ├── index.html
│ │ │ └── rst.js
│ │ ├── ruby
│ │ │ ├── index.html
│ │ │ ├── ruby.js
│ │ │ └── test.js
│ │ ├── rust
│ │ │ ├── index.html
│ │ │ └── rust.js
│ │ ├── sass
│ │ │ ├── index.html
│ │ │ └── sass.js
│ │ ├── scheme
│ │ │ ├── index.html
│ │ │ └── scheme.js
│ │ ├── shell
│ │ │ ├── index.html
│ │ │ ├── shell.js
│ │ │ └── test.js
│ │ ├── sieve
│ │ │ ├── index.html
│ │ │ └── sieve.js
│ │ ├── slim
│ │ │ ├── index.html
│ │ │ ├── slim.js
│ │ │ └── test.js
│ │ ├── smalltalk
│ │ │ ├── index.html
│ │ │ └── smalltalk.js
│ │ ├── smarty
│ │ │ ├── index.html
│ │ │ └── smarty.js
│ │ ├── solr
│ │ │ ├── index.html
│ │ │ └── solr.js
│ │ ├── soy
│ │ │ ├── index.html
│ │ │ └── soy.js
│ │ ├── sparql
│ │ │ ├── index.html
│ │ │ └── sparql.js
│ │ ├── spreadsheet
│ │ │ ├── index.html
│ │ │ └── spreadsheet.js
│ │ ├── sql
│ │ │ ├── index.html
│ │ │ └── sql.js
│ │ ├── stex
│ │ │ ├── index.html
│ │ │ ├── stex.js
│ │ │ └── test.js
│ │ ├── stylus
│ │ │ ├── index.html
│ │ │ └── stylus.js
│ │ ├── swift
│ │ │ ├── index.html
│ │ │ └── swift.js
│ │ ├── tcl
│ │ │ ├── index.html
│ │ │ └── tcl.js
│ │ ├── textile
│ │ │ ├── index.html
│ │ │ ├── test.js
│ │ │ └── textile.js
│ │ ├── tiddlywiki
│ │ │ ├── index.html
│ │ │ ├── tiddlywiki.css
│ │ │ └── tiddlywiki.js
│ │ ├── tiki
│ │ │ ├── index.html
│ │ │ ├── tiki.css
│ │ │ └── tiki.js
│ │ ├── toml
│ │ │ ├── index.html
│ │ │ └── toml.js
│ │ ├── tornado
│ │ │ ├── index.html
│ │ │ └── tornado.js
│ │ ├── troff
│ │ │ ├── index.html
│ │ │ └── troff.js
│ │ ├── ttcn-cfg
│ │ │ ├── index.html
│ │ │ └── ttcn-cfg.js
│ │ ├── ttcn
│ │ │ ├── index.html
│ │ │ └── ttcn.js
│ │ ├── turtle
│ │ │ ├── index.html
│ │ │ └── turtle.js
│ │ ├── twig
│ │ │ ├── index.html
│ │ │ └── twig.js
│ │ ├── vb
│ │ │ ├── index.html
│ │ │ └── vb.js
│ │ ├── vbscript
│ │ │ ├── index.html
│ │ │ └── vbscript.js
│ │ ├── velocity
│ │ │ ├── index.html
│ │ │ └── velocity.js
│ │ ├── verilog
│ │ │ ├── index.html
│ │ │ ├── test.js
│ │ │ └── verilog.js
│ │ ├── vhdl
│ │ │ ├── index.html
│ │ │ └── vhdl.js
│ │ ├── xml
│ │ │ ├── index.html
│ │ │ ├── test.js
│ │ │ └── xml.js
│ │ ├── xquery
│ │ │ ├── index.html
│ │ │ ├── test.js
│ │ │ └── xquery.js
│ │ ├── yaml
│ │ │ ├── index.html
│ │ │ └── yaml.js
│ │ └── z80
│ │ │ ├── index.html
│ │ │ └── z80.js
│ └── theme
│ │ ├── 3024-day.css
│ │ ├── 3024-night.css
│ │ ├── ambiance-mobile.css
│ │ ├── ambiance.css
│ │ ├── base16-dark.css
│ │ ├── base16-light.css
│ │ ├── blackboard.css
│ │ ├── cobalt.css
│ │ ├── colorforth.css
│ │ ├── dracula.css
│ │ ├── eclipse.css
│ │ ├── elegant.css
│ │ ├── erlang-dark.css
│ │ ├── icecoder.css
│ │ ├── lesser-dark.css
│ │ ├── liquibyte.css
│ │ ├── material.css
│ │ ├── mbo.css
│ │ ├── mdn-like.css
│ │ ├── midnight.css
│ │ ├── monokai.css
│ │ ├── neat.css
│ │ ├── neo.css
│ │ ├── night.css
│ │ ├── paraiso-dark.css
│ │ ├── paraiso-light.css
│ │ ├── pastel-on-dark.css
│ │ ├── rubyblue.css
│ │ ├── seti.css
│ │ ├── solarized.css
│ │ ├── the-matrix.css
│ │ ├── tomorrow-night-bright.css
│ │ ├── tomorrow-night-eighties.css
│ │ ├── ttcn.css
│ │ ├── twilight.css
│ │ ├── vibrant-ink.css
│ │ ├── xq-dark.css
│ │ ├── xq-light.css
│ │ ├── yeti.css
│ │ └── zenburn.css
├── css
│ ├── 960.css
│ ├── reset.css
│ └── styles.css
├── index.html
└── js
│ ├── jquery-2.1.4.min.js
│ ├── js.cookie.js
│ └── script.js
├── tests
└── default_test.go
└── views
├── errorHead.tpl
├── layout.tpl
├── login.html
├── problem
├── addtest.tpl
├── create.tpl
├── list.tpl
├── show.tpl
└── submit_head.tpl
├── sidebar
├── recently_solved_by.tpl
└── showcategories.tpl
├── testExec.html
└── user
├── login.tpl
└── show.tpl
/.gitattributes:
--------------------------------------------------------------------------------
1 | static/* linguist-vendored
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | tests
2 | OnlineJudge
3 |
--------------------------------------------------------------------------------
/Judge/Listener.go:
--------------------------------------------------------------------------------
1 | package Judge
2 |
3 | import (
4 | "encoding/json"
5 | "io/ioutil"
6 | "log"
7 | "os"
8 | "strconv"
9 | "time"
10 | )
11 |
12 | const (
13 | directories = 10
14 | prefix = "d"
15 | requestName = "problem.json"
16 | solutionName = "solution.json"
17 | ProgramFileName = "code"
18 | )
19 |
20 | func DirectoryListener(dir string) {
21 | i := true
22 | _, _ = os.Create(dir + "file")
23 | for i == true {
24 | if file, _ := os.OpenFile(dir+requestName, os.O_RDWR, 0777); file != nil {
25 | file.Close()
26 | bytes, _ := ioutil.ReadFile(dir + requestName)
27 | cr := CRManager{}
28 | json.Unmarshal(bytes, &cr)
29 | cr.Program.name = ProgramFileName
30 | cr.Program.path = dir
31 | cr.CR()
32 | solutionBytes, _ := json.Marshal(&cr)
33 | ioutil.WriteFile(dir+solutionName, solutionBytes, 0755)
34 | os.Remove(dir + requestName)
35 | }
36 | time.Sleep(time.Second)
37 | }
38 | }
39 |
40 | func init() {
41 | log.Println("Judge: Successful")
42 | for i := 1; i <= directories; i++ {
43 | dir := prefix + strconv.Itoa(i) + "/"
44 | go DirectoryListener(dir)
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Judge/lxcmain.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | _ "Judge"
5 | "time"
6 | )
7 |
8 | func main() {
9 | time.Sleep(time.Hour * 10000)
10 | }
11 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Ronak Jain
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OnlineJudge (Deprecated)
2 | Judge built using Golang for hosting competetive programming contests and problems. Real time compilation and execution
3 | of programs against testcases. Safe compilation and execution of the user program carried out in Linux containers
4 | protecting host against malicious code. Languages supported are
5 | * C++
6 | * C
7 | * Python (3.4 & 2.7)
8 | * Java
9 | * Golang (1.4)
10 | (Check serverLxc branch)
11 |
12 | ## Requirements
13 | * GoLang (1.4 or higher)
14 | * mysql
15 |
16 | ## Installation
17 | ```
18 | go get -u github.com/JRonak/OnlineJudge
19 | ```
20 | Run the firstsetup.bash to setup Linux containers
21 | In the project directory
22 | ```
23 | bee run
24 | ```
25 | Make sure $GOPATH and git are added to env. Also setup dependencies
26 |
27 | ## Dependancy
28 | * Beego Framework
29 | ```
30 | go get github.com/astaxie/beego
31 | ```
32 | * Bcrypt
33 | ```
34 | golang.org/x/crypto/bcrypt
35 | ```
36 | * Go-Sql-Driver
37 | ```
38 | go get github.com/go-sql-driver/mysql
39 | ```
40 |
--------------------------------------------------------------------------------
/conf/app.conf:
--------------------------------------------------------------------------------
1 | appname = OnlineJudge
2 | httpport = 8080
3 | runmode = dev
4 | copyrequestbody = true
--------------------------------------------------------------------------------
/controllers/Admin.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "OnlineJudge/models"
5 | "encoding/json"
6 | "strconv"
7 | )
8 |
9 | type AdminController struct {
10 | BaseController
11 | }
12 |
13 | func (this *AdminController) isAdmin() bool {
14 | if !this.isLoggedIn() {
15 | this.Redirect("/user/login", 302)
16 | return false
17 | }
18 | name := this.GetSession("Uid")
19 | if name.(string) != "admin" {
20 | this.Redirect("/", 302)
21 | return false
22 | }
23 | return true
24 | }
25 |
26 | func (this *AdminController) isLoggedIn() bool {
27 | if this.GetSession("id") != nil {
28 | return true
29 | }
30 | return false
31 | }
32 |
33 | func (this *AdminController) ShowEditors() {
34 | if !this.isAdmin() {
35 | return
36 | }
37 | user := models.User{}
38 | users := user.GetEditors()
39 | bytes, _ := json.Marshal(users)
40 | this.Data["json"] = string(bytes)
41 | this.ServeJson()
42 | }
43 |
44 | // /admin/makeEditor/:uid
45 | func (this *AdminController) MakeEditor() {
46 | if !this.isAdmin() {
47 | return
48 | }
49 | uid := this.Ctx.Input.Param("uid")
50 | user := models.User{}
51 | id, _ := strconv.Atoi(uid)
52 | user.Uid = id
53 | status := user.MakeEditor()
54 | this.Data["status"] = status
55 | }
56 |
57 | // /admin/revokeEditor/:uid
58 | func (this *AdminController) RevokeEditor() {
59 | if !this.isAdmin() {
60 | return
61 | }
62 | uid := this.Ctx.Input.Param("uid")
63 | user := models.User{}
64 | id, _ := strconv.Atoi(uid)
65 | user.Uid = id
66 | status := user.RevokeEditor()
67 | this.Data["status"] = status
68 | }
69 |
70 | // /admin/search/name/:name
71 | func (this *AdminController) SearchName() {
72 | if !this.isAdmin() {
73 | return
74 | }
75 | name := this.Ctx.Input.Param(":name")
76 | user := models.User{}
77 | user.Name = name
78 | users, _ := user.SearchByName()
79 | bytes, _ := json.Marshal(users)
80 | this.Data["json"] = string(bytes)
81 | this.ServeJson()
82 | }
83 |
84 | // /admin/search/name/:uid
85 | func (this *AdminController) DeleteUser() {
86 | if !this.isAdmin() {
87 | return
88 | }
89 |
90 | uid := this.Ctx.Input.Param("uid")
91 | user := models.User{}
92 | id, _ := strconv.Atoi(uid)
93 | user.Uid = id
94 | status := user.Delete()
95 | this.Data["status"] = status
96 | }
97 |
--------------------------------------------------------------------------------
/controllers/BaseController.go:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import (
4 | "github.com/astaxie/beego"
5 | "OnlineJudge/models"
6 | )
7 |
8 | type BaseController struct {
9 | beego.Controller
10 | }
11 |
12 | func (this *BaseController) Prepare() {
13 | uname := this.GetSession("Uid")
14 | uid := this.GetSession("id")
15 |
16 | this.Data["logged"] = false
17 | if uname != nil {
18 | user := models.User{ Uid: uid.(int), Username: uname.(string) }
19 | _ = user.GetUserInfo()
20 | this.Data["isEditor"] = false
21 | if user.IsEditor() {
22 | this.Data["isEditor"] = true
23 | }
24 | this.Data["user"] = user
25 | this.Data["login"] = uname.(string)
26 | this.Data["logged"] = true
27 | }
28 | }
--------------------------------------------------------------------------------
/firstSetup.bash:
--------------------------------------------------------------------------------
1 |
2 | if [ "$EUID" -ne 0 ]
3 | then echo "Please run as root"
4 | exit 1
5 | fi
6 | apt-get install gcc
7 | if [ "$?" -ne 0 ]
8 | then echo "Gcc installation failed"
9 | exit 1
10 | fi
11 | apt-get install g++
12 | if [ "$?" -ne 0 ]
13 | then echo "G++ installation failed"
14 | exit 1
15 | fi
16 | apt-get install python
17 | if [ "$?" -ne 0 ]
18 | then echo "Python2 installation failed"
19 | exit 1
20 | fi
21 | apt-get install python3
22 | if [ "$?" -ne 0 ]
23 | then echo "Python3 installation failed"
24 | exit 1
25 | fi
26 | apt-get install wget
27 | wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
28 | tar -C /usr/local -xzf go*.tar.gz
29 | rm go*.tar.gz
30 | apt-get install openjdk-6-jdk
31 | if [ "$?" -ne 0 ]
32 | then echo "Python3 installation failed"
33 | exit 1
34 | fi
35 | i=1
36 | while [ $i -lt 11 ]
37 | do
38 | mkdir d$i
39 | chmod a+rwx d$i
40 | touch d$i/GoBackhomeKid
41 | chattr +i d$i/GoBackhomeKid
42 | ((i=i+1))
43 | done
44 | mkdir -p go/src/Judge
45 | chmod o-r go
46 | export PATH=$PATH:/usr/local/go/bin
47 | export GOPATH=/home/ubuntu/go
48 | cp -R Judge firstSetup.bash *.bash go/src
49 | rm *
50 | rm -r Judge
51 | cd go/src/Judge
52 | cp lxc* ../
53 | rm lxc**
54 | go build
55 | cd ..
56 | go build lxcmain.go
57 | cp lxcmain /home/ubuntu
58 | cp startJudge.bash /home/ubuntu
59 | cd /home/ubuntu
60 | chmod o+rw lxcmain startJudge.bash
61 | echo "Go to localhost:5000 Setup the constraints for the container
62 | Then run the startJudge.bash as user
63 | "
--------------------------------------------------------------------------------
/lxcSetup.bash:
--------------------------------------------------------------------------------
1 | #!bin/bash
2 | container=judge1
3 | if [ "$EUID" -ne 0 ]
4 | then echo "Please run as root"
5 | exit 1
6 | fi
7 | apt-get install lxc-dev
8 | if [ "$?" -ne 0 ]
9 | then echo "*******Lxc package installation failed*********"
10 | exit 1
11 | fi
12 | echo "*********Installing primary container, please be patient***********"
13 | lxc-create -t ubuntu -n $container
14 | chmod a+rwx /var/lib/lxc/$container
15 | chmod a+rwx /var/lib/lxc/$container/rootfs
16 | chmod a+rxw /var/lib/lxc/$container/rootfs/home/ubuntu/
17 | cp -R Judge /var/lib/lxc/$container/rootfs/home/ubuntu/
18 | cp firstSetup.bash startJudge.bash restart.bash .lxcmain.go /var/lib/lxc/$container/rootfs/home/ubuntu/
19 | echo "********Open another terminal, run the following command******
20 | *lxc-start -n $container
21 | *lxc-console -n $container
22 | *Username:ubuntu
23 | *Password:ubuntu
24 | *Recommended to change the default Password
25 | *Setup root Password
26 | *As root run script firstSetup.bash*********"
27 | exit 0
28 |
--------------------------------------------------------------------------------
/lxcWebPanel.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | sudo apt-get install lxc debootstrap bridge-utils -y
3 | sudo su
4 | wget http://lxc-webpanel.github.com/tools/install.sh -O - | bash
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | _ "OnlineJudge/routers"
5 | "github.com/astaxie/beego"
6 | "strings"
7 | )
8 |
9 | func main() {
10 | beego.SessionOn = true
11 | beego.SessionName = "OnlineJudge"
12 | beego.SessionProvider = "OnlineJudge"
13 | beego.SessionCookieLifeTime = 0
14 | beego.SessionProvider = "file"
15 | beego.SessionSavePath = "./tmp"
16 |
17 | beego.AddFuncMap("n2br", n2br)
18 | beego.Run()
19 | }
20 |
21 | func n2br(str string) string {
22 | return strings.Replace(str,"\n"," ",-1)
23 | }
24 |
--------------------------------------------------------------------------------
/models/ContestScore.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "github.com/astaxie/beego/orm"
5 | )
6 |
7 | func (score *Contestlogs) Add() bool {
8 | o := orm.NewOrm()
9 | o.Using("default")
10 | _, err := o.Insert(score)
11 | if err != nil {
12 | return false
13 | }
14 | return true
15 | }
16 |
17 | func (score *Contestlogs) GetByUidCid() bool {
18 | o := orm.NewOrm()
19 | o.Using("default")
20 | err := o.QueryTable("contestlogs").Filter("uid", score.Uid).Filter("cid", score.Cid).One(score)
21 | if err != nil {
22 | return false
23 | }
24 | return true
25 | }
26 |
27 | func (score *Contestlogs) Update() bool {
28 | o := orm.NewOrm()
29 | o.Using("default")
30 | _, err := o.Update(score)
31 | if err != nil {
32 | return false
33 | }
34 | return true
35 | }
36 |
37 | func (score *Contestlogs) GetByCid() (*[]Contestlogs, bool) {
38 | logs := new([]Contestlogs)
39 | o := orm.NewOrm()
40 | o.Using("default")
41 | _, err := o.QueryTable("contestlogs").Filter("cid", score.Cid).OrderBy("-points").All(logs)
42 | if err != nil {
43 | return nil, false
44 | }
45 | return logs, true
46 | }
47 |
--------------------------------------------------------------------------------
/models/Exec.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "OnlineJudge/Bridge"
5 | )
6 |
7 | // Just run code used here. if stdin is nil, then sample input is used
8 | func Exec(pid int, rawCode string, lang string, stdin string) Bridge.Code {
9 | code := Bridge.Code{Lang: lang, Stdin: stdin}
10 | cr := Bridge.CRManager{Program: &code, RawCode: &rawCode}
11 | if stdin == "" {
12 | problem := new(Problem)
13 | problem.Pid = pid
14 | if err := problem.GetSampleIOByPid(); err != true {
15 | return Bridge.Code{}
16 | }
17 | code.Stdin = problem.Sample_input
18 | Bridge.CompileExec(&cr)
19 | if code.Stdout != problem.Sample_output {
20 | code.RunStatus = false
21 | }
22 | } else {
23 | Bridge.CompileExec(&cr)
24 | }
25 | return code
26 | }
27 |
28 | func ExecBatch(pid int, rawcode string, lang string) []Bridge.TestCaseStatus {
29 | testcase := Testcases{}
30 | testcase.Pid = pid
31 | testcases, count := testcase.GetAllByPid()
32 | j := Bridge.TestCaseStatus{}
33 | j.Comment = "Internal Error"
34 | j.Success = false
35 | if count == 0 {
36 | return []Bridge.TestCaseStatus{j}
37 | }
38 | code := Bridge.Code{}
39 | code.Lang = lang
40 | cr := Bridge.CRManager{}
41 | cr.RawCode = &rawcode
42 | cr.Program = &code
43 | cr.Isbatch = true
44 | testInput := make([]string, count)
45 | testOutput := make([]string, count)
46 | for i, test := range testcases {
47 | testInput[i] = test.Input
48 | testOutput[i] = test.Output
49 |
50 | }
51 | cr.TestInput = testInput
52 | cr.TestOutput = testOutput
53 | Bridge.CompileExec(&cr)
54 | return cr.TestCaseOutput
55 | }
56 |
--------------------------------------------------------------------------------
/models/Models.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "github.com/astaxie/beego/orm"
5 | _ "github.com/go-sql-driver/mysql"
6 | "time"
7 | )
8 |
9 | type User struct {
10 | Uid int `orm:"pk"`
11 | Username string
12 | Password string `json:"-"`
13 | Name string
14 | College string
15 | Email string
16 | Score int
17 | Rank int
18 | Is_editor int `json:"-"`
19 | }
20 |
21 | type Problem struct {
22 | Pid int `orm:"pk"`
23 | Uid int
24 | Statement string
25 | Description string
26 | Constraints string
27 | Sample_input string
28 | Sample_output string
29 | Solution_description string `json:"-"`
30 | Solution_code string `json:"-"`
31 | Type string
32 | Difficulty string
33 | Created_at time.Time `orm:"auto_now_add;type(datetime)"`
34 | Points int
35 | Solve_count int
36 | }
37 |
38 | type Testcases struct {
39 | Id int `orm:"pk"`
40 | Pid int
41 | Tid int
42 | Input string
43 | Output string
44 | Timeout int
45 | }
46 |
47 | type Problemlogs struct {
48 | Id int `orm:"pk"`
49 | Pid int
50 | Uid int
51 | Solved int
52 | Points int
53 | Time time.Time `orm:"auto_now_add;type(datetime)"`
54 | }
55 |
56 | type Contest struct {
57 | Id int `orm:"pk"`
58 | Name string
59 | Description string
60 | StartTime time.Time
61 | EndTime time.Time
62 | }
63 |
64 | type Contestlogs struct {
65 | Id int `orm:"pk"`
66 | Uid int
67 | Cid int
68 | Points int
69 | Time time.Time `orm:"auto_now_add;type(datetime)"`
70 | }
71 |
72 | func init() {
73 | orm.RegisterDriver("mysql", orm.DR_MySQL)
74 | orm.RegisterDataBase("default", "mysql", "ronak:ronak@/OnlineJudge")
75 | orm.RegisterModel(new(User))
76 | orm.RegisterModel(new(Problem))
77 | orm.RegisterModel(new(Problemlogs))
78 | orm.RegisterModel(new(Testcases))
79 | orm.RegisterModel(new(Contest))
80 | orm.RegisterModel(new(Contestlogs))
81 | }
82 |
--------------------------------------------------------------------------------
/models/ProblemLogs.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "github.com/astaxie/beego/orm"
5 | )
6 |
7 | func (log *Problemlogs) CommitByPidUid() bool {
8 | o := orm.NewOrm()
9 | o.Using("default")
10 | _, er := o.Insert(log)
11 | if er == nil {
12 | return true
13 | }
14 | return false
15 | }
16 |
17 | func (log *Problemlogs) Update() bool {
18 | o := orm.NewOrm()
19 | o.Using("default")
20 | _, err := o.Update(log)
21 | if err == nil {
22 | return true
23 | }
24 | return false
25 | }
26 |
27 | func (log *Problemlogs) GetByPidUid() bool {
28 | o := orm.NewOrm()
29 | o.Using("default")
30 | err := o.Read(log, "Pid", "Uid")
31 | if err == nil {
32 | return true
33 | }
34 | return false
35 | }
36 |
37 | func (log *Problemlogs) GetByUid() ([]Problemlogs, int64) {
38 | var logs []Problemlogs
39 | o := orm.NewOrm()
40 | o.Using("default")
41 | count, err := o.QueryTable("problemlogs").OrderBy("-Time").Filter("uid", log.Uid).All(&logs)
42 | if err == nil {
43 | return logs, count
44 | }
45 | return nil, count
46 | }
47 |
48 | func (log *Problemlogs) GetRecentByPid() ([]Problemlogs, int64) {
49 | var logs []Problemlogs
50 | o := orm.NewOrm()
51 | o.Using("default")
52 | count, err := o.QueryTable("problemlogs").OrderBy("-Time").Filter("pid", log.Pid).All(&logs)
53 | if err == nil {
54 | return logs, count
55 | }
56 | return nil, count
57 | }
58 |
--------------------------------------------------------------------------------
/models/Score.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "OnlineJudge/Bridge"
5 | "time"
6 | )
7 |
8 | type SubmitResponse struct {
9 | Score int
10 | Status []Bridge.TestCaseStatus
11 | }
12 |
13 | func SubmitUpdateScore(uid int, pid int, rawcode string, lang string) SubmitResponse {
14 | testCaseStatus := ExecBatch(pid, rawcode, lang)
15 | submitResponse := SubmitResponse{}
16 | submitResponse.Status = testCaseStatus
17 | problem := Problem{}
18 | problem.Pid = pid
19 | _ = problem.GetByPid()
20 | problemlog := Problemlogs{}
21 | problemlog.Pid = pid
22 | problemlog.Uid = uid
23 | b := problemlog.GetByPidUid()
24 | score := computeScore(problem.Points, testCaseStatus)
25 | if score == 0 {
26 | return submitResponse
27 | }
28 | if b == false {
29 | problemlog.Uid = uid
30 | problemlog.Pid = pid
31 | problemlog.Solved = 1
32 | problemlog.Points = score
33 | problemlog.Time = time.Now()
34 | problemlog.CommitByPidUid()
35 | problem.Solve_count++
36 | problem.Update()
37 | user := User{Uid: uid}
38 | user.AddScore(score)
39 | } else {
40 | if problemlog.Points < score {
41 | user := User{Uid: uid}
42 | user.AddScore(score - problemlog.Points)
43 | problemlog.Points = score
44 | problemlog.Solved++
45 | problemlog.Update()
46 | }
47 | }
48 | submitResponse.Score = score
49 | return submitResponse
50 | }
51 |
52 | func computeScore(maxScore int, testCaseStatus []Bridge.TestCaseStatus) int {
53 | casePassed := 0
54 | for _, status := range testCaseStatus {
55 | if status.Success == true {
56 | casePassed++
57 | }
58 | }
59 | return (casePassed * maxScore) / len(testCaseStatus)
60 | }
61 |
--------------------------------------------------------------------------------
/models/TestCases.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "github.com/astaxie/beego/orm"
5 | )
6 |
7 | func (testcase *Testcases) Create() bool {
8 | o := orm.NewOrm()
9 | o.Using("default")
10 | _, err := o.Insert(testcase)
11 | if err == nil {
12 | return true
13 | }
14 | return false
15 | }
16 |
17 | func (testcase *Testcases) GetAllByPid() ([]Testcases, int64) {
18 | var testcases []Testcases
19 | o := orm.NewOrm()
20 | o.Using("default")
21 | count, err := o.QueryTable("testcases").Filter("Pid", testcase.Pid).All(&testcases)
22 | if err == nil {
23 | return testcases, count
24 | }
25 | return nil, 0
26 | }
27 |
28 | func (testcase *Testcases) GetOneByPidTid() (Testcases, bool) {
29 | var testcaseN Testcases
30 | o := orm.NewOrm()
31 | o.Using("default")
32 | err := o.QueryTable("testcases").Filter("Pid", testcase.Pid).Filter("Tid", testcase.Tid).One(&testcaseN)
33 | if err == nil {
34 | return testcaseN, true
35 | }
36 | return testcaseN, false
37 | }
38 |
39 | func (testcase *Testcases) DeleteAllByPid() (int64, bool) {
40 | o := orm.NewOrm()
41 | o.Using("default")
42 | count, err := o.QueryTable("testcases").Filter("Pid", testcase.Pid).Delete()
43 | if err == nil {
44 | return count, true
45 | }
46 | return 0, false
47 | }
48 |
49 | func (testcase *Testcases) DeleteOneByPidTid() bool {
50 | o := orm.NewOrm()
51 | o.Using("default")
52 | _, err := o.QueryTable("testcases").Filter("Pid", testcase.Pid).Filter("Tid", testcase.Tid).Delete()
53 | if err == nil {
54 | return true
55 | }
56 | return false
57 | }
58 |
--------------------------------------------------------------------------------
/models/Verify.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "regexp"
5 | "unicode"
6 | )
7 |
8 | var (
9 | usernameMatcher *regexp.Regexp
10 | emailMatcher *regexp.Regexp
11 | nameMatcher *regexp.Regexp
12 | collegeMatcher *regexp.Regexp
13 | )
14 |
15 | func init() {
16 | usernameMatcher = regexp.MustCompile("^[\\w\\d_\\.]*$")
17 | emailMatcher = regexp.MustCompile("^[\\w\\d_\\.]{2,}\\@[\\w\\d]*\\.[\\w]{2,4}(\\.[\\w]{2,4})?$")
18 | nameMatcher = regexp.MustCompile("^([\\w]{1,}\\s?){1,}$")
19 | collegeMatcher = regexp.MustCompile("^([\\w-]{1,}\\s?){1,}$")
20 | }
21 |
22 | func CheckUserName(username string) bool {
23 | if len(username) < 6 {
24 | return false
25 | }
26 | return usernameMatcher.Match([]byte(username))
27 | }
28 |
29 | func CheckEmail(email string) bool {
30 | return emailMatcher.Match([]byte(email))
31 | }
32 |
33 | func CheckPassword(password string) bool {
34 | if len(password) < 8 {
35 | return false
36 | }
37 | return matchPassword(password)
38 | }
39 |
40 | func CheckName(name string) bool {
41 | return nameMatcher.Match([]byte(name))
42 | }
43 |
44 | func CheckCollege(college string) bool {
45 | return collegeMatcher.Match([]byte(college))
46 | }
47 |
48 | func matchPassword(password string) bool {
49 | var (
50 | letter bool
51 | number bool
52 | )
53 | for _, r := range password {
54 | if unicode.IsLetter(r) {
55 | letter = true
56 | } else if unicode.IsNumber(r) {
57 | number = true
58 | } else {
59 | return false
60 | }
61 | }
62 | return letter && number
63 | }
64 |
--------------------------------------------------------------------------------
/models/contest.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "github.com/astaxie/beego/orm"
5 | "log"
6 | )
7 |
8 | func (this *Contest) Create() (int64, bool) {
9 | o := orm.NewOrm()
10 | o.Using("default")
11 | id, err := o.Insert(this)
12 | if err != nil {
13 | log.Println("Contest Model: ", err)
14 | return -1, false
15 | }
16 | return id, true
17 | }
18 |
19 | func (this *Contest) Edit() bool {
20 | o := orm.NewOrm()
21 | o.Using("default")
22 | _, err := o.Update(this)
23 | if err != nil {
24 | log.Println("Contest Model: ", err)
25 | return false
26 | }
27 | return true
28 | }
29 |
30 | func (this *Contest) GetByName() bool {
31 | o := orm.NewOrm()
32 | o.Using("default")
33 | err := o.QueryTable("contest").Filter("name", this.Name).One(this)
34 | if err != nil {
35 | return false
36 | }
37 | return true
38 | }
39 |
40 | func (this *Contest) Delete() bool {
41 | o := orm.NewOrm()
42 | o.Using("default")
43 | _, err := o.Delete(this)
44 | if err != nil {
45 | log.Println("Contest Model: ", err)
46 | return false
47 | }
48 | return true
49 | }
50 |
--------------------------------------------------------------------------------
/restart.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | if [ "$EUID" -ne 0 ]
3 | then echo "Please run as root"
4 | exit 1
5 | fi
6 | cd go/src
7 | cp lxcmain /home/ubuntu
8 | cp start* /home/ubuntu
9 | echo "Run the startJudge in $HOME as user"
--------------------------------------------------------------------------------
/routers/router.go:
--------------------------------------------------------------------------------
1 | package routers
2 |
3 | import (
4 | "OnlineJudge/controllers"
5 | "github.com/astaxie/beego"
6 | )
7 |
8 | func init() {
9 | // List problems (or have a seperate controller as IndexController?)
10 | beego.Router("/", &controllers.ProblemController{}, "*:List")
11 |
12 | // On User -- Includes user profiles, settings and login and sign up routes
13 | beego.AutoRouter(&controllers.UserController{})
14 |
15 | // On Problems
16 | beego.Router("/problem/create", &controllers.ProblemController{}, "*:Create;post:SaveProblem")
17 | beego.Router("/problem/:id/addtest", &controllers.ProblemController{}, "*:AddTestCase;post:SaveTestCase")
18 | beego.Router("/problem/:id", &controllers.ProblemController{}, "*:ProblemById")
19 | beego.Router("/problem/:type/:page", &controllers.ProblemController{}, "*:ProblemByCategory")
20 | beego.Router("/problem/:id/submit", &controllers.ProblemController{}, "post:SaveSubmission") // ->ProblemController(notes that user has tried solving problem)->ExecController(seek for helper to exec)->ProblemController(get result info & build on it)
21 | beego.Router("/problem/:id/run", &controllers.ProblemController{}, "post:RunCode")
22 | beego.Router("/test", &controllers.ProblemController{}, "post:Test")
23 | // beego.Router("/problem/:id/edit", &controllers.ProblemController{}, "post:SaveProblem;*:Edit")
24 | }
25 |
--------------------------------------------------------------------------------
/startJudge.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | export PATH=$PATH:/usr/local/go/bin
3 | export GOPATH=/home/ubuntu/go
4 | nohup ./lxcmain &
5 | rm startJudge.bash
6 | echo "Judge is running, on reboot run script restart.bash in go/src as root"
--------------------------------------------------------------------------------
/static/CodeMirror/addon/dialog/dialog.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-dialog {
2 | position: absolute;
3 | left: 0; right: 0;
4 | background: inherit;
5 | z-index: 15;
6 | padding: .1em .8em;
7 | overflow: hidden;
8 | color: inherit;
9 | }
10 |
11 | .CodeMirror-dialog-top {
12 | border-bottom: 1px solid #eee;
13 | top: 0;
14 | }
15 |
16 | .CodeMirror-dialog-bottom {
17 | border-top: 1px solid #eee;
18 | bottom: 0;
19 | }
20 |
21 | .CodeMirror-dialog input {
22 | border: none;
23 | outline: none;
24 | background: transparent;
25 | width: 20em;
26 | color: inherit;
27 | font-family: monospace;
28 | }
29 |
30 | .CodeMirror-dialog button {
31 | font-size: 70%;
32 | }
33 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/display/fullscreen.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-fullscreen {
2 | position: fixed;
3 | top: 0; left: 0; right: 0; bottom: 0;
4 | height: auto;
5 | z-index: 9;
6 | }
7 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/display/fullscreen.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
15 | if (old == CodeMirror.Init) old = false;
16 | if (!old == !val) return;
17 | if (val) setFullscreen(cm);
18 | else setNormal(cm);
19 | });
20 |
21 | function setFullscreen(cm) {
22 | var wrap = cm.getWrapperElement();
23 | cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
24 | width: wrap.style.width, height: wrap.style.height};
25 | wrap.style.width = "";
26 | wrap.style.height = "auto";
27 | wrap.className += " CodeMirror-fullscreen";
28 | document.documentElement.style.overflow = "hidden";
29 | cm.refresh();
30 | }
31 |
32 | function setNormal(cm) {
33 | var wrap = cm.getWrapperElement();
34 | wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
35 | document.documentElement.style.overflow = "";
36 | var info = cm.state.fullScreenRestore;
37 | wrap.style.width = info.width; wrap.style.height = info.height;
38 | window.scrollTo(info.scrollLeft, info.scrollTop);
39 | cm.refresh();
40 | }
41 | });
42 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/display/placeholder.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
13 | var prev = old && old != CodeMirror.Init;
14 | if (val && !prev) {
15 | cm.on("blur", onBlur);
16 | cm.on("change", onChange);
17 | onChange(cm);
18 | } else if (!val && prev) {
19 | cm.off("blur", onBlur);
20 | cm.off("change", onChange);
21 | clearPlaceholder(cm);
22 | var wrapper = cm.getWrapperElement();
23 | wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
24 | }
25 |
26 | if (val && !cm.hasFocus()) onBlur(cm);
27 | });
28 |
29 | function clearPlaceholder(cm) {
30 | if (cm.state.placeholder) {
31 | cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
32 | cm.state.placeholder = null;
33 | }
34 | }
35 | function setPlaceholder(cm) {
36 | clearPlaceholder(cm);
37 | var elt = cm.state.placeholder = document.createElement("pre");
38 | elt.style.cssText = "height: 0; overflow: visible";
39 | elt.className = "CodeMirror-placeholder";
40 | elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
41 | cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
42 | }
43 |
44 | function onBlur(cm) {
45 | if (isEmpty(cm)) setPlaceholder(cm);
46 | }
47 | function onChange(cm) {
48 | var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
49 | wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
50 |
51 | if (empty) setPlaceholder(cm);
52 | else clearPlaceholder(cm);
53 | }
54 |
55 | function isEmpty(cm) {
56 | return (cm.lineCount() === 1) && (cm.getLine(0) === "");
57 | }
58 | });
59 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/display/rulers.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineOption("rulers", false, function(cm, val, old) {
15 | if (old && old != CodeMirror.Init) {
16 | clearRulers(cm);
17 | cm.off("refresh", refreshRulers);
18 | }
19 | if (val && val.length) {
20 | setRulers(cm);
21 | cm.on("refresh", refreshRulers);
22 | }
23 | });
24 |
25 | function clearRulers(cm) {
26 | for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) {
27 | var node = cm.display.lineSpace.childNodes[i];
28 | if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
29 | node.parentNode.removeChild(node);
30 | }
31 | }
32 |
33 | function setRulers(cm) {
34 | var val = cm.getOption("rulers");
35 | var cw = cm.defaultCharWidth();
36 | var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
37 | var minH = cm.display.scroller.offsetHeight + 30;
38 | for (var i = 0; i < val.length; i++) {
39 | var elt = document.createElement("div");
40 | elt.className = "CodeMirror-ruler";
41 | var col, conf = val[i];
42 | if (typeof conf == "number") {
43 | col = conf;
44 | } else {
45 | col = conf.column;
46 | if (conf.className) elt.className += " " + conf.className;
47 | if (conf.color) elt.style.borderColor = conf.color;
48 | if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
49 | if (conf.width) elt.style.borderLeftWidth = conf.width;
50 | }
51 | elt.style.left = (left + col * cw) + "px";
52 | elt.style.top = "-50px";
53 | elt.style.bottom = "-20px";
54 | elt.style.minHeight = minH + "px";
55 | cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
56 | }
57 | }
58 |
59 | function refreshRulers(cm) {
60 | clearRulers(cm);
61 | setRulers(cm);
62 | }
63 | });
64 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/edit/continuelist.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,
15 | emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,
16 | unorderedListRE = /[*+-]\s/;
17 |
18 | CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
19 | if (cm.getOption("disableInput")) return CodeMirror.Pass;
20 | var ranges = cm.listSelections(), replacements = [];
21 | for (var i = 0; i < ranges.length; i++) {
22 | var pos = ranges[i].head;
23 | var eolState = cm.getStateAfter(pos.line);
24 | var inList = eolState.list !== false;
25 | var inQuote = eolState.quote !== 0;
26 |
27 | var line = cm.getLine(pos.line), match = listRE.exec(line);
28 | if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
29 | cm.execCommand("newlineAndIndent");
30 | return;
31 | }
32 | if (emptyListRE.test(line)) {
33 | cm.replaceRange("", {
34 | line: pos.line, ch: 0
35 | }, {
36 | line: pos.line, ch: pos.ch + 1
37 | });
38 | replacements[i] = "\n";
39 | } else {
40 | var indent = match[1], after = match[5];
41 | var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
42 | ? match[2]
43 | : (parseInt(match[3], 10) + 1) + match[4];
44 |
45 | replacements[i] = "\n" + indent + bullet + after;
46 | }
47 | }
48 |
49 | cm.replaceSelections(replacements);
50 | };
51 | });
52 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/edit/trailingspace.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
13 | if (prev == CodeMirror.Init) prev = false;
14 | if (prev && !val)
15 | cm.removeOverlay("trailingspace");
16 | else if (!prev && val)
17 | cm.addOverlay({
18 | token: function(stream) {
19 | for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
20 | if (i > stream.pos) { stream.pos = i; return null; }
21 | stream.pos = l;
22 | return "trailingspace";
23 | },
24 | name: "trailingspace"
25 | });
26 | });
27 | });
28 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/fold/comment-fold.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
15 | return mode.blockCommentStart && mode.blockCommentEnd;
16 | }, function(cm, start) {
17 | var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd;
18 | if (!startToken || !endToken) return;
19 | var line = start.line, lineText = cm.getLine(line);
20 |
21 | var startCh;
22 | for (var at = start.ch, pass = 0;;) {
23 | var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1);
24 | if (found == -1) {
25 | if (pass == 1) return;
26 | pass = 1;
27 | at = lineText.length;
28 | continue;
29 | }
30 | if (pass == 1 && found < start.ch) return;
31 | if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
32 | startCh = found + startToken.length;
33 | break;
34 | }
35 | at = found - 1;
36 | }
37 |
38 | var depth = 1, lastLine = cm.lastLine(), end, endCh;
39 | outer: for (var i = line; i <= lastLine; ++i) {
40 | var text = cm.getLine(i), pos = i == line ? startCh : 0;
41 | for (;;) {
42 | var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
43 | if (nextOpen < 0) nextOpen = text.length;
44 | if (nextClose < 0) nextClose = text.length;
45 | pos = Math.min(nextOpen, nextClose);
46 | if (pos == text.length) break;
47 | if (pos == nextOpen) ++depth;
48 | else if (!--depth) { end = i; endCh = pos; break outer; }
49 | ++pos;
50 | }
51 | }
52 | if (end == null || line == end && endCh == startCh) return;
53 | return {from: CodeMirror.Pos(line, startCh),
54 | to: CodeMirror.Pos(end, endCh)};
55 | });
56 |
57 | });
58 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/fold/foldgutter.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-foldmarker {
2 | color: blue;
3 | text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
4 | font-family: arial;
5 | line-height: .3;
6 | cursor: pointer;
7 | }
8 | .CodeMirror-foldgutter {
9 | width: .7em;
10 | }
11 | .CodeMirror-foldgutter-open,
12 | .CodeMirror-foldgutter-folded {
13 | cursor: pointer;
14 | }
15 | .CodeMirror-foldgutter-open:after {
16 | content: "\25BE";
17 | }
18 | .CodeMirror-foldgutter-folded:after {
19 | content: "\25B8";
20 | }
21 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/fold/indent-fold.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.registerHelper("fold", "indent", function(cm, start) {
15 | var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
16 | if (!/\S/.test(firstLine)) return;
17 | var getIndent = function(line) {
18 | return CodeMirror.countColumn(line, null, tabSize);
19 | };
20 | var myIndent = getIndent(firstLine);
21 | var lastLineInFold = null;
22 | // Go through lines until we find a line that definitely doesn't belong in
23 | // the block we're folding, or to the end.
24 | for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
25 | var curLine = cm.getLine(i);
26 | var curIndent = getIndent(curLine);
27 | if (curIndent > myIndent) {
28 | // Lines with a greater indent are considered part of the block.
29 | lastLineInFold = i;
30 | } else if (!/\S/.test(curLine)) {
31 | // Empty lines might be breaks within the block we're trying to fold.
32 | } else {
33 | // A non-empty line at an indent equal to or less than ours marks the
34 | // start of another block.
35 | break;
36 | }
37 | }
38 | if (lastLineInFold) return {
39 | from: CodeMirror.Pos(start.line, firstLine.length),
40 | to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
41 | };
42 | });
43 |
44 | });
45 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/fold/markdown-fold.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.registerHelper("fold", "markdown", function(cm, start) {
15 | var maxDepth = 100;
16 |
17 | function isHeader(lineNo) {
18 | var tokentype = cm.getTokenTypeAt(CodeMirror.Pos(lineNo, 0));
19 | return tokentype && /\bheader\b/.test(tokentype);
20 | }
21 |
22 | function headerLevel(lineNo, line, nextLine) {
23 | var match = line && line.match(/^#+/);
24 | if (match && isHeader(lineNo)) return match[0].length;
25 | match = nextLine && nextLine.match(/^[=\-]+\s*$/);
26 | if (match && isHeader(lineNo + 1)) return nextLine[0] == "=" ? 1 : 2;
27 | return maxDepth;
28 | }
29 |
30 | var firstLine = cm.getLine(start.line), nextLine = cm.getLine(start.line + 1);
31 | var level = headerLevel(start.line, firstLine, nextLine);
32 | if (level === maxDepth) return undefined;
33 |
34 | var lastLineNo = cm.lastLine();
35 | var end = start.line, nextNextLine = cm.getLine(end + 2);
36 | while (end < lastLineNo) {
37 | if (headerLevel(end + 1, nextLine, nextNextLine) <= level) break;
38 | ++end;
39 | nextLine = nextNextLine;
40 | nextNextLine = cm.getLine(end + 2);
41 | }
42 |
43 | return {
44 | from: CodeMirror.Pos(start.line, firstLine.length),
45 | to: CodeMirror.Pos(end, cm.getLine(end).length)
46 | };
47 | });
48 |
49 | });
50 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/hint/anyword-hint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var WORD = /[\w$]+/, RANGE = 500;
15 |
16 | CodeMirror.registerHelper("hint", "anyword", function(editor, options) {
17 | var word = options && options.word || WORD;
18 | var range = options && options.range || RANGE;
19 | var cur = editor.getCursor(), curLine = editor.getLine(cur.line);
20 | var end = cur.ch, start = end;
21 | while (start && word.test(curLine.charAt(start - 1))) --start;
22 | var curWord = start != end && curLine.slice(start, end);
23 |
24 | var list = [], seen = {};
25 | var re = new RegExp(word.source, "g");
26 | for (var dir = -1; dir <= 1; dir += 2) {
27 | var line = cur.line, endLine = Math.min(Math.max(line + dir * range, editor.firstLine()), editor.lastLine()) + dir;
28 | for (; line != endLine; line += dir) {
29 | var text = editor.getLine(line), m;
30 | while (m = re.exec(text)) {
31 | if (line == cur.line && m[0] === curWord) continue;
32 | if ((!curWord || m[0].lastIndexOf(curWord, 0) == 0) && !Object.prototype.hasOwnProperty.call(seen, m[0])) {
33 | seen[m[0]] = true;
34 | list.push(m[0]);
35 | }
36 | }
37 | }
38 | }
39 | return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
40 | });
41 | });
42 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/hint/show-hint.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-hints {
2 | position: absolute;
3 | z-index: 10;
4 | overflow: hidden;
5 | list-style: none;
6 |
7 | margin: 0;
8 | padding: 2px;
9 |
10 | -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
11 | -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
12 | box-shadow: 2px 3px 5px rgba(0,0,0,.2);
13 | border-radius: 3px;
14 | border: 1px solid silver;
15 |
16 | background: white;
17 | font-size: 90%;
18 | font-family: monospace;
19 |
20 | max-height: 20em;
21 | overflow-y: auto;
22 | }
23 |
24 | .CodeMirror-hint {
25 | margin: 0;
26 | padding: 0 4px;
27 | border-radius: 2px;
28 | max-width: 19em;
29 | overflow: hidden;
30 | white-space: pre;
31 | color: black;
32 | cursor: pointer;
33 | }
34 |
35 | li.CodeMirror-hint-active {
36 | background: #08f;
37 | color: white;
38 | }
39 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/lint/coffeescript-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
5 |
6 | // declare global: coffeelint
7 |
8 | (function(mod) {
9 | if (typeof exports == "object" && typeof module == "object") // CommonJS
10 | mod(require("../../lib/codemirror"));
11 | else if (typeof define == "function" && define.amd) // AMD
12 | define(["../../lib/codemirror"], mod);
13 | else // Plain browser env
14 | mod(CodeMirror);
15 | })(function(CodeMirror) {
16 | "use strict";
17 |
18 | CodeMirror.registerHelper("lint", "coffeescript", function(text) {
19 | var found = [];
20 | var parseError = function(err) {
21 | var loc = err.lineNumber;
22 | found.push({from: CodeMirror.Pos(loc-1, 0),
23 | to: CodeMirror.Pos(loc, 0),
24 | severity: err.level,
25 | message: err.message});
26 | };
27 | try {
28 | var res = coffeelint.lint(text);
29 | for(var i = 0; i < res.length; i++) {
30 | parseError(res[i]);
31 | }
32 | } catch(e) {
33 | found.push({from: CodeMirror.Pos(e.location.first_line, 0),
34 | to: CodeMirror.Pos(e.location.last_line, e.location.last_column),
35 | severity: 'error',
36 | message: e.message});
37 | }
38 | return found;
39 | });
40 |
41 | });
42 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/lint/css-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // Depends on csslint.js from https://github.com/stubbornella/csslint
5 |
6 | // declare global: CSSLint
7 |
8 | (function(mod) {
9 | if (typeof exports == "object" && typeof module == "object") // CommonJS
10 | mod(require("../../lib/codemirror"));
11 | else if (typeof define == "function" && define.amd) // AMD
12 | define(["../../lib/codemirror"], mod);
13 | else // Plain browser env
14 | mod(CodeMirror);
15 | })(function(CodeMirror) {
16 | "use strict";
17 |
18 | CodeMirror.registerHelper("lint", "css", function(text) {
19 | var found = [];
20 | if (!window.CSSLint) return found;
21 | var results = CSSLint.verify(text), messages = results.messages, message = null;
22 | for ( var i = 0; i < messages.length; i++) {
23 | message = messages[i];
24 | var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
25 | found.push({
26 | from: CodeMirror.Pos(startLine, startCol),
27 | to: CodeMirror.Pos(endLine, endCol),
28 | message: message.message,
29 | severity : message.type
30 | });
31 | }
32 | return found;
33 | });
34 |
35 | });
36 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/lint/json-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // Depends on jsonlint.js from https://github.com/zaach/jsonlint
5 |
6 | // declare global: jsonlint
7 |
8 | (function(mod) {
9 | if (typeof exports == "object" && typeof module == "object") // CommonJS
10 | mod(require("../../lib/codemirror"));
11 | else if (typeof define == "function" && define.amd) // AMD
12 | define(["../../lib/codemirror"], mod);
13 | else // Plain browser env
14 | mod(CodeMirror);
15 | })(function(CodeMirror) {
16 | "use strict";
17 |
18 | CodeMirror.registerHelper("lint", "json", function(text) {
19 | var found = [];
20 | jsonlint.parseError = function(str, hash) {
21 | var loc = hash.loc;
22 | found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
23 | to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
24 | message: str});
25 | };
26 | try { jsonlint.parse(text); }
27 | catch(e) {}
28 | return found;
29 | });
30 |
31 | });
32 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/lint/yaml-lint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | // Depends on js-yaml.js from https://github.com/nodeca/js-yaml
15 |
16 | // declare global: jsyaml
17 |
18 | CodeMirror.registerHelper("lint", "yaml", function(text) {
19 | var found = [];
20 | try { jsyaml.load(text); }
21 | catch(e) {
22 | var loc = e.mark;
23 | found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
24 | }
25 | return found;
26 | });
27 |
28 | });
29 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/mode/multiplex_test.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function() {
5 | CodeMirror.defineMode("markdown_with_stex", function(){
6 | var inner = CodeMirror.getMode({}, "stex");
7 | var outer = CodeMirror.getMode({}, "markdown");
8 |
9 | var innerOptions = {
10 | open: '$',
11 | close: '$',
12 | mode: inner,
13 | delimStyle: 'delim',
14 | innerStyle: 'inner'
15 | };
16 |
17 | return CodeMirror.multiplexingMode(outer, innerOptions);
18 | });
19 |
20 | var mode = CodeMirror.getMode({}, "markdown_with_stex");
21 |
22 | function MT(name) {
23 | test.mode(
24 | name,
25 | mode,
26 | Array.prototype.slice.call(arguments, 1),
27 | 'multiplexing');
28 | }
29 |
30 | MT(
31 | "stexInsideMarkdown",
32 | "[strong **Equation:**] [delim $][inner&tag \\pi][delim $]");
33 | })();
34 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/runmode/colorize.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"), require("./runmode"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror", "./runmode"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/;
15 |
16 | function textContent(node, out) {
17 | if (node.nodeType == 3) return out.push(node.nodeValue);
18 | for (var ch = node.firstChild; ch; ch = ch.nextSibling) {
19 | textContent(ch, out);
20 | if (isBlock.test(node.nodeType)) out.push("\n");
21 | }
22 | }
23 |
24 | CodeMirror.colorize = function(collection, defaultMode) {
25 | if (!collection) collection = document.body.getElementsByTagName("pre");
26 |
27 | for (var i = 0; i < collection.length; ++i) {
28 | var node = collection[i];
29 | var mode = node.getAttribute("data-lang") || defaultMode;
30 | if (!mode) continue;
31 |
32 | var text = [];
33 | textContent(node, text);
34 | node.innerHTML = "";
35 | CodeMirror.runMode(text.join(""), mode, node);
36 |
37 | node.className += " cm-s-default";
38 | }
39 | };
40 | });
41 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/scroll/scrollpastend.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) {
15 | if (old && old != CodeMirror.Init) {
16 | cm.off("change", onChange);
17 | cm.off("refresh", updateBottomMargin);
18 | cm.display.lineSpace.parentNode.style.paddingBottom = "";
19 | cm.state.scrollPastEndPadding = null;
20 | }
21 | if (val) {
22 | cm.on("change", onChange);
23 | cm.on("refresh", updateBottomMargin);
24 | updateBottomMargin(cm);
25 | }
26 | });
27 |
28 | function onChange(cm, change) {
29 | if (CodeMirror.changeEnd(change).line == cm.lastLine())
30 | updateBottomMargin(cm);
31 | }
32 |
33 | function updateBottomMargin(cm) {
34 | var padding = "";
35 | if (cm.lineCount() > 1) {
36 | var totalH = cm.display.scroller.clientHeight - 30,
37 | lastLineH = cm.getLineHandle(cm.lastLine()).height;
38 | padding = (totalH - lastLineH) + "px";
39 | }
40 | if (cm.state.scrollPastEndPadding != padding) {
41 | cm.state.scrollPastEndPadding = padding;
42 | cm.display.lineSpace.parentNode.style.paddingBottom = padding;
43 | cm.setSize();
44 | }
45 | }
46 | });
47 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/scroll/simplescrollbars.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-simplescroll-horizontal div, .CodeMirror-simplescroll-vertical div {
2 | position: absolute;
3 | background: #ccc;
4 | -moz-box-sizing: border-box;
5 | box-sizing: border-box;
6 | border: 1px solid #bbb;
7 | border-radius: 2px;
8 | }
9 |
10 | .CodeMirror-simplescroll-horizontal, .CodeMirror-simplescroll-vertical {
11 | position: absolute;
12 | z-index: 6;
13 | background: #eee;
14 | }
15 |
16 | .CodeMirror-simplescroll-horizontal {
17 | bottom: 0; left: 0;
18 | height: 8px;
19 | }
20 | .CodeMirror-simplescroll-horizontal div {
21 | bottom: 0;
22 | height: 100%;
23 | }
24 |
25 | .CodeMirror-simplescroll-vertical {
26 | right: 0; top: 0;
27 | width: 8px;
28 | }
29 | .CodeMirror-simplescroll-vertical div {
30 | right: 0;
31 | width: 100%;
32 | }
33 |
34 |
35 | .CodeMirror-overlayscroll .CodeMirror-scrollbar-filler, .CodeMirror-overlayscroll .CodeMirror-gutter-filler {
36 | display: none;
37 | }
38 |
39 | .CodeMirror-overlayscroll-horizontal div, .CodeMirror-overlayscroll-vertical div {
40 | position: absolute;
41 | background: #bcd;
42 | border-radius: 3px;
43 | }
44 |
45 | .CodeMirror-overlayscroll-horizontal, .CodeMirror-overlayscroll-vertical {
46 | position: absolute;
47 | z-index: 6;
48 | }
49 |
50 | .CodeMirror-overlayscroll-horizontal {
51 | bottom: 0; left: 0;
52 | height: 6px;
53 | }
54 | .CodeMirror-overlayscroll-horizontal div {
55 | bottom: 0;
56 | height: 100%;
57 | }
58 |
59 | .CodeMirror-overlayscroll-vertical {
60 | right: 0; top: 0;
61 | width: 6px;
62 | }
63 | .CodeMirror-overlayscroll-vertical div {
64 | right: 0;
65 | width: 100%;
66 | }
67 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/search/matchesonscrollbar.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-search-match {
2 | background: gold;
3 | border-top: 1px solid orange;
4 | border-bottom: 1px solid orange;
5 | -moz-box-sizing: border-box;
6 | box-sizing: border-box;
7 | opacity: .5;
8 | }
9 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/tern/tern.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-Tern-completion {
2 | padding-left: 22px;
3 | position: relative;
4 | line-height: 1.5;
5 | }
6 | .CodeMirror-Tern-completion:before {
7 | position: absolute;
8 | left: 2px;
9 | bottom: 2px;
10 | border-radius: 50%;
11 | font-size: 12px;
12 | font-weight: bold;
13 | height: 15px;
14 | width: 15px;
15 | line-height: 16px;
16 | text-align: center;
17 | color: white;
18 | -moz-box-sizing: border-box;
19 | box-sizing: border-box;
20 | }
21 | .CodeMirror-Tern-completion-unknown:before {
22 | content: "?";
23 | background: #4bb;
24 | }
25 | .CodeMirror-Tern-completion-object:before {
26 | content: "O";
27 | background: #77c;
28 | }
29 | .CodeMirror-Tern-completion-fn:before {
30 | content: "F";
31 | background: #7c7;
32 | }
33 | .CodeMirror-Tern-completion-array:before {
34 | content: "A";
35 | background: #c66;
36 | }
37 | .CodeMirror-Tern-completion-number:before {
38 | content: "1";
39 | background: #999;
40 | }
41 | .CodeMirror-Tern-completion-string:before {
42 | content: "S";
43 | background: #999;
44 | }
45 | .CodeMirror-Tern-completion-bool:before {
46 | content: "B";
47 | background: #999;
48 | }
49 |
50 | .CodeMirror-Tern-completion-guess {
51 | color: #999;
52 | }
53 |
54 | .CodeMirror-Tern-tooltip {
55 | border: 1px solid silver;
56 | border-radius: 3px;
57 | color: #444;
58 | padding: 2px 5px;
59 | font-size: 90%;
60 | font-family: monospace;
61 | background-color: white;
62 | white-space: pre-wrap;
63 |
64 | max-width: 40em;
65 | position: absolute;
66 | z-index: 10;
67 | -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
68 | -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
69 | box-shadow: 2px 3px 5px rgba(0,0,0,.2);
70 |
71 | transition: opacity 1s;
72 | -moz-transition: opacity 1s;
73 | -webkit-transition: opacity 1s;
74 | -o-transition: opacity 1s;
75 | -ms-transition: opacity 1s;
76 | }
77 |
78 | .CodeMirror-Tern-hint-doc {
79 | max-width: 25em;
80 | margin-top: -3px;
81 | }
82 |
83 | .CodeMirror-Tern-fname { color: black; }
84 | .CodeMirror-Tern-farg { color: #70a; }
85 | .CodeMirror-Tern-farg-current { text-decoration: underline; }
86 | .CodeMirror-Tern-type { color: #07c; }
87 | .CodeMirror-Tern-fhint-guess { opacity: .7; }
88 |
--------------------------------------------------------------------------------
/static/CodeMirror/addon/tern/worker.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | // declare global: tern, server
5 |
6 | var server;
7 |
8 | this.onmessage = function(e) {
9 | var data = e.data;
10 | switch (data.type) {
11 | case "init": return startServer(data.defs, data.plugins, data.scripts);
12 | case "add": return server.addFile(data.name, data.text);
13 | case "del": return server.delFile(data.name);
14 | case "req": return server.request(data.body, function(err, reqData) {
15 | postMessage({id: data.id, body: reqData, err: err && String(err)});
16 | });
17 | case "getFile":
18 | var c = pending[data.id];
19 | delete pending[data.id];
20 | return c(data.err, data.text);
21 | default: throw new Error("Unknown message type: " + data.type);
22 | }
23 | };
24 |
25 | var nextId = 0, pending = {};
26 | function getFile(file, c) {
27 | postMessage({type: "getFile", name: file, id: ++nextId});
28 | pending[nextId] = c;
29 | }
30 |
31 | function startServer(defs, plugins, scripts) {
32 | if (scripts) importScripts.apply(null, scripts);
33 |
34 | server = new tern.Server({
35 | getFile: getFile,
36 | async: true,
37 | defs: defs,
38 | plugins: plugins
39 | });
40 | }
41 |
42 | this.console = {
43 | log: function(v) { postMessage({type: "debug", message: v}); }
44 | };
45 |
--------------------------------------------------------------------------------
/static/CodeMirror/doc/activebookmark.js:
--------------------------------------------------------------------------------
1 | // Kludge in HTML5 tag recognition in IE8
2 | document.createElement("section");
3 | document.createElement("article");
4 |
5 | (function() {
6 | if (!window.addEventListener) return;
7 | var pending = false, prevVal = null;
8 |
9 | function updateSoon() {
10 | if (!pending) {
11 | pending = true;
12 | setTimeout(update, 250);
13 | }
14 | }
15 |
16 | function update() {
17 | pending = false;
18 | var marks = document.getElementById("nav").getElementsByTagName("a"), found;
19 | for (var i = 0; i < marks.length; ++i) {
20 | var mark = marks[i], m;
21 | if (mark.getAttribute("data-default")) {
22 | if (found == null) found = i;
23 | } else if (m = mark.href.match(/#(.*)/)) {
24 | var ref = document.getElementById(m[1]);
25 | if (ref && ref.getBoundingClientRect().top < 50)
26 | found = i;
27 | }
28 | }
29 | if (found != null && found != prevVal) {
30 | prevVal = found;
31 | var lis = document.getElementById("nav").getElementsByTagName("li");
32 | for (var i = 0; i < lis.length; ++i) lis[i].className = "";
33 | for (var i = 0; i < marks.length; ++i) {
34 | if (found == i) {
35 | marks[i].className = "active";
36 | for (var n = marks[i]; n; n = n.parentNode)
37 | if (n.nodeName == "LI") n.className = "active";
38 | } else {
39 | marks[i].className = "";
40 | }
41 | }
42 | }
43 | }
44 |
45 | window.addEventListener("scroll", updateSoon);
46 | window.addEventListener("load", updateSoon);
47 | window.addEventListener("hashchange", function() {
48 | setTimeout(function() {
49 | var hash = document.location.hash, found = null, m;
50 | var marks = document.getElementById("nav").getElementsByTagName("a");
51 | for (var i = 0; i < marks.length; i++)
52 | if ((m = marks[i].href.match(/(#.*)/)) && m[1] == hash) { found = i; break; }
53 | if (found != null) for (var i = 0; i < marks.length; i++)
54 | marks[i].className = i == found ? "active" : "";
55 | }, 300);
56 | });
57 | })();
58 |
--------------------------------------------------------------------------------
/static/CodeMirror/doc/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jronak/OnlineJudge/f6b89fe09600e42565dec08cc80c28b70e1801aa/static/CodeMirror/doc/logo.png
--------------------------------------------------------------------------------
/static/CodeMirror/doc/reporting.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
CodeMirror: Reporting Bugs
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 | Reporting bugs effectively
23 |
24 |
25 |
26 |
So you found a problem in CodeMirror. By all means, report it! Bug
27 | reports from users are the main drive behind improvements to
28 | CodeMirror. But first, please read over these points:
29 |
30 |
31 | CodeMirror is maintained by volunteers. They don't owe you
32 | anything, so be polite. Reports with an indignant or belligerent
33 | tone tend to be moved to the bottom of the pile.
34 |
35 | Include information about the browser in which the
36 | problem occurred . Even if you tested several browsers, and
37 | the problem occurred in all of them, mention this fact in the bug
38 | report. Also include browser version numbers and the operating
39 | system that you're on.
40 |
41 | Mention which release of CodeMirror you're using. Preferably,
42 | try also with the current development snapshot, to ensure the
43 | problem has not already been fixed.
44 |
45 | Mention very precisely what went wrong. "X is broken" is not a
46 | good bug report. What did you expect to happen? What happened
47 | instead? Describe the exact steps a maintainer has to take to make
48 | the problem occur. We can not fix something that we can not
49 | observe.
50 |
51 | If the problem can not be reproduced in any of the demos
52 | included in the CodeMirror distribution, please provide an HTML
53 | document that demonstrates the problem. The best way to do this is
54 | to go to jsbin.com , enter
55 | it there, press save, and include the resulting link in your bug
56 | report.
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/static/CodeMirror/doc/yinyang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jronak/OnlineJudge/f6b89fe09600e42565dec08cc80c28b70e1801aa/static/CodeMirror/doc/yinyang.png
--------------------------------------------------------------------------------
/static/CodeMirror/mode/asciiarmor/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: ASCII Armor (PGP) mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | ASCII Armor (PGP) mode
27 |
36 |
37 |
42 |
43 | MIME types
44 | defined: application/pgp
, application/pgp-keys
, application/pgp-signature
45 |
46 |
47 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/clike/test.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function() {
5 | var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
6 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
7 |
8 | MT("indent",
9 | "[variable-3 void] [def foo]([variable-3 void*] [variable a], [variable-3 int] [variable b]) {",
10 | " [variable-3 int] [variable c] [operator =] [variable b] [operator +]",
11 | " [number 1];",
12 | " [keyword return] [operator *][variable a];",
13 | "}");
14 |
15 | MT("indent_switch",
16 | "[keyword switch] ([variable x]) {",
17 | " [keyword case] [number 10]:",
18 | " [keyword return] [number 20];",
19 | " [keyword default]:",
20 | " [variable printf]([string \"foo %c\"], [variable x]);",
21 | "}");
22 |
23 | MT("def",
24 | "[variable-3 void] [def foo]() {}",
25 | "[keyword struct] [def bar]{}",
26 | "[variable-3 int] [variable-3 *][def baz]() {}");
27 |
28 | MT("double_block",
29 | "[keyword for] (;;)",
30 | " [keyword for] (;;)",
31 | " [variable x][operator ++];",
32 | "[keyword return];");
33 | })();
34 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/css/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: CSS mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
27 |
28 |
29 | CSS mode
30 |
31 | /* Some example CSS */
32 |
33 | @import url("something.css");
34 |
35 | body {
36 | margin: 0;
37 | padding: 3em 6em;
38 | font-family: tahoma, arial, sans-serif;
39 | color: #000;
40 | }
41 |
42 | #navigation a {
43 | font-weight: bold;
44 | text-decoration: none !important;
45 | }
46 |
47 | h1 {
48 | font-size: 2.5em;
49 | }
50 |
51 | h2 {
52 | font-size: 1.7em;
53 | }
54 |
55 | h1:before, h2:before {
56 | content: "::";
57 | }
58 |
59 | code {
60 | font-family: courier, monospace;
61 | font-size: 80%;
62 | color: #418A8A;
63 | }
64 |
65 |
70 |
71 | MIME types defined: text/css
, text/x-scss
(demo ), text/x-less
(demo ).
72 |
73 | Parsing/Highlighting Tests: normal , verbose .
74 |
75 |
76 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/css/less_test.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function() {
5 | "use strict";
6 |
7 | var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-less");
8 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "less"); }
9 |
10 | MT("variable",
11 | "[variable-2 @base]: [atom #f04615];",
12 | "[qualifier .class] {",
13 | " [property width]: [variable percentage]([number 0.5]); [comment // returns `50%`]",
14 | " [property color]: [variable saturate]([variable-2 @base], [number 5%]);",
15 | "}");
16 |
17 | MT("amp",
18 | "[qualifier .child], [qualifier .sibling] {",
19 | " [qualifier .parent] [atom &] {",
20 | " [property color]: [keyword black];",
21 | " }",
22 | " [atom &] + [atom &] {",
23 | " [property color]: [keyword red];",
24 | " }",
25 | "}");
26 |
27 | MT("mixin",
28 | "[qualifier .mixin] ([variable dark]; [variable-2 @color]) {",
29 | " [property color]: [variable darken]([variable-2 @color], [number 10%]);",
30 | "}",
31 | "[qualifier .mixin] ([variable light]; [variable-2 @color]) {",
32 | " [property color]: [variable lighten]([variable-2 @color], [number 10%]);",
33 | "}",
34 | "[qualifier .mixin] ([variable-2 @_]; [variable-2 @color]) {",
35 | " [property display]: [atom block];",
36 | "}",
37 | "[variable-2 @switch]: [variable light];",
38 | "[qualifier .class] {",
39 | " [qualifier .mixin]([variable-2 @switch]; [atom #888]);",
40 | "}");
41 |
42 | MT("nest",
43 | "[qualifier .one] {",
44 | " [def @media] ([property width]: [number 400px]) {",
45 | " [property font-size]: [number 1.2em];",
46 | " [def @media] [attribute print] [keyword and] [property color] {",
47 | " [property color]: [keyword blue];",
48 | " }",
49 | " }",
50 | "}");
51 |
52 |
53 | MT("interpolation", ".@{[variable foo]} { [property font-weight]: [atom bold]; }");
54 | })();
55 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/cypher/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Cypher Mode for CodeMirror
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
17 |
30 |
31 |
32 | Cypher Mode for CodeMirror
33 |
34 | // Cypher Mode for CodeMirror, using the neo theme
35 | MATCH (joe { name: 'Joe' })-[:knows*2..2]-(friend_of_friend)
36 | WHERE NOT (joe)-[:knows]-(friend_of_friend)
37 | RETURN friend_of_friend.name, COUNT(*)
38 | ORDER BY COUNT(*) DESC , friend_of_friend.name
39 |
40 |
41 | MIME types defined:
42 | application/x-cypher-query
43 |
44 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/dart/dart.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"), require("../clike/clike"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror", "../clike/clike"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var keywords = ("this super static final const abstract class extends external factory " +
15 | "implements get native operator set typedef with enum throw rethrow " +
16 | "assert break case continue default in return new deferred async await " +
17 | "try catch finally do else for if switch while import library export " +
18 | "part of show hide is").split(" ");
19 | var blockKeywords = "try catch finally do else for if switch while".split(" ");
20 | var atoms = "true false null".split(" ");
21 | var builtins = "void bool num int double dynamic var String".split(" ");
22 |
23 | function set(words) {
24 | var obj = {};
25 | for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
26 | return obj;
27 | }
28 |
29 | CodeMirror.defineMIME("application/dart", {
30 | name: "clike",
31 | keywords: set(keywords),
32 | multiLineStrings: true,
33 | blockKeywords: set(blockKeywords),
34 | builtin: set(builtins),
35 | atoms: set(atoms),
36 | hooks: {
37 | "@": function(stream) {
38 | stream.eatWhile(/[\w\$_]/);
39 | return "meta";
40 | }
41 | }
42 | });
43 |
44 | CodeMirror.registerHelper("hintWords", "application/dart", keywords.concat(atoms).concat(builtins));
45 |
46 | // This is needed to make loading through meta.js work.
47 | CodeMirror.defineMode("dart", function(conf) {
48 | return CodeMirror.getMode(conf, "application/dart");
49 | }, "clike");
50 | });
51 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/dart/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Dart mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Dart mode
27 |
28 |
29 | import 'dart:math' show Random;
30 |
31 | void main() {
32 | print(new Die(n: 12).roll());
33 | }
34 |
35 | // Define a class.
36 | class Die {
37 | // Define a class variable.
38 | static Random shaker = new Random();
39 |
40 | // Define instance variables.
41 | int sides, value;
42 |
43 | // Define a method using shorthand syntax.
44 | String toString() => '$value';
45 |
46 | // Define a constructor.
47 | Die({int n: 6}) {
48 | if (4 <= n && n <= 20) {
49 | sides = n;
50 | } else {
51 | // Support for errors and exceptions.
52 | throw new ArgumentError(/* */);
53 | }
54 | }
55 |
56 | // Define an instance method.
57 | int roll() {
58 | return value = shaker.nextInt(sides) + 1;
59 | }
60 | }
61 |
62 |
63 |
64 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/diff/diff.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineMode("diff", function() {
15 |
16 | var TOKEN_NAMES = {
17 | '+': 'positive',
18 | '-': 'negative',
19 | '@': 'meta'
20 | };
21 |
22 | return {
23 | token: function(stream) {
24 | var tw_pos = stream.string.search(/[\t ]+?$/);
25 |
26 | if (!stream.sol() || tw_pos === 0) {
27 | stream.skipToEnd();
28 | return ("error " + (
29 | TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
30 | }
31 |
32 | var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
33 |
34 | if (tw_pos === -1) {
35 | stream.skipToEnd();
36 | } else {
37 | stream.pos = tw_pos;
38 | }
39 |
40 | return token_name;
41 | }
42 | };
43 | });
44 |
45 | CodeMirror.defineMIME("text/x-diff", "diff");
46 |
47 | });
48 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/ecl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: ECL mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | ECL mode
27 |
28 | /*
29 | sample useless code to demonstrate ecl syntax highlighting
30 | this is a multiline comment!
31 | */
32 |
33 | // this is a singleline comment!
34 |
35 | import ut;
36 | r :=
37 | record
38 | string22 s1 := '123';
39 | integer4 i1 := 123;
40 | end;
41 | #option('tmp', true);
42 | d := dataset('tmp::qb', r, thor);
43 | output(d);
44 |
45 |
48 |
49 | Based on CodeMirror's clike mode. For more information see HPCC Systems web site.
50 | MIME types defined: text/x-ecl
.
51 |
52 |
53 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/elm/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Elm mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Elm mode
27 |
28 |
29 | import Color exposing (..)
30 | import Graphics.Collage exposing (..)
31 | import Graphics.Element exposing (..)
32 | import Time exposing (..)
33 |
34 | main =
35 | Signal.map clock (every second)
36 |
37 | clock t =
38 | collage 400 400
39 | [ filled lightGrey (ngon 12 110)
40 | , outlined (solid grey) (ngon 12 110)
41 | , hand orange 100 t
42 | , hand charcoal 100 (t/60)
43 | , hand charcoal 60 (t/720)
44 | ]
45 |
46 | hand clr len time =
47 | let angle = degrees (90 - 6 * inSeconds time)
48 | in
49 | segment (0,0) (fromPolar (len,angle))
50 | |> traced (solid clr)
51 |
52 |
53 |
59 |
60 | MIME types defined: text/x-elm
.
61 |
62 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/factor/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Factor mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
18 |
31 |
32 |
33 |
34 | Factor mode
35 |
36 |
37 | ! Copyright (C) 2008 Slava Pestov.
38 | ! See http://factorcode.org/license.txt for BSD license.
39 |
40 | ! A simple time server
41 |
42 | USING: accessors calendar calendar.format io io.encodings.ascii
43 | io.servers kernel threads ;
44 | IN: time-server
45 |
46 | : handle-time-client ( -- )
47 | now timestamp>rfc822 print ;
48 |
49 | : ( -- threaded-server )
50 | ascii
51 | "time-server" >>name
52 | 1234 >>insecure
53 | [ handle-time-client ] >>handler ;
54 |
55 | : start-time-server ( -- )
56 | start-server drop ;
57 |
58 | MAIN: start-time-server
59 |
60 |
61 |
62 |
72 |
73 | Simple mode that handles Factor Syntax (Factor on WikiPedia ).
74 |
75 | MIME types defined: text/x-factor
.
76 |
77 |
78 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/forth/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Forth mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
18 |
31 |
32 |
33 |
34 | Forth mode
35 |
36 |
37 | \ Insertion sort
38 |
39 | : cell- 1 cells - ;
40 |
41 | : insert ( start end -- start )
42 | dup @ >r ( r: v )
43 | begin
44 | 2dup <
45 | while
46 | r@ over cell- @ <
47 | while
48 | cell-
49 | dup @ over cell+ !
50 | repeat then
51 | r> swap ! ;
52 |
53 | : sort ( array len -- )
54 | 1 ?do
55 | dup i cells + insert
56 | loop drop ;
57 |
58 |
59 |
70 |
71 | Simple mode that handle Forth-Syntax (Forth on WikiPedia ).
72 |
73 | MIME types defined: text/x-forth
.
74 |
75 |
76 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/gas/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Gas mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Gas mode
27 |
28 |
29 | .syntax unified
30 | .global main
31 |
32 | /*
33 | * A
34 | * multi-line
35 | * comment.
36 | */
37 |
38 | @ A single line comment.
39 |
40 | main:
41 | push {sp, lr}
42 | ldr r0, =message
43 | bl puts
44 | mov r0, #0
45 | pop {sp, pc}
46 |
47 | message:
48 | .asciz "Hello world! "
49 |
50 |
51 |
52 |
58 |
59 | Handles AT&T assembler syntax (more specifically this handles
60 | the GNU Assembler (gas) syntax.)
61 | It takes a single optional configuration parameter:
62 | architecture
, which can be one of "ARM"
,
63 | "ARMv6"
or "x86"
.
64 | Including the parameter adds syntax for the registers and special
65 | directives for the supplied architecture.
66 |
67 |
MIME types defined: text/x-gas
68 |
69 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/gherkin/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Gherkin mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Gherkin mode
27 |
28 | Feature: Using Google
29 | Background:
30 | Something something
31 | Something else
32 | Scenario: Has a homepage
33 | When I navigate to the google home page
34 | Then the home page should contain the menu and the search form
35 | Scenario: Searching for a term
36 | When I navigate to the google home page
37 | When I search for Tofu
38 | Then the search results page is displayed
39 | Then the search results page contains 10 individual search results
40 | Then the search results contain a link to the wikipedia tofu page
41 |
42 |
45 |
46 | MIME types defined: text/x-feature
.
47 |
48 |
49 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/handlebars/handlebars.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineSimpleMode("handlebars", {
15 | start: [
16 | { regex: /\{\{!--/, push: "dash_comment", token: "comment" },
17 | { regex: /\{\{!/, push: "comment", token: "comment" },
18 | { regex: /\{\{/, push: "handlebars", token: "tag" }
19 | ],
20 | handlebars: [
21 | { regex: /\}\}/, pop: true, token: "tag" },
22 |
23 | // Double and single quotes
24 | { regex: /"(?:[^\\]|\\.)*?"/, token: "string" },
25 | { regex: /'(?:[^\\]|\\.)*?'/, token: "string" },
26 |
27 | // Handlebars keywords
28 | { regex: />|[#\/]([A-Za-z_]\w*)/, token: "keyword" },
29 | { regex: /(?:else|this)\b/, token: "keyword" },
30 |
31 | // Numeral
32 | { regex: /\d+/i, token: "number" },
33 |
34 | // Atoms like = and .
35 | { regex: /=|~|@|true|false/, token: "atom" },
36 |
37 | // Paths
38 | { regex: /(?:\.\.\/)*(?:[A-Za-z_][\w\.]*)+/, token: "variable-2" }
39 | ],
40 | dash_comment: [
41 | { regex: /--\}\}/, pop: true, token: "comment" },
42 |
43 | // Commented code
44 | { regex: /./, token: "comment"}
45 | ],
46 | comment: [
47 | { regex: /\}\}/, pop: true, token: "comment" },
48 | { regex: /./, token: "comment" }
49 | ]
50 | });
51 |
52 | CodeMirror.defineMIME("text/x-handlebars-template", "handlebars");
53 | });
54 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/htmlembedded/htmlembedded.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: http://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
7 | require("../../addon/mode/multiplex"));
8 | else if (typeof define == "function" && define.amd) // AMD
9 | define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
10 | "../../addon/mode/multiplex"], mod);
11 | else // Plain browser env
12 | mod(CodeMirror);
13 | })(function(CodeMirror) {
14 | "use strict";
15 |
16 | CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
17 | return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), {
18 | open: parserConfig.open || parserConfig.scriptStartRegex || "<%",
19 | close: parserConfig.close || parserConfig.scriptEndRegex || "%>",
20 | mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec)
21 | });
22 | }, "htmlmixed");
23 |
24 | CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"});
25 | CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
26 | CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"});
27 | CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"});
28 | });
29 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/htmlembedded/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Html Embedded Scripts mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
29 |
30 |
31 | Html Embedded Scripts mode
32 |
33 | <%
34 | function hello(who) {
35 | return "Hello " + who;
36 | }
37 | %>
38 | This is an example of EJS (embedded javascript)
39 | The program says <%= hello("world") %>.
40 |
43 |
44 |
45 |
53 |
54 | Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
55 | JavaScript, CSS and XML. Other dependancies include those of the scriping language chosen.
56 |
57 | MIME types defined: application/x-aspx
(ASP.NET),
58 | application/x-ejs
(Embedded Javascript), application/x-jsp
(JavaServer Pages)
59 |
60 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/http/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: HTTP mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | HTTP mode
27 |
28 |
29 |
30 | POST /somewhere HTTP/1.1
31 | Host: example.com
32 | If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
33 | Content-Type: application/x-www-form-urlencoded;
34 | charset=utf-8
35 | User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Ubuntu/12.04 Chromium/20.0.1132.47 Chrome/20.0.1132.47 Safari/536.11
36 |
37 | This is the request body!
38 |
39 |
40 |
43 |
44 | MIME types defined: message/http
.
45 |
46 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/idl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: IDL mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | IDL mode
27 |
28 |
29 | ;; Example IDL code
30 | FUNCTION mean_and_stddev,array
31 | ;; This program reads in an array of numbers
32 | ;; and returns a structure containing the
33 | ;; average and standard deviation
34 |
35 | ave = 0.0
36 | count = 0.0
37 |
38 | for i=0,N_ELEMENTS(array)-1 do begin
39 | ave = ave + array[i]
40 | count = count + 1
41 | endfor
42 |
43 | ave = ave/count
44 |
45 | std = stddev(array)
46 |
47 | return, {average:ave,std:std}
48 |
49 | END
50 |
51 |
52 |
62 |
63 | MIME types defined: text/x-idl
.
64 |
65 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/javascript/typescript.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: TypeScript mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | TypeScript mode
27 |
28 |
29 |
30 | class Greeter {
31 | greeting: string;
32 | constructor (message: string) {
33 | this.greeting = message;
34 | }
35 | greet() {
36 | return "Hello, " + this.greeting;
37 | }
38 | }
39 |
40 | var greeter = new Greeter("world");
41 |
42 | var button = document.createElement('button')
43 | button.innerText = "Say Hello"
44 | button.onclick = function() {
45 | alert(greeter.greet())
46 | }
47 |
48 | document.body.appendChild(button)
49 |
50 |
51 |
52 |
59 |
60 | This is a specialization of the JavaScript mode .
61 |
62 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/jinja2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Jinja2 mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Jinja2 mode
27 |
28 | {# this is a comment #}
29 | {%- for item in li -%}
30 | <li>{{ item.label }}</li>
31 | {% endfor -%}
32 | {{ item.sand == true and item.keyword == false ? 1 : 0 }}
33 | {{ app.get(55, 1.2, true) }}
34 | {% if app.get('_route') == ('_home') %}home{% endif %}
35 | {% if app.session.flashbag.has('message') %}
36 | {% for message in app.session.flashbag.get('message') %}
37 | {{ message.content }}
38 | {% endfor %}
39 | {% endif %}
40 | {{ path('_home', {'section': app.request.get('section')}) }}
41 | {{ path('_home', {
42 | 'section': app.request.get('section'),
43 | 'boolean': true,
44 | 'number': 55.33
45 | })
46 | }}
47 | {% include ('test.incl.html.twig') %}
48 |
49 |
54 |
55 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/modelica/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Modelica mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
27 |
28 |
29 | Modelica mode
30 |
31 |
32 | model BouncingBall
33 | parameter Real e = 0.7;
34 | parameter Real g = 9.81;
35 | Real h(start=1);
36 | Real v;
37 | Boolean flying(start=true);
38 | Boolean impact;
39 | Real v_new;
40 | equation
41 | impact = h <= 0.0;
42 | der(v) = if flying then -g else 0;
43 | der(h) = v;
44 | when {h <= 0.0 and v <= 0.0, impact} then
45 | v_new = if edge(impact) then -e*pre(v) else 0;
46 | flying = v_new > 0;
47 | reinit(v, v_new);
48 | end when;
49 | annotation (uses(Modelica(version="3.2")));
50 | end BouncingBall;
51 |
52 |
53 |
62 |
63 | Simple mode that tries to handle Modelica as well as it can.
64 |
65 | MIME types defined: text/x-modelica
66 | (Modlica code).
67 |
68 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/ntriples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: NTriples mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
28 |
29 |
30 | NTriples mode
31 |
32 |
33 | .
34 | "literal 1" .
35 | _:bnode3 .
36 | _:bnode4 "literal 2"@lang .
37 | _:bnode5 "literal 3"^^ .
38 |
39 |
40 |
41 |
44 | MIME types defined: text/n-triples
.
45 |
46 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/octave/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Octave mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Octave mode
27 |
28 |
29 | %numbers
30 | [1234 1234i 1234j]
31 | [.234 .234j 2.23i]
32 | [23e2 12E1j 123D-4 0x234]
33 |
34 | %strings
35 | 'asda''a'
36 | "asda""a"
37 |
38 | %identifiers
39 | a + as123 - __asd__
40 |
41 | %operators
42 | -
43 | +
44 | =
45 | ==
46 | >
47 | <
48 | >=
49 | <=
50 | &
51 | ~
52 | ...
53 | break zeros default margin round ones rand
54 | ceil floor size clear zeros eye mean std cov
55 | error eval function
56 | abs acos atan asin cos cosh exp log prod sum
57 | log10 max min sign sin sinh sqrt tan reshape
58 | return
59 | case switch
60 | else elseif end if otherwise
61 | do for while
62 | try catch
63 | classdef properties events methods
64 | global persistent
65 |
66 | %one line comment
67 | %{ multi
68 | line commment %}
69 |
70 |
71 |
81 |
82 | MIME types defined: text/x-octave
.
83 |
84 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/pascal/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Pascal mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Pascal mode
27 |
28 |
29 |
30 | (* Example Pascal code *)
31 |
32 | while a <> b do writeln('Waiting');
33 |
34 | if a > b then
35 | writeln('Condition met')
36 | else
37 | writeln('Condition not met');
38 |
39 | for i := 1 to 10 do
40 | writeln('Iteration: ', i:1);
41 |
42 | repeat
43 | a := a + 1
44 | until a = 10;
45 |
46 | case i of
47 | 0: write('zero');
48 | 1: write('one');
49 | 2: write('two')
50 | end;
51 |
52 |
53 |
59 |
60 | MIME types defined: text/x-pascal
.
61 |
62 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/pegjs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CodeMirror: PEG.js Mode
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
28 |
29 |
30 | PEG.js Mode
31 |
32 | /*
33 | * Classic example grammar, which recognizes simple arithmetic expressions like
34 | * "2*(3+4)". The parser generated from this grammar then computes their value.
35 | */
36 |
37 | start
38 | = additive
39 |
40 | additive
41 | = left:multiplicative "+" right:additive { return left + right; }
42 | / multiplicative
43 |
44 | multiplicative
45 | = left:primary "*" right:multiplicative { return left * right; }
46 | / primary
47 |
48 | primary
49 | = integer
50 | / "(" additive:additive ")" { return additive; }
51 |
52 | integer "integer"
53 | = digits:[0-9]+ { return parseInt(digits.join(""), 10); }
54 |
55 | letter = [a-z]+
56 |
62 | The PEG.js Mode
63 | Created by Forbes Lindesay.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/perl/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Perl mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Perl mode
27 |
28 |
29 |
30 | #!/usr/bin/perl
31 |
32 | use Something qw(func1 func2);
33 |
34 | # strings
35 | my $s1 = qq'single line';
36 | our $s2 = q(multi-
37 | line);
38 |
39 | =item Something
40 | Example.
41 | =cut
42 |
43 | my $html=<<'HTML'
44 |
45 | hi!
46 |
47 | HTML
48 |
49 | print "first,".join(',', 'second', qq~third~);
50 |
51 | if($s1 =~ m[(?{$1}=$$.' predefined variables';
53 | $s2 =~ s/\-line//ox;
54 | $s1 =~ s[
55 | line ]
56 | [
57 | block
58 | ]ox;
59 | }
60 |
61 | 1; # numbers and comments
62 |
63 | __END__
64 | something...
65 |
66 |
67 |
68 |
73 |
74 | MIME types defined: text/x-perl
.
75 |
76 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/php/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: PHP mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
30 |
31 |
32 | PHP mode
33 |
34 | 1, 'b' => 2, 3 => 'c');
36 |
37 | echo "$a[a] ${a[3] /* } comment */} {$a[b]} \$a[a]";
38 |
39 | function hello($who) {
40 | return "Hello $who!";
41 | }
42 | ?>
43 | The program says = hello("World") ?>.
44 |
47 |
48 |
49 |
58 |
59 | Simple HTML/PHP mode based on
60 | the C-like mode. Depends on XML,
61 | JavaScript, CSS, HTMLMixed, and C-like modes.
62 |
63 | MIME types defined: application/x-httpd-php
(HTML with PHP code), text/x-php
(plain, non-wrapped PHP code).
64 |
65 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/pig/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Pig Latin mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Pig Latin mode
27 |
28 | -- Apache Pig (Pig Latin Language) Demo
29 | /*
30 | This is a multiline comment.
31 | */
32 | a = LOAD "\path\to\input" USING PigStorage('\t') AS (x:long, y:chararray, z:bytearray);
33 | b = GROUP a BY (x,y,3+4);
34 | c = FOREACH b GENERATE flatten(group) as (x,y), SUM(group.$2) as z;
35 | STORE c INTO "\path\to\output";
36 |
37 | --
38 |
39 |
40 |
47 |
48 |
49 | Simple mode that handles Pig Latin language.
50 |
51 |
52 | MIME type defined: text/x-pig
53 | (PIG code)
54 |