You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/07/09 11:50:43 UTC
[02/41] - moved SNORQL to WebJar - moved CodeMirror to WebJar - moved
Sgvizler to WebJar - cleaned up uses of non-webjar jquery and jquery-ui -
configured YUI compressor for the above packages in build
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5fd590b4/platform/marmotta-sparql/src/main/resources/web/cm/index.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/resources/web/cm/index.html b/platform/marmotta-sparql/src/main/resources/web/cm/index.html
deleted file mode 100644
index 29a4279..0000000
--- a/platform/marmotta-sparql/src/main/resources/web/cm/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 src="../../core/public/js/lib/jquery-1.7.2.js" type="text/javascript"></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/5fd590b4/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.css
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.css b/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.css
deleted file mode 100644
index c7a040c..0000000
--- a/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.css
+++ /dev/null
@@ -1,33 +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.
- */
-#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/incubator-marmotta/blob/5fd590b4/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.js
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.js b/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.js
deleted file mode 100644
index 27f8ead..0000000
--- a/platform/marmotta-sparql/src/main/resources/web/cm/simple-hint.js
+++ /dev/null
@@ -1,89 +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.
- */
-(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/incubator-marmotta/blob/5fd590b4/platform/marmotta-sparql/src/main/resources/web/cm/sparql.js
----------------------------------------------------------------------
diff --git a/platform/marmotta-sparql/src/main/resources/web/cm/sparql.js b/platform/marmotta-sparql/src/main/resources/web/cm/sparql.js
deleted file mode 100644
index ff3ad70..0000000
--- a/platform/marmotta-sparql/src/main/resources/web/cm/sparql.js
+++ /dev/null
@@ -1,219 +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.
- */
-CodeMirror.defineMode("sparql", function(config) {
- var indentUnit = config.indentUnit;
- var curPunc;
-
- function wordRegexp(words) {
- return new RegExp("^(?:" + words.join("|") + ")$", "i");
- }
- var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
- "isblank", "isliteral", "union", "a"]);
- var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
- "ask", "from", "named", "where", "group", "order", "limit", "offset", "filter",
- "optional", "graph", "by", "asc", "desc", "insert", "data", "delete"]);
- var operatorChars = /[*+\-<>=&|]/;
-
- function tokenBase(stream, state) {
- var ch = stream.next();
- curPunc = null;
- if (ch == "$" || ch == "?") {
- stream.match(/^[\w\d]*/);
- return "variable-2";
- }
- else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) {
- stream.match(/^[^\s\u00a0>]*>?/);
- return "atom";
- }
- else if (ch == "\"" || ch == "'") {
- state.tokenize = tokenLiteral(ch);
- return state.tokenize(stream, state);
- }
- else if (/[{}\(\),\.;\[\]]/.test(ch)) {
- curPunc = ch;
- return null;
- }
- else if (ch == "#") {
- stream.skipToEnd();
- return "comment";
- }
- else if (operatorChars.test(ch)) {
- stream.eatWhile(operatorChars);
- return null;
- }
- else if (ch == ":") {
- stream.eatWhile(/[\w\d\._\-]/);
- return "atom";
- }
- else {
- stream.eatWhile(/[_\w\d]/);
- if (stream.eat(":")) {
- stream.eatWhile(/[\w\d_\-]/);
- return "atom";
- }
- var word = stream.current(), type;
- if (ops.test(word))
- return null;
- else if (keywords.test(word))
- return "keyword";
- else
- return "variable";
- }
- }
-
- function tokenLiteral(quote) {
- return function(stream, state) {
- var escaped = false, ch;
- while ((ch = stream.next()) != null) {
- if (ch == quote && !escaped) {
- state.tokenize = tokenBase;
- break;
- }
- escaped = !escaped && ch == "\\";
- }
- return "string";
- };
- }
-
- function pushContext(state, type, col) {
- state.context = {prev: state.context, indent: state.indent, col: col, type: type};
- }
- function popContext(state) {
- state.indent = state.context.indent;
- state.context = state.context.prev;
- }
-
- return {
- startState: function(base) {
- return {tokenize: tokenBase,
- context: null,
- indent: 0,
- col: 0};
- },
-
- token: function(stream, state) {
- if (stream.sol()) {
- if (state.context && state.context.align == null) state.context.align = false;
- state.indent = stream.indentation();
- }
- if (stream.eatSpace()) return null;
- var style = state.tokenize(stream, state);
-
- if (style != "comment" && state.context && state.context.align == null && state.context.type != "pattern") {
- state.context.align = true;
- }
-
- if (curPunc == "(") pushContext(state, ")", stream.column());
- else if (curPunc == "[") pushContext(state, "]", stream.column());
- else if (curPunc == "{") pushContext(state, "}", stream.column());
- else if (/[\]\}\)]/.test(curPunc)) {
- while (state.context && state.context.type == "pattern") popContext(state);
- if (state.context && curPunc == state.context.type) popContext(state);
- }
- else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state);
- else if (/atom|string|variable/.test(style) && state.context) {
- if (/[\}\]]/.test(state.context.type))
- pushContext(state, "pattern", stream.column());
- else if (state.context.type == "pattern" && !state.context.align) {
- state.context.align = true;
- state.context.col = stream.column();
- }
- }
-
- return style;
- },
-
- indent: function(state, textAfter) {
- var firstChar = textAfter && textAfter.charAt(0);
- var context = state.context;
- if (/[\]\}]/.test(firstChar))
- while (context && context.type == "pattern") context = context.prev;
-
- var closing = context && firstChar == context.type;
- if (!context)
- return 0;
- else if (context.type == "pattern")
- return context.col;
- else if (context.align)
- return context.col + (closing ? 0 : 1);
- else
- return context.indent + (closing ? 0 : indentUnit);
- }
- };
-});
-
-if (CodeMirror.simpleHint && jQuery) {
- function completePrefix(editor, cur, token, prevToken) {
- 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("http://prefix.cc/" + prefix + ".file.json", {
- async: false,
- 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;
- }
- CodeMirror.commands.sparqlAutocomplete = function(cm) {
- CodeMirror.simpleHint(cm, function(editor) {
- var cur = editor.getCursor();
- var line = editor.getLine(cur.line);
-
- // search for the last prefix
- for(i = cur.ch; i >= 0; i--) {
- var token = editor.getTokenAt({line: cur.line, ch: i});
- if(token.className == "keyword" && token.string == "PREFIX") {
- break;
- }
- }
- console.dir(token);
-
- // search for the next atom
- for(i = token.end + 1; i <= cur.ch; i++) {
- var atomToken = editor.getTokenAt({line: cur.line, ch: i});
- if(atomToken.className == "atom") {
- break;
- }
- }
- console.dir(atomToken);
-
-
- if (atomToken.className == "atom") {
- return completePrefix(editor, cur, atomToken, token);
- }
- });
- }
-}
-
-
-CodeMirror.defineMIME("application/x-sparql-query", "sparql");
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5fd590b4/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
index 37fec15..1f4dcc3 100644
--- a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
+++ b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
@@ -237,25 +237,29 @@ public class UserWebService {
@GET
@Path("/{login:[^#?]+}")
public Response getUser(@PathParam("login") String login, @HeaderParam("Accept") String types) {
- try {
- RepositoryConnection conn = sesameService.getConnection();
+ if(login.equals("me")) {
+ return get();
+ } else {
try {
- final URI user = userService.getUser(login);
- if (user == null) return Response.status(Status.NOT_FOUND).entity(String.format("User %s not found", login)).build();
+ RepositoryConnection conn = sesameService.getConnection();
+ try {
+ final URI user = userService.getUser(login);
+ if (user == null) return Response.status(Status.NOT_FOUND).entity(String.format("User %s not found", login)).build();
- java.net.URI u = new java.net.URI(configurationService.getServerUri() + "resource?uri=" + URLEncoder.encode(user.stringValue(), "utf-8"));
+ java.net.URI u = new java.net.URI(configurationService.getServerUri() + "resource?uri=" + URLEncoder.encode(user.stringValue(), "utf-8"));
- return Response.seeOther(u).header("Accept", types).build();
- } finally {
- conn.commit();
- conn.commit();
+ return Response.seeOther(u).header("Accept", types).build();
+ } finally {
+ conn.commit();
+ conn.commit();
+ }
+ } catch (URISyntaxException e) {
+ return Response.status(Status.BAD_REQUEST).entity(String.format("Invalid URI: %s", e.getMessage())).build();
+ } catch (UnsupportedEncodingException e) {
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
+ } catch (RepositoryException e) {
+ return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
- } catch (URISyntaxException e) {
- return Response.status(Status.BAD_REQUEST).entity(String.format("Invalid URI: %s", e.getMessage())).build();
- } catch (UnsupportedEncodingException e) {
- return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
- } catch (RepositoryException e) {
- return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}