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/08/28 14:11:28 UTC
[1/3] git commit: MARMOTTA-220: skwrl mode for codemirror
Updated Branches:
refs/heads/develop 54b765008 -> b7502cae7
MARMOTTA-220: skwrl mode for codemirror
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/b7502cae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/b7502cae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/b7502cae
Branch: refs/heads/develop
Commit: b7502cae75b18d6898f26ed9a2d2201977d9298a
Parents: 8f99c34
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Aug 27 17:13:13 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Wed Aug 28 14:09:47 2013 +0200
----------------------------------------------------------------------
.../codemirror/src/main/resources/index.html | 242 ---------
.../codemirror/src/main/resources/ldpath.html | 242 +++++++++
.../codemirror/src/main/resources/skwrl.html | 250 ++++++++++
.../codemirror/src/main/resources/skwrl.js | 491 +++++++++++++++++++
4 files changed, 983 insertions(+), 242 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/b7502cae/extras/webjars/codemirror/src/main/resources/index.html
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/index.html b/extras/webjars/codemirror/src/main/resources/index.html
deleted file mode 100644
index 3fef19a..0000000
--- a/extras/webjars/codemirror/src/main/resources/index.html
+++ /dev/null
@@ -1,242 +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>
- <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/incubator-marmotta/blob/b7502cae/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
new file mode 100644
index 0000000..3fef19a
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/ldpath.html
@@ -0,0 +1,242 @@
+<!--
+
+ 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>
+ <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/incubator-marmotta/blob/b7502cae/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
new file mode 100644
index 0000000..6352236
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/skwrl.html
@@ -0,0 +1,250 @@
+<!--
+
+ 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: LDPath demo</h1>
+ <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>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/b7502cae/extras/webjars/codemirror/src/main/resources/skwrl.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/skwrl.js b/extras/webjars/codemirror/src/main/resources/skwrl.js
new file mode 100644
index 0000000..e4f473f
--- /dev/null
+++ b/extras/webjars/codemirror/src/main/resources/skwrl.js
@@ -0,0 +1,491 @@
+/*
+ * 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.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", {
+ 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}
+ };
+ }
+ }
+ }
+ CodeMirror.commands.skwrlAutocomplete = 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);
+ }
+ }
+ });
+ }
+}
+
+}
[3/3] git commit: MARMOTTA-242: Set default output-encoding for
freemarker
Posted by ja...@apache.org.
MARMOTTA-242: Set default output-encoding for freemarker
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/0eed0277
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/0eed0277
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/0eed0277
Branch: refs/heads/develop
Commit: 0eed02773c8de1dda60a3c075a4d20cf102e763a
Parents: 54b7650
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Aug 27 12:21:51 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Wed Aug 28 14:09:47 2013 +0200
----------------------------------------------------------------------
.../ldpath/template/engine/LDPathDirective.java | 5 +++--
.../template/engine/NamespaceDirective.java | 1 +
.../ldpath/template/engine/TemplateEngine.java | 18 +++++++++---------
.../model/freemarker/TemplateNodeModel.java | 2 +-
.../model/freemarker/TemplateWrapperModel.java | 2 +-
.../transformers/TemplateLongTransformer.java | 4 ++--
6 files changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/0eed0277/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/LDPathDirective.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/LDPathDirective.java b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/LDPathDirective.java
index 78902e8..d5deeaa 100644
--- a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/LDPathDirective.java
+++ b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/LDPathDirective.java
@@ -116,8 +116,9 @@ public class LDPathDirective<Node> implements TemplateDirectiveModel {
*
* @throws java.io.IOException
*/
+ @SuppressWarnings("unchecked")
@Override
- public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
+ public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
TemplateStackModel contextStack = (TemplateStackModel)env.getVariable("context");
if(contextStack == null || contextStack.empty()) {
throw new TemplateModelException("error; no context node available");
@@ -147,7 +148,7 @@ public class LDPathDirective<Node> implements TemplateDirectiveModel {
path = path + ":: xsd:string";
}
try {
- Collection results = ldpath.pathTransform(context.getNode(),path,namespaces);
+ Collection<?> results = ldpath.pathTransform(context.getNode(),path,namespaces);
if(results.size() > 0) {
Object result = results.iterator().next();
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/0eed0277/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/NamespaceDirective.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/NamespaceDirective.java b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/NamespaceDirective.java
index fc5ea85..a111963 100644
--- a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/NamespaceDirective.java
+++ b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/NamespaceDirective.java
@@ -70,6 +70,7 @@ public class NamespaceDirective implements TemplateDirectiveModel {
*
* @throws java.io.IOException
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
TemplateWrapperModel<Map<String,String>> namespacesWrapped = (TemplateWrapperModel<Map<String,String>>)env.getGlobalVariable("namespaces");
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/0eed0277/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/TemplateEngine.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/TemplateEngine.java b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/TemplateEngine.java
index d99d542..a10534e 100644
--- a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/TemplateEngine.java
+++ b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/engine/TemplateEngine.java
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import org.apache.marmotta.ldpath.api.backend.RDFBackend;
import org.apache.marmotta.ldpath.template.model.freemarker.TemplateNodeModel;
@@ -52,6 +51,7 @@ public class TemplateEngine<Node> {
this.backend = backend;
freemarker = new Configuration();
+ freemarker.setDefaultEncoding("utf-8");
freemarker.setObjectWrapper(new DefaultObjectWrapper());
@@ -77,7 +77,7 @@ public class TemplateEngine<Node> {
freemarker.setServletContextForTemplateLoading(sctxt, path);
}
- public void setClassForTemplateLoading(Class clazz, String pathPrefix) {
+ public void setClassForTemplateLoading(Class<?> clazz, String pathPrefix) {
freemarker.setClassForTemplateLoading(clazz, pathPrefix);
}
@@ -109,26 +109,26 @@ public class TemplateEngine<Node> {
* @throws IOException
* @throws TemplateException
*/
- public void processFileTemplate(Node context, String templateName, Map initialEnv, Writer out) throws IOException, TemplateException {
+ public void processFileTemplate(Node context, String templateName, Map<String, ?> initialEnv, Writer out) throws IOException, TemplateException {
processTemplate(context,freemarker.getTemplate(templateName),initialEnv,out);
}
- private void processTemplate(Node context, Template template, Map initialEnv, Writer out) throws IOException, TemplateException {
- Map root = new HashMap();
+ private void processTemplate(Node context, Template template, Map<String, ?> initialEnv, Writer out) throws IOException, TemplateException {
+ Map<String, Object> root = new HashMap<>();
if(initialEnv != null) {
- for(Map.Entry entry : (Set<Map.Entry>) initialEnv.entrySet()) {
+ for(Map.Entry<String, ?> entry : initialEnv.entrySet()) {
root.put(entry.getKey(), entry.getValue());
}
}
root.put("namespace", new NamespaceDirective());
- root.put("evalLDPath",new LDPathMethod(backend));
- root.put("ldpath",new LDPathDirective(backend));
+ root.put("evalLDPath",new LDPathMethod<>(backend));
+ root.put("ldpath",new LDPathDirective<>(backend));
TemplateStackModel contexts = new TemplateStackModel();
- contexts.push(new TemplateNodeModel(context,backend));
+ contexts.push(new TemplateNodeModel<>(context,backend));
root.put("context",contexts);
template.process(root,out);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/0eed0277/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateNodeModel.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateNodeModel.java b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateNodeModel.java
index 91fc21c..6d369fa 100644
--- a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateNodeModel.java
+++ b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateNodeModel.java
@@ -105,7 +105,7 @@ public class TemplateNodeModel<Node> implements TemplateModel, TemplateHashModel
* class.
*/
@Override
- public Object getAdaptedObject(Class hint) {
+ public Object getAdaptedObject(@SuppressWarnings("rawtypes") Class hint) {
return node;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/0eed0277/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateWrapperModel.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateWrapperModel.java b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateWrapperModel.java
index 90b066f..2f24609 100644
--- a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateWrapperModel.java
+++ b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/freemarker/TemplateWrapperModel.java
@@ -50,7 +50,7 @@ public class TemplateWrapperModel<T> implements AdapterTemplateModel {
* class.
*/
@Override
- public T getAdaptedObject(Class hint) {
+ public T getAdaptedObject(@SuppressWarnings("rawtypes") Class hint) {
return object;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/0eed0277/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/transformers/TemplateLongTransformer.java
----------------------------------------------------------------------
diff --git a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/transformers/TemplateLongTransformer.java b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/transformers/TemplateLongTransformer.java
index 3e55e01..8f12d36 100644
--- a/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/transformers/TemplateLongTransformer.java
+++ b/libraries/ldpath/ldpath-template/src/main/java/org/apache/marmotta/ldpath/template/model/transformers/TemplateLongTransformer.java
@@ -33,10 +33,10 @@ import java.util.Map;
*/
public class TemplateLongTransformer<Node> implements NodeTransformer<TemplateNumberModel,Node> {
- private LongTransformer delegate;
+ private LongTransformer<Node> delegate;
public TemplateLongTransformer() {
- delegate = new LongTransformer();
+ delegate = new LongTransformer<>();
}
/**
[2/3] git commit: MARMOTTA-219: Added support for comments in the
ldpath-plugin for codemirror MARMOTTA-213: Fixed License-Header in 3rd-party
source files (codemirror)
Posted by ja...@apache.org.
MARMOTTA-219: Added support for comments in the ldpath-plugin for
codemirror
MARMOTTA-213: Fixed License-Header in 3rd-party source files
(codemirror)
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/8f99c34b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/8f99c34b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/8f99c34b
Branch: refs/heads/develop
Commit: 8f99c34b0a71e7d90f4e78142566681ead0f87bb
Parents: 0eed027
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Aug 27 14:45:29 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Wed Aug 28 14:09:47 2013 +0200
----------------------------------------------------------------------
.../src/main/resources/codemirror.css | 19 ++-----------
.../codemirror/src/main/resources/codemirror.js | 19 ++-----------
.../codemirror/src/main/resources/ldpath.js | 30 ++++++++++++++++++--
.../src/main/resources/simple-hint.css | 19 ++-----------
.../src/main/resources/simple-hint.js | 25 ++++++----------
.../codemirror/src/main/resources/sparql.js | 25 ++++++----------
parent/pom.xml | 7 +++++
7 files changed, 59 insertions(+), 85 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8f99c34b/extras/webjars/codemirror/src/main/resources/codemirror.css
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/codemirror.css b/extras/webjars/codemirror/src/main/resources/codemirror.css
index b5385d7..8c8ffe0 100644
--- a/extras/webjars/codemirror/src/main/resources/codemirror.css
+++ b/extras/webjars/codemirror/src/main/resources/codemirror.css
@@ -1,20 +1,7 @@
-/**
- * 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
+/* CodeMirror version 2.24
*
- * 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.
- */
+ * License: MIT-License <http://codemirror.net/LICENSE>
+*/
#center .CodeMirror, .CodeMirror {
line-height: 1em;
font-family: monospace;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8f99c34b/extras/webjars/codemirror/src/main/resources/codemirror.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/codemirror.js b/extras/webjars/codemirror/src/main/resources/codemirror.js
index 72609ee..bbe5006 100644
--- a/extras/webjars/codemirror/src/main/resources/codemirror.js
+++ b/extras/webjars/codemirror/src/main/resources/codemirror.js
@@ -1,25 +1,10 @@
-/*
- * 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 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>
// CodeMirror is the only global var we claim
var CodeMirror = (function() {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8f99c34b/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
index 016142f..a5eb1a4 100644
--- a/extras/webjars/codemirror/src/main/resources/ldpath.js
+++ b/extras/webjars/codemirror/src/main/resources/ldpath.js
@@ -18,6 +18,7 @@
if (CodeMirror && CodeMirror.defineMode) {
CodeMirror.defineMode("ldpath", function(config, parserConfig) {
var token = {
+ COMMENT: "comment",
OP: "operator",
KWD: "keyword",
PREFIX: "qualifier",
@@ -92,6 +93,12 @@ CodeMirror.defineMode("ldpath", function(config, parserConfig) {
}
function tokenDefault(stream, state) {
+ // /* ... */
+ if (stream.match('/*')) {
+ state.push('comment');
+ return token.COMMENT;
+ }
+
// @...
var kw = stream.match(/^@(\w+)/, true);
if (kw) {
@@ -134,7 +141,7 @@ CodeMirror.defineMode("ldpath", function(config, parserConfig) {
px = stream.current();
stream.eat(':');
if (state.getNamespace(px))
- return token.PREFIX;
+ return token.PREFIX;
else return token.WARNING;
}
}
@@ -207,6 +214,9 @@ CodeMirror.defineMode("ldpath", function(config, parserConfig) {
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;
@@ -232,8 +242,21 @@ CodeMirror.defineMode("ldpath", function(config, parserConfig) {
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']);
@@ -246,9 +269,12 @@ CodeMirror.defineMode("ldpath", function(config, parserConfig) {
log(stream, state, result);
return result;
},
- electricChars: "@=[];",
+ 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;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8f99c34b/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
index c7a040c..2deea4e 100644
--- a/extras/webjars/codemirror/src/main/resources/simple-hint.css
+++ b/extras/webjars/codemirror/src/main/resources/simple-hint.css
@@ -1,20 +1,7 @@
-/**
- * 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
+/* CodeMirror version 2.24
*
- * 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.
- */
+ * License: MIT-License <http://codemirror.net/LICENSE>
+*/
#center .CodeMirror-completions, .CodeMirror-completions {
position: absolute;
z-index: 10;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8f99c34b/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
index 27f8ead..ad0f5eb 100644
--- a/extras/webjars/codemirror/src/main/resources/simple-hint.js
+++ b/extras/webjars/codemirror/src/main/resources/simple-hint.js
@@ -1,20 +1,11 @@
-/*
- * 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 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.
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8f99c34b/extras/webjars/codemirror/src/main/resources/sparql.js
----------------------------------------------------------------------
diff --git a/extras/webjars/codemirror/src/main/resources/sparql.js b/extras/webjars/codemirror/src/main/resources/sparql.js
index ff3ad70..8ffa73b 100644
--- a/extras/webjars/codemirror/src/main/resources/sparql.js
+++ b/extras/webjars/codemirror/src/main/resources/sparql.js
@@ -1,20 +1,11 @@
-/*
- * 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 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>
+
CodeMirror.defineMode("sparql", function(config) {
var indentUnit = config.indentUnit;
var curPunc;
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/8f99c34b/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 6774a67..283c25e 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -410,6 +410,13 @@
<exclude>**/src/main/java/solr2155/**</exclude>
<exclude>**/src/main/java/net/miginfocom/**</exclude>
<exclude>**/src/main/java/org/oxbow/**</exclude>
+
+ <!-- codemirror -->
+ <exclude>**/codemirror.js</exclude>
+ <exclude>**/codemirror.css</exclude>
+ <exclude>**/simple-hint.js</exclude>
+ <exclude>**/simple-hint.css</exclude>
+ <exclude>**/sparql.js</exclude>
</excludes>
</configuration>
</plugin>