From: <tho...@us...> - 2014-03-06 22:38:59
|
Revision: 7916 http://sourceforge.net/p/bigdata/code/7916 Author: thompsonbry Date: 2014-03-06 22:38:54 +0000 (Thu, 06 Mar 2014) Log Message: ----------- Checkpoint in the RDR branch on a continued refactoring to support both the web.xml and jetty.xml based configuration of the HAJournalServer, the restructuring of the webapp, and forward movement to jetty 9.1. jetty 9.1 will give us the ability to transparently map http://localhost:8080 onto http://localhost:8080/bigdata (which we can probably accomplish anyway with jetty-rewrite). It will also provide us with a supportable basis for the ProxyServlet to support transparent load balancing. Finally, jetty 9.1 has a new IO layer and could potentially increase http performance - it is certainly the starting point for optimization at that layer. See #730 (Allow configuration of embedded NSS jetty server using jetty-web.xml) See #624 (Transparent proxy of requests for HA) Modified Paths: -------------- branches/RDR/.classpath branches/RDR/bigdata/src/java/com/bigdata/btree/BytesUtil.c branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java branches/RDR/bigdata-war/src/WEB-INF/web.xml branches/RDR/bigdata-war/src/html/index.html branches/RDR/bigdata-war/src/html/new.html branches/RDR/build.properties branches/RDR/build.xml branches/RDR/src/resources/HAJournal/startHAServices.config branches/RDR/src/resources/bin/startHAServices branches/RDR/src/resources/etc/bigdata/bigdataHA.config Added Paths: ----------- branches/RDR/bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar branches/RDR/bigdata-war/src/html/css/ branches/RDR/bigdata-war/src/html/css/style.css branches/RDR/bigdata-war/src/html/images/ branches/RDR/bigdata-war/src/html/images/logo.png branches/RDR/bigdata-war/src/html/js/ branches/RDR/bigdata-war/src/html/js/vendor/ branches/RDR/bigdata-war/src/html/js/vendor/jquery.hotkeys.js branches/RDR/bigdata-war/src/html/js/vendor/jquery.min.js branches/RDR/bigdata-war/src/html/js/workbench.js branches/RDR/bigdata-war/src/jetty.xml Removed Paths: ------------- branches/RDR/bigdata-war/src/WEB-INF/jetty.xml branches/RDR/bigdata-war/src/html/jquery.hotkeys.js branches/RDR/bigdata-war/src/html/jquery.min.js branches/RDR/bigdata-war/src/html/logo.png branches/RDR/bigdata-war/src/html/style.css branches/RDR/bigdata-war/src/html/workbench.js branches/RDR/bigdata-war/src/images/ branches/RDR/bigdata-war/src/index.html branches/RDR/bigdata-war/src/jsp/ branches/RDR/bigdata-war/src/resources/ branches/RDR/bigdata-war/src/result-to-html.xsl Modified: branches/RDR/.classpath =================================================================== --- branches/RDR/.classpath 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/.classpath 2014-03-06 22:38:54 UTC (rev 7916) @@ -67,6 +67,7 @@ <classpathentry exported="true" kind="lib" path="bigdata/lib/unimi/fastutil-5.1.5.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/lucene/lucene-analyzers-3.0.0.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/lucene/lucene-core-3.0.0.jar"/> + <classpathentry kind="lib" path="bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/high-scale-lib-v1.1.2.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/junit-ext-1.1-b3-dev.jar"/> Added: branches/RDR/bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar =================================================================== (Binary files differ) Index: branches/RDR/bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar =================================================================== --- branches/RDR/bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar 2014-03-06 22:38:54 UTC (rev 7916) Property changes on: branches/RDR/bigdata/lib/jetty/jetty-rewrite-7.2.2.v20101205.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: branches/RDR/bigdata/src/java/com/bigdata/btree/BytesUtil.c =================================================================== --- branches/RDR/bigdata/src/java/com/bigdata/btree/BytesUtil.c 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata/src/java/com/bigdata/btree/BytesUtil.c 2014-03-06 22:38:54 UTC (rev 7916) @@ -1,6 +1,6 @@ /** -Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. +Copyright (C) SYSTAP, LLC 2006-2014. All rights reserved. Contact: SYSTAP, LLC @@ -32,29 +32,60 @@ * Compile the Java class and then generate the C header file from that class. * From the bigdata directory, do: -javac src/java/com/bigdata/btree/BytesUtil.java +# Note: This approach no longer works as executed due to new imports that +# can not be trivially resolved by javac. +# +# cd bigdata +# javac src/java/com/bigdata/btree/BytesUtil.java +# javah -classpath src/java com.bigdata.btree.BytesUtil -javah -classpath src/java com.bigdata.btree.BytesUtil +# The easiest thing to do is "ant jar" first to generate the class files. +# Then you can do something like: +# +ant bundleJar # generate the class files, the jar, and colocate the dependency jars. +cd bigdata +javah -classpath ../ant-build/classes com.bigdata.btree.BytesUtil - * This places the .class file in the source directory and the .h files in the - * bigdata directory. - */ +This places the .h files in the bigdata directory. -/* Now compile the C file. You can compile this under linix as follows: - * +Now compile the C file. You can compile this under linux as follows: -set JAVA_HOME="/usr/java/j2sdk1.4.2_05" +## For linux. +export JAVA_HOME="/usr/java/jdk1.7.0_25" +export JAVA_INCLUDE=$JAVA_HOME/include +## For OSX +export JAVA_HOME=$(/usr/libexec/java_home) +export JAVA_INCLUDE=/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers -export PATH=$PATH:/$JAVA_HOME/bin +# For both : put the java version on the command path. +export PATH=$JAVA_HOME/bin:$PATH +# For linux. +gcc -fPIC -g -I$JAVA_INCLUDE -I$JAVA_INCLUDE/linux -c src/java/com/bigdata/btree/BytesUtil.c +# +# For OSX +gcc -fPIC -g -I. -I$JAVA_INCLUDE -c src/java/com/bigdata/btree/BytesUtil.c + +# Works for linux/OSX. +gcc -shared -W1,-soname,libBytesUtil.so -o libBytesUtil.so BytesUtil.o -lc + +## At this point you have something like the following in the cwd: +# header files from javac. +# com_bigdata_btree_BytesUtil.h +# com_bigdata_btree_BytesUtil_UnsignedByteArrayComparator.h +# Compiled version of BytesUtil.c +# BytesUtil.o +# Shared library for BytesUtil.o +# libBytesUtil.so - shared library. + +# For both : specify the location of the shared libraries (once compiled). export LD_LIBRARY_PATH=. -gcc -fPIC -g -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -c BytesUtil.c +# Execute the test program: +java -Dcom.bigdata.btree.BytesUtil.jni=true -classpath ../ant-build/classes:../ant-build/lib/log4j-1.2.17.jar com.bigdata.btree.BytesUtil -gcc -shared -W1,-soname,libBytesUtil.so -olibBytesUtil.so BytesUtil.o -lc +---- -java -classpath src/java com.bigdata.btree.BytesUtil - * On Win32, the following command builds a dynamic link library (DLL) * using the Microsoft Visual C++ compiler: Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java =================================================================== --- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/BigdataRDFContext.java 2014-03-06 22:38:54 UTC (rev 7916) @@ -171,7 +171,7 @@ * * @see #XSL_STYLESHEET */ - protected static final String DEFAULT_XSL_STYLESHEET = "result-to-html.xsl"; + protected static final String DEFAULT_XSL_STYLESHEET = "/bigdata/html/result-to-html.xsl"; /** * URL Query parameter used to request an incremental XHTML representation Modified: branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java =================================================================== --- branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/NanoSparqlServer.java 2014-03-06 22:38:54 UTC (rev 7916) @@ -35,6 +35,7 @@ import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.ContextHandler; +import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; @@ -354,17 +355,17 @@ // Force the use of the caller's IIndexManager. context.setAttribute(IIndexManager.class.getName(), indexManager); - final HandlerList handlers = new HandlerList(); - final ResourceHandler resourceHandler = new ResourceHandler(); setupStaticResources(NanoSparqlServer.class.getClassLoader(), resourceHandler); + final HandlerList handlers = new HandlerList(); + handlers.setHandlers(new Handler[] { - context,// - resourceHandler,// -// new DefaultHandler()// + context,// maps servlets + resourceHandler,// maps welcome files. + new DefaultHandler() // responsible for anything not explicitly served. }); server.setHandler(handlers); @@ -525,8 +526,6 @@ final ServletContextHandler context = getContextHandler(//server, initParams); - final HandlerList handlers = new HandlerList(); - final ResourceHandler resourceHandler = new ResourceHandler(); setupStaticResources(NanoSparqlServer.class.getClassLoader(), @@ -555,9 +554,12 @@ * Note: In order for this to work, it must also be supported in the * alternative newInstance() method above. */ + final HandlerList handlers = new HandlerList(); + handlers.setHandlers(new Handler[] {// - context,// - resourceHandler,// + context,// maps servlets + resourceHandler,// maps welcome files. + new DefaultHandler() // responsible for anything not explicitly served. }); server.setHandler(handlers); @@ -589,6 +591,9 @@ // | ServletContextHandler.NO_SESSIONS ); + // Path to the webapp. + context.setContextPath("/bigdata"); + // /* // * Setup resolution for the static web app resources (index.html). // */ @@ -723,8 +728,13 @@ final String webDir = indexHtml.substring(0, indexHtml.length() - file.length()); + // Path to the content in the local file system or JAR. context.setResourceBase(webDir); - + + /* + * Note: replace with "new.html" for the new UX. Also change in + * web.xml. + */ context.setWelcomeFiles(new String[]{"index.html"}); } @@ -756,7 +766,7 @@ /* * This is the resource path in the JAR. */ - final String WEB_DIR_JAR = "bigdata-war/src" + final String WEB_DIR_JAR = "bigdata-war/src/html" + (path == null ? "" : "/" + path); /* @@ -764,13 +774,13 @@ * * Note: You MUST have "bigdata-war/src" on the build path for the IDE. */ - final String WEB_DIR_IDE = path; // "html"; + final String WEB_DIR_IDE = "html/" + path; // "html"; URL url = classLoader.getResource(WEB_DIR_JAR); if (url == null && path != null) { - url = classLoader.getResource(path);// "html"); + url = classLoader.getResource(WEB_DIR_IDE);// "html"); } Deleted: branches/RDR/bigdata-war/src/WEB-INF/jetty.xml =================================================================== --- branches/RDR/bigdata-war/src/WEB-INF/jetty.xml 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/WEB-INF/jetty.xml 2014-03-06 22:38:54 UTC (rev 7916) @@ -1,60 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"> -<!-- See http://www.eclipse.org/jetty/documentation/current/ --> -<!-- See http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax --> -<Configure id="Server" class="org.eclipse.jetty.server.Server"> - - <!-- =========================================================== --> - <!-- Server Thread Pool --> - <!-- =========================================================== --> - <Set name="ThreadPool"> - <!-- Default queued blocking threadpool --> - <New class="org.eclipse.jetty.util.thread.QueuedThreadPool"> - <Set name="minThreads">10</Set> - <Set name="maxThreads">64</Set> - </New> - </Set> - - <!-- =========================================================== --> - <!-- Set connectors --> - <!-- =========================================================== --> - - <Call name="addConnector"> - <Arg> - <New class="org.eclipse.jetty.server.nio.SelectChannelConnector"> - <Set name="host"><SystemProperty name="jetty.host" /></Set> - <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set> - </New> - </Arg> - </Call> - - <!-- =========================================================== --> - <!-- Set handler Collection Structure --> - <!-- =========================================================== --> - <Set name="handler"> - <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> - <Set name="handlers"> - <Array type="org.eclipse.jetty.server.Handler"> - <Item> - <New id="WebAppContext" class="org.eclipse.jetty.webapp.WebAppContext"> - <!-- The location of the top-level of the bigdata webapp. --> - <Set name="resourceBase"> - <SystemProperty name="jetty.resourceBase" default="bigdata-war/src" /> - </Set> - <Set name="contextPath">/</Set> - <Set name="descriptor">WEB-INF/web.xml</Set> - <Set name="parentLoaderPriority">true</Set> - <Set name="extractWAR">false</Set> - <Set name="welcomeFiles"> - <Array type="java.lang.String"> - <Item>index.html</Item> - </Array> - </Set> - </New> - </Item> - </Array> - </Set> - </New> - </Set> - -</Configure> \ No newline at end of file Modified: branches/RDR/bigdata-war/src/WEB-INF/web.xml =================================================================== --- branches/RDR/bigdata-war/src/WEB-INF/web.xml 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/WEB-INF/web.xml 2014-03-06 22:38:54 UTC (rev 7916) @@ -83,6 +83,15 @@ <description>Performance counters.</description> <servlet-class>com.bigdata.rdf.sail.webapp.CountersServlet</servlet-class> </servlet> + <!-- Map the initial request into the UI. --> + <welcome-file-list> + <welcome-file>html/index.html</welcome-file> + </welcome-file-list> + <!-- Serve anything under /html/* as a simple file. --> + <servlet-mapping> + <servlet-name>default</servlet-name> + <url-pattern>/html/*</url-pattern> + </servlet-mapping> <!-- Mapping for the default KB namespace (as configured above). --> <servlet-mapping> <servlet-name>REST API</servlet-name> Copied: branches/RDR/bigdata-war/src/html/css/style.css (from rev 7915, branches/RDR/bigdata-war/src/html/style.css) =================================================================== --- branches/RDR/bigdata-war/src/html/css/style.css (rev 0) +++ branches/RDR/bigdata-war/src/html/css/style.css 2014-03-06 22:38:54 UTC (rev 7916) @@ -0,0 +1,178 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} + + +/* Workbench */ + +body { + margin: 10px; +} + +#container { + /*max-width: 600px;*/ +} + +#top { + text-align: right; + margin-bottom: 20px; +} + +#logo { + float: left; +} + +.shadow { + -webkit-box-shadow: 0px 3px 5px 0px rgba(50, 50, 50, 0.75); + -moz-box-shadow: 0px 3px 5px 0px rgba(50, 50, 50, 0.75); + box-shadow: 0px 3px 5px 0px rgba(50, 50, 50, 0.75); +} + +#tab-selector { + clear: both; +} + +#tab-selector a { + padding: 10px; + border: 1px solid; + border-right: none; + border-bottom: none; + display: inline-block; + float: left; + cursor: pointer; +} + +#tab-selector a:last-of-type { + border-right: 1px solid; +} + +.active { + background: lightgrey; +} + +.tab { + display: none; + clear: both; +} + +.box { + border: 1px solid; + padding: 10px; + border: 1px solid; + border-bottom: none; + min-height: 100px; + overflow-x: scroll; +} + +.box:last-of-type { + border-bottom: 1px solid; +} + +.namespace-shortcuts { + text-align: right; +} + +.namespace-shortcuts li { + display: inline-block; + border: 1px solid; + padding: 5px; + margin-left: 5px; + cursor: pointer; +} + +#large-file-message { + display: none; + margin: 5px 0; +} + +textarea { + margin: 5px 0; + width: 100%; + height: 200px; + box-sizing: border-box; +} + +#rdf-type-container { + display: none; +} + +hr { + background: #929292; + border: none; + height: 5px; + width: 50%; + margin: 20px auto; +} + +#load-load { + margin: 0 auto; + display: block; +} + +#load-buttons { + text-align: center; +} + +.bottom { + border-top: 1px solid; + text-align: right; +} + +#advanced-features, #query-explanation { + display: none; +} + +td { + border: 1px solid; + padding: 5px; +} + +pre { + font-family: monospace; +} + Added: branches/RDR/bigdata-war/src/html/images/logo.png =================================================================== (Binary files differ) Index: branches/RDR/bigdata-war/src/html/images/logo.png =================================================================== --- branches/RDR/bigdata-war/src/html/images/logo.png 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/html/images/logo.png 2014-03-06 22:38:54 UTC (rev 7916) Property changes on: branches/RDR/bigdata-war/src/html/images/logo.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: branches/RDR/bigdata-war/src/html/index.html =================================================================== --- branches/RDR/bigdata-war/src/html/index.html 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/html/index.html 2014-03-06 22:38:54 UTC (rev 7916) @@ -5,20 +5,15 @@ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <title>bigdata® NanoSparqlServer</title> <!-- $Id$ --> -<style> -td { - border: 1px solid; -} -</style> </head> <body> <h2>Welcome to bigdata®.</h2> <p>Please consult the -<a href="https://sourceforge.net/apps/mediawiki/bigdata/index.php?title=NanoSparqlServer" +<a href="http://wiki.bigdata.com/wiki/index.php/NanoSparqlServer" target="_blank" > documentation</a> for information on using the NanoSparqlServer's REST Api. </br>See the - <a href="https://sourceforge.net/apps/mediawiki/bigdata/index.php?title=Main_Page" + <a href="http://wiki.bigdata.com/wiki/index.php/Main_Page" target="_blank" >wiki</a> for help on query optimization, bigdata SPARQL extensions, etc. </p> @@ -30,13 +25,13 @@ <dt>http://hostname:port/bigdata</dt> <dd>This page.</dd> <dt>http://hostname:port/bigdata/sparql</dt> -<dd>The SPARQL REST API (<a href="sparql">Service Description + VoID Description</a>).</dd> +<dd>The SPARQL REST API (<a href="/bigdata/sparql">Service Description + VoID Description</a>).</dd> <dt>http://hostname:port/bigdata/namespace</dt> -<dd>VoID <a href="namespace">graph of available KBs</a> from this service.</dd> +<dd>VoID <a href="/bigdata/namespace">graph of available KBs</a> from this service.</dd> <dt>http://hostname:port/bigdata/status</dt> -<dd>A <a href="status">status</a> page.</dd> +<dd>A <a href="/bigdata/status">status</a> page.</dd> <dt>http://hostname:port/bigdata/counters</dt> -<dd>A <a href="counters"> performance counters</a> page.</dd> +<dd>A <a href="/bigdata/counters"> performance counters</a> page.</dd> </dl> <p> @@ -44,13 +39,6 @@ which this page was accessed. </p> -<h2>Linked Data Navigation</h2> -<form action="navigate" method="get"> - <p>Enter a URI to navigate to <input type="text" name="uri"></p> - <p>Tenant Namespace <input type="text" name="namespace" title="Tenant namespace."> (leave empty for default KB)</p> - <input type="submit" value="Send" title="Submit query."> -</form> - <!-- Note: Some applications (firefox 7) can not handle a GET with a very long URL. For that reason ONLY this operation defaults to a POST. You SHOULD use GET for database queries since they are, by and large, idempotent. @@ -59,7 +47,7 @@ title="W3C SPARQL 1.1 Query Recommendation" target="_blank" > SPARQL Query </a></h2> -<FORM action="sparql" method="post" name="QUERY"> +<FORM action="/bigdata/sparql" method="post" name="QUERY"> <P> <TEXTAREA name="query" rows="10" cols="80" title="Enter SPARQL Query." >SELECT * { ?s ?p ?o } LIMIT 1</TEXTAREA> @@ -93,7 +81,7 @@ title="W3C SPARQL Update Recommendation" target="_blank" >SPARQL Update</a></h2> -<FORM action="sparql" method="post"> +<FORM action="/bigdata/sparql" method="post"> <P> <TEXTAREA name="update" rows="10" cols="80" title="Enter SPARQL Update." > @@ -148,48 +136,5 @@ </p> </form> --> - -<h2>Multi-purpose textarea</h2> -<input id="mp-file" type="file" name="file"> -<br> -<input id="mp-hidden" type="hidden" name="large-file-contents"> -<p id="large-file-message" style="display: none;">Your file is too large to display here, but will be uploaded as normal.</p> -<textarea id="mp-box" name="textarea" rows="10" cols="80"></textarea> -<br> -<select id="mp-type"> -<option value="sparql" selected="selected">SPARQL</option> -<option value="rdf">RDF</option> -<option value="path">File path</option> -</select> -<select id="rdf-type" style="display: none;"> -<option value="">Select RDF format</option> -<option value="n-quads">N-Quads</option> -<option value="n-triples">N-Triples</option> -<option value="n3">Notation3</option> -<option value="rdf/xml">RDF/XML</option> -<option value="trig">TriG</option> -<option value="trix">TriX</option> -<option value="turtle">Turtle</option> -</select> -<br> -Tenant Namespace <input type="text" name="namespace" title="Tenant namespace."> (leave empty for default KB) -<br> -<button type="button" id="mp-send">Send</button> -<br> -Response: -<pre id="response"></pre> - -<h2>Navigator</h2> -Enter a URI to begin navigation -<br> -<form id="navigator"> -<input type="text" id="navigator-uri"> -<input type="submit"> -</form> -<div id="navigator-display"></div> - -<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> -<script>window.jQuery || document.write('<script src="/jquery.min.js"><\/script>')</script> -<script src="/workbench.js"></script> </body> </html> \ No newline at end of file Deleted: branches/RDR/bigdata-war/src/html/jquery.hotkeys.js =================================================================== --- branches/RDR/bigdata-war/src/html/jquery.hotkeys.js 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/html/jquery.hotkeys.js 2014-03-06 22:38:54 UTC (rev 7916) @@ -1,110 +0,0 @@ -/* - * jQuery Hotkeys Plugin - * Copyright 2010, John Resig - * Dual licensed under the MIT or GPL Version 2 licenses. - * - * Based upon the plugin by Tzury Bar Yochay: - * http://github.com/tzuryby/hotkeys - * - * Original idea by: - * Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/ -*/ - -/* - * One small change is: now keys are passed by object { keys: '...' } - * Might be useful, when you want to pass some other data to your handler - */ - -(function(jQuery){ - - jQuery.hotkeys = { - version: "0.8", - - specialKeys: { - 8: "backspace", 9: "tab", 10: "return", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause", - 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", - 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del", - 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", - 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/", - 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", - 120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 186: ";", 191: "/", - 220: "\\", 222: "'", 224: "meta" - }, - - shiftNums: { - "`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", - "8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<", - ".": ">", "/": "?", "\\": "|" - } - }; - - function keyHandler( handleObj ) { - if ( typeof handleObj.data === "string" ) { - handleObj.data = { keys: handleObj.data }; - } - - // Only care when a possible input has been specified - if ( !handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== "string" ) { - return; - } - - var origHandler = handleObj.handler, - keys = handleObj.data.keys.toLowerCase().split(" "), - textAcceptingInputTypes = ["text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime", "datetime-local", "search", "color", "tel"]; - - handleObj.handler = function( event ) { - // Don't fire in text-accepting inputs that we didn't directly bind to - if ( this !== event.target && (/textarea|select/i.test( event.target.nodeName ) || - jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1 ) ) { - return; - } - - var special = jQuery.hotkeys.specialKeys[ event.keyCode ], - character = String.fromCharCode( event.which ).toLowerCase(), - modif = "", possible = {}; - - // check combinations (alt|ctrl|shift+anything) - if ( event.altKey && special !== "alt" ) { - modif += "alt+"; - } - - if ( event.ctrlKey && special !== "ctrl" ) { - modif += "ctrl+"; - } - - // TODO: Need to make sure this works consistently across platforms - if ( event.metaKey && !event.ctrlKey && special !== "meta" ) { - modif += "meta+"; - } - - if ( event.shiftKey && special !== "shift" ) { - modif += "shift+"; - } - - if ( special ) { - possible[ modif + special ] = true; - } - - if ( character ) { - possible[ modif + character ] = true; - possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true; - - // "$" can be triggered as "Shift+4" or "Shift+$" or just "$" - if ( modif === "shift+" ) { - possible[ jQuery.hotkeys.shiftNums[ character ] ] = true; - } - } - - for ( var i = 0, l = keys.length; i < l; i++ ) { - if ( possible[ keys[i] ] ) { - return origHandler.apply( this, arguments ); - } - } - }; - } - - jQuery.each([ "keydown", "keyup", "keypress" ], function() { - jQuery.event.special[ this ] = { add: keyHandler }; - }); - -})( this.jQuery ); Deleted: branches/RDR/bigdata-war/src/html/jquery.min.js =================================================================== Added: branches/RDR/bigdata-war/src/html/js/vendor/jquery.hotkeys.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/vendor/jquery.hotkeys.js (rev 0) +++ branches/RDR/bigdata-war/src/html/js/vendor/jquery.hotkeys.js 2014-03-06 22:38:54 UTC (rev 7916) @@ -0,0 +1,110 @@ +/* + * jQuery Hotkeys Plugin + * Copyright 2010, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * + * Based upon the plugin by Tzury Bar Yochay: + * http://github.com/tzuryby/hotkeys + * + * Original idea by: + * Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/ +*/ + +/* + * One small change is: now keys are passed by object { keys: '...' } + * Might be useful, when you want to pass some other data to your handler + */ + +(function(jQuery){ + + jQuery.hotkeys = { + version: "0.8", + + specialKeys: { + 8: "backspace", 9: "tab", 10: "return", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause", + 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", + 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del", + 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", + 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111 : "/", + 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", + 120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 186: ";", 191: "/", + 220: "\\", 222: "'", 224: "meta" + }, + + shiftNums: { + "`": "~", "1": "!", "2": "@", "3": "#", "4": "$", "5": "%", "6": "^", "7": "&", + "8": "*", "9": "(", "0": ")", "-": "_", "=": "+", ";": ": ", "'": "\"", ",": "<", + ".": ">", "/": "?", "\\": "|" + } + }; + + function keyHandler( handleObj ) { + if ( typeof handleObj.data === "string" ) { + handleObj.data = { keys: handleObj.data }; + } + + // Only care when a possible input has been specified + if ( !handleObj.data || !handleObj.data.keys || typeof handleObj.data.keys !== "string" ) { + return; + } + + var origHandler = handleObj.handler, + keys = handleObj.data.keys.toLowerCase().split(" "), + textAcceptingInputTypes = ["text", "password", "number", "email", "url", "range", "date", "month", "week", "time", "datetime", "datetime-local", "search", "color", "tel"]; + + handleObj.handler = function( event ) { + // Don't fire in text-accepting inputs that we didn't directly bind to + if ( this !== event.target && (/textarea|select/i.test( event.target.nodeName ) || + jQuery.inArray(event.target.type, textAcceptingInputTypes) > -1 ) ) { + return; + } + + var special = jQuery.hotkeys.specialKeys[ event.keyCode ], + character = String.fromCharCode( event.which ).toLowerCase(), + modif = "", possible = {}; + + // check combinations (alt|ctrl|shift+anything) + if ( event.altKey && special !== "alt" ) { + modif += "alt+"; + } + + if ( event.ctrlKey && special !== "ctrl" ) { + modif += "ctrl+"; + } + + // TODO: Need to make sure this works consistently across platforms + if ( event.metaKey && !event.ctrlKey && special !== "meta" ) { + modif += "meta+"; + } + + if ( event.shiftKey && special !== "shift" ) { + modif += "shift+"; + } + + if ( special ) { + possible[ modif + special ] = true; + } + + if ( character ) { + possible[ modif + character ] = true; + possible[ modif + jQuery.hotkeys.shiftNums[ character ] ] = true; + + // "$" can be triggered as "Shift+4" or "Shift+$" or just "$" + if ( modif === "shift+" ) { + possible[ jQuery.hotkeys.shiftNums[ character ] ] = true; + } + } + + for ( var i = 0, l = keys.length; i < l; i++ ) { + if ( possible[ keys[i] ] ) { + return origHandler.apply( this, arguments ); + } + } + }; + } + + jQuery.each([ "keydown", "keyup", "keypress" ], function() { + jQuery.event.special[ this ] = { add: keyHandler }; + }); + +})( this.jQuery ); Added: branches/RDR/bigdata-war/src/html/js/vendor/jquery.min.js =================================================================== Copied: branches/RDR/bigdata-war/src/html/js/workbench.js (from rev 7915, branches/RDR/bigdata-war/src/html/workbench.js) =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js (rev 0) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-06 22:38:54 UTC (rev 7916) @@ -0,0 +1,639 @@ +$(function() { + +/* Tab selection */ + +$('#tab-selector a').click(function(e) { + showTab($(this).data('target')); +}); + +if(window.location.hash) { + showTab(window.location.hash.substr(1)); +} else { + $('#tab-selector a:first').click(); +} + +function showTab(tab) { + $('.tab').hide(); + $('#' + tab + '-tab').show(); + $('#tab-selector a').removeClass(); + $('a[data-target=' + tab + ']').addClass('active'); + window.location.hash = tab; +} + +function moveTab(next) { + // get current position + var current = $('#tab-selector .active'); + if(next) { + if(current.next().length) { + current.next().click(); + } else { + $('#tab-selector a:first').click(); + } + } else { + if(current.prev().length) { + current.prev().click(); + } else { + $('#tab-selector a:last').click(); + } + } +} + +// these should be , and . but Hotkeys views those keypresses as these characters +$('html, textarea, select').bind('keydown', 'ctrl+¼', function() { moveTab(false); }); +$('html, textarea, select').bind('keydown', 'ctrl+¾', function() { moveTab(true); }); + +/* Namespaces */ + +function getNamespaces() { + $.get('/namespace', function(data) { + $('#namespaces-list').empty(); + var rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'; + var namespaces = namespaces = data.getElementsByTagNameNS(rdf, 'Description') + for(var i=0; i<namespaces.length; i++) { + var title = namespaces[i].getElementsByTagName('title')[0].textContent; + var titleText = title == DEFAULT_NAMESPACE ? title + ' (default)' : title; + var url = namespaces[i].getElementsByTagName('sparqlEndpoint')[0].getAttributeNS(rdf, 'resource'); + $('#namespaces-list').append('<li data-name="' + title + '" data-url="' + url + '">' + titleText + ' - <a href="#" class="use-namespace">Use</a> - <a href="#" class="delete-namespace">Delete</a></li>'); + } + $('.use-namespace').click(function(e) { + e.preventDefault(); + useNamespace($(this).parent().data('name'), $(this).parent().data('url')); + }); + $('.delete-namespace').click(function(e) { + e.preventDefault(); + deleteNamespace($(this).parent().data('name')); + }); + }); +} + +function useNamespace(name, url) { + $('#current-namespace').html(name); + NAMESPACE = name; + NAMESPACE_URL = url; +} + +function deleteNamespace(namespace) { + if(confirm('Are you sure you want to delete the namespace ' + namespace + '?')) { + // FIXME: should we check if the default namespace is the one being deleted? + if(namespace == NAMESPACE) { + // FIXME: what is the desired behaviour when deleting the current namespace? + } + var url = '/namespace/' + namespace; + var settings = { + type: 'DELETE', + success: getNamespaces, + error: function() { alert('Could not delete namespace ' + namespace); } + }; + $.ajax(url, settings); + } +} + +function createNamespace(e) { + e.preventDefault(); + var namespace = $(this).find('input').val(); + if(!namespace) { + return; + } + // TODO: validate namespace + // TODO: allow for other options to be specified + var data = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">\n<properties>\n<entry key="com.bigdata.rdf.sail.namespace">' + namespace + '</entry>\n</properties>'; + var settings = { + type: 'POST', + data: data, + contentType: 'application/xml', + success: getNamespaces, + error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); } + }; + $.ajax('/namespace', settings); +} +$('#namespace-create').submit(createNamespace); + +function getDefaultNamespace() { + $.get('/sparql', function(data) { + // Chrome does not work with rdf\:Description, so look for Description too + var defaultDataset = $(data).find('rdf\\:Description[rdf\\:nodeID=defaultDataset], Description[rdf\\:nodeID=defaultDataset]'); + DEFAULT_NAMESPACE = defaultDataset.find('title')[0].textContent; + var url = defaultDataset.find('sparqlEndpoint')[0].attributes['rdf:resource'].textContent; + useNamespace(DEFAULT_NAMESPACE, url); + getNamespaces(); + }); +} +var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACE_URL, fileContents; + +getDefaultNamespace(); + + +/* Namespace shortcuts */ + +$('.namespace-shortcuts li').click(function() { + var textarea = $(this).parents('.tab').find('textarea'); + var current = textarea.val(); + var ns = $(this).data('ns'); + + if(current.indexOf(ns) == -1) { + textarea.val(ns + '\n' + current); + } +}); + + +/* Load */ + +function handleDragOver(e) { + e.stopPropagation(); + e.preventDefault(); + e.originalEvent.dataTransfer.dropEffect = 'copy'; +} + +function handleFile(e) { + e.stopPropagation(); + e.preventDefault(); + + if(e.type == 'drop') { + var files = e.originalEvent.dataTransfer.files; + } else { + var files = e.originalEvent.target.files; + } + + // only one file supported + if(files.length > 1) { + alert('Ignoring all but first file'); + } + + var f = files[0]; + + // if file is too large, tell user to supply local path + if(f.size > 1048576 * 100) { + alert('File too large, enter local path to file'); + $('#load-box').val('/path/to/' + f.name); + setType('path'); + $('#load-box').prop('disabled', false) + $('#large-file-message, #clear-file').hide(); + } else { + var fr = new FileReader(); + fr.onload = function(e2) { + if(f.size > 10240) { + // do not use textarea + $('#load-box').prop('disabled', true) + $('#large-file-message, #clear-file').show() + $('#load-box').val(''); + fileContents = e2.target.result; + } else { + // display file contents in the textarea + clearFile(); + $('#load-box').val(e2.target.result); + } + guessType(f.name.split('.').pop().toLowerCase(), e2.target.result); + }; + fr.readAsText(f); + } + + $('#load-file').val(''); +} + +function clearFile(e) { + if(e) { + e.preventDefault(); + } + $('#load-box').prop('disabled', false) + $('#large-file-message, #clear-file').hide() + fileContents = null; +} + +function guessType(extension, content) { + // try to guess type + if(extension == 'rq') { + // SPARQL + setType('sparql'); + } else if(extension in rdf_types) { + // RDF + setType('rdf', rdf_types[extension]); + } else { + // extension is no help, see if we can find some SPARQL commands + setType(identify(content)); + } +} + +function identify(text, considerPath) { + if(considerPath) { + // match Unix, Windows or HTTP paths + // file:// is optional for local paths + // when file:// is not present, Windows paths may use \ or / and must include a : + // when file:// is present, Windows paths must use / and may include a : + // http[s]:// is mandatory for HTTP paths + var unix = /^(file:\/\/)?((\/[^\/]+)+)$/; + var windows = /^((file:\/\/)([A-Za-z]:?([\/][^\/\\]+)+))|([A-Za-z]:([\\\/][^\\\/]+)+)$/; + var http = /^https?:\/((\/[^\/]+)+)$/; + if(unix.test(text.trim()) || windows.test(text.trim()) || http.test(text.trim())) { + return 'path'; + } + } + + text = text.toUpperCase(); + for(var i=0; i<sparql_update_commands.length; i++) { + if(text.indexOf(sparql_update_commands[i]) != -1) { + return 'sparql'; + } + } + + return 'rdf'; +} + +function handlePaste(e) { + // if the input is currently empty, try to identify the pasted content + var that = this; + if(this.value == '') { + setTimeout(function() { setType(identify(that.value, true)); }, 10); + } +} + +function handleTypeChange(e) { + $('#rdf-type-container').toggle($(this).val() == 'rdf'); +} + +function setType(type, format) { + $('#load-type').val(type); + if(type == 'rdf') { + $('#rdf-type-container').show(); + $('#rdf-type').val(format); + } else { + $('#rdf-type-container').hide(); + } +} + +// .xml is used for both RDF and TriX, assume it's RDF +// We could check the parent element to see which it is +var rdf_types = {'nq': 'n-quads', + 'nt': 'n-triples', + 'n3': 'n3', + 'rdf': 'rdf/xml', + 'rdfs': 'rdf/xml', + 'owl': 'rdf/xml', + 'xml': 'rdf/xml', + 'trig': 'trig', + 'trix': 'trix', + //'xml': 'trix', + 'ttl': 'turtle'}; + +var rdf_content_types = {'n-quads': 'application/n-quads', + 'n-triples': 'text/plain', + 'n3': 'text/n3', + 'rdf/xml': 'application/rdf+xml', + 'trig': 'application/trig', + 'trix': 'application/trix', + 'turtle': 'text/turtle'}; + +var sparql_update_commands = ['INSERT', 'DELETE']; + +$('#load-file').change(handleFile); +$('#load-box').on('dragover', handleDragOver) + .on('drop', handleFile) + .on('paste', handlePaste) + .bind('keydown', 'ctrl+return', submitLoad) + .change(handleTypeChange); +$('#clear-file').click(clearFile); + +$('#load-load').click(submitLoad); + +function submitLoad(e) { + e.preventDefault(); + + var settings = { + type: 'POST', + data: fileContents == null ? $('#load-box').val() : fileContents, + success: updateResponseXML, + error: updateResponseError + } + + // determine action based on type + switch($('#load-type').val()) { + case 'sparql': + settings.data = 'update=' + encodeURIComponent(settings.data); + settings.success = updateResponseHTML; + break; + case 'rdf': + var type = $('#rdf-type').val(); + if(!type) { + alert('Please select an RDF content type.'); + return; + } + settings.contentType = rdf_content_types[type]; + break; + case 'path': + // if no scheme is specified, assume a local path + if(!/^(file|(https?)):\/\//.test(settings.data)) { + settings.data = 'file://' + settings.data; + } + settings.data = 'uri=' + encodeURIComponent(settings.data); + break; + } + + $.ajax(NAMESPACE_URL, settings); +} + +$('#load-clear').click(function() { + $('#load-response').text(''); +}); + +$('#advanced-features-toggle').click(function() { + $('#advanced-features').toggle(); + return false; +}); + +function updateResponseHTML(data) { + $('#load-response').html(data); +} + +function updateResponseXML(data) { + var modified = data.childNodes[0].attributes['modified'].value; + var milliseconds = data.childNodes[0].attributes['milliseconds'].value; + $('#load-response').text('Modified: ' + modified + '\nMilliseconds: ' + milliseconds); +} + +function updateResponseError(jqXHR, textStatus, errorThrown) { + $('#load-response').text('Error! ' + textStatus + ' ' + errorThrown); +} + + +/* Query */ + +$('#query-box').bind('keydown', 'ctrl+return', function(e) { e.preventDefault(); $('#query-form').submit(); }); +$('#query-form').submit(submitQuery); + +function submitQuery(e) { + e.preventDefault(); + + var settings = { + type: 'POST', + data: $(this).serialize(), + headers: { 'Accept': 'application/sparql-results+json, application/rdf+xml' }, + success: showQueryResults, + error: queryResultsError + } + + $.ajax(NAMESPACE_URL, settings); + + $('#query-explanation').empty(); + if($('#query-explain').is(':checked')) { + settings = { + type: 'POST', + data: $(this).serialize() + '&explain=details', + dataType: 'html', + success: showQueryExplanation, + error: queryResultsError + }; + $.ajax(NAMESPACE_URL, settings); + } else { + $('#query-explanation').hide(); + } +} + +$('#query-response-clear').click(function() { + $('#query-response, #query-explanation').empty(''); + $('#query-explanation').hide(); +}); + +$('#query-export-csv').click(exportCSV); +$('#query-export-xml').click(exportXML); + +function exportXML() { + var xml = '<?xml version="1.0"?>\n<sparql xmlns="http://www.w3.org/2005/sparql-results#">\n\t<head>\n'; + var bindings = []; + $('#query-response thead tr td').each(function(i, td) { + xml += '\t\t<variable name="' + td.textContent + '"/>\n'; + bindings.push(td.textContent); + }); + xml += '\t</head>\n\t<results>\n'; + $('#query-response tbody tr').each(function(i, tr) { + xml += '\t\t<result>\n'; + $(tr).find('td').each(function(j, td) { + var bindingType = td.className; + if(bindingType == 'unbound') { + return; + } + var dataType = $(td).data('datatype'); + if(dataType) { + dataType = ' datatype="' + dataType + '"'; + } else { + dataType = ''; + } + var lang = $(td).data('lang'); + if(lang) { + lang = ' xml:lang="' + lang + '"'; + } else { + lang = ''; + } + xml += '\t\t\t<binding name="' + bindings[j] + '"><' + bindingType + dataType + lang + '>' + td.textContent + '</' + bindingType + '></binding>\n'; + }); + xml += '\t\t</result>\n'; + }); + xml += '\t</results>\n</sparql>\n'; + downloadFile(xml, 'application/sparql-results+xml', 'export.xml'); +} + +function exportCSV() { + // FIXME: escape commas + var csv = ''; + $('#query-response table tr').each(function(i, tr) { + $(tr).find('td').each(function(j, td) { + if(j > 0) { + csv += ','; + } + csv += td.textContent; + }); + csv += '\n'; + }); + downloadFile(csv, 'application/csv', 'export.csv'); +} + +function downloadFile(data, type, filename) { + var uri = 'data:' + type + ';charset=utf-8,' + encodeURIComponent(data); + $('<a id="download-link" download="' + filename + '" href="' + uri + '">').appendTo('body')[0].click(); + $('#download-link').remove(); +} + +function showQueryResults(data) { + $('#query-response').empty(); + var table = $('<table>').appendTo($('#query-response')); + if(this.dataTypes[1] == 'xml') { + // RDF + table.append($('<thead><tr><td>s</td><td>p</td><td>o</td></tr></thead>')); + var rows = $(data).find('Description'); + for(var i=0; i<rows.length; i++) { + // FIXME: are about and nodeID the only possible attributes here? + var s = rows[i].attributes['rdf:about']; + if(typeof(s) == 'undefined') { + s = rows[i].attributes['rdf:nodeID']; + } + s = s.textContent; + for(var j=0; j<rows[i].children.length; j++) { + var p = rows[i].children[j].tagName; + var o = rows[i].children[j].attributes['rdf:resource']; + // FIXME: is this the correct behaviour? + if(typeof(o) == 'undefined') { + o = rows[i].children[j].textContent; + } else { + o = o.textContent; + } + var tr = $('<tr><td>' + (j == 0 ? s : '') + '</td><td>' + p + '</td><td>' + o + '</td>'); + table.append(tr); + } + } + } else { + // JSON + if(typeof(data.boolean) != 'undefined') { + // ASK query + table.append('<tr><td>' + data.boolean + '</td></tr>').addClass('boolean'); + return; + } + var thead = $('<thead>').appendTo(table); + var vars = []; + var tr = $('<tr>'); + for(var i=0; i<data.head.vars.length; i++) { + tr.append('<td>' + data.head.vars[i] + '</td>'); + vars.push(data.head.vars[i]); + } + thead.append(tr); + table.append(thead); + for(var i=0; i<data.results.bindings.length; i++) { + var tr = $('<tr>'); + for(var j=0; j<vars.length; j++) { + if(vars[j] in data.results.bindings[i]) { + var binding = data.results.bindings[i][vars[j]]; + if(binding.type == 'typed-literal') { + var tdData = ' class="literal" data-datatype="' + binding.datatype + '"'; + } else { + var tdData = ' class="' + binding.type + '"'; + if(binding['xml:lang']) { + tdData += ' data-lang="' + binding['xml:lang'] + '"'; + } + } + tr.append('<td' + tdData + '>' + binding.value + '</td>'); + } else { + // no binding + tr.append('<td class="unbound">'); + } + } + table.append(tr); + } + } +} + +function showQueryExplanation(data) { + $('#query-explanation').html(data).show(); +} + +function queryResultsError(jqXHR, textStatus, errorThrown) { + $('#query-response').text('Error! ' + textStatus + ' ' + errorThrown); +} + + +/* Explore */ + +$('#explore-form').submit(function(e) { + e.preventDefault(); + var uri = $(this).find('input').val(); + if(uri) { + loadURI(uri); + } +}); + +function loadURI(uri) { + // send query to server + var query = 'select * \ + where { \ + bind (<URI> as ?vertex) . \ + { \ + bind (<<?vertex ?p ?o>> as ?sid) . \ + optional \ + { \ + { \ + ?sid ?sidP ?sidO . \ + } union { \ + ?sidS ?sidP ?sid . \ + } \ + } \ + } union { \ + bind (<<?s ?p ?vertex>> as ?sid) . \ + optional \ + { \ + { \ + ?sid ?sidP ?sidO . \ + } union { \ + ?sidS ?sidP ?sid . \ + } \ + } \ + } \ + }'; + + query = query.replace('URI', uri); + var settings = { + type: 'POST', + data: 'query=' + encodeURI(query), + dataType: 'json', + accepts: {'json': 'application/sparql-results+json'}, + success: updateExploreStart, + error: updateExploreError + }; + $.ajax('/sparql', settings); +} + +function updateExploreStart(data) { + var disp = $('#explore-results'); + disp.html(''); + // see if we got any results + if(data.results.bindings.length == 0) { + disp.append('No vertex found!'); + return; + } + + var vertex = data.results.bindings[0].vertex; + disp.append('<h3>' + vertex.value + '</h3>'); + var outbound=[], inbound=[], attributes=[]; + for(var i=0; i<data.results.bindings.length; i++) { + var binding = data.results.bindings[i]; + // TODO: are attributes always on outbound relationships? + if('o' in binding) { + if(binding.o.type == 'uri') { + outbound.push(binding); + } else { + attributes.push(binding); + } + } else { + inbound.push(binding); + } + } + + if(outbound.length) { + disp.append('<h4>Outbound links</h4>'); + var table = $('<table>').appendTo(disp); + for(var i=0; i<outbound.length; i++) { + var linkAttributes = outbound[i].sidP.value + ': ' + outbound[i].sidO.value; + table.append('<tr><td>' + outbound[i].p.value + '</td><td><a href="#">' + outbound[i].o.value + '</a></td><td>' + linkAttributes + '</td></tr>'); + } + } + + if(inbound.length) { + disp.append('<h4>Inbound links</h4>'); + var table = $('<table>').appendTo(disp); + for(var i=0; i<inbound.length; i++) { + var linkAttributes = inbound[i].sidP.value + ': ' + inbound[i].sidO.value; + table.append('<tr><td><a href="#">' + inbound[i].s.value + '</a></td><td>' + inbound[i].p.value + '</td><td>' + linkAttributes + '</td></tr>'); + } + } + + if(attributes.length) { + disp.append('<h4>Attributes</h4>'); + var table = $('<table>').appendTo(disp); + for(var i=0; i<attributes.length; i++) { + table.append('<tr><td>' + attributes[i].p.value + '</td><td>' + attributes[i].o.value + '</td></tr>'); + } + } + + disp.find('a').click(function(e) { e.preventDefault(); loadURI(this.text); }); +} + +function updateExploreError(jqXHR, textStatus, errorThrown) { + $('#explore-results').html('Error! ' + textStatus + ' ' + errorThrown); +} + +}); Deleted: branches/RDR/bigdata-war/src/html/logo.png =================================================================== (Binary files differ) Modified: branches/RDR/bigdata-war/src/html/new.html =================================================================== --- branches/RDR/bigdata-war/src/html/new.html 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/html/new.html 2014-03-06 22:38:54 UTC (rev 7916) @@ -2,15 +2,15 @@ <html lang="en"> <head> <meta charset="utf-8"> - <title>RedPoint Workbench</title> - <link rel="stylesheet" href="style.css"> + <title>Bigdata Workbench</title> + <link rel="stylesheet" href="/bigdata/html/css/style.css"> </head> <body> <div id="container"> <div id="top"> - <img src="logo.png" id="logo"> + <img src="/bigdata/html/images/logo.png" id="logo"> <p><label for="search-text">Search:</label> <input type="text" id="search-text"></p> <p>Current namespace: <span id="current-namespace"></span></p> </div> @@ -161,8 +161,8 @@ <!--[if IE]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> - <script>window.jQuery || document.write('<script src="jquery.min.js"><\/script>')</script> - <script src="jquery.hotkeys.js"></script> - <script src="workbench.js"></script> + <script>window.jQuery || document.write('<script src="/bigdata/html/js/vendor/jquery.min.js"><\/script>')</script> + <script src="/bigdata/html/js/vendor/jquery.hotkeys.js"></script> + <script src="/bigdata/html/js/workbench.js"></script> </body> </html> Deleted: branches/RDR/bigdata-war/src/html/style.css =================================================================== --- branches/RDR/bigdata-war/src/html/style.css 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/html/style.css 2014-03-06 22:38:54 UTC (rev 7916) @@ -1,178 +0,0 @@ -/* http://meyerweb.com/eric/tools/css/reset/ - v2.0 | 20110126 - License: none (public domain) -*/ - -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -/* HTML5 display-role reset for older browsers */ -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} -body { - line-height: 1; -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -} - - -/* Workbench */ - -body { - margin: 10px; -} - -#container { - /*max-width: 600px;*/ -} - -#top { - text-align: right; - margin-bottom: 20px; -} - -#logo { - float: left; -} - -.shadow { - -webkit-box-shadow: 0px 3px 5px 0px rgba(50, 50, 50, 0.75); - -moz-box-shadow: 0px 3px 5px 0px rgba(50, 50, 50, 0.75); - box-shadow: 0px 3px 5px 0px rgba(50, 50, 50, 0.75); -} - -#tab-selector { - clear: both; -} - -#tab-selector a { - padding: 10px; - border: 1px solid; - border-right: none; - border-bottom: none; - display: inline-block; - float: left; - cursor: pointer; -} - -#tab-selector a:last-of-type { - border-right: 1px solid; -} - -.active { - background: lightgrey; -} - -.tab { - display: none; - clear: both; -} - -.box { - border: 1px solid; - padding: 10px; - border: 1px solid; - border-bottom: none; - min-height: 100px; - overflow-x: scroll; -} - -.box:last-of-type { - border-bottom: 1px solid; -} - -.namespace-shortcuts { - text-align: right; -} - -.namespace-shortcuts li { - display: inline-block; - border: 1px solid; - padding: 5px; - margin-left: 5px; - cursor: pointer; -} - -#large-file-message { - display: none; - margin: 5px 0; -} - -textarea { - margin: 5px 0; - width: 100%; - height: 200px; - box-sizing: border-box; -} - -#rdf-type-container { - display: none; -} - -hr { - background: #929292; - border: none; - height: 5px; - width: 50%; - margin: 20px auto; -} - -#load-load { - margin: 0 auto; - display: block; -} - -#load-buttons { - text-align: center; -} - -.bottom { - border-top: 1px solid; - text-align: right; -} - -#advanced-features, #query-explanation { - display: none; -} - -td { - border: 1px solid; - padding: 5px; -} - -pre { - font-family: monospace; -} - Deleted: branches/RDR/bigdata-war/src/html/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/workbench.js 2014-03-05 18:18:32 UTC (rev 7915) +++ branches/RDR/bigdata-war/src/html/workbench.js 2014-03-06 22:38:54 UTC (rev 7916) @@ -1,639 +0,0 @@ -$(function() { - -/* Tab selection */ - -$('#tab-selector a').click(function(e) { - showTab($(this).data('target')); -}); - -if(window.location.hash) { - showTab(window.location.hash.substr(1)); -} else { - $('#tab-selector a:first').click(); -} - -function showTab(tab) { - $('.tab').hide(); - $('#' + tab + '-tab').show(); - $('#tab-selector a').removeClass(); - $('a[data-target=' + tab + ']').addClass('active'); - window.location.hash = ... [truncated message content] |