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 2013/11/11 01:15:23 UTC
svn commit: r1540579 - in /jena/branches/jena-fuseki-new-ui/pages: ./ css/
js/app/ js/app/controllers/ js/app/models/ js/app/services/ js/app/views/
Author: ijd
Date: Mon Nov 11 00:15:22 2013
New Revision: 1540579
URL: http://svn.apache.org/r1540579
Log:
Interim checkin: working on validatation page
Added:
jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.js
jena/branches/jena-fuseki-new-ui/pages/js/app/main.validation.js
jena/branches/jena-fuseki-new-ui/pages/js/app/models/validation-options.js
jena/branches/jena-fuseki-new-ui/pages/js/app/services/validation-service.js
jena/branches/jena-fuseki-new-ui/pages/js/app/views/validation-options.js
Modified:
jena/branches/jena-fuseki-new-ui/pages/css/fui.css
jena/branches/jena-fuseki-new-ui/pages/js/app/fui.js
jena/branches/jena-fuseki-new-ui/pages/validation.html
Modified: jena/branches/jena-fuseki-new-ui/pages/css/fui.css
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/css/fui.css?rev=1540579&r1=1540578&r2=1540579&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/css/fui.css (original)
+++ jena/branches/jena-fuseki-new-ui/pages/css/fui.css Mon Nov 11 00:15:22 2013
@@ -48,4 +48,8 @@ a#server-status-light {
a.navbar-brand {
padding-top: 0;
padding-bottom: 0;
-}
\ No newline at end of file
+}
+
+.options-list {
+ margin-bottom: 5px;
+}
Added: jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.js
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.js?rev=1540579&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.js (added)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.js Mon Nov 11 00:15:22 2013
@@ -0,0 +1,35 @@
+/** Controller for the main index.html page */
+define(
+ function( require ) {
+ var Marionette = require( "marionette" ),
+ Backbone = require( "backbone" ),
+ _ = require( "underscore" ),
+ fui = require( "fui" ),
+ ValidationOptions = require( "views/validation-options" ),
+ ValidationService = require( "services/validation-service" );
+
+ var ValidationController = function() {
+ this.initEvents();
+ this.initServices();
+ };
+
+ // add the behaviours defined on the controller
+ _.extend( ValidationController.prototype, {
+ initEvents: function() {
+ fui.vent.on( "models.validation-options.ready", this.onValidationOptionsModelReady );
+ },
+
+ onValidationOptionsModelReady: function( e ) {
+ fui.views.validationOptions = new ValidationOptions( {model: fui.models.validationOptions} );
+ },
+
+ initServices: function() {
+ fui.services.validation = new ValidationService( "#query-edit-cm", "#validation-output-cm" );
+ fui.services.validation.init();
+ }
+
+ } );
+
+ return ValidationController;
+ }
+);
Modified: jena/branches/jena-fuseki-new-ui/pages/js/app/fui.js
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/js/app/fui.js?rev=1540579&r1=1540578&r2=1540579&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/fui.js (original)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/fui.js Mon Nov 11 00:15:22 2013
@@ -11,31 +11,20 @@ define( ['require', 'backbone', 'marione
// see https://github.com/marionettejs/backbone.marionette/wiki/AMD-Modules-vs-Marionette%27s-Modules
fui.module( "models" );
fui.module( "views" );
- fui.module( "apis" );
fui.module( "layouts" );
fui.module( "controllers" );
+ fui.module( "services" );
// define top-level regions where our layouts will go
fui.addRegions({
});
fui.on('initialize:before', function( options ) {
- // attach API instances
-// fui.apis.qb = new QB( options );
});
fui.on('initialize:after', function( options ) {
// Backbone.history.start();
this.initialized = true;
-
- // view association
- // TODO temp: this will migrate into the layout component in due course
- var DatasetSelectionList = require( "views/dataset-selection-list" );
- var dsl = new DatasetSelectionList( {model: fui.models.fusekiServer} );
- var dslRegion = new Marionette.Region({
- el: '#datasetSelectionList'
- });
- dslRegion.show(dsl);
});
Added: jena/branches/jena-fuseki-new-ui/pages/js/app/main.validation.js
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/js/app/main.validation.js?rev=1540579&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/main.validation.js (added)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/main.validation.js Mon Nov 11 00:15:22 2013
@@ -0,0 +1,27 @@
+
+define( ['require', '../common-config'],
+ function( require ) {
+ require(
+ ['underscore', 'jquery', 'backbone', 'marionette', 'fui', 'controllers/validation-controller',
+ 'sprintf', 'bootstrap',
+ 'models/validation-options',
+ 'services/ping-service', 'services/validation-service',
+ 'lib/jquery.xdomainrequest'
+ ],
+ function( _, $, Backbone, Marionette, fui, ValidationController ) {
+
+ // TODO: these variables need to be set dynamically based on the current server config
+ var options = {
+ serverPort: 3030,
+ managementPort: 3131
+ };
+
+ // initialise the backbone application
+ fui.controllers.indexController = new ValidationController();
+ fui.start( options );
+
+ // additional services
+// require( 'services/ping-service' ).start(); TODO restore
+ });
+ }
+);
\ No newline at end of file
Added: jena/branches/jena-fuseki-new-ui/pages/js/app/models/validation-options.js
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/js/app/models/validation-options.js?rev=1540579&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/models/validation-options.js (added)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/models/validation-options.js Mon Nov 11 00:15:22 2013
@@ -0,0 +1,70 @@
+/**
+ * Backbone model denoting the remote Fuseki server.
+ */
+define(
+ function( require ) {
+ "use strict";
+
+ var Marionette = require( "marionette" ),
+ Backbone = require( "backbone" ),
+ _ = require( "underscore" ),
+ fui = require( "fui" ),
+ sprintf = require( "sprintf" );
+
+ /**
+ * This model represents the users current choice of options to the
+ * validation service.
+ */
+ var ValidationOptions = Backbone.Model.extend( {
+ initialize: function() {
+ this.set( {validateAs: "sparql"} );
+ this.set( {outputFormat: "algebra"} );
+ },
+
+ validateAs: function() {
+ return this.get( "validateAs" );
+ },
+
+ validateAsQuery: function() {
+ return this.validateAs() === "sparql" || this.validateAs() === "arq";
+ },
+
+ setValidateAs: function( va ) {
+ this.set( "validateAs", va );
+ console.log( JSON.stringify( this.toJSON() ));
+ console.log( "----" );
+ },
+
+ outputFormat: function() {
+ return this.get( "outputFormat" );
+ },
+
+ setOutputFormat: function( of ) {
+ this.set( "outputFormat", of );
+ },
+
+ toJSON: function() {
+ var json = {
+ languageSyntax: this.validateAs(),
+ lineNumbers: true
+ };
+
+ if (this.validateAsQuery()) {
+ json.outputFormat = this.outputFormat();
+ }
+
+ return json;
+ }
+
+ } );
+
+ // when the models module starts, create the model
+ fui.models.addInitializer( function( options ) {
+ fui.models.validationOptions = new ValidationOptions();
+ fui.vent.trigger( "models.validation-options.ready" );
+ } );
+
+
+ return ValidationOptions;
+ }
+);
\ No newline at end of file
Added: jena/branches/jena-fuseki-new-ui/pages/js/app/services/validation-service.js
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/js/app/services/validation-service.js?rev=1540579&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/services/validation-service.js (added)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/services/validation-service.js Mon Nov 11 00:15:22 2013
@@ -0,0 +1,43 @@
+define( ['underscore', 'jquery', 'fui', 'codemirror/codemirror'],
+ function( _, $, fui ) {
+
+ var ValidationService = function( editor_el, output_el ) {
+ this.editor_el = editor_el;
+ this.output_el = output_el;
+ };
+
+ _.extend( ValidationService.prototype, {
+ init: function() {
+ this.editorElement();
+ this.outputElement();
+ },
+
+ /** Return the DOM node representing the query editor */
+ editorElement: function() {
+ if (!this._editor) {
+ this._editor = new CodeMirror( $(this.editor_el).get(0), {
+ lineNumbers: true,
+ mode: "text"
+ } );
+ }
+ return this._editor;
+ },
+
+ /** Return the DOM node representing the output editor */
+ outputElement: function() {
+ if (!this._output) {
+ this._output = new CodeMirror( $(this.output_el).get(0), {
+ lineNumbers: true,
+ mode: "text",
+ readOnly: true
+ } );
+ }
+ return this._output;
+ }
+
+ } );
+
+
+ return ValidationService;
+ }
+);
\ No newline at end of file
Added: jena/branches/jena-fuseki-new-ui/pages/js/app/views/validation-options.js
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/js/app/views/validation-options.js?rev=1540579&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/views/validation-options.js (added)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/views/validation-options.js Mon Nov 11 00:15:22 2013
@@ -0,0 +1,54 @@
+define(
+ function( require ) {
+ var Backbone = require( "backbone" ),
+ _ = require( "underscore" ),
+ fui = require( "fui" );
+
+ var ValidationOptions = Backbone.Marionette.ItemView.extend( {
+ initialize: function(){
+ _.bindAll( this, "onValidateAs", "onOutputFormat", "onModelChange" );
+ this.listenTo( this.model, "change", this.onModelChange, this );
+ },
+
+ el: ".validation",
+
+ events: {
+ "click .validate-as-options a": "onValidateAs",
+ "click .output-format-options a": "onOutputFormat",
+ },
+
+ templateHelpers: {
+ },
+
+ onValidateAs: function( e ) {
+ e.preventDefault();
+ var elem = $(e.currentTarget);
+ this.model.setValidateAs( elem.data( "validate-as" ) );
+ this.$el.find(".validate-as-options a").removeClass("active");
+ elem.addClass("active");
+
+ if (this.model.validateAsQuery()) {
+ this.$el.find(".output-format-options").removeClass("hidden");
+ }
+ else {
+ this.$el.find(".output-format-options").addClass("hidden");
+ }
+ },
+
+ onOutputFormat: function( e ) {
+ e.preventDefault();
+ var elem = $(e.currentTarget);
+ this.model.setOutputFormat( elem.data( "output-format" ) );
+ this.$el.find(".output-format-options a").removeClass("active");
+ elem.addClass("active");
+ },
+
+ onModelChange: function( event ) {
+ }
+
+ });
+
+
+ return ValidationOptions;
+ }
+);
Modified: jena/branches/jena-fuseki-new-ui/pages/validation.html
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pages/validation.html?rev=1540579&r1=1540578&r2=1540579&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/validation.html (original)
+++ jena/branches/jena-fuseki-new-ui/pages/validation.html Mon Nov 11 00:15:22 2013
@@ -10,6 +10,8 @@
<link href="css/jquery.dataTables.css" rel="stylesheet" media="screen">
<link href="css/fui.css" rel="stylesheet" media="screen">
+ <script data-main="js/app/main.validation.js" src="js/lib/require.min.js"></script>
+
<!--[if lt IE 9]>
<script src="../js/lib/html5shiv.js"></script>
<script src="../js/lib/respond.min.js"></script>
@@ -57,8 +59,79 @@
<div class="container">
<div class="row">
<h1>Fuseki – validation</h1>
- </div>
- </div>
+ <p>Use this page to validate SPARQL queries or RDF data.</p>
+
+ <div class="validation qonsole">
+ <div class="col-md-12 well">
+ <div class="query-edit">
+ <div id="query-edit-cm" class=""></div>
+ </div>
+ <div class="query-chrome">
+ <form class="form-inline" role="form">
+ <div class="validate-as-options options-list">
+ <h2>Validate as:</h2>
+ <ul class="list-inline">
+ <li><a class="btn btn-custom2 btn-sm active validate-as-option" data-toggle="button" data-validate-as="sparql">SPARQL</a></li>
+ <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="arq">SPARQL extended syntax</a></li>
+ <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="Turtle">Turtle</a></li>
+ <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="TriG">TriG</a></li>
+ <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="N-Triples">N-Triples</a></li>
+ <li><a class="btn btn-custom2 btn-sm validate-as-option" data-toggle="button" data-validate-as="N-Quads">N-Quads</a></li>
+ </ul>
+ </div><!-- /.validate-as-options -->
+
+ <div class="output-format-options options-list">
+ <h2>Output format:</h2>
+ <ul class="list-inline">
+ <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="sparql">SPARQL</a></li>
+ <li><a class="btn btn-custom2 btn-sm active" data-toggle="button" data-output-format="algebra">SPARQL algebra</a></li>
+ <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="quads">SPARQL algebra (quads)</a></li>
+ <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="opt">SPARQL algebra (with optimizations)</a></li>
+ <li><a class="btn btn-custom2 btn-sm" data-toggle="button" data-output-format="optquads">SPARQL algebra (quads, with optimizations)</a></li>
+ </ul>
+ </div><!-- /.output-format-options -->
+
+ <div class="row">
+ <div class="col-md-3 col-md-offset-1">
+ <a href="#" class="btn btn-success perform-validation">perform validation</a>
+ </div>
+ </div>
+
+ </form>
+ </div>
+ </div>
+
+ <!-- results -->
+ <div id="results-block" class="row validation-output">
+ <div class="col-md-12">
+ <div class="well">
+ <div class="row">
+ <div class="col-md-12">
+ <span class="loadingSpinner hidden">
+ <img src="images/wait30.gif" alt="waiting for server action to complete" />
+ </span>
+ <span class="timeTaken hidden"></span>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-12" id="results">
+ <h2 class="col-md-12">Validation output</h2>
+ <div class="query-edit">
+ <div id="validation-output-cm" class=""></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="row clearfix"></div>
+
+ <footer>
+ </footer>
+ </div><!-- /.validation-->
+ </div><!-- /.row -->
+ </div><!-- /.container -->
<script src="../js/lib/jquery-1.10.2.min.js"></script>
<script src="../js/lib/bootstrap.min.js"></script>