jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject svn commit: r1540899 - in /jena/branches/jena-fuseki-new-ui/pages/js/app: controllers/validation-controller.js models/validation-options.js services/validation-service.js
Date Tue, 12 Nov 2013 00:37:18 GMT
Author: ijd
Date: Tue Nov 12 00:37:17 2013
New Revision: 1540899

URL: http://svn.apache.org/r1540899
Log:
Progress on validation, but needs to strip out HTML content

Modified:
    jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.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

Modified: 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=1540899&r1=1540898&r2=1540899&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.js (original)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/controllers/validation-controller.js Tue
Nov 12 00:37:17 2013
@@ -9,14 +9,17 @@ define(
         ValidationService = require( "services/validation-service" );
 
     var ValidationController = function() {
-      this.initEvents();
       this.initServices();
+      this.initEvents();
     };
 
     // add the behaviours defined on the controller
     _.extend( ValidationController.prototype, {
       initEvents: function() {
         fui.vent.on( "models.validation-options.ready", this.onValidationOptionsModelReady
);
+        $(".validation").on( "click", "a.perform-validation", function( event ) {
+          fui.services.validation.performValidation( fui.views.validationOptions.model );
+        } );
       },
 
       onValidationOptionsModelReady: function( e ) {

Modified: 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=1540899&r1=1540898&r2=1540899&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/models/validation-options.js (original)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/models/validation-options.js Tue Nov 12
00:37:17 2013
@@ -43,6 +43,21 @@ define(
         this.set( "outputFormat", of );
       },
 
+      validationURL: function() {
+        switch (this.get( "validateAs" )) {
+        case "sparql":  return "/validate/query";
+        case "arq":  return "/validate/query";
+        case "Turtle": return "/validate/data";
+        case "TriG": return "/validate/data";
+        case "N-Triples": return "/validate/data";
+        case "N-Quads": return "/validate/data";
+        }
+      },
+
+      payloadParam: function() {
+        return this.validateAsQuery() ? "query" : "data";
+      },
+
       toJSON: function() {
         var json = {
           languageSyntax: this.validateAs(),

Modified: 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=1540899&r1=1540898&r2=1540899&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pages/js/app/services/validation-service.js (original)
+++ jena/branches/jena-fuseki-new-ui/pages/js/app/services/validation-service.js Tue Nov 12
00:37:17 2013
@@ -33,6 +33,28 @@ define( ['underscore', 'jquery', 'fui', 
           } );
         }
         return this._output;
+      },
+
+      /** Return the current code editor contents */
+      editorContent: function() {
+        return this.editorElement().getValue();
+      },
+
+      /** Perform the given action to validate the current content */
+      performValidation: function( optionsModel ) {
+        var self = this;
+        var content = {};
+        content[optionsModel.payloadParam()] = this.editorContent();
+
+        var options = {
+            data: _.extend( optionsModel.toJSON(), content ),
+            type: "POST"
+        };
+
+        $.ajax( optionsModel.validationURL(), options )
+         .done( function( data ) {
+           self.outputElement().setValue( data );
+         } );
       }
 
     } );



Mime
View raw message