You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/11/29 16:14:57 UTC
[2/9] removed codemirror sources and added dependency to the
codemirror webjar TODO: Update L&N
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/ldpath.html
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/ldpath.html b/extras/webjars/codemirror/src/main/resources/ldpath.html
deleted file mode 100644
index 4a0ea12..0000000
--- a/extras/webjars/codemirror/src/main/resources/ldpath.html
+++ /dev/null
@@ -1,246 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!doctype html>
-<html>
-<head>
-<title>CodeMirror: LDPath Demo</title>
-<link rel="stylesheet" href="codemirror.css">
-<link rel="stylesheet" href="simple-hint.css">
-
-<script type="text/javascript" src="../../../webjars/jquery/1.8.2/jquery.min.js"></script>
-
-<script src="codemirror.js"></script>
-<script src="simple-hint.js"></script>
-<script src="ldpath.js"></script>
-
-<link rel="stylesheet" href="ldpath.css">
-
-<style type="text/css">
-.CodeMirror {
- border: 1px solid #eee;
-}
-
-td {
- padding-right: 20px;
-}
-body {
- font-family: Droid Sans, Arial, sans-serif;
- line-height: 1.5;
- max-width: 64.3em;
- margin: 3em auto;
- padding: 0 1em;
-}
-
-h1 {
- letter-spacing: -3px;
- font-size: 3.23em;
- font-weight: bold;
- margin: 0;
-}
-
-h2 {
- font-size: 1.23em;
- font-weight: bold;
- margin: .5em 0;
- letter-spacing: -1px;
-}
-
-h3 {
- font-size: 1em;
- font-weight: bold;
- margin: .4em 0;
-}
-
-pre {
- background-color: #eee;
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
- border-radius: 6px;
- padding: 1em;
-}
-
-pre.code {
- margin: 0 1em;
-}
-
-.grey {
- font-size: 2.2em;
- padding: .5em 1em;
- line-height: 1.2em;
- margin-top: .5em;
- position: relative;
-}
-
-img.logo {
- position: absolute;
- right: -25px;
- bottom: 4px;
-}
-
-a:link, a:visited, .quasilink {
- color: #df0019;
- cursor: pointer;
- text-decoration: none;
-}
-
-a:hover, .quasilink:hover {
- color: #800004;
-}
-
-h1 a:link, h1 a:visited, h1 a:hover {
- color: black;
-}
-
-ul {
- margin: 0;
- padding-left: 1.2em;
-}
-
-a.download {
- color: white;
- background-color: #df0019;
- width: 100%;
- display: block;
- text-align: center;
- font-size: 1.23em;
- font-weight: bold;
- text-decoration: none;
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
- border-radius: 6px;
- padding: .5em 0;
- margin-bottom: 1em;
-}
-
-a.download:hover {
- background-color: #bb0010;
-}
-
-.rel {
- margin-bottom: 0;
-}
-
-.rel-note {
- color: #777;
- font-size: .9em;
- margin-top: .1em;
-}
-
-.logo-braces {
- color: #df0019;
- position: relative;
- top: -4px;
-}
-
-.blk {
- float: left;
-}
-
-.left {
- width: 37em;
- padding-right: 6.53em;
- padding-bottom: 1em;
-}
-
-.left1 {
- width: 15.24em;
- padding-right: 6.45em;
-}
-
-.left2 {
- width: 15.24em;
-}
-
-.right {
- width: 20.68em;
-}
-
-.leftbig {
- width: 42.44em;
- padding-right: 6.53em;
-}
-
-.rightsmall {
- width: 15.24em;
-}
-
-.clear:after {
- visibility: hidden;
- display: block;
- font-size: 0;
- content: " ";
- clear: both;
- height: 0;
-}
-.clear { display: inline-block; }
-/* start commented backslash hack \*/
-* html .clear { height: 1%; }
-.clear { display: block; }
-/* close commented backslash hack */
-</style>
-</head>
-<body>
- <h1>CodeMirror: LDPath demo</h1>
- <div>
- Read about the <a href="http://marmotta.incubator.apache.org/ldpath/language.html" title="LDPath">LDPath Syntax</a>
- in <a href="http://marmotta.incubator.apache.org/">Apache Marmotta</a>.
- </div>
- <div>
- <button onclick="javascript:createEditor()">Editor</button>
- <button onclick="javascript:removeEditor()">Plain</button>
- </div>
- <form>
- <textarea id="code" name="code">
-@prefix iptc : <http://iptc.org/std/nar/2006-10-01/> ;
-@prefix foaf ;
-@prefix rss: ;
-@prefix sioc: ;
-@filter rdf:type is rss:item | rdf:type is isig:WebPage | rdf:type is sioc:Post ;
- date = dc:date :: xsd:date(multiValued="false") ;
- desc = dc:description[@de] :: lmf:text_en ;
- feed = (^rss:items / rss:title | (page:partOf | sioc:has_container / dc:title)) :: xsd:string ;
- lang = fn:first(^rss:items / dc:language, "de") :: xsd:string ;
- summary = fn:removeTags((rss:description | dc:description)) :: lmf:text_en ;
- title = (rss:title | (html:title | dc:title)) :: lmf:text_en ;
- user = dc:creator :: xsd:string(multiValue="false") ;
-</textarea>
- </form>
- <script>
- var editor = null;
- function createEditor() {
- if (editor === null) {
- editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- lineNumbers : true,
- matchBrackets : true,
- extraKeys: {"Ctrl-Space": "ldpathAutocomplete"},
- mode : "ldpath"
- });
- }
- }
- function removeEditor() {
- if (editor) {
- editor.toTextArea();
- editor = null;
- }
- }
- createEditor();
- </script>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/ldpath.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/ldpath.js b/extras/webjars/codemirror/src/main/resources/ldpath.js
deleted file mode 100644
index a5eb1a4..0000000
--- a/extras/webjars/codemirror/src/main/resources/ldpath.js
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-if (CodeMirror && CodeMirror.defineMode) {
-CodeMirror.defineMode("ldpath", function(config, parserConfig) {
- var token = {
- COMMENT: "comment",
- OP: "operator",
- KWD: "keyword",
- PREFIX: "qualifier",
- IDENT: "atom",
- DEF: "builtin",
- TEST: "meta",
- URL: "link",
- STR: "string",
- INT: "number",
- BRACKET: "bracket",
- WARNING: "string-2",
- ERROR: "error"
- },
- predefinedNamespaces = parserConfig.namespaces || {},
- baseURL = parserConfig.baseURL || null;
-
- function log(stream, status, result) {
- return;
- if (console && console.log) {
- console.log(stream.current() + " := " + result + " (-> " + status.current() + ")");
- }
- }
-
- function getInitialState() {
- return {
- tmp: {},
- namespaces: {},
- predefinedNamespaces: predefinedNamespaces,
- lmfBaseURL: baseURL,
- stack: ['default'],
- /* STACKING */
- push: function(next) {
- this.stack.unshift(next);
- },
- pop: function() {
- if (this.stack.length <= 1) {
- return this.current();
- } else {
- return this.stack.shift();
- }
- },
- current: function() {
- return this.stack[0];
- },
- reset: function() {
- this.stack = ['default'];
- this.tmp = {};
- },
- height: function() {
- return this.stack.length;
- },
- /* PARSING */
- parser: function(stream, state) {
- var parser = parsers[this.current()] || parsers['default'];
- return parser(stream, state);
- },
- /* NAMESPACES */
- addPrefix: function(prefix, namespace) {
- if (prefix && namespace)
- this.namespaces[prefix] = namespace;
- },
- getNamespace: function(prefix) {
- return this.namespaces[prefix] || this.predefinedNamespaces[prefix];
- }
- };
- }
-
- function tokenError(stream, state) {
- if (state.current() !== 'error') state.push('error');
- stream.skipToEnd();
- return token.ERROR;
- }
-
- function tokenDefault(stream, state) {
- // /* ... */
- if (stream.match('/*')) {
- state.push('comment');
- return token.COMMENT;
- }
-
- // @...
- var kw = stream.match(/^@(\w+)/, true);
- if (kw) {
- state.push(kw[1]);
- return token.KWD;
- }
-
- // <URL>
- if (stream.eat('<')) {
- state.push('url');
- return token.BRACKET;
- }
- if (stream.eat('[')) {
- state.push('test');
- return token.BRACKET;
- }
- if (stream.eat('(')) {
- if (state.current() == "transformer") {
- state.push('config');
- }
- return token.BRACKET;
- }
- if (stream.eat(')')) {
- if (state.current() == "config") {
- state.pop();
- }
- return token.BRACKET;
- }
- if (stream.eat(/[\]>\{\}]/)) {
- return token.BRACKET;
- }
-
- // prefix:label
- if (stream.match(/^\w+:\w*/, false)) {
- stream.skipTo(":")
- if (state.current() == 'prefix') {
- state.tmp["prefix"] = stream.current();
- return token.PREFIX;
- } else {
- px = stream.current();
- stream.eat(':');
- if (state.getNamespace(px))
- return token.PREFIX;
- else return token.WARNING;
- }
- }
-
- if (stream.match("=", true)) {
- if (state.current() == "default") {
- state.push("path");
- }
- return token.DEF;
- }
- if (stream.match("::", true)) {
- state.push("transformer");
- return token.DEF;
- }
- // OPERATORS
- if (stream.eat(/[:,&\|\/^\+\*.]/)) {
- return token.OP;
- }
-
- if (stream.eat('"')) {
- if (stream.skipTo('"') && stream.eat('"'))
- return token.STR;
- return tokenError(stream, state);
- }
-
- // NUMBERS
- if (stream.match(/^\d+/, true)) {
- return token.INT;
- }
-
- // IDENT
- if (state.current() == "prefix") {
- if (stream.match(/^\w+/, true)) {
- state.tmp["prefix"] = stream.current();
- return token.PREFIX;
- }
- } else {
- if (stream.match(/^[\w.-]+/, true)) {
- return token.IDENT;
- }
- }
-
- return tokenError(stream, state);
- }
-
- function tokenURL(stream, state) {
- if (stream.eat('>')) {
- state.pop();
- return token.BRACKET;
- }
- if (stream.skipTo('>')) {
- //state.pop();
- var url = stream.current();
- if (url.search(/^https?:\/\//) < 0 || url.search(/\s/) >= 0) {
- return token.ERROR;
- }
- if (state.stack.indexOf("prefix") >= 0) {
- state.tmp["ns"] = url;
- }
- return token.URL;
- }
- return tokenError(stream, state);
- }
-
- function tokenTest(stream, state) {
- if (stream.eat(']')) {
- state.pop();
- return token.BRACKET;
- }
- if (stream.match(/@\w+/, true) || stream.match("^^", true)) {
- return token.TEST;
- }
- if (stream.match("is-a", true)) {
- return token.TEST;
- }
- if (stream.match("is ", false)) {
- stream.match("is", true);
- return token.TEST;
- }
- if (stream.eat(/[&\|]/)) {
- return token.TEST;
- }
- return tokenDefault(stream, state);
- }
-
- var parsers = {
- 'default': tokenDefault,
- filter: tokenTest,
- url: tokenURL,
- test: tokenTest,
- error: tokenError
- }
-
-
- return {
- startState: getInitialState,
- compareStates: function(state1, state2) {
- return state1.stack == state2.stack && state1.namespaces == state2.namespaces;
- },
- token: function(stream, state) {
- // parse comments
- if (state.current() == "comment") {
- stream.skipTo('*') || stream.skipToEnd();
- if (stream.match('*/')) {
- state.pop();
- } else stream.eat('*');
- return token.COMMENT;
- } else if (stream.match('/*')) {
- state.tmp.commentStart = stream.column();
- state.push("comment");
- return this.token(stream, state);
- }
- // ignore spaces
- if (stream.eatSpace()) return null;
- // ; starts parsing from scratch
- if (stream.eat(';')) {
- if (state.current() == "prefix") {
- state.addPrefix(state.tmp['prefix'], state.tmp['ns']);
- }
- log(stream, state, "RESET");
- state.reset();
- return token.OP;
- }
- var result = state.parser(stream, state);
- log(stream, state, result);
- return result;
- },
- electricChars: "/@=[];",
- indent: function(state, textAfter) {
- switch (state.current()) {
- case 'comment':
- return state.tmp.commentStart +(textAfter.search(/^\s*\*\//)==0?1:3);
- break;
- case 'test':
- case 'filter':
- return 2 * config.indentUnit;
- break;
- case 'default':
- // no indent for @prefix etc...
- if (textAfter.search(/^\s*@/) == 0) {
- return 0;
- }
- return config.indentUnit;
- break;
- }
- return 0;
- }
- }
-});
-
-// Autocompletion
-if (CodeMirror.simpleHint && jQuery) {
- function completePrefix(editor, cur, token) {
- var line = editor.getLine(cur.line);
- var match = line.match(/(^|;)\s*@prefix\s+(\w+)\s*(:\s*<?)?(;|$)/);
- if (match && match[2] && match[2] !== "") {
- var prefix = match[2], result;
- try {
- jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/prefix", {
- async: false,
- data: {prefix: prefix},
- success: function(data) {
- result = data[prefix];
- },
- dataType: "json"
- });
- } catch (e) {}
- if (result !== undefined) {
- var pfx = line.substr(0,cur.ch);
- var st = pfx.search(/\s*(:\s*<?)?$/);
- return {
- list: [ ": <"+result+">;" ],
- from: {line: cur.line, ch: st},
- to: cur
- };
- }
- }
- return false;
- }
- function completeURI(editor, cur, token) {
- var bC = token.string.substr(0, cur.ch - token.start),
- aC = token.string.substr(cur.ch - token.start),
- replUntil = token.state.current()=='url'?token.end+1:cur.ch + Math.max(aC.search(/[\s]/), 0);
-
- var suggestions;
- try {
- var qs = {};
- if (token.state.stack.indexOf("transformer") >= 0) qs['mode'] = "transformer";
- for (var n in token.state.namespaces) {
- qs['ns_'+n] = token.state.getNamespace(n);
- }
- qs['uri'] = bC;
-
- jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/complete", {
- async: false,
- data: qs,
- success: function(data) {
- suggestions = data;
- },
- dataType: "json"
- });
- } catch (e) {}
- if (suggestions !== undefined) {
- for (var i = 0; i < suggestions.length; i++) {
- if (suggestions[i].match(/^\w+:\w+$/)) {
- // curie!
- suggestions[i] = suggestions[i] + " ";
- } else {
- suggestions[i] = "<" + suggestions[i] + "> ";
- }
- }
- return {
- list: suggestions,
- from: {line: cur.line, ch: token.start - 1},
- to: {line: cur.line, ch: replUntil}
- };
- }
- return false;
- }
- function completeCUIE(editor, cur, token) {
- var from = token.start,
- to = token.end,
- req = token.string.substr(0, cur.ch - token.start);
- var prevToken = editor.getTokenAt({line: cur.line, ch: token.start});
- if (token.className == 'atom' && prevToken.className == 'qualifier') {
- from = prevToken.start;
- req = prevToken.string + req;
- }
-
- var suggestions;
- try {
- var qs = {};
- if (token.state.stack.indexOf("transformer") >= 0) qs['mode'] = "transformer";
- for (var n in token.state.namespaces) {
- qs['ns_'+n] = token.state.getNamespace(n);
- }
- qs['prefix'] = req;
-
- jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/complete", {
- async: false,
- data: qs,
- success: function(data) {
- suggestions = data;
- },
- dataType: "json"
- });
- } catch (e) {}
- if (suggestions !== undefined) {
- for (var i = 0; i < suggestions.length; i++) {
- if (suggestions[i].match(/^\w+:\w+(\(\))?$/)) {
- // curie!
- suggestions[i] = suggestions[i] + " ";
- } else {
- // prefix only
- suggestions[i] = suggestions[i] + ":";
- }
- }
- return {
- list: suggestions,
- from: {line: cur.line, ch: from},
- to: {line: cur.line, ch: to}
- };
- }
-
- return false;
- }
- function insertPrefixDef(editor, cur, token) {
- var prefix = token.string.replace(/:?$/, ""), result;
- try {
- jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/prefix", {
-// jQuery.ajax("http://prefix.cc/" + prefix + ".file.json", {
- async: false,
- data: {prefix: prefix},
- success: function(data) {
- result = data[prefix];
- },
- dataType: "json"
- });
- } catch (e) {}
- if (result !== undefined) {
- // check if this url is already prefixed
- var px;
- for (var i in token.state.namespaces) {
- if (token.state.namespaces[i] == result) {
- px = i;
- break;
- }
- }
- if (px) {
- return {
- list: [ px + ":" ],
- from: { line: cur.line, ch: token.start },
- to: { line: cur.line, ch: token.end }
- };
- } else {
- return {
- list: [ "@prefix " + prefix + ": <" + result + "> ;\n" ],
- from: {line: 0, ch: 0},
- to: {line: 0, ch: 0}
- };
- }
- }
- }
- CodeMirror.commands.ldpathAutocomplete = function(cm) {
- CodeMirror.simpleHint(cm, function(editor) {
- var cur = editor.getCursor();
- var line = editor.getLine(cur.line);
- var token = editor.getTokenAt(cur);
-
- if (token.state.stack.indexOf('prefix') >= 0) {
- return completePrefix(editor, cur, token);
- } else if (token.state.current() == 'url' || (token.state.current() == 'error' && token.state.stack[1] == 'url')) {
- return completeURI(editor, cur, token);
- } else if (token.className == "qualifier" || (token.className == "atom" && token.state.stack.indexOf("path") >= 0)) {
- return completeCUIE(editor, cur, token);
- } else if (token.className == "string-2") {
- return insertPrefixDef(editor, cur, token);
- } else {
- if (console && console.log) {
- console.log("State: " + token.state.stack);
- }
- }
- });
- }
-}
-
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/matchbrackets.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/matchbrackets.js b/extras/webjars/codemirror/src/main/resources/matchbrackets.js
deleted file mode 100644
index 131fe83..0000000
--- a/extras/webjars/codemirror/src/main/resources/matchbrackets.js
+++ /dev/null
@@ -1,86 +0,0 @@
-(function() {
- var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
- (document.documentMode == null || document.documentMode < 8);
-
- var Pos = CodeMirror.Pos;
-
- var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
- function findMatchingBracket(cm, where, strict) {
- var state = cm.state.matchBrackets;
- var maxScanLen = (state && state.maxScanLineLength) || 10000;
-
- var cur = where || cm.getCursor(), line = cm.getLineHandle(cur.line), pos = cur.ch - 1;
- var match = (pos >= 0 && matching[line.text.charAt(pos)]) || matching[line.text.charAt(++pos)];
- if (!match) return null;
- var forward = match.charAt(1) == ">", d = forward ? 1 : -1;
- if (strict && forward != (pos == cur.ch)) return null;
- var style = cm.getTokenTypeAt(Pos(cur.line, pos + 1));
-
- var stack = [line.text.charAt(pos)], re = /[(){}[\]]/;
- function scan(line, lineNo, start) {
- if (!line.text) return;
- var pos = forward ? 0 : line.text.length - 1, end = forward ? line.text.length : -1;
- if (line.text.length > maxScanLen) return null;
- if (start != null) pos = start + d;
- for (; pos != end; pos += d) {
- var ch = line.text.charAt(pos);
- if (re.test(ch) && cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style) {
- var match = matching[ch];
- if (match.charAt(1) == ">" == forward) stack.push(ch);
- else if (stack.pop() != match.charAt(0)) return {pos: pos, match: false};
- else if (!stack.length) return {pos: pos, match: true};
- }
- }
- }
- for (var i = cur.line, found, e = forward ? Math.min(i + 100, cm.lineCount()) : Math.max(-1, i - 100); i != e; i+=d) {
- if (i == cur.line) found = scan(line, i, pos);
- else found = scan(cm.getLineHandle(i), i);
- if (found) break;
- }
- return {from: Pos(cur.line, pos), to: found && Pos(i, found.pos),
- match: found && found.match, forward: forward};
- }
-
- function matchBrackets(cm, autoclear) {
- // Disable brace matching in long lines, since it'll cause hugely slow updates
- var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
- var found = findMatchingBracket(cm);
- if (!found || cm.getLine(found.from.line).length > maxHighlightLen ||
- found.to && cm.getLine(found.to.line).length > maxHighlightLen)
- return;
-
- var style = found.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
- var one = cm.markText(found.from, Pos(found.from.line, found.from.ch + 1), {className: style});
- var two = found.to && cm.markText(found.to, Pos(found.to.line, found.to.ch + 1), {className: style});
- // Kludge to work around the IE bug from issue #1193, where text
- // input stops going to the textare whever this fires.
- if (ie_lt8 && cm.state.focused) cm.display.input.focus();
- var clear = function() {
- cm.operation(function() { one.clear(); two && two.clear(); });
- };
- if (autoclear) setTimeout(clear, 800);
- else return clear;
- }
-
- var currentlyHighlighted = null;
- function doMatchBrackets(cm) {
- cm.operation(function() {
- if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
- if (!cm.somethingSelected()) currentlyHighlighted = matchBrackets(cm, false);
- });
- }
-
- CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
- if (old && old != CodeMirror.Init)
- cm.off("cursorActivity", doMatchBrackets);
- if (val) {
- cm.state.matchBrackets = typeof val == "object" ? val : {};
- cm.on("cursorActivity", doMatchBrackets);
- }
- });
-
- CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
- CodeMirror.defineExtension("findMatchingBracket", function(pos, strict){
- return findMatchingBracket(this, pos, strict);
- });
-})();
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.css
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.css b/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.css
new file mode 100644
index 0000000..7cede3f
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.css
@@ -0,0 +1,181 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+.CodeMirror {
+ border: 1px solid #eee;
+}
+
+td {
+ padding-right: 20px;
+}
+body {
+ font-family: Droid Sans, Arial, sans-serif;
+ line-height: 1.5;
+ max-width: 64.3em;
+ margin: 3em auto;
+ padding: 0 1em;
+}
+
+h1 {
+ letter-spacing: -3px;
+ font-size: 3.23em;
+ font-weight: bold;
+ margin: 0;
+}
+
+h2 {
+ font-size: 1.23em;
+ font-weight: bold;
+ margin: .5em 0;
+ letter-spacing: -1px;
+}
+
+h3 {
+ font-size: 1em;
+ font-weight: bold;
+ margin: .4em 0;
+}
+
+pre {
+ background-color: #eee;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+ padding: 1em;
+}
+
+pre.code {
+ margin: 0 1em;
+}
+
+.grey {
+ font-size: 2.2em;
+ padding: .5em 1em;
+ line-height: 1.2em;
+ margin-top: .5em;
+ position: relative;
+}
+
+img.logo {
+ position: absolute;
+ right: -25px;
+ bottom: 4px;
+}
+
+a:link, a:visited, .quasilink {
+ color: #df0019;
+ cursor: pointer;
+ text-decoration: none;
+}
+
+a:hover, .quasilink:hover {
+ color: #800004;
+}
+
+h1 a:link, h1 a:visited, h1 a:hover {
+ color: black;
+}
+
+ul {
+ margin: 0;
+ padding-left: 1.2em;
+}
+
+a.download {
+ color: white;
+ background-color: #df0019;
+ width: 100%;
+ display: block;
+ text-align: center;
+ font-size: 1.23em;
+ font-weight: bold;
+ text-decoration: none;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+ padding: .5em 0;
+ margin-bottom: 1em;
+}
+
+a.download:hover {
+ background-color: #bb0010;
+}
+
+.rel {
+ margin-bottom: 0;
+}
+
+.rel-note {
+ color: #777;
+ font-size: .9em;
+ margin-top: .1em;
+}
+
+.logo-braces {
+ color: #df0019;
+ position: relative;
+ top: -4px;
+}
+
+.blk {
+ float: left;
+}
+
+.left {
+ width: 37em;
+ padding-right: 6.53em;
+ padding-bottom: 1em;
+}
+
+.left1 {
+ width: 15.24em;
+ padding-right: 6.45em;
+}
+
+.left2 {
+ width: 15.24em;
+}
+
+.right {
+ width: 20.68em;
+}
+
+.leftbig {
+ width: 42.44em;
+ padding-right: 6.53em;
+}
+
+.rightsmall {
+ width: 15.24em;
+}
+
+.clear:after {
+ visibility: hidden;
+ display: block;
+ font-size: 0;
+ content: " ";
+ clear: both;
+ height: 0;
+}
+.clear { display: inline-block; }
+/* start commented backslash hack \*/
+* html .clear { height: 1%; }
+.clear { display: block; }
+/* close commented backslash hack */
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.html
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.html b/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.html
new file mode 100644
index 0000000..38f11ba
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.html
@@ -0,0 +1,87 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!doctype html>
+<html>
+<head>
+<title>CodeMirror: LDPath Demo</title>
+
+<script type="text/javascript" src="../../../../../webjars/jquery/1.8.2/jquery.min.js"></script>
+
+<script type="text/javascript" src="../../../../../webjars/codemirror/3.16/lib/codemirror.js"></script>
+<link rel="stylesheet" href="../../../../../webjars/codemirror/3.16/lib/codemirror.css">
+
+<script src="../../../../../webjars/codemirror/3.16/addon/hint/show-hint.js"></script>
+<link rel="stylesheet" href="../../../../../webjars/codemirror/3.16/addon/hint/show-hint.css">
+
+<script src="ldpath.js"></script>
+<link rel="stylesheet" href="ldpath.css">
+
+</head>
+<body>
+ <h1>CodeMirror: LDPath demo</h1>
+ <div>
+ Read about the <a href="http://marmotta.incubator.apache.org/ldpath/language.html" title="LDPath">LDPath Syntax</a>
+ in <a href="http://marmotta.incubator.apache.org/">Apache Marmotta</a>.
+ </div>
+ <div>
+ <button onclick="javascript:createEditor()">Editor</button>
+ <button onclick="javascript:removeEditor()">Plain</button>
+ </div>
+ <form>
+ <textarea id="code" name="code">
+@prefix iptc : <http://iptc.org/std/nar/2006-10-01/> ;
+@prefix foaf ;
+@prefix rss: ;
+@prefix sioc: ;
+@filter rdf:type is rss:item | rdf:type is isig:WebPage | rdf:type is sioc:Post ;
+ date = dc:date :: xsd:date(multiValued="false") ;
+ desc = dc:description[@de] :: lmf:text_en ;
+ feed = (^rss:items / rss:title | (page:partOf | sioc:has_container / dc:title)) :: xsd:string ;
+ lang = fn:first(^rss:items / dc:language, "de") :: xsd:string ;
+ summary = fn:removeTags((rss:description | dc:description)) :: lmf:text_en ;
+ title = (rss:title | (html:title | dc:title)) :: lmf:text_en ;
+ user = dc:creator :: xsd:string(multiValue="false") ;
+</textarea>
+ </form>
+ <script>
+ var editor = null;
+ function createEditor() {
+ if (editor === null) {
+ CodeMirror.commands.autocomplete = function(cm) {
+ CodeMirror.showHint(cm, CodeMirror.hint.ldpath);
+ };
+ editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers : true,
+ matchBrackets : true,
+ extraKeys: {"Ctrl-Space": "autocomplete"},
+ mode : "ldpath"
+ });
+ }
+ }
+ function removeEditor() {
+ if (editor) {
+ editor.toTextArea();
+ editor = null;
+ }
+ }
+ createEditor();
+ </script>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.js b/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.js
new file mode 100644
index 0000000..f981f87
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/mode/ldpath/ldpath.js
@@ -0,0 +1,471 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+if (CodeMirror && CodeMirror.defineMode) {
+CodeMirror.defineMode("ldpath", function(config, parserConfig) {
+ var token = {
+ COMMENT: "comment",
+ OP: "operator",
+ KWD: "keyword",
+ PREFIX: "qualifier",
+ IDENT: "atom",
+ DEF: "builtin",
+ TEST: "meta",
+ URL: "link",
+ STR: "string",
+ INT: "number",
+ BRACKET: "bracket",
+ WARNING: "string-2",
+ ERROR: "error"
+ },
+ predefinedNamespaces = parserConfig.namespaces || {},
+ baseURL = parserConfig.baseURL || null;
+
+ function log(stream, status, result) {
+ return;
+ if (console && console.log) {
+ console.log(stream.current() + " := " + result + " (-> " + status.current() + ")");
+ }
+ }
+
+ function getInitialState() {
+ return {
+ tmp: {},
+ namespaces: {},
+ predefinedNamespaces: predefinedNamespaces,
+ lmfBaseURL: baseURL,
+ stack: ['default'],
+ /* STACKING */
+ push: function(next) {
+ this.stack.unshift(next);
+ },
+ pop: function() {
+ if (this.stack.length <= 1) {
+ return this.current();
+ } else {
+ return this.stack.shift();
+ }
+ },
+ current: function() {
+ return this.stack[0];
+ },
+ reset: function() {
+ this.stack = ['default'];
+ this.tmp = {};
+ },
+ height: function() {
+ return this.stack.length;
+ },
+ /* PARSING */
+ parser: function(stream, state) {
+ var parser = parsers[this.current()] || parsers['default'];
+ return parser(stream, state);
+ },
+ /* NAMESPACES */
+ addPrefix: function(prefix, namespace) {
+ if (prefix && namespace)
+ this.namespaces[prefix] = namespace;
+ },
+ getNamespace: function(prefix) {
+ return this.namespaces[prefix] || this.predefinedNamespaces[prefix];
+ }
+ };
+ }
+
+ function tokenError(stream, state) {
+ if (state.current() !== 'error') state.push('error');
+ stream.skipToEnd();
+ return token.ERROR;
+ }
+
+ function tokenDefault(stream, state) {
+ // /* ... */
+ if (stream.match('/*')) {
+ state.push('comment');
+ return token.COMMENT;
+ }
+
+ // @...
+ var kw = stream.match(/^@(\w+)/, true);
+ if (kw) {
+ state.push(kw[1]);
+ return token.KWD;
+ }
+
+ // <URL>
+ if (stream.eat('<')) {
+ state.push('url');
+ return token.BRACKET;
+ }
+ if (stream.eat('[')) {
+ state.push('test');
+ return token.BRACKET;
+ }
+ if (stream.eat('(')) {
+ if (state.current() == "transformer") {
+ state.push('config');
+ }
+ return token.BRACKET;
+ }
+ if (stream.eat(')')) {
+ if (state.current() == "config") {
+ state.pop();
+ }
+ return token.BRACKET;
+ }
+ if (stream.eat(/[\]>\{\}]/)) {
+ return token.BRACKET;
+ }
+
+ // prefix:label
+ if (stream.match(/^\w+:\w*/, false)) {
+ stream.skipTo(":")
+ if (state.current() == 'prefix') {
+ state.tmp["prefix"] = stream.current();
+ return token.PREFIX;
+ } else {
+ px = stream.current();
+ stream.eat(':');
+ if (state.getNamespace(px))
+ return token.PREFIX;
+ else return token.WARNING;
+ }
+ }
+
+ if (stream.match("=", true)) {
+ if (state.current() == "default") {
+ state.push("path");
+ }
+ return token.DEF;
+ }
+ if (stream.match("::", true)) {
+ state.push("transformer");
+ return token.DEF;
+ }
+ // OPERATORS
+ if (stream.eat(/[:,&\|\/^\+\*.]/)) {
+ return token.OP;
+ }
+
+ if (stream.eat('"')) {
+ if (stream.skipTo('"') && stream.eat('"'))
+ return token.STR;
+ return tokenError(stream, state);
+ }
+
+ // NUMBERS
+ if (stream.match(/^\d+/, true)) {
+ return token.INT;
+ }
+
+ // IDENT
+ if (state.current() == "prefix") {
+ if (stream.match(/^\w+/, true)) {
+ state.tmp["prefix"] = stream.current();
+ return token.PREFIX;
+ }
+ } else {
+ if (stream.match(/^[\w.-]+/, true)) {
+ return token.IDENT;
+ }
+ }
+
+ return tokenError(stream, state);
+ }
+
+ function tokenURL(stream, state) {
+ if (stream.eat('>')) {
+ state.pop();
+ return token.BRACKET;
+ }
+ if (stream.skipTo('>')) {
+ //state.pop();
+ var url = stream.current();
+ if (url.search(/^https?:\/\//) < 0 || url.search(/\s/) >= 0) {
+ return token.ERROR;
+ }
+ if (state.stack.indexOf("prefix") >= 0) {
+ state.tmp["ns"] = url;
+ }
+ return token.URL;
+ }
+ return tokenError(stream, state);
+ }
+
+ function tokenTest(stream, state) {
+ if (stream.eat(']')) {
+ state.pop();
+ return token.BRACKET;
+ }
+ if (stream.match(/@\w+/, true) || stream.match("^^", true)) {
+ return token.TEST;
+ }
+ if (stream.match("is-a", true)) {
+ return token.TEST;
+ }
+ if (stream.match("is ", false)) {
+ stream.match("is", true);
+ return token.TEST;
+ }
+ if (stream.eat(/[&\|]/)) {
+ return token.TEST;
+ }
+ return tokenDefault(stream, state);
+ }
+
+ var parsers = {
+ 'default': tokenDefault,
+ filter: tokenTest,
+ url: tokenURL,
+ test: tokenTest,
+ error: tokenError
+ }
+
+
+ return {
+ startState: getInitialState,
+ compareStates: function(state1, state2) {
+ return state1.stack == state2.stack && state1.namespaces == state2.namespaces;
+ },
+ token: function(stream, state) {
+ // parse comments
+ if (state.current() == "comment") {
+ stream.skipTo('*') || stream.skipToEnd();
+ if (stream.match('*/')) {
+ state.pop();
+ } else stream.eat('*');
+ return token.COMMENT;
+ } else if (stream.match('/*')) {
+ state.tmp.commentStart = stream.column();
+ state.push("comment");
+ return this.token(stream, state);
+ }
+ // ignore spaces
+ if (stream.eatSpace()) return null;
+ // ; starts parsing from scratch
+ if (stream.eat(';')) {
+ if (state.current() == "prefix") {
+ state.addPrefix(state.tmp['prefix'], state.tmp['ns']);
+ }
+ log(stream, state, "RESET");
+ state.reset();
+ return token.OP;
+ }
+ var result = state.parser(stream, state);
+ log(stream, state, result);
+ return result;
+ },
+ electricChars: "/@=[];",
+ indent: function(state, textAfter) {
+ switch (state.current()) {
+ case 'comment':
+ return state.tmp.commentStart +(textAfter.search(/^\s*\*\//)==0?1:3);
+ break;
+ case 'test':
+ case 'filter':
+ return 2 * config.indentUnit;
+ break;
+ case 'default':
+ // no indent for @prefix etc...
+ if (textAfter.search(/^\s*@/) == 0) {
+ return 0;
+ }
+ return config.indentUnit;
+ break;
+ }
+ return 0;
+ }
+ }
+});
+
+// Autocompletion
+if (CodeMirror.showHint && jQuery) {
+ function completePrefix(editor, cur, token) {
+ var line = editor.getLine(cur.line);
+ var match = line.match(/(^|;)\s*@prefix\s+(\w+)\s*(:\s*<?)?(;|$)/);
+ if (match && match[2] && match[2] !== "") {
+ var prefix = match[2], result;
+ try {
+ jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/prefix", {
+// jQuery.ajax("http://prefix.cc/" + prefix + ".file.json", {
+ async: false,
+ data: {prefix: prefix},
+ success: function(data) {
+ result = data[prefix];
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (result !== undefined) {
+ var pfx = line.substr(0,cur.ch);
+ var st = pfx.search(/\s*(:\s*<?)?$/);
+ return {
+ list: [ ": <"+result+">;" ],
+ from: {line: cur.line, ch: st},
+ to: cur
+ };
+ }
+ }
+ return false;
+ }
+ function completeURI(editor, cur, token) {
+ var bC = token.string.substr(0, cur.ch - token.start),
+ aC = token.string.substr(cur.ch - token.start),
+ replUntil = token.state.current()=='url'?token.end+1:cur.ch + Math.max(aC.search(/[\s]/), 0);
+
+ var suggestions;
+ try {
+ var qs = {};
+ if (token.state.stack.indexOf("transformer") >= 0) qs['mode'] = "transformer";
+ for (var n in token.state.namespaces) {
+ qs['ns_'+n] = token.state.getNamespace(n);
+ }
+ qs['uri'] = bC;
+
+ jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/complete", {
+ async: false,
+ data: qs,
+ success: function(data) {
+ suggestions = data;
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (suggestions !== undefined) {
+ for (var i = 0; i < suggestions.length; i++) {
+ if (suggestions[i].match(/^\w+:\w+$/)) {
+ // curie!
+ suggestions[i] = suggestions[i] + " ";
+ } else {
+ suggestions[i] = "<" + suggestions[i] + "> ";
+ }
+ }
+ return {
+ list: suggestions,
+ from: {line: cur.line, ch: token.start - 1},
+ to: {line: cur.line, ch: replUntil}
+ };
+ }
+ return false;
+ }
+ function completeCUIE(editor, cur, token) {
+ var from = token.start,
+ to = token.end,
+ req = token.string.substr(0, cur.ch - token.start);
+ var prevToken = editor.getTokenAt({line: cur.line, ch: token.start});
+ if (token.className == 'atom' && prevToken.className == 'qualifier') {
+ from = prevToken.start;
+ req = prevToken.string + req;
+ }
+
+ var suggestions;
+ try {
+ var qs = {};
+ if (token.state.stack.indexOf("transformer") >= 0) qs['mode'] = "transformer";
+ for (var n in token.state.namespaces) {
+ qs['ns_'+n] = token.state.getNamespace(n);
+ }
+ qs['prefix'] = req;
+
+ jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/complete", {
+ async: false,
+ data: qs,
+ success: function(data) {
+ suggestions = data;
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (suggestions !== undefined) {
+ for (var i = 0; i < suggestions.length; i++) {
+ if (suggestions[i].match(/^\w+:\w+(\(\))?$/)) {
+ // curie!
+ suggestions[i] = suggestions[i] + " ";
+ } else {
+ // prefix only
+ suggestions[i] = suggestions[i] + ":";
+ }
+ }
+ return {
+ list: suggestions,
+ from: {line: cur.line, ch: from},
+ to: {line: cur.line, ch: to}
+ };
+ }
+
+ return false;
+ }
+ function insertPrefixDef(editor, cur, token) {
+ var prefix = token.string.replace(/:?$/, ""), result;
+ try {
+ jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/prefix", {
+// jQuery.ajax("http://prefix.cc/" + prefix + ".file.json", {
+ async: false,
+ data: {prefix: prefix},
+ success: function(data) {
+ result = data[prefix];
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (result !== undefined) {
+ // check if this url is already prefixed
+ var px;
+ for (var i in token.state.namespaces) {
+ if (token.state.namespaces[i] == result) {
+ px = i;
+ break;
+ }
+ }
+ if (px) {
+ return {
+ list: [ px + ":" ],
+ from: { line: cur.line, ch: token.start },
+ to: { line: cur.line, ch: token.end }
+ };
+ } else {
+ return {
+ list: [ "@prefix " + prefix + ": <" + result + "> ;\n" ],
+ from: {line: 0, ch: 0},
+ to: {line: 0, ch: 0}
+ };
+ }
+ }
+ }
+ function ldpathAutocomplete(editor, options) {
+ var cur = editor.getCursor(),
+ line = editor.getLine(cur.line),
+ token = editor.getTokenAt(cur);
+
+ if (token.state.stack.indexOf('prefix') >= 0) {
+ return completePrefix(editor, cur, token);
+ } else if (token.state.current() == 'url' || (token.state.current() == 'error' && token.state.stack[1] == 'url')) {
+ return completeURI(editor, cur, token);
+ } else if (token.className == "qualifier" || (token.className == "atom" && token.state.stack.indexOf("path") >= 0)) {
+ return completeCUIE(editor, cur, token);
+ } else if (token.className == "string-2") {
+ return insertPrefixDef(editor, cur, token);
+ } else {
+ if (console && console.log) {
+ console.log("State: " + token.state.stack);
+ }
+ }
+ }
+ CodeMirror.registerHelper("hint", "ldpath", ldpathAutocomplete);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.css
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.css b/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.css
new file mode 100644
index 0000000..838b773
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.css
@@ -0,0 +1,172 @@
+@CHARSET "UTF-8";
+
+.CodeMirror {
+ border: 1px solid #eee;
+}
+
+td {
+ padding-right: 20px;
+}
+
+body {
+ font-family: Droid Sans, Arial, sans-serif;
+ line-height: 1.5;
+ max-width: 64.3em;
+ margin: 3em auto;
+ padding: 0 1em;
+}
+
+h1 {
+ letter-spacing: -3px;
+ font-size: 3.23em;
+ font-weight: bold;
+ margin: 0;
+}
+
+h2 {
+ font-size: 1.23em;
+ font-weight: bold;
+ margin: .5em 0;
+ letter-spacing: -1px;
+}
+
+h3 {
+ font-size: 1em;
+ font-weight: bold;
+ margin: .4em 0;
+}
+
+pre {
+ background-color: #eee;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+ padding: 1em;
+}
+
+pre.code {
+ margin: 0 1em;
+}
+
+.grey {
+ font-size: 2.2em;
+ padding: .5em 1em;
+ line-height: 1.2em;
+ margin-top: .5em;
+ position: relative;
+}
+
+img.logo {
+ position: absolute;
+ right: -25px;
+ bottom: 4px;
+}
+
+a:link,a:visited,.quasilink {
+ color: #df0019;
+ cursor: pointer;
+ text-decoration: none;
+}
+
+a:hover,.quasilink:hover {
+ color: #800004;
+}
+
+h1 a:link,h1 a:visited,h1 a:hover {
+ color: black;
+}
+
+ul {
+ margin: 0;
+ padding-left: 1.2em;
+}
+
+a.download {
+ color: white;
+ background-color: #df0019;
+ width: 100%;
+ display: block;
+ text-align: center;
+ font-size: 1.23em;
+ font-weight: bold;
+ text-decoration: none;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+ padding: .5em 0;
+ margin-bottom: 1em;
+}
+
+a.download:hover {
+ background-color: #bb0010;
+}
+
+.rel {
+ margin-bottom: 0;
+}
+
+.rel-note {
+ color: #777;
+ font-size: .9em;
+ margin-top: .1em;
+}
+
+.logo-braces {
+ color: #df0019;
+ position: relative;
+ top: -4px;
+}
+
+.blk {
+ float: left;
+}
+
+.left {
+ width: 37em;
+ padding-right: 6.53em;
+ padding-bottom: 1em;
+}
+
+.left1 {
+ width: 15.24em;
+ padding-right: 6.45em;
+}
+
+.left2 {
+ width: 15.24em;
+}
+
+.right {
+ width: 20.68em;
+}
+
+.leftbig {
+ width: 42.44em;
+ padding-right: 6.53em;
+}
+
+.rightsmall {
+ width: 15.24em;
+}
+
+.clear:after {
+ visibility: hidden;
+ display: block;
+ font-size: 0;
+ content: " ";
+ clear: both;
+ height: 0;
+}
+
+.clear {
+ display: inline-block;
+}
+/* start commented backslash hack \*/
+* html .clear {
+ height: 1%;
+}
+
+.clear {
+ display: block;
+}
+/* close commented backslash hack */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.html
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.html b/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.html
new file mode 100644
index 0000000..8666d8c
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.html
@@ -0,0 +1,96 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!doctype html>
+<html>
+<head>
+<title>CodeMirror: SKWRL Demo</title>
+
+
+<script type="text/javascript" src="../../../../../webjars/jquery/1.8.2/jquery.min.js"></script>
+
+<script type="text/javascript" src="../../../../../webjars/codemirror/3.16/lib/codemirror.js"></script>
+<link rel="stylesheet" href="../../../../../webjars/codemirror/3.16/lib/codemirror.css">
+
+<script src="../../../../../webjars/codemirror/3.16/addon/hint/show-hint.js"></script>
+<link rel="stylesheet" href="../../../../../webjars/codemirror/3.16/addon/hint/show-hint.css">
+
+<script type="text/javascript" src="skwrl.js"></script>
+<link rel="stylesheet" href="skwrl.css">
+
+</head>
+<body>
+ <h1>CodeMirror: SKWRL demo</h1>
+ <div>
+ Read about the <a href="http://marmotta.incubator.apache.org/kiwi/reasoner.html" title="Simple KiWi Reasoning Language">SKWRL Langugae</a>
+ in <a href="http://marmotta.incubator.apache.org/">Apache Marmotta</a>.
+ </div>
+ <div>
+ <button onclick="javascript:createEditor()">Editor</button>
+ <button onclick="javascript:removeEditor()">Plain</button>
+ </div>
+ <form>
+<textarea id="code" name="code">
+/* rules taken from http://www.w3.org/TR/2004/REC-rdf-mt-20040210/#RDFRules */
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
+@prefix foaf: <http://xmlns.com/foaf/0.1/>
+
+rdf1: ($u $a $y) -> ($a rdf:type rdf:Property)
+rdfs2: ($a rdfs:domain $x), ($u $a $y) -> ($u rdf:type $x)
+rdfs3: ($a rdfs:range $x), ($u $a $v) -> ($v rdf:type $x)
+rdfs4a: ($u $a $x) -> ($u rdf:type rdfs:Resource)
+rdfs5: ($u rdfs:subPropertyOf $v), ($v rdfs:subPropertyOf $x) -> ($u rdfs:subPropertyOf $x)
+rdfs6: ($u rdf:type rdf:Property) -> ($u rdfs:subPropertyOf $u)
+rdfs7: ($a rdfs:subPropertyOf $b), ($u $a $y) -> ($u $b $y)
+rdfs8: ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf rdfs:Resource)
+rdfs9: ($u rdfs:subClassOf $x), ($v rdf:type $u) -> ($v rdf:type $x)
+rdfs10: ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf $u)
+rdfs11: ($u rdfs:subClassOf $v), ($v rdfs:subClassOf $x) -> ($u rdfs:subClassOf $x)
+rdfs12: ($u rdf:type rdfs:ContainerMembershipProperty) -> ($u rdfs:subPropertyOf rdfs:member)
+rdfs13: ($u rdf:type rdfs:Datatype) -> ($u rdfs:subClassOf rdfs:Literal)
+
+</textarea>
+ </form>
+ <script>
+ var editor = null;
+ function createEditor() {
+ if (editor === null) {
+ CodeMirror.commands.autocomplete = function(cm) {
+ CodeMirror.showHint(cm, CodeMirror.hint.skwrl);
+ };
+ editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers : true,
+ matchBrackets : true,
+ extraKeys: {"Ctrl-Space": "autocomplete"},
+ mode : "skwrl"
+ });
+ }
+ }
+ function removeEditor() {
+ if (editor) {
+ editor.toTextArea();
+ editor = null;
+ }
+ }
+ createEditor();
+ </script>
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.js b/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.js
new file mode 100644
index 0000000..5f85565
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/mode/skwrl/skwrl.js
@@ -0,0 +1,486 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+if (CodeMirror && CodeMirror.defineMode) {
+CodeMirror.defineMode("skwrl", function(config, parserConfig) {
+ var token = {
+ COMMENT: "comment",
+ KWD: "keyword",
+ IDENT: "atom",
+ OP: "operator",
+ BRACKET: "bracket",
+ URL: "link",
+ VAR: "variable-3",
+ PREFIX: "qualifier",
+ DEF: "variable",
+ WARNING: "string-2",
+ ERROR: "error"
+ },
+ predefinedNamespaces = parserConfig.namespaces || {},
+ baseURL = parserConfig.baseURL || null;
+
+ function log(stream, status, result) {
+ return;
+ if (console && console.log) {
+ console.log(stream.current() + " := " + result + " (-> " + status.current() + ")");
+ }
+ }
+
+ function getInitialState() {
+ return {
+ tmp: {},
+ namespaces: {},
+ predefinedNamespaces: predefinedNamespaces,
+ lmfBaseURL: baseURL,
+ stack: ['default'],
+ /* STACKING */
+ push: function(next) {
+ this.stack.unshift(next);
+ },
+ pop: function() {
+ if (this.stack.length <= 1) {
+ return this.current();
+ } else {
+ return this.stack.shift();
+ }
+ },
+ current: function() {
+ return this.stack[0];
+ },
+ reset: function() {
+ this.stack = ['default'];
+ this.tmp = {};
+ },
+ height: function() {
+ return this.stack.length;
+ },
+ /* PARSING */
+ parser: function(stream, state) {
+ var parser = parsers[this.current()] || parsers['default'];
+ return parser(stream, state);
+ },
+ /* NAMESPACES */
+ addPrefix: function(prefix, namespace) {
+ if (prefix && namespace)
+ this.namespaces[prefix] = namespace;
+ },
+ getNamespace: function(prefix) {
+ return this.namespaces[prefix] || this.predefinedNamespaces[prefix];
+ }
+ };
+ }
+
+ function tokenError(stream, state) {
+ if (state.current() !== 'error') state.push('error');
+ stream.skipToEnd();
+ return token.ERROR;
+ }
+
+ function tokenDefault(stream, state) {
+ // @...
+ var kw = stream.match(/^@(\w+)/, true);
+ if (kw) {
+ if (kw[1] == "prefix") {
+ state.push(kw[1]);
+ return token.KWD;
+ } else return token.ERROR;
+ }
+
+ // <URL>
+ if (stream.eat('<')) {
+ state.push('url');
+ return token.BRACKET;
+ }
+
+ if (stream.eat('(')) {
+ state.tmp['rule'] = 0;
+ state.push('rule');
+ return token.BRACKET;
+ }
+ if (stream.eat(')')) {
+ if (state.current() != 'rule') return token.ERROR;
+ state.pop();
+ return token.BRACKET;
+ }
+ if (stream.eat(/[)(]/)) {
+ return token.BRACKET;
+ }
+
+ // prefix:label
+ if (stream.match(/^\w+:\w*/, false)) {
+ stream.skipTo(":")
+ if (state.current() == 'prefix') {
+ state.tmp["prefix"] = stream.current();
+ return token.PREFIX;
+ } else if (state.current() == 'default') {
+ return token.DEF;
+ } else {
+ px = stream.current();
+ stream.eat(':');
+ if (state.getNamespace(px))
+ return token.PREFIX;
+ else return token.WARNING;
+ }
+ }
+
+ if (stream.match("->", true)) {
+ return token.DEF;
+ }
+ // OPERATORS
+ if (stream.eat(/[:,]/)) {
+ return token.OP;
+ }
+
+
+ // IDENT
+ if (state.current() == "prefix") {
+
+ } else {
+ if (stream.match(/^[\w.-]+/, true)) {
+ return token.IDENT;
+ }
+ }
+
+ return tokenError(stream, state);
+ }
+
+ function tokenRule(stream, state) {
+ if (stream.eat(')')) {
+ state.pop();
+ if (state.tmp['rule'] != 3) return token.ERROR;
+ return token.BRACKET;
+ } else if (state.tmp['rule'] >= 3) {
+ state.tmp['rule'] = 4;
+ stream.skipTo(')') || stream.next();
+ return token.ERROR;
+ } else
+ // <URL>
+ if (stream.eat('<')) {
+ state.push('url');
+ return token.BRACKET;
+ } else if (stream.eat('>')) {
+ state.tmp['rule']++;
+ return token.BRACKET;
+ } else
+ // $s
+ if (stream.match(/^\$\w+/)) {
+ state.tmp['rule']++;
+ return token.VAR;
+ } else
+ // ns:local
+ if (stream.match(/^\w+:\w*/, false)) {
+ stream.skipTo(':');
+ var px = stream.current();
+ stream.eat(':');
+ if (!stream.match(/^\w+/, false)) {
+ return token.ERROR;
+ } else if (state.getNamespace(px))
+ return token.PREFIX;
+ else return token.WARNING;
+ } else if (stream.match(/^\w+/)) {
+ state.tmp['rule']++;
+ return token.IDENT;
+ } else if (stream.eat(')')) {
+ state.pop();
+ if (state.tmp['rule'] != 3) return token.ERROR;
+ return token.BRACKET;
+ } else {
+ stream.next();
+ return token.ERROR;
+ }
+
+ return tokenError(stream, state);
+ }
+
+ function tokenPrefix(stream, state) {
+ if (stream.match(/^\w+/, true)) {
+ state.tmp["prefix"] = stream.current();
+ return token.PREFIX;
+ } else if (stream.eat(':')) {
+ return token.OP;
+ } else
+ // <URL>
+ if (stream.eat('<')) {
+ state.push('url');
+ return token.BRACKET;
+ } else if (stream.eat('>')) {
+ if (state.tmp['prefix'] && state.tmp['ns']) {
+ state.addPrefix(state.tmp['prefix'], state.tmp['ns']);
+ state.reset();
+ // End of prefix state:
+ state.pop();
+ return token.BRACKET;
+ } else return token.ERROR;
+ }
+
+ return tokenError(stream, state);
+ }
+
+ function tokenURL(stream, state) {
+ if (stream.skipTo('>')) {
+ state.pop();
+ var url = stream.current();
+ if (url.search(/\s/) >= 0) {
+ return token.ERROR;
+ }
+ if (state.stack.indexOf("prefix") >= 0) {
+ state.tmp["ns"] = url;
+ }
+ return token.URL;
+ }
+ return tokenError(stream, state);
+ }
+
+ var parsers = {
+ 'default': tokenDefault,
+ rule: tokenRule,
+ prefix: tokenPrefix,
+ url: tokenURL,
+ error: tokenError
+ };
+
+
+
+ return {
+ startState: getInitialState,
+ compareStates: function(state1, state2) {
+ return state1.stack == state2.stack && state1.namespaces == state2.namespaces;
+ },
+ token: function(stream, state) {
+ // parse comments
+ if (state.current() == "comment") {
+ stream.skipTo('*') || stream.skipToEnd();
+ if (stream.match('*/')) {
+ state.pop();
+ } else stream.eat('*');
+ return token.COMMENT;
+ } else if (stream.match('/*')) {
+ state.tmp.commentStart = stream.column();
+ state.push("comment");
+ return this.token(stream, state);
+ }
+ // ignore spaces
+ if (stream.eatSpace()) return null;
+ // ; starts parsing from scratch
+ /*
+ if (stream.eat(';')) {
+ if (state.current() == "prefix") {
+ state.addPrefix(state.tmp['prefix'], state.tmp['ns']);
+ }
+ log(stream, state, "RESET");
+ state.reset();
+ return token.OP;
+ }
+ */
+ var result = state.parser(stream, state);
+ log(stream, state, result);
+ return result;
+ },
+ electricChars: "/@=[];",
+ indent: function(state, textAfter) {
+ switch (state.current()) {
+ case 'comment':
+ return state.tmp.commentStart +(textAfter.search(/^\s*\*\//)==0?1:3);
+ break;
+ case 'default':
+ // no indent for @prefix etc...
+ if (textAfter.search(/^\s*@/) == 0) {
+ return 0;
+ }
+ return config.indentUnit;
+ break;
+ }
+ return 0;
+ }
+ }
+});
+
+// Autocompletion
+if (CodeMirror.showHint && jQuery) {
+ function completePrefix(editor, cur, token) {
+ var line = editor.getLine(cur.line);
+ var match = line.match(/(^|>)\s*@prefix\s+(\w+)\s*(:\s*<?)?$/);
+ if (match && match[2] && match[2] !== "") {
+ var prefix = match[2], result;
+ try {
+// jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/prefix", {
+ jQuery.ajax("http://prefix.cc/" + prefix + ".file.json", {
+ async: false,
+ data: {prefix: prefix},
+ success: function(data) {
+ result = data[prefix];
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (result !== undefined) {
+ var pfx = line.substr(0,cur.ch);
+ var st = pfx.search(/\s*(:\s*<?)?$/);
+ return {
+ list: [ ": <"+result+">" ],
+ from: {line: cur.line, ch: st},
+ to: cur
+ };
+ }
+ }
+ return false;
+ }
+ function completeURI(editor, cur, token) {
+ return false; // No completion here in skwrl
+ var bC = token.string.substr(0, cur.ch - token.start),
+ aC = token.string.substr(cur.ch - token.start),
+ replUntil = token.state.current()=='url'?token.end+1:cur.ch + Math.max(aC.search(/[\s]/), 0);
+
+ var suggestions;
+ try {
+ var qs = {};
+ if (token.state.stack.indexOf("transformer") >= 0) qs['mode'] = "transformer";
+ for (var n in token.state.namespaces) {
+ qs['ns_'+n] = token.state.getNamespace(n);
+ }
+ qs['uri'] = bC;
+
+ jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/complete", {
+ async: false,
+ data: qs,
+ success: function(data) {
+ suggestions = data;
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (suggestions !== undefined) {
+ for (var i = 0; i < suggestions.length; i++) {
+ if (suggestions[i].match(/^\w+:\w+$/)) {
+ // curie!
+ suggestions[i] = suggestions[i] + " ";
+ } else {
+ suggestions[i] = "<" + suggestions[i] + "> ";
+ }
+ }
+ return {
+ list: suggestions,
+ from: {line: cur.line, ch: token.start - 1},
+ to: {line: cur.line, ch: replUntil}
+ };
+ }
+ return false;
+ }
+ function completeCUIE(editor, cur, token) {
+ return false; // no completion here in skwrl
+ var from = token.start,
+ to = token.end,
+ req = token.string.substr(0, cur.ch - token.start);
+ var prevToken = editor.getTokenAt({line: cur.line, ch: token.start});
+ if (token.className == 'atom' && prevToken.className == 'qualifier') {
+ from = prevToken.start;
+ req = prevToken.string + req;
+ }
+
+ var suggestions;
+ try {
+ var qs = {};
+ if (token.state.stack.indexOf("transformer") >= 0) qs['mode'] = "transformer";
+ for (var n in token.state.namespaces) {
+ qs['ns_'+n] = token.state.getNamespace(n);
+ }
+ qs['prefix'] = req;
+
+ jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/complete", {
+ async: false,
+ data: qs,
+ success: function(data) {
+ suggestions = data;
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (suggestions !== undefined) {
+ for (var i = 0; i < suggestions.length; i++) {
+ if (suggestions[i].match(/^\w+:\w+(\(\))?$/)) {
+ // curie!
+ suggestions[i] = suggestions[i] + " ";
+ } else {
+ // prefix only
+ suggestions[i] = suggestions[i] + ":";
+ }
+ }
+ return {
+ list: suggestions,
+ from: {line: cur.line, ch: from},
+ to: {line: cur.line, ch: to}
+ };
+ }
+
+ return false;
+ }
+ function insertPrefixDef(editor, cur, token) {
+ var prefix = token.string.replace(/:?$/, ""), result;
+ try {
+// jQuery.ajax(token.state.lmfBaseURL + "ldpath/util/prefix", {
+ jQuery.ajax("http://prefix.cc/" + prefix + ".file.json", {
+ async: false,
+ data: {prefix: prefix},
+ success: function(data) {
+ result = data[prefix];
+ },
+ dataType: "json"
+ });
+ } catch (e) {}
+ if (result !== undefined) {
+ // check if this url is already prefixed
+ var px;
+ for (var i in token.state.namespaces) {
+ if (token.state.namespaces[i] == result) {
+ px = i;
+ break;
+ }
+ }
+ if (px) {
+ return {
+ list: [ px + ":" ],
+ from: { line: cur.line, ch: token.start },
+ to: { line: cur.line, ch: token.end }
+ };
+ } else {
+ return {
+ list: [ "@prefix " + prefix + ": <" + result + ">\n" ],
+ from: {line: 0, ch: 0},
+ to: {line: 0, ch: 0}
+ };
+ }
+ }
+ }
+ function skwrlAutocomplete(editor, options) {
+ var cur = editor.getCursor(),
+ line = editor.getLine(cur.line),
+ token = editor.getTokenAt(cur);
+
+ if (token.state.stack.indexOf('prefix') >= 0) {
+ return completePrefix(editor, cur, token);
+ } else if (token.className == "string-2") {
+ return insertPrefixDef(editor, cur, token);
+ } else {
+ if (console && console.log) {
+ console.log("State: " + token.state.stack);
+ }
+ }
+ }
+ CodeMirror.registerHelper("hint", "skwrl", skwrlAutocomplete);
+}
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/simple-hint.css
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/simple-hint.css b/extras/webjars/codemirror/src/main/resources/simple-hint.css
deleted file mode 100644
index 2deea4e..0000000
--- a/extras/webjars/codemirror/src/main/resources/simple-hint.css
+++ /dev/null
@@ -1,20 +0,0 @@
-/* CodeMirror version 2.24
- *
- * License: MIT-License <http://codemirror.net/LICENSE>
-*/
-#center .CodeMirror-completions, .CodeMirror-completions {
- position: absolute;
- z-index: 10;
- overflow: hidden;
- -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
- -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
- box-shadow: 2px 3px 5px rgba(0,0,0,.2);
-}
-#center .CodeMirror-completions select, .CodeMirror-completions select {
- background: #fafafa;
- outline: none;
- border: none;
- padding: 0;
- margin: 0;
- font-family: monospace;
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/simple-hint.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/simple-hint.js b/extras/webjars/codemirror/src/main/resources/simple-hint.js
deleted file mode 100644
index ad0f5eb..0000000
--- a/extras/webjars/codemirror/src/main/resources/simple-hint.js
+++ /dev/null
@@ -1,80 +0,0 @@
-// CodeMirror version 2.24
-//
-// All functions that need access to the editor's state live inside
-// the CodeMirror function. Below that, at the bottom of the file,
-// some utilities are defined.
-//
-// License: MIT-License <http://codemirror.net/LICENSE>
-
-(function() {
- CodeMirror.simpleHint = function(editor, getHints) {
- // We want a single cursor position.
- if (editor.somethingSelected()) return;
- var result = getHints(editor);
- if (!result || !result.list.length) return;
- var completions = result.list;
- function insert(str) {
- editor.replaceRange(str, result.from, result.to);
- }
- // When there is only one completion, use it directly.
- if (completions.length == 1) {insert(completions[0]); return true;}
-
- // Build the select widget
- var complete = document.createElement("div");
- complete.className = "CodeMirror-completions";
- var sel = complete.appendChild(document.createElement("select"));
- // Opera doesn't move the selection when pressing up/down in a
- // multi-select, but it does properly support the size property on
- // single-selects, so no multi-select is necessary.
- if (!window.opera) sel.multiple = true;
- for (var i = 0; i < completions.length; ++i) {
- var opt = sel.appendChild(document.createElement("option"));
- opt.appendChild(document.createTextNode(completions[i]));
- }
- sel.firstChild.selected = true;
- sel.size = Math.min(10, completions.length);
- var pos = editor.cursorCoords();
- complete.style.left = pos.x + "px";
- complete.style.top = pos.yBot + "px";
- document.body.appendChild(complete);
- // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
- var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
- if(winW - pos.x < sel.clientWidth)
- complete.style.left = (pos.x - sel.clientWidth) + "px";
- // Hack to hide the scrollbar.
- if (completions.length <= 10)
- complete.style.width = (sel.clientWidth - 1) + "px";
-
- var done = false;
- function close() {
- if (done) return;
- done = true;
- complete.parentNode.removeChild(complete);
- }
- function pick() {
- insert(completions[sel.selectedIndex]);
- close();
- setTimeout(function(){editor.focus();}, 50);
- }
- CodeMirror.connect(sel, "blur", close);
- CodeMirror.connect(sel, "keydown", function(event) {
- var code = event.keyCode;
- // Enter
- if (code == 13) {CodeMirror.e_stop(event); pick();}
- // Escape
- else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
- else if (code != 38 && code != 40) {
- close(); editor.focus();
- // Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
- editor.triggerOnKeyDown(event);
- setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50);
- }
- });
- CodeMirror.connect(sel, "dblclick", pick);
-
- sel.focus();
- // Opera sometimes ignores focusing a freshly created node
- if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
- return true;
- };
-})();
http://git-wip-us.apache.org/repos/asf/marmotta/blob/9c3b63b1/extras/webjars/codemirror/src/main/resources/skwrl.html
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/skwrl.html b/extras/webjars/codemirror/src/main/resources/skwrl.html
deleted file mode 100644
index 6ed695b..0000000
--- a/extras/webjars/codemirror/src/main/resources/skwrl.html
+++ /dev/null
@@ -1,254 +0,0 @@
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<!doctype html>
-<html>
-<head>
-<title>CodeMirror: SKWRL Demo</title>
-<link rel="stylesheet" href="codemirror.css">
-<link rel="stylesheet" href="simple-hint.css">
-
-<script type="text/javascript" src="../../../webjars/jquery/1.8.2/jquery.min.js"></script>
-
-<script src="codemirror.js"></script>
-<script src="simple-hint.js"></script>
-<script src="skwrl.js"></script>
-
-<link rel="stylesheet" href="skwrl.css">
-
-<style type="text/css">
-.CodeMirror {
- border: 1px solid #eee;
-}
-
-td {
- padding-right: 20px;
-}
-body {
- font-family: Droid Sans, Arial, sans-serif;
- line-height: 1.5;
- max-width: 64.3em;
- margin: 3em auto;
- padding: 0 1em;
-}
-
-h1 {
- letter-spacing: -3px;
- font-size: 3.23em;
- font-weight: bold;
- margin: 0;
-}
-
-h2 {
- font-size: 1.23em;
- font-weight: bold;
- margin: .5em 0;
- letter-spacing: -1px;
-}
-
-h3 {
- font-size: 1em;
- font-weight: bold;
- margin: .4em 0;
-}
-
-pre {
- background-color: #eee;
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
- border-radius: 6px;
- padding: 1em;
-}
-
-pre.code {
- margin: 0 1em;
-}
-
-.grey {
- font-size: 2.2em;
- padding: .5em 1em;
- line-height: 1.2em;
- margin-top: .5em;
- position: relative;
-}
-
-img.logo {
- position: absolute;
- right: -25px;
- bottom: 4px;
-}
-
-a:link, a:visited, .quasilink {
- color: #df0019;
- cursor: pointer;
- text-decoration: none;
-}
-
-a:hover, .quasilink:hover {
- color: #800004;
-}
-
-h1 a:link, h1 a:visited, h1 a:hover {
- color: black;
-}
-
-ul {
- margin: 0;
- padding-left: 1.2em;
-}
-
-a.download {
- color: white;
- background-color: #df0019;
- width: 100%;
- display: block;
- text-align: center;
- font-size: 1.23em;
- font-weight: bold;
- text-decoration: none;
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
- border-radius: 6px;
- padding: .5em 0;
- margin-bottom: 1em;
-}
-
-a.download:hover {
- background-color: #bb0010;
-}
-
-.rel {
- margin-bottom: 0;
-}
-
-.rel-note {
- color: #777;
- font-size: .9em;
- margin-top: .1em;
-}
-
-.logo-braces {
- color: #df0019;
- position: relative;
- top: -4px;
-}
-
-.blk {
- float: left;
-}
-
-.left {
- width: 37em;
- padding-right: 6.53em;
- padding-bottom: 1em;
-}
-
-.left1 {
- width: 15.24em;
- padding-right: 6.45em;
-}
-
-.left2 {
- width: 15.24em;
-}
-
-.right {
- width: 20.68em;
-}
-
-.leftbig {
- width: 42.44em;
- padding-right: 6.53em;
-}
-
-.rightsmall {
- width: 15.24em;
-}
-
-.clear:after {
- visibility: hidden;
- display: block;
- font-size: 0;
- content: " ";
- clear: both;
- height: 0;
-}
-.clear { display: inline-block; }
-/* start commented backslash hack \*/
-* html .clear { height: 1%; }
-.clear { display: block; }
-/* close commented backslash hack */
-</style>
-</head>
-<body>
- <h1>CodeMirror: SKWRL demo</h1>
- <div>
- Read about the <a href="http://marmotta.incubator.apache.org/kiwi/reasoner.html" title="Simple KiWi Reasoning Language">SKWRL Langugae</a>
- in <a href="http://marmotta.incubator.apache.org/">Apache Marmotta</a>.
- </div>
- <div>
- <button onclick="javascript:createEditor()">Editor</button>
- <button onclick="javascript:removeEditor()">Plain</button>
- </div>
- <form>
-<textarea id="code" name="code">
-/* rules taken from http://www.w3.org/TR/2004/REC-rdf-mt-20040210/#RDFRules */
-@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
-@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
-@prefix foaf: <http://xmlns.com/foaf/0.1/>
-
-rdf1: ($u $a $y) -> ($a rdf:type rdf:Property)
-rdfs2: ($a rdfs:domain $x), ($u $a $y) -> ($u rdf:type $x)
-rdfs3: ($a rdfs:range $x), ($u $a $v) -> ($v rdf:type $x)
-rdfs4a: ($u $a $x) -> ($u rdf:type rdfs:Resource)
-rdfs5: ($u rdfs:subPropertyOf $v), ($v rdfs:subPropertyOf $x) -> ($u rdfs:subPropertyOf $x)
-rdfs6: ($u rdf:type rdf:Property) -> ($u rdfs:subPropertyOf $u)
-rdfs7: ($a rdfs:subPropertyOf $b), ($u $a $y) -> ($u $b $y)
-rdfs8: ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf rdfs:Resource)
-rdfs9: ($u rdfs:subClassOf $x), ($v rdf:type $u) -> ($v rdf:type $x)
-rdfs10: ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf $u)
-rdfs11: ($u rdfs:subClassOf $v), ($v rdfs:subClassOf $x) -> ($u rdfs:subClassOf $x)
-rdfs12: ($u rdf:type rdfs:ContainerMembershipProperty) -> ($u rdfs:subPropertyOf rdfs:member)
-rdfs13: ($u rdf:type rdfs:Datatype) -> ($u rdfs:subClassOf rdfs:Literal)
-
-</textarea>
- </form>
- <script>
- var editor = null;
- function createEditor() {
- if (editor === null) {
- editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- lineNumbers : true,
- matchBrackets : true,
- extraKeys: {"Ctrl-Space": "skwrlAutocomplete"},
- mode : "skwrl"
- });
- }
- }
- function removeEditor() {
- if (editor) {
- editor.toTextArea();
- editor = null;
- }
- }
- createEditor();
- </script>
-</body>
-</html>