├── static
├── index.html
├── js
│ └── script.js
├── CodeMirror
│ ├── doc
│ │ ├── logo.png
│ │ ├── yinyang.png
│ │ ├── activebookmark.js
│ │ └── reporting.html
│ ├── theme
│ │ ├── ambiance-mobile.css
│ │ ├── neat.css
│ │ ├── elegant.css
│ │ ├── neo.css
│ │ ├── eclipse.css
│ │ ├── colorforth.css
│ │ ├── cobalt.css
│ │ ├── rubyblue.css
│ │ ├── night.css
│ │ ├── tomorrow-night-bright.css
│ │ ├── monokai.css
│ │ ├── the-matrix.css
│ │ ├── blackboard.css
│ │ ├── zenburn.css
│ │ ├── 3024-day.css
│ │ ├── paraiso-dark.css
│ │ ├── paraiso-light.css
│ │ ├── 3024-night.css
│ │ ├── mbo.css
│ │ ├── base16-dark.css
│ │ ├── base16-light.css
│ │ ├── vibrant-ink.css
│ │ ├── ttcn.css
│ │ ├── twilight.css
│ │ ├── yeti.css
│ │ └── midnight.css
│ ├── addon
│ │ ├── display
│ │ │ ├── fullscreen.css
│ │ │ ├── fullscreen.js
│ │ │ ├── placeholder.js
│ │ │ └── rulers.js
│ │ ├── search
│ │ │ └── matchesonscrollbar.css
│ │ ├── fold
│ │ │ ├── foldgutter.css
│ │ │ ├── indent-fold.js
│ │ │ ├── markdown-fold.js
│ │ │ └── comment-fold.js
│ │ ├── dialog
│ │ │ └── dialog.css
│ │ ├── hint
│ │ │ ├── show-hint.css
│ │ │ └── anyword-hint.js
│ │ ├── mode
│ │ │ └── multiplex_test.js
│ │ ├── lint
│ │ │ ├── yaml-lint.js
│ │ │ ├── json-lint.js
│ │ │ ├── css-lint.js
│ │ │ └── coffeescript-lint.js
│ │ ├── edit
│ │ │ ├── trailingspace.js
│ │ │ └── continuelist.js
│ │ ├── tern
│ │ │ ├── worker.js
│ │ │ └── tern.css
│ │ ├── runmode
│ │ │ └── colorize.js
│ │ └── scroll
│ │ │ ├── simplescrollbars.css
│ │ │ └── scrollpastend.js
│ └── mode
│ │ ├── tiddlywiki
│ │ └── tiddlywiki.css
│ │ ├── ruby
│ │ └── test.js
│ │ ├── tiki
│ │ ├── tiki.css
│ │ └── index.html
│ │ ├── clike
│ │ └── test.js
│ │ ├── diff
│ │ └── diff.js
│ │ ├── asciiarmor
│ │ └── index.html
│ │ ├── htmlembedded
│ │ ├── htmlembedded.js
│ │ └── index.html
│ │ ├── ntriples
│ │ └── index.html
│ │ ├── twig
│ │ └── index.html
│ │ ├── spreadsheet
│ │ └── index.html
│ │ ├── http
│ │ └── index.html
│ │ ├── solr
│ │ └── index.html
│ │ ├── ecl
│ │ └── index.html
│ │ ├── rust
│ │ └── index.html
│ │ ├── z80
│ │ └── index.html
│ │ ├── turtle
│ │ └── index.html
│ │ ├── pascal
│ │ └── index.html
│ │ ├── pig
│ │ └── index.html
│ │ ├── vbscript
│ │ └── index.html
│ │ ├── gherkin
│ │ └── index.html
│ │ ├── properties
│ │ └── index.html
│ │ ├── javascript
│ │ └── typescript.html
│ │ ├── sass
│ │ └── index.html
│ │ ├── perl
│ │ └── index.html
│ │ ├── elm
│ │ └── index.html
│ │ ├── idl
│ │ └── index.html
│ │ ├── dart
│ │ ├── index.html
│ │ └── dart.js
│ │ ├── handlebars
│ │ └── handlebars.js
│ │ ├── xml
│ │ ├── test.js
│ │ └── index.html
│ │ ├── jinja2
│ │ └── index.html
│ │ ├── shell
│ │ ├── test.js
│ │ └── index.html
│ │ ├── sparql
│ │ └── index.html
│ │ ├── tornado
│ │ └── index.html
│ │ ├── css
│ │ ├── less_test.js
│ │ └── index.html
│ │ ├── forth
│ │ └── index.html
│ │ ├── gas
│ │ └── index.html
│ │ ├── toml
│ │ └── index.html
│ │ ├── octave
│ │ └── index.html
│ │ ├── pegjs
│ │ └── index.html
│ │ ├── cypher
│ │ └── index.html
│ │ ├── smalltalk
│ │ └── index.html
│ │ ├── soy
│ │ └── index.html
│ │ ├── php
│ │ └── index.html
│ │ ├── modelica
│ │ └── index.html
│ │ └── factor
│ │ └── index.html
└── css
│ └── styles.css
├── .gitignore
├── .gitattributes
├── conf
└── app.conf
├── views
├── sidebar
│ ├── showcategories.tpl
│ └── recently_solved_by.tpl
├── errorHead.tpl
├── problem
│ ├── list.tpl
│ ├── addtest.tpl
│ ├── create.tpl
│ └── show.tpl
├── login.html
├── user
│ ├── show.tpl
│ └── login.tpl
├── testExec.html
└── layout.tpl
├── Judge
├── lxcmain.go
└── Listener.go
├── lxcWebPanel.bash
├── restart.bash
├── startJudge.bash
├── main.go
├── controllers
├── BaseController.go
└── Admin.go
├── lxcSetup.bash
├── README.md
├── models
├── contest.go
├── ContestScore.go
├── ProblemLogs.go
├── Verify.go
├── TestCases.go
├── Exec.go
├── Score.go
└── Models.go
├── tests
└── default_test.go
├── LICENSE.md
├── routers
└── router.go
└── firstSetup.bash
/static/index.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/js/script.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | tests
2 | OnlineJudge
3 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | static/* linguist-vendored
2 |
--------------------------------------------------------------------------------
/conf/app.conf:
--------------------------------------------------------------------------------
1 | appname = OnlineJudge
2 | httpport = 8080
3 | runmode = dev
4 | copyrequestbody = true
--------------------------------------------------------------------------------
/static/CodeMirror/doc/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jronak/OnlineJudge/HEAD/static/CodeMirror/doc/logo.png
--------------------------------------------------------------------------------
/static/CodeMirror/doc/yinyang.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jronak/OnlineJudge/HEAD/static/CodeMirror/doc/yinyang.png
--------------------------------------------------------------------------------
/views/sidebar/showcategories.tpl:
--------------------------------------------------------------------------------
1 |
Categories
2 | {{range $key, $val := .types}}
3 | {{.}}
4 | {{end}}
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/static/CodeMirror/theme/ambiance-mobile.css:
--------------------------------------------------------------------------------
1 | .cm-s-ambiance.CodeMirror {
2 | -webkit-box-shadow: none;
3 | -moz-box-shadow: none;
4 | box-shadow: none;
5 | }
6 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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"
--------------------------------------------------------------------------------
/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"
--------------------------------------------------------------------------------
/views/errorHead.tpl:
--------------------------------------------------------------------------------
1 |
2 | {{.flash.error}}
3 | {{.flash.warning}}
4 | {{.flash.notice}}
5 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/views/sidebar/recently_solved_by.tpl:
--------------------------------------------------------------------------------
1 | Recently Solved by
2 | {{ if .recentlySolvedUsersExist }}
3 | {{range $key, $val := .recentlySolvedUsers}}
4 | {{.Username}}
5 | {{end}}
6 | {{ else }}
7 | Be the first to solve!
8 | {{ end }}
9 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/tiddlywiki/tiddlywiki.css:
--------------------------------------------------------------------------------
1 | span.cm-underlined {
2 | text-decoration: underline;
3 | }
4 | span.cm-strikethrough {
5 | text-decoration: line-through;
6 | }
7 | span.cm-brace {
8 | color: #170;
9 | font-weight: bold;
10 | }
11 | span.cm-table {
12 | color: blue;
13 | font-weight: bold;
14 | }
15 |
--------------------------------------------------------------------------------
/views/problem/list.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{range $key, $val := .problems}}
4 |
5 |
6 |
Type: {{.Type}}Difficulty: {{.Difficulty}}Solved by: {{.Solve_count}}Created: {{.Created_at}}
7 |
8 | {{end}}
9 |
--------------------------------------------------------------------------------
/views/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Online Judge
5 |
6 |
7 |
13 | {{.error}}
14 |
15 |
--------------------------------------------------------------------------------
/views/user/show.tpl:
--------------------------------------------------------------------------------
1 |
2 |
{{.userDetails.Name}} @{{.userDetails.Username}}
3 |
4 | Score: {{.userDetails.Score}}
5 | College: {{.userDetails.College}}
6 |
7 |
8 |
Problems Solved
9 | {{ if .solvedProblemsExist }}
10 | {{range $key, $val := .solvedProblems}}
11 |
{{.Statement}}
12 | {{end}}
13 | {{ else }}
14 |
Not solved any yet.
15 | {{ end }}
16 |
17 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/ruby/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}, "ruby");
6 | function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
7 |
8 | MT("divide_equal_operator",
9 | "[variable bar] [operator /=] [variable foo]");
10 |
11 | MT("divide_equal_operator_no_spacing",
12 | "[variable foo][operator /=][number 42]");
13 |
14 | })();
15 |
--------------------------------------------------------------------------------
/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/mode/tiki/tiki.css:
--------------------------------------------------------------------------------
1 | .cm-tw-syntaxerror {
2 | color: #FFF;
3 | background-color: #900;
4 | }
5 |
6 | .cm-tw-deleted {
7 | text-decoration: line-through;
8 | }
9 |
10 | .cm-tw-header5 {
11 | font-weight: bold;
12 | }
13 | .cm-tw-listitem:first-child { /*Added first child to fix duplicate padding when highlighting*/
14 | padding-left: 10px;
15 | }
16 |
17 | .cm-tw-box {
18 | border-top-width: 0px ! important;
19 | border-style: solid;
20 | border-width: 1px;
21 | border-color: inherit;
22 | }
23 |
24 | .cm-tw-underline {
25 | text-decoration: underline;
26 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | }
--------------------------------------------------------------------------------
/views/testExec.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Yo
5 |
6 |
7 |
24 |
25 |
--------------------------------------------------------------------------------
/static/CodeMirror/theme/neat.css:
--------------------------------------------------------------------------------
1 | .cm-s-neat span.cm-comment { color: #a86; }
2 | .cm-s-neat span.cm-keyword { line-height: 1em; font-weight: bold; color: blue; }
3 | .cm-s-neat span.cm-string { color: #a22; }
4 | .cm-s-neat span.cm-builtin { line-height: 1em; font-weight: bold; color: #077; }
5 | .cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
6 | .cm-s-neat span.cm-variable { color: black; }
7 | .cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
8 | .cm-s-neat span.cm-meta {color: #555;}
9 | .cm-s-neat span.cm-link { color: #3a3; }
10 |
11 | .cm-s-neat .CodeMirror-activeline-background {background: #e8f2ff !important;}
12 | .cm-s-neat .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
13 |
--------------------------------------------------------------------------------
/static/CodeMirror/theme/elegant.css:
--------------------------------------------------------------------------------
1 | .cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
2 | .cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
3 | .cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
4 | .cm-s-elegant span.cm-variable {color: black;}
5 | .cm-s-elegant span.cm-variable-2 {color: #b11;}
6 | .cm-s-elegant span.cm-qualifier {color: #555;}
7 | .cm-s-elegant span.cm-keyword {color: #730;}
8 | .cm-s-elegant span.cm-builtin {color: #30a;}
9 | .cm-s-elegant span.cm-link {color: #762;}
10 | .cm-s-elegant span.cm-error {background-color: #fdd;}
11 |
12 | .cm-s-elegant .CodeMirror-activeline-background {background: #e8f2ff !important;}
13 | .cm-s-elegant .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
14 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/views/user/login.tpl:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/views/problem/addtest.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{range $key, $val := .cases}}
5 |
6 |
Input:
{{str2html (.Input | n2br)}}
7 | Output:
{{str2html (.Output | n2br)}}
8 | Timeout:
{{.Timeout}}
9 |
10 |
11 | {{end}}
12 |
Create Test Case
13 |
24 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/tests/default_test.go:
--------------------------------------------------------------------------------
1 | package test
2 |
3 | import (
4 | "net/http"
5 | "net/http/httptest"
6 | "testing"
7 | "runtime"
8 | "path/filepath"
9 | _ "OnlineJudge/routers"
10 |
11 | "github.com/astaxie/beego"
12 | . "github.com/smartystreets/goconvey/convey"
13 | )
14 |
15 | func init() {
16 | _, file, _, _ := runtime.Caller(1)
17 | apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
18 | beego.TestBeegoInit(apppath)
19 | }
20 |
21 |
22 | // TestMain is a sample to run an endpoint test
23 | func TestMain(t *testing.T) {
24 | r, _ := http.NewRequest("GET", "/", nil)
25 | w := httptest.NewRecorder()
26 | beego.BeeApp.Handlers.ServeHTTP(w, r)
27 |
28 | beego.Trace("testing", "TestMain", "Code[%d]\n%s", w.Code, w.Body.String())
29 |
30 | Convey("Subject: Test Station Endpoint\n", t, func() {
31 | Convey("Status Code Should Be 200", func() {
32 | So(w.Code, ShouldEqual, 200)
33 | })
34 | Convey("The Result Should Not Be Empty", func() {
35 | So(w.Body.Len(), ShouldBeGreaterThan, 0)
36 | })
37 | })
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/static/CodeMirror/theme/neo.css:
--------------------------------------------------------------------------------
1 | /* neo theme for codemirror */
2 |
3 | /* Color scheme */
4 |
5 | .cm-s-neo.CodeMirror {
6 | background-color:#ffffff;
7 | color:#2e383c;
8 | line-height:1.4375;
9 | }
10 | .cm-s-neo .cm-comment {color:#75787b}
11 | .cm-s-neo .cm-keyword, .cm-s-neo .cm-property {color:#1d75b3}
12 | .cm-s-neo .cm-atom,.cm-s-neo .cm-number {color:#75438a}
13 | .cm-s-neo .cm-node,.cm-s-neo .cm-tag {color:#9c3328}
14 | .cm-s-neo .cm-string {color:#b35e14}
15 | .cm-s-neo .cm-variable,.cm-s-neo .cm-qualifier {color:#047d65}
16 |
17 |
18 | /* Editor styling */
19 |
20 | .cm-s-neo pre {
21 | padding:0;
22 | }
23 |
24 | .cm-s-neo .CodeMirror-gutters {
25 | border:none;
26 | border-right:10px solid transparent;
27 | background-color:transparent;
28 | }
29 |
30 | .cm-s-neo .CodeMirror-linenumber {
31 | padding:0;
32 | color:#e0e2e5;
33 | }
34 |
35 | .cm-s-neo .CodeMirror-guttermarker { color: #1d75b3; }
36 | .cm-s-neo .CodeMirror-guttermarker-subtle { color: #e0e2e5; }
37 |
38 | .cm-s-neo div.CodeMirror-cursor {
39 | width: auto;
40 | border: 0;
41 | background: rgba(155,157,162,0.37);
42 | z-index: 1;
43 | }
44 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/static/CodeMirror/theme/eclipse.css:
--------------------------------------------------------------------------------
1 | .cm-s-eclipse span.cm-meta {color: #FF1717;}
2 | .cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
3 | .cm-s-eclipse span.cm-atom {color: #219;}
4 | .cm-s-eclipse span.cm-number {color: #164;}
5 | .cm-s-eclipse span.cm-def {color: #00f;}
6 | .cm-s-eclipse span.cm-variable {color: black;}
7 | .cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
8 | .cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
9 | .cm-s-eclipse span.cm-property {color: black;}
10 | .cm-s-eclipse span.cm-operator {color: black;}
11 | .cm-s-eclipse span.cm-comment {color: #3F7F5F;}
12 | .cm-s-eclipse span.cm-string {color: #2A00FF;}
13 | .cm-s-eclipse span.cm-string-2 {color: #f50;}
14 | .cm-s-eclipse span.cm-qualifier {color: #555;}
15 | .cm-s-eclipse span.cm-builtin {color: #30a;}
16 | .cm-s-eclipse span.cm-bracket {color: #cc7;}
17 | .cm-s-eclipse span.cm-tag {color: #170;}
18 | .cm-s-eclipse span.cm-attribute {color: #00c;}
19 | .cm-s-eclipse span.cm-link {color: #219;}
20 | .cm-s-eclipse span.cm-error {color: #f00;}
21 |
22 | .cm-s-eclipse .CodeMirror-activeline-background {background: #e8f2ff !important;}
23 | .cm-s-eclipse .CodeMirror-matchingbracket {outline:1px solid grey; color:black !important;}
24 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/views/problem/create.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Create Problem
4 |
27 |
--------------------------------------------------------------------------------
/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/css/styles.css:
--------------------------------------------------------------------------------
1 | /* General Styles */
2 | .center {
3 | text-align: center;
4 | }
5 | a {
6 | color: #2F4C84;
7 | text-decoration: none;
8 | }
9 | a:hover {
10 | text-decoration: underline;
11 | }
12 | .margin-15 {
13 | margin: 15px 0;
14 | }
15 | .left {
16 | display: block;
17 | float: left;
18 | }
19 | .right {
20 | display: inline-block;
21 | float: right;
22 | }
23 | .bottom-border {
24 | border-bottom: solid 1px #DDD;
25 | }
26 |
27 | /* All-through pages styles */
28 | #logo a {
29 | color: #000;
30 | text-decoration: none;
31 | }
32 | #header h1 {
33 | margin: 10px 0;
34 | }
35 | .login-button {
36 | padding: 18px 0;
37 | font-size: 14px;
38 | text-align: center;
39 | background-color: #F2F2F2;
40 | }
41 | .login-button:hover {
42 | background-color: #F8F8F8;
43 | }
44 | #content, #sidebar {
45 | margin: 10px 0 20px 0;
46 | border: solid 1px #F0F0F0;
47 | padding: 5px 10px;
48 | }
49 |
50 | /* List Page */
51 | .problems-list {
52 | margin: 15px 0;
53 | background-color: #F9F9F9;
54 | }
55 |
56 | .problem {
57 | padding: 5px;
58 | border-bottom: solid 1px #DDD;
59 | }
60 | .problem:hover {
61 | border: solid 1px #DDD;
62 | padding-left: 4px;
63 | }
64 |
65 | .problem span {
66 | margin-right: 20px;
67 | }
68 |
69 |
70 | /* Problem Page */
71 | .problem-details {
72 | margin: 15px;
73 | }
74 |
75 | .write-code {
76 | margin-top: 50px;
77 | margin-left: 20px;
78 | }
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/views/layout.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{.title}} | OnlineJudge
5 |
6 |
7 |
8 |
9 |
10 | {{ .HtmlHead }}
11 |
12 |
13 |
14 |
15 |
32 |
33 |
34 |
35 | {{ .ErrorHead }}
36 |
37 |
38 |
39 | {{ .LayoutContent }}
40 |
41 |
42 |
43 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/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 | "
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/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/ntriples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: NTriples mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
28 |
29 |
30 | NTriples mode
31 |
40 |
41 |
44 | MIME types defined: text/n-triples.
45 |
46 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/twig/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Twig mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Twig mode
27 |
40 |
45 |
46 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/spreadsheet/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Spreadsheet mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
25 |
26 |
27 | Spreadsheet mode
28 |
29 |
30 |
37 |
38 | MIME types defined: text/x-spreadsheet.
39 |
40 | The Spreadsheet Mode
41 | Created by Robert Plummer
42 |
43 |
--------------------------------------------------------------------------------
/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 |
39 |
40 |
43 |
44 | MIME types defined: message/http.
45 |
46 |
--------------------------------------------------------------------------------
/views/problem/show.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
{{.problem.Statement}}
4 |
Problem Description{{ if .isEditor }}+{{ end }}
{{str2html (.problem.Description | n2br)}}
5 |
Constraints
{{str2html (.problem.Constraints | n2br)}}
6 |
Sample Input
{{str2html (.problem.Sample_input | n2br)}}
7 |
Sample Output
{{str2html (.problem.Sample_output | n2br)}}
8 |
9 |
28 |
29 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/solr/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Solr mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
20 |
33 |
34 |
35 | Solr mode
36 |
37 |
38 |
47 |
48 |
49 |
55 |
56 | MIME types defined: text/x-solr.
57 |
58 |
--------------------------------------------------------------------------------
/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 |
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/rust/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Rust mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Rust mode
27 |
28 |
29 |
52 |
53 |
58 |
59 | MIME types defined: text/x-rustsrc.
60 |
61 |
--------------------------------------------------------------------------------
/static/CodeMirror/mode/z80/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Z80 assembly mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Z80 assembly mode
27 |
28 |
29 |
45 |
46 |
51 |
52 | MIME types defined: text/x-z80, text/x-ez80.
53 |
54 |
--------------------------------------------------------------------------------
/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/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/mode/turtle/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeMirror: Turtle mode
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
24 |
25 |
26 | Turtle mode
27 |
41 |
47 |
48 | MIME types defined: text/turtle.
49 |
50 |
51 |
--------------------------------------------------------------------------------
/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/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 |
52 |
53 |
59 |
60 | MIME types defined: text/x-pascal.
61 |
62 |
--------------------------------------------------------------------------------
/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 |
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 |