You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by ij...@apache.org on 2014/07/05 11:15:18 UTC
svn commit: r1607985 [1/3] - in
/jena/Experimental/jena-fuseki2/src/main/webapp: ./ css/ js/
js/app/controllers/ js/app/models/ js/app/services/ js/app/templates/
js/app/views/ js/lib/ js/lib/addon/ js/lib/addon/fold/ js/lib/codemirror/
js/lib/lib/ js/...
Author: ijd
Date: Sat Jul 5 09:15:16 2014
New Revision: 1607985
URL: http://svn.apache.org/r1607985
Log:
Work-in-progress commit on graph editing. Updated local versions of
CodeMirror and Qonsole. Basic skeleton of graph editing working,
but more shakedown and checking needed. Also does not handle dirty
check to prevent loss of edits.
Added:
jena/Experimental/jena-fuseki2/src/main/webapp/css/foldgutter.css (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/app/templates/dataset-edit.tpl
jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-edit.js
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/brace-fold.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/comment-fold.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldcode.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldgutter.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/xml-fold.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/lib/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/lib/codemirror.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/javascript/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/javascript/javascript.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/sparql/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/sparql/sparql.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/turtle/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/turtle/turtle.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/xml/
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/mode/xml/xml.js (with props)
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/refresh.sh
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/remote-sparql-service.js (with props)
Removed:
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/codemirror/
Modified:
jena/Experimental/jena-fuseki2/src/main/webapp/css/codemirror.css
jena/Experimental/jena-fuseki2/src/main/webapp/css/fui.css
jena/Experimental/jena-fuseki2/src/main/webapp/css/qonsole.css
jena/Experimental/jena-fuseki2/src/main/webapp/dataset.html
jena/Experimental/jena-fuseki2/src/main/webapp/js/app/controllers/dataset-controller.js
jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/dataset.js
jena/Experimental/jena-fuseki2/src/main/webapp/js/app/services/validation-service.js
jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-info.js
jena/Experimental/jena-fuseki2/src/main/webapp/js/common-config.js
jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/qonsole.js
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/css/codemirror.css
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/css/codemirror.css?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/css/codemirror.css (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/css/codemirror.css Sat Jul 5 09:15:16 2014
@@ -36,13 +36,17 @@
min-width: 20px;
text-align: right;
color: #999;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
}
+.CodeMirror-guttermarker { color: black; }
+.CodeMirror-guttermarker-subtle { color: #999; }
+
/* CURSOR */
.CodeMirror div.CodeMirror-cursor {
border-left: 1px solid black;
- z-index: 3;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
@@ -52,29 +56,56 @@
width: auto;
border: 0;
background: #7e7;
- z-index: 1;
}
+.cm-animate-fat-cursor {
+ width: auto;
+ border: 0;
+ -webkit-animation: blink 1.06s steps(1) infinite;
+ -moz-animation: blink 1.06s steps(1) infinite;
+ animation: blink 1.06s steps(1) infinite;
+}
+@-moz-keyframes blink {
+ 0% { background: #7e7; }
+ 50% { background: none; }
+ 100% { background: #7e7; }
+}
+@-webkit-keyframes blink {
+ 0% { background: #7e7; }
+ 50% { background: none; }
+ 100% { background: #7e7; }
+}
+@keyframes blink {
+ 0% { background: #7e7; }
+ 50% { background: none; }
+ 100% { background: #7e7; }
+}
+
/* Can style cursor different in overwrite (non-insert) mode */
-.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}
+div.CodeMirror-overwrite div.CodeMirror-cursor {}
.cm-tab { display: inline-block; }
+.CodeMirror-ruler {
+ border-left: 1px solid #ccc;
+ position: absolute;
+}
+
/* DEFAULT THEME */
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
-.cm-s-default .cm-variable {color: black;}
+.cm-s-default .cm-variable,
+.cm-s-default .cm-punctuation,
+.cm-s-default .cm-property,
+.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3 {color: #085;}
-.cm-s-default .cm-property {color: black;}
-.cm-s-default .cm-operator {color: black;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
-.cm-s-default .cm-error {color: #f00;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
@@ -91,10 +122,14 @@
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
+.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
+/* Default styles for common addons */
+
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
+.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
@@ -114,7 +149,7 @@ div.CodeMirror span.CodeMirror-nonmatchi
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
- padding-bottom: 30px; padding-right: 30px;
+ padding-bottom: 30px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
@@ -123,6 +158,9 @@ div.CodeMirror span.CodeMirror-nonmatchi
}
.CodeMirror-sizer {
position: relative;
+ border-right: 30px solid transparent;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
@@ -197,16 +235,7 @@ div.CodeMirror span.CodeMirror-nonmatchi
white-space: pre-wrap;
word-break: normal;
}
-.CodeMirror-code pre {
- border-right: 30px solid transparent;
- width: -webkit-fit-content;
- width: -moz-fit-content;
- width: fit-content;
-}
-.CodeMirror-wrap .CodeMirror-code pre {
- border-right: none;
- width: auto;
-}
+
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
@@ -236,16 +265,22 @@ div.CodeMirror span.CodeMirror-nonmatchi
.CodeMirror div.CodeMirror-cursor {
position: absolute;
- visibility: hidden;
border-right: none;
width: 0;
}
-.CodeMirror-focused div.CodeMirror-cursor {
+
+div.CodeMirror-cursors {
+ visibility: hidden;
+ position: relative;
+ z-index: 1;
+}
+.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
+.CodeMirror-crosshair { cursor: crosshair; }
.cm-searching {
background: #ffa;
@@ -255,9 +290,12 @@ div.CodeMirror span.CodeMirror-nonmatchi
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
.CodeMirror span { *vertical-align: text-bottom; }
+/* Used to force a border model for a node */
+.cm-force-border { padding-right: .1px; }
+
@media print {
/* Hide the cursor when printing */
- .CodeMirror div.CodeMirror-cursor {
+ .CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
Added: jena/Experimental/jena-fuseki2/src/main/webapp/css/foldgutter.css
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/css/foldgutter.css?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/css/foldgutter.css (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/css/foldgutter.css Sat Jul 5 09:15:16 2014
@@ -0,0 +1,20 @@
+.CodeMirror-foldmarker {
+ color: blue;
+ text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
+ font-family: arial;
+ line-height: .3;
+ cursor: pointer;
+}
+.CodeMirror-foldgutter {
+ width: .7em;
+}
+.CodeMirror-foldgutter-open,
+.CodeMirror-foldgutter-folded {
+ cursor: pointer;
+}
+.CodeMirror-foldgutter-open:after {
+ content: "\25BE";
+}
+.CodeMirror-foldgutter-folded:after {
+ content: "\25B8";
+}
Propchange: jena/Experimental/jena-fuseki2/src/main/webapp/css/foldgutter.css
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/css/fui.css
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/css/fui.css?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/css/fui.css (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/css/fui.css Sat Jul 5 09:15:16 2014
@@ -180,3 +180,12 @@ dd .numeric {
min-width: 4em;
text-align: right;
}
+
+.bordered-box {
+ border: 1px solid #ccc;
+ border-radius: 5px;
+}
+
+.pull-right > button {
+ margin: 10px 2px 0 0;
+}
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/css/qonsole.css
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/css/qonsole.css?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/css/qonsole.css (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/css/qonsole.css Sat Jul 5 09:15:16 2014
@@ -1,14 +1,11 @@
/* Copyright (c) 2012-2013 Epimorphics Ltd. Released under Apache License 2.0 http://www.apache.org/licenses/ */
-body {
-}
-
.qonsole h2, .query-chrome label {
font-size: 10px;
color: #666666;
margin: 0;
text-transform: uppercase;
- display: inline-block;
+ display: block;
font-weight: normal;
}
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/dataset.html
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/dataset.html?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/dataset.html (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/dataset.html Sat Jul 5 09:15:16 2014
@@ -6,6 +6,7 @@
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/font-awesome.min.css" rel="stylesheet" media="screen">
<link href="css/codemirror.css" rel="stylesheet" media="screen">
+ <link href="css/foldgutter.css" rel="stylesheet" media="screen">
<link href="css/qonsole.css" rel="stylesheet" media="screen">
<link href="css/jquery.dataTables.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-select.min.css" rel="stylesheet" media="screen">
@@ -105,7 +106,7 @@
<ul class="list-inline prefixes">
<li class="keep">
<a data-toggle="modal" href="#prefixEditor" class="button" title="Add a SPARQL prefix">
- <i class="fa fa-plus-circle"></i>
+ <i class="icon-plus-sign"></i>
</a>
</li>
</ul>
@@ -117,17 +118,12 @@
</div>
<div class="query-chrome">
<form class="form-inline" role="form">
- <div class="col-md-4">
- <div class="form-group">
- <label>SPARQL endpoint</label>
- <div class="">
- <input type="text" class="form-control" id="sparqlEndpoint" />
- </div>
- </div>
+ <div class="form-group">
+ <label for="sparqlEndpoint">SPARQL endpoint</label>
+ <input type="text" class="form-control" id="sparqlEndpoint" />
</div>
-
<div class="form-group">
- <label>Results</label>
+ <label for="displayFormat">Results</label>
<div class="dropdown ">
<a data-toggle="dropdown" class="btn btn-custom2 display-format" href="#" data-value="tsv">
<span>table</span> <i class="icon-collapse"></i>
@@ -139,13 +135,11 @@
<li role='presentation' class="" ><a data-value="xml"role='menuitem' tabindex='-1' href='#'>XML</a></li>
</ul>
</div>
- </div>
+ </div>
<div class="form-group">
- <label></label>
- <div>
- <a id="perform-btn" href="#" class="btn btn-success run-query form-control">perform query</a>
- </div>
+ <label> </label>
+ <a href="#" class="btn btn-success run-query form-control">perform query</a>
</div>
</form>
@@ -172,7 +166,9 @@
</div>
</div>
</div>
- </div><!-- /.qonsole-->
+
+ <div class="row clearfix"></div>
+ </div><!-- /.qonsole -->
<!-- modal dialogue -->
<div class="modal fade" id="prefixEditor" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
@@ -228,9 +224,7 @@
<div class="tab-pane" id="edit">
<div class="no-dataset">Please select a dataset.</div>
- <div class="with-dataset hidden">
- edit
- </div>
+ <div class="with-dataset hidden"></div>
</div>
<div class="tab-pane" id="info">
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/js/app/controllers/dataset-controller.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/controllers/dataset-controller.js?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/app/controllers/dataset-controller.js (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/app/controllers/dataset-controller.js Sat Jul 5 09:15:16 2014
@@ -11,6 +11,7 @@ define(
TabbedViewManagerView = require( "app/views/tabbed-view-manager" ),
FileUploadView = require( "app/views/file-upload" ),
DatasetInfoView = require( "app/views/dataset-info" ),
+ DatasetEditView = require( "app/views/dataset-edit" ),
QueryController = require( "app/controllers/query-controller" ),
UploadController = require( "app/controllers/upload-controller" );
@@ -55,6 +56,9 @@ define(
var dataset = fui.models.fusekiServer.dataset( dsName );
fui.views.datasetInfoView = new DatasetInfoView( {model: dataset} );
fui.views.datasetInfoView.render();
+
+ fui.views.datasetEditView = new DatasetEditView( {model: dataset} );
+ fui.views.datasetEditView.render();
}
} );
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/dataset.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/dataset.js?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/dataset.js (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/app/models/dataset.js Sat Jul 5 09:15:16 2014
@@ -129,6 +129,11 @@ define(
return this.endpointURL( "GSP" ) ;
},
+ /** Return the GSP read URL for this dataset, if it has one, or null */
+ graphStoreProtocolReadURL: function() {
+ return this.endpointURL( "GSP_R" ) ;
+ },
+
/** Return the upload URL for this dataset, if it has one, or null */
uploadURL: function( graphName ) {
if (this.graphStoreProtocolURL() !== null) {
@@ -212,6 +217,31 @@ define(
self.set( {countPerformed: true, counting: false} );
} );
+ },
+
+ /**
+ * Fetch the content of the given graph as Turtle. Return the jQuery promise
+ * object for the Ajax call.
+ */
+ fetchGraph: function( graphName ) {
+ return $.ajax( this.graphStoreProtocolReadURL(),
+ {method: "get",
+ headers: {Accept : "text/turtle; charset=utf-8"},
+ dataType: "html",
+ data: {graph: graphName}
+ } );
+ },
+
+ /**
+ * Put the given Turtle content back to the server using the given graph name
+ */
+ putGraph: function( turtle, graphName ) {
+ return $.ajax( sprintf( "%s?graph=%s", this.graphStoreProtocolURL(), graphName ),
+ {method: "put",
+ dataType: "json",
+ data: turtle,
+ contentType: "text/turtle; charset=uft-8"
+ } );
}
} );
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/js/app/services/validation-service.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/services/validation-service.js?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/app/services/validation-service.js (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/app/services/validation-service.js Sat Jul 5 09:15:16 2014
@@ -1,5 +1,5 @@
define( ['underscore', 'jquery', 'fui',
- 'codemirror/codemirror', 'codemirror/javascript', 'codemirror/sparql'],
+ 'lib/codemirror', 'mode/javascript/javascript', 'mode/sparql/sparql'],
function( _, $, fui, CodeMirror ) {
var ValidationService = function( editor_el, output_el ) {
Added: jena/Experimental/jena-fuseki2/src/main/webapp/js/app/templates/dataset-edit.tpl
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/templates/dataset-edit.tpl?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/app/templates/dataset-edit.tpl (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/app/templates/dataset-edit.tpl Sat Jul 5 09:15:16 2014
@@ -0,0 +1,58 @@
+<div class="row">
+ <div class="col-md-4">
+ <div class="bordered-box">
+ <span class="pull-right">
+ <button class="btn btn-sm btn-info action list-graphs">list current graphs</button>
+ </span>
+ <h3>Available graphs</h3>
+
+ <% if (countPerformed()) { %>
+ <ul class="nav nav-pills nav-stacked graphs">
+ <% _.each( counts(), function( n, g ) { %>
+ <li class="">
+ <a href="#" class="select-dataset" data-graph-name="<%= g %>" data-graph-size="<%= n %>">
+ <%= g %> (<%= n %> triples)
+ </a>
+ </li>
+ <% } ); %>
+ </ul>
+ <% } else { %>
+ <p class="text-muted text-sm">Click to list current graphs</p>
+ <% } %>
+ </div> <!-- /.bordered-box -->
+ </div> <!-- /.col-md-4 -->
+
+ <div class="col-md-8">
+ <div class="row">
+ <div class="col-md-12">
+ <div class="form-group">
+ <div class="input-group">
+ <div class="input-group-addon">graph:</div>
+ <input class="form-control graph-name" type="text" placeholder="">
+ </div>
+ </div>
+ </div>
+ </div> <!-- /.row -->
+
+ <div class="row">
+ <div class="col-md-12">
+ <div id="graph-editor" class="bordered-box"></div>
+ </div>
+ </div> <!-- /.row -->
+
+ <div class="row">
+ <div class="col-md-12">
+ <span class="pull-right">
+ <button class="btn btn-default action cancel-edit"><i class="fa fa-times"></i> discard changes</button>
+ <button class="btn btn-info action save-edit"><i class="fa fa-check"></i> save</button>
+ </span>
+ </div>
+ </div> <!-- /.row -->
+
+ <div class="row">
+ <div class="col-md-12">
+ <p class="server-response"></p>
+ </div>
+ </div> <!-- /.row -->
+ </div> <!-- /.col-md-8 -->
+</div>
Added: jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-edit.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-edit.js?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-edit.js (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-edit.js Sat Jul 5 09:15:16 2014
@@ -0,0 +1,191 @@
+/** Component for showing detailed information about a dataset */
+
+define(
+ function( require ) {
+ var Backbone = require( "backbone" ),
+ _ = require( "underscore" ),
+ fui = require( "app/fui" ),
+ DatasetEditTpl = require( "plugins/text!app/templates/dataset-edit.tpl" ),
+ CodeMirror = require( "lib/codemirror" ),
+ CodeMirrorTurtle = require( "mode/turtle/turtle" );
+
+ var MAX_EDITABLE_SIZE = 10000;
+
+ var DatasetEdit = Backbone.Marionette.ItemView.extend( {
+
+ initialize: function() {
+ _.bindAll( this, "onCountGraphs", "onModelChanged", "onSelectDataset",
+ "onShownTab", "onShownEditTab", "onGraphContent",
+ "onSaveEdit", "onCancelEdit" );
+
+ this.model.on( "change", this.onModelChanged );
+ this._editor = null;
+
+ fui.vent.on( "shown.bs.tab", this.onShownTab );
+ },
+
+ template: _.template( DatasetEditTpl ),
+
+ ui: {
+ listGraphs: ".action.list-graphs",
+ editor: "#graph-editor",
+ graphName: "input.graph-name",
+ saveButton: "button.save-edit",
+ cancelButton: "button.cancel-edit"
+ },
+
+ el: "#edit .with-dataset",
+
+ events: {
+ "click .list-graphs": "onCountGraphs",
+ "click .select-dataset": "onSelectDataset",
+ "click .save-edit": "onSaveEdit",
+ "click .cancel-edit": "onCancelEdit"
+ },
+
+ templateHelpers: {
+ },
+
+ serializeData: function() {
+ return this.model;
+ },
+
+ /** Alias for the model */
+ dataset: function() {
+ return this.model;
+ },
+
+ // event handlers
+
+ onModelChanged: function() {
+ if (!this.model.counting) {
+ this.render();
+ }
+ },
+
+ onCountGraphs: function( e ) {
+ e.preventDefault();
+ this.model.count();
+ },
+
+ /** Event that triggers when any tab is shown */
+ onShownTab: function( tab ) {
+ if (tab.attr("href") === "#edit") {
+ this.onShownEditTab();
+ }
+ },
+
+ /** When the tab is show, ensure the editor element is initialised */
+ onShownEditTab: function() {
+ this.showEditor();
+ },
+
+ /** When rendering, only show the code mirror editor if the tab is visible */
+ onRender: function() {
+ this.showEditor();
+ },
+
+ /** Ensure the code mirror element is visible */
+ showEditor: function() {
+ if (this.editorElementVisible() && this.editorNotYetInitialised()) {
+ this._editor = null;
+ this.editorElement();
+ }
+ },
+
+ /** Return true if the editor container element is visible */
+ editorElementVisible: function() {
+ return this.ui.editor.is( ":visible" );
+ },
+
+ /** Return true if the CodeMirror element has not yet been initialised */
+ editorNotYetInitialised: function() {
+ return this.ui.editor.is( ":not(:has(.CodeMirror))" );
+ },
+
+ /** User has (attempted to) select a dataset */
+ onSelectDataset: function( e ) {
+ e.preventDefault();
+ var self = this;
+ var elem = $(e.currentTarget);
+ var graphName = elem.data( "graph-name" );
+ var graphSize = parseInt( elem.data( "graph-size" ));
+
+ if (graphSize > MAX_EDITABLE_SIZE) {
+ alert( "Sorry, that dataset is too large to load into the editor" );
+ }
+ else {
+ if (this.dirtyCheck()) {
+ $(".nav.graphs").find( ".active" ).removeClass( "active" );
+ elem.parent().addClass( "active" );
+
+ var gn = this.setGraphName( graphName );
+ this.dataset()
+ .fetchGraph( gn )
+ .done( self.onGraphContent );
+ }
+ }
+ },
+
+ /** Return true if the edit buffer is not dirty, or if the user says OK */
+ dirtyCheck: function() {
+ return true; // TODO
+ },
+
+ /** Return the DOM node representing the query editor */
+ editorElement: function() {
+ if (!this._editor) {
+ this._editor = new CodeMirror( this.ui.editor.get(0), {
+ lineNumbers: true,
+ mode: "turtle"
+ } );
+ }
+ return this._editor;
+ },
+
+ /** Set the graph name, return the actual name used */
+ setGraphName: function( name ) {
+ var text = (name === "default" || name === "default graph") ? "default" : name;
+
+ this.ui.graphName.val( text );
+
+ return text;
+ },
+
+ /** Get the graph name */
+ graphName: function() {
+ return this.ui.graphName.val();
+ },
+
+ /** Server has sent the content of the graph encoded as turtle */
+ onGraphContent: function( data ) {
+ this.editorElement().setValue( data );
+ },
+
+ /** User wants to save changes */
+ onSaveEdit: function( e ) {
+ e.preventDefault();
+
+ var turtle = this.editorElement().getValue();
+ this.dataset()
+ .putGraph( turtle, this.graphName() )
+ .done( function( data ) {
+
+ } )
+ .error()
+ },
+
+ /** User wants to discard changes */
+ onCancelEdit: function( e ) {
+ e.preventDefault();
+ this.ui.graphName.val( "" );
+ this.editorElement().setValue( "" );
+ }
+
+
+ });
+
+
+ return DatasetEdit;
+ }
+);
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-info.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-info.js?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-info.js (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/app/views/dataset-info.js Sat Jul 5 09:15:16 2014
@@ -14,8 +14,6 @@ define(
initialize: function() {
_.bindAll( this, "onModelChanged", "onCountGraphs" );
- var dataset = this.dataset();
-
this.showStatistics( true );
this.model.on( "change", this.onModelChanged );
},
Modified: jena/Experimental/jena-fuseki2/src/main/webapp/js/common-config.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/common-config.js?rev=1607985&r1=1607984&r2=1607985&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/common-config.js (original)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/common-config.js Sat Jul 5 09:15:16 2014
@@ -35,8 +35,9 @@ require.config({
deps: ['jquery']
},
'qonsole': {
- deps: ['codemirror/brace-fold', 'codemirror/comment-fold', 'codemirror/foldgutter', 'codemirror/xml-fold',
- 'codemirror/javascript', 'codemirror/sparql', 'codemirror/xml', 'jquery.dataTables.min' ],
+ deps: ['addon/fold/brace-fold', 'addon/fold/comment-fold', 'addon/fold/foldgutter', 'addon/fold/xml-fold',
+ 'mode/javascript/javascript', 'mode/sparql/sparql', 'mode/xml/xml', 'jquery.dataTables.min',
+ 'remote-sparql-service'],
exports: 'qonsole'
},
'jquery.fileupload': {
@@ -55,16 +56,17 @@ require.config({
deps: ['backbone'],
exports: 'Marionette'
},
- 'codemirror/codemirror': {
+ 'lib/codemirror': {
exports: 'CodeMirror'
},
- 'codemirror/foldcode': {deps: ['codemirror/codemirror']},
- 'codemirror/brace-fold': {deps: ['codemirror/foldcode']},
- 'codemirror/comment-fold': {deps: ['codemirror/foldcode']},
- 'codemirror/foldgutter': {deps: ['codemirror/foldcode']},
- 'codemirror/xml-fold': {deps: ['codemirror/foldcode']},
- 'codemirror/javascript': {deps: ['codemirror/codemirror']},
- 'codemirror/sparql': {deps: ['codemirror/codemirror']},
- 'codemirror/xml': {deps: ['codemirror/codemirror']},
+ 'addon/fold/foldcode': {deps: ['lib/codemirror']},
+ 'addon/fold/brace-fold': {deps: ['addon/fold/foldcode']},
+ 'addon/fold/comment-fold': {deps: ['addon/fold/foldcode']},
+ 'addon/fold/foldgutter': {deps: ['addon/fold/foldcode']},
+ 'addon/fold/xml-fold': {deps: ['addon/fold/foldcode']},
+ 'mode/javascript/javascript': {deps: ['lib/codemirror']},
+ 'mode/sparql/sparql': {deps: ['lib/codemirror']},
+ 'mode/xml/xml': {deps: ['lib/codemirror']},
+ 'mode/turtle/turtle': {deps: ['lib/codemirror']}
}
});
Added: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/brace-fold.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/brace-fold.js?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/brace-fold.js (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/brace-fold.js Sat Jul 5 09:15:16 2014
@@ -0,0 +1,105 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.registerHelper("fold", "brace", function(cm, start) {
+ var line = start.line, lineText = cm.getLine(line);
+ var startCh, tokenType;
+
+ function findOpening(openCh) {
+ for (var at = start.ch, pass = 0;;) {
+ var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
+ if (found == -1) {
+ if (pass == 1) break;
+ pass = 1;
+ at = lineText.length;
+ continue;
+ }
+ if (pass == 1 && found < start.ch) break;
+ tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
+ if (!/^(comment|string)/.test(tokenType)) return found + 1;
+ at = found - 1;
+ }
+ }
+
+ var startToken = "{", endToken = "}", startCh = findOpening("{");
+ if (startCh == null) {
+ startToken = "[", endToken = "]";
+ startCh = findOpening("[");
+ }
+
+ if (startCh == null) return;
+ var count = 1, lastLine = cm.lastLine(), end, endCh;
+ outer: for (var i = line; i <= lastLine; ++i) {
+ var text = cm.getLine(i), pos = i == line ? startCh : 0;
+ for (;;) {
+ var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
+ if (nextOpen < 0) nextOpen = text.length;
+ if (nextClose < 0) nextClose = text.length;
+ pos = Math.min(nextOpen, nextClose);
+ if (pos == text.length) break;
+ if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
+ if (pos == nextOpen) ++count;
+ else if (!--count) { end = i; endCh = pos; break outer; }
+ }
+ ++pos;
+ }
+ }
+ if (end == null || line == end && endCh == startCh) return;
+ return {from: CodeMirror.Pos(line, startCh),
+ to: CodeMirror.Pos(end, endCh)};
+});
+
+CodeMirror.registerHelper("fold", "import", function(cm, start) {
+ function hasImport(line) {
+ if (line < cm.firstLine() || line > cm.lastLine()) return null;
+ var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
+ if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
+ if (start.type != "keyword" || start.string != "import") return null;
+ // Now find closing semicolon, return its position
+ for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) {
+ var text = cm.getLine(i), semi = text.indexOf(";");
+ if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)};
+ }
+ }
+
+ var start = start.line, has = hasImport(start), prev;
+ if (!has || hasImport(start - 1) || ((prev = hasImport(start - 2)) && prev.end.line == start - 1))
+ return null;
+ for (var end = has.end;;) {
+ var next = hasImport(end.line + 1);
+ if (next == null) break;
+ end = next.end;
+ }
+ return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
+});
+
+CodeMirror.registerHelper("fold", "include", function(cm, start) {
+ function hasInclude(line) {
+ if (line < cm.firstLine() || line > cm.lastLine()) return null;
+ var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
+ if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
+ if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
+ }
+
+ var start = start.line, has = hasInclude(start);
+ if (has == null || hasInclude(start - 1) != null) return null;
+ for (var end = start;;) {
+ var next = hasInclude(end + 1);
+ if (next == null) break;
+ ++end;
+ }
+ return {from: CodeMirror.Pos(start, has + 1),
+ to: cm.clipPos(CodeMirror.Pos(end))};
+});
+
+});
Propchange: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/brace-fold.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/comment-fold.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/comment-fold.js?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/comment-fold.js (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/comment-fold.js Sat Jul 5 09:15:16 2014
@@ -0,0 +1,57 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
+ return mode.blockCommentStart && mode.blockCommentEnd;
+}, function(cm, start) {
+ var mode = cm.getModeAt(start), startToken = mode.blockCommentStart, endToken = mode.blockCommentEnd;
+ if (!startToken || !endToken) return;
+ var line = start.line, lineText = cm.getLine(line);
+
+ var startCh;
+ for (var at = start.ch, pass = 0;;) {
+ var found = at <= 0 ? -1 : lineText.lastIndexOf(startToken, at - 1);
+ if (found == -1) {
+ if (pass == 1) return;
+ pass = 1;
+ at = lineText.length;
+ continue;
+ }
+ if (pass == 1 && found < start.ch) return;
+ if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1)))) {
+ startCh = found + startToken.length;
+ break;
+ }
+ at = found - 1;
+ }
+
+ var depth = 1, lastLine = cm.lastLine(), end, endCh;
+ outer: for (var i = line; i <= lastLine; ++i) {
+ var text = cm.getLine(i), pos = i == line ? startCh : 0;
+ for (;;) {
+ var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
+ if (nextOpen < 0) nextOpen = text.length;
+ if (nextClose < 0) nextClose = text.length;
+ pos = Math.min(nextOpen, nextClose);
+ if (pos == text.length) break;
+ if (pos == nextOpen) ++depth;
+ else if (!--depth) { end = i; endCh = pos; break outer; }
+ ++pos;
+ }
+ }
+ if (end == null || line == end && endCh == startCh) return;
+ return {from: CodeMirror.Pos(line, startCh),
+ to: CodeMirror.Pos(end, endCh)};
+});
+
+});
Propchange: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/comment-fold.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldcode.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldcode.js?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldcode.js (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldcode.js Sat Jul 5 09:15:16 2014
@@ -0,0 +1,145 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ function doFold(cm, pos, options, force) {
+ if (options && options.call) {
+ var finder = options;
+ options = null;
+ } else {
+ var finder = getOption(cm, options, "rangeFinder");
+ }
+ if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
+ var minSize = getOption(cm, options, "minFoldSize");
+
+ function getRange(allowFolded) {
+ var range = finder(cm, pos);
+ if (!range || range.to.line - range.from.line < minSize) return null;
+ var marks = cm.findMarksAt(range.from);
+ for (var i = 0; i < marks.length; ++i) {
+ if (marks[i].__isFold && force !== "fold") {
+ if (!allowFolded) return null;
+ range.cleared = true;
+ marks[i].clear();
+ }
+ }
+ return range;
+ }
+
+ var range = getRange(true);
+ if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) {
+ pos = CodeMirror.Pos(pos.line - 1, 0);
+ range = getRange(false);
+ }
+ if (!range || range.cleared || force === "unfold") return;
+
+ var myWidget = makeWidget(cm, options);
+ CodeMirror.on(myWidget, "mousedown", function(e) {
+ myRange.clear();
+ CodeMirror.e_preventDefault(e);
+ });
+ var myRange = cm.markText(range.from, range.to, {
+ replacedWith: myWidget,
+ clearOnEnter: true,
+ __isFold: true
+ });
+ myRange.on("clear", function(from, to) {
+ CodeMirror.signal(cm, "unfold", cm, from, to);
+ });
+ CodeMirror.signal(cm, "fold", cm, range.from, range.to);
+ }
+
+ function makeWidget(cm, options) {
+ var widget = getOption(cm, options, "widget");
+ if (typeof widget == "string") {
+ var text = document.createTextNode(widget);
+ widget = document.createElement("span");
+ widget.appendChild(text);
+ widget.className = "CodeMirror-foldmarker";
+ }
+ return widget;
+ }
+
+ // Clumsy backwards-compatible interface
+ CodeMirror.newFoldFunction = function(rangeFinder, widget) {
+ return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); };
+ };
+
+ // New-style interface
+ CodeMirror.defineExtension("foldCode", function(pos, options, force) {
+ doFold(this, pos, options, force);
+ });
+
+ CodeMirror.defineExtension("isFolded", function(pos) {
+ var marks = this.findMarksAt(pos);
+ for (var i = 0; i < marks.length; ++i)
+ if (marks[i].__isFold) return true;
+ });
+
+ CodeMirror.commands.toggleFold = function(cm) {
+ cm.foldCode(cm.getCursor());
+ };
+ CodeMirror.commands.fold = function(cm) {
+ cm.foldCode(cm.getCursor(), null, "fold");
+ };
+ CodeMirror.commands.unfold = function(cm) {
+ cm.foldCode(cm.getCursor(), null, "unfold");
+ };
+ CodeMirror.commands.foldAll = function(cm) {
+ cm.operation(function() {
+ for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
+ cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
+ });
+ };
+ CodeMirror.commands.unfoldAll = function(cm) {
+ cm.operation(function() {
+ for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
+ cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
+ });
+ };
+
+ CodeMirror.registerHelper("fold", "combine", function() {
+ var funcs = Array.prototype.slice.call(arguments, 0);
+ return function(cm, start) {
+ for (var i = 0; i < funcs.length; ++i) {
+ var found = funcs[i](cm, start);
+ if (found) return found;
+ }
+ };
+ });
+
+ CodeMirror.registerHelper("fold", "auto", function(cm, start) {
+ var helpers = cm.getHelpers(start, "fold");
+ for (var i = 0; i < helpers.length; i++) {
+ var cur = helpers[i](cm, start);
+ if (cur) return cur;
+ }
+ });
+
+ var defaultOptions = {
+ rangeFinder: CodeMirror.fold.auto,
+ widget: "\u2194",
+ minFoldSize: 0,
+ scanUp: false
+ };
+
+ CodeMirror.defineOption("foldOptions", null);
+
+ function getOption(cm, options, name) {
+ if (options && options[name] !== undefined)
+ return options[name];
+ var editorOptions = cm.options.foldOptions;
+ if (editorOptions && editorOptions[name] !== undefined)
+ return editorOptions[name];
+ return defaultOptions[name];
+ }
+});
Propchange: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldcode.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldgutter.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldgutter.js?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldgutter.js (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldgutter.js Sat Jul 5 09:15:16 2014
@@ -0,0 +1,134 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("./foldcode"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "./foldcode"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
+ if (old && old != CodeMirror.Init) {
+ cm.clearGutter(cm.state.foldGutter.options.gutter);
+ cm.state.foldGutter = null;
+ cm.off("gutterClick", onGutterClick);
+ cm.off("change", onChange);
+ cm.off("viewportChange", onViewportChange);
+ cm.off("fold", onFold);
+ cm.off("unfold", onFold);
+ cm.off("swapDoc", updateInViewport);
+ }
+ if (val) {
+ cm.state.foldGutter = new State(parseOptions(val));
+ updateInViewport(cm);
+ cm.on("gutterClick", onGutterClick);
+ cm.on("change", onChange);
+ cm.on("viewportChange", onViewportChange);
+ cm.on("fold", onFold);
+ cm.on("unfold", onFold);
+ cm.on("swapDoc", updateInViewport);
+ }
+ });
+
+ var Pos = CodeMirror.Pos;
+
+ function State(options) {
+ this.options = options;
+ this.from = this.to = 0;
+ }
+
+ function parseOptions(opts) {
+ if (opts === true) opts = {};
+ if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter";
+ if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open";
+ if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded";
+ return opts;
+ }
+
+ function isFolded(cm, line) {
+ var marks = cm.findMarksAt(Pos(line));
+ for (var i = 0; i < marks.length; ++i)
+ if (marks[i].__isFold && marks[i].find().from.line == line) return true;
+ }
+
+ function marker(spec) {
+ if (typeof spec == "string") {
+ var elt = document.createElement("div");
+ elt.className = spec + " CodeMirror-guttermarker-subtle";
+ return elt;
+ } else {
+ return spec.cloneNode(true);
+ }
+ }
+
+ function updateFoldInfo(cm, from, to) {
+ var opts = cm.state.foldGutter.options, cur = from;
+ cm.eachLine(from, to, function(line) {
+ var mark = null;
+ if (isFolded(cm, cur)) {
+ mark = marker(opts.indicatorFolded);
+ } else {
+ var pos = Pos(cur, 0), func = opts.rangeFinder || CodeMirror.fold.auto;
+ var range = func && func(cm, pos);
+ if (range && range.from.line + 1 < range.to.line)
+ mark = marker(opts.indicatorOpen);
+ }
+ cm.setGutterMarker(line, opts.gutter, mark);
+ ++cur;
+ });
+ }
+
+ function updateInViewport(cm) {
+ var vp = cm.getViewport(), state = cm.state.foldGutter;
+ if (!state) return;
+ cm.operation(function() {
+ updateFoldInfo(cm, vp.from, vp.to);
+ });
+ state.from = vp.from; state.to = vp.to;
+ }
+
+ function onGutterClick(cm, line, gutter) {
+ var opts = cm.state.foldGutter.options;
+ if (gutter != opts.gutter) return;
+ cm.foldCode(Pos(line, 0), opts.rangeFinder);
+ }
+
+ function onChange(cm) {
+ var state = cm.state.foldGutter, opts = cm.state.foldGutter.options;
+ state.from = state.to = 0;
+ clearTimeout(state.changeUpdate);
+ state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600);
+ }
+
+ function onViewportChange(cm) {
+ var state = cm.state.foldGutter, opts = cm.state.foldGutter.options;
+ clearTimeout(state.changeUpdate);
+ state.changeUpdate = setTimeout(function() {
+ var vp = cm.getViewport();
+ if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
+ updateInViewport(cm);
+ } else {
+ cm.operation(function() {
+ if (vp.from < state.from) {
+ updateFoldInfo(cm, vp.from, state.from);
+ state.from = vp.from;
+ }
+ if (vp.to > state.to) {
+ updateFoldInfo(cm, state.to, vp.to);
+ state.to = vp.to;
+ }
+ });
+ }
+ }, opts.updateViewportTimeSpan || 400);
+ }
+
+ function onFold(cm, from) {
+ var state = cm.state.foldGutter, line = from.line;
+ if (line >= state.from && line < state.to)
+ updateFoldInfo(cm, line, line + 1);
+ }
+});
Propchange: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/foldgutter.js
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/xml-fold.js
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/xml-fold.js?rev=1607985&view=auto
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/xml-fold.js (added)
+++ jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/xml-fold.js Sat Jul 5 09:15:16 2014
@@ -0,0 +1,181 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ var Pos = CodeMirror.Pos;
+ function cmp(a, b) { return a.line - b.line || a.ch - b.ch; }
+
+ var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
+ var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
+ var xmlTagStart = new RegExp("<(/?)([" + nameStartChar + "][" + nameChar + "]*)", "g");
+
+ function Iter(cm, line, ch, range) {
+ this.line = line; this.ch = ch;
+ this.cm = cm; this.text = cm.getLine(line);
+ this.min = range ? range.from : cm.firstLine();
+ this.max = range ? range.to - 1 : cm.lastLine();
+ }
+
+ function tagAt(iter, ch) {
+ var type = iter.cm.getTokenTypeAt(Pos(iter.line, ch));
+ return type && /\btag\b/.test(type);
+ }
+
+ function nextLine(iter) {
+ if (iter.line >= iter.max) return;
+ iter.ch = 0;
+ iter.text = iter.cm.getLine(++iter.line);
+ return true;
+ }
+ function prevLine(iter) {
+ if (iter.line <= iter.min) return;
+ iter.text = iter.cm.getLine(--iter.line);
+ iter.ch = iter.text.length;
+ return true;
+ }
+
+ function toTagEnd(iter) {
+ for (;;) {
+ var gt = iter.text.indexOf(">", iter.ch);
+ if (gt == -1) { if (nextLine(iter)) continue; else return; }
+ if (!tagAt(iter, gt + 1)) { iter.ch = gt + 1; continue; }
+ var lastSlash = iter.text.lastIndexOf("/", gt);
+ var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
+ iter.ch = gt + 1;
+ return selfClose ? "selfClose" : "regular";
+ }
+ }
+ function toTagStart(iter) {
+ for (;;) {
+ var lt = iter.ch ? iter.text.lastIndexOf("<", iter.ch - 1) : -1;
+ if (lt == -1) { if (prevLine(iter)) continue; else return; }
+ if (!tagAt(iter, lt + 1)) { iter.ch = lt; continue; }
+ xmlTagStart.lastIndex = lt;
+ iter.ch = lt;
+ var match = xmlTagStart.exec(iter.text);
+ if (match && match.index == lt) return match;
+ }
+ }
+
+ function toNextTag(iter) {
+ for (;;) {
+ xmlTagStart.lastIndex = iter.ch;
+ var found = xmlTagStart.exec(iter.text);
+ if (!found) { if (nextLine(iter)) continue; else return; }
+ if (!tagAt(iter, found.index + 1)) { iter.ch = found.index + 1; continue; }
+ iter.ch = found.index + found[0].length;
+ return found;
+ }
+ }
+ function toPrevTag(iter) {
+ for (;;) {
+ var gt = iter.ch ? iter.text.lastIndexOf(">", iter.ch - 1) : -1;
+ if (gt == -1) { if (prevLine(iter)) continue; else return; }
+ if (!tagAt(iter, gt + 1)) { iter.ch = gt; continue; }
+ var lastSlash = iter.text.lastIndexOf("/", gt);
+ var selfClose = lastSlash > -1 && !/\S/.test(iter.text.slice(lastSlash + 1, gt));
+ iter.ch = gt + 1;
+ return selfClose ? "selfClose" : "regular";
+ }
+ }
+
+ function findMatchingClose(iter, tag) {
+ var stack = [];
+ for (;;) {
+ var next = toNextTag(iter), end, startLine = iter.line, startCh = iter.ch - (next ? next[0].length : 0);
+ if (!next || !(end = toTagEnd(iter))) return;
+ if (end == "selfClose") continue;
+ if (next[1]) { // closing tag
+ for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == next[2]) {
+ stack.length = i;
+ break;
+ }
+ if (i < 0 && (!tag || tag == next[2])) return {
+ tag: next[2],
+ from: Pos(startLine, startCh),
+ to: Pos(iter.line, iter.ch)
+ };
+ } else { // opening tag
+ stack.push(next[2]);
+ }
+ }
+ }
+ function findMatchingOpen(iter, tag) {
+ var stack = [];
+ for (;;) {
+ var prev = toPrevTag(iter);
+ if (!prev) return;
+ if (prev == "selfClose") { toTagStart(iter); continue; }
+ var endLine = iter.line, endCh = iter.ch;
+ var start = toTagStart(iter);
+ if (!start) return;
+ if (start[1]) { // closing tag
+ stack.push(start[2]);
+ } else { // opening tag
+ for (var i = stack.length - 1; i >= 0; --i) if (stack[i] == start[2]) {
+ stack.length = i;
+ break;
+ }
+ if (i < 0 && (!tag || tag == start[2])) return {
+ tag: start[2],
+ from: Pos(iter.line, iter.ch),
+ to: Pos(endLine, endCh)
+ };
+ }
+ }
+ }
+
+ CodeMirror.registerHelper("fold", "xml", function(cm, start) {
+ var iter = new Iter(cm, start.line, 0);
+ for (;;) {
+ var openTag = toNextTag(iter), end;
+ if (!openTag || iter.line != start.line || !(end = toTagEnd(iter))) return;
+ if (!openTag[1] && end != "selfClose") {
+ var start = Pos(iter.line, iter.ch);
+ var close = findMatchingClose(iter, openTag[2]);
+ return close && {from: start, to: close.from};
+ }
+ }
+ });
+ CodeMirror.findMatchingTag = function(cm, pos, range) {
+ var iter = new Iter(cm, pos.line, pos.ch, range);
+ if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
+ var end = toTagEnd(iter), to = end && Pos(iter.line, iter.ch);
+ var start = end && toTagStart(iter);
+ if (!end || end == "selfClose" || !start || cmp(iter, pos) > 0) return;
+ var here = {from: Pos(iter.line, iter.ch), to: to, tag: start[2]};
+
+ if (start[1]) { // closing tag
+ return {open: findMatchingOpen(iter, start[2]), close: here, at: "close"};
+ } else { // opening tag
+ iter = new Iter(cm, to.line, to.ch, range);
+ return {open: here, close: findMatchingClose(iter, start[2]), at: "open"};
+ }
+ };
+
+ CodeMirror.findEnclosingTag = function(cm, pos, range) {
+ var iter = new Iter(cm, pos.line, pos.ch, range);
+ for (;;) {
+ var open = findMatchingOpen(iter);
+ if (!open) break;
+ var forward = new Iter(cm, pos.line, pos.ch, range);
+ var close = findMatchingClose(forward, open.tag);
+ if (close) return {open: open, close: close};
+ }
+ };
+
+ // Used by addon/edit/closetag.js
+ CodeMirror.scanForClosingTag = function(cm, pos, name, end) {
+ var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null);
+ return findMatchingClose(iter, name);
+ };
+});
Propchange: jena/Experimental/jena-fuseki2/src/main/webapp/js/lib/addon/fold/xml-fold.js
------------------------------------------------------------------------------
svn:mime-type = text/plain