You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/12/17 14:52:01 UTC

[2/3] git commit: MARMOTTA-346: Added syntax-highlighting to reasoner config page.

MARMOTTA-346: Added syntax-highlighting to reasoner config page.


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/559d2e67
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/559d2e67
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/559d2e67

Branch: refs/heads/develop
Commit: 559d2e67b3656ad0c4ffe478de3daaf520f115d7
Parents: 9a3913d
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Dec 17 14:14:58 2013 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Tue Dec 17 14:14:58 2013 +0100

----------------------------------------------------------------------
 .../src/main/resources/web/admin/configure.html | 24 ++++++---
 .../resources/web/admin/widget/conf_reasoner.js | 56 +++++++++++++++++---
 2 files changed, 67 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/559d2e67/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
----------------------------------------------------------------------
diff --git a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
index 63b0c64..5a97628 100644
--- a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
+++ b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/configure.html
@@ -17,8 +17,7 @@
     limitations under the License.
 
 -->
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
-        "http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE HTML>
 <html>
 <head>
 <!--###BEGIN_HEAD###-->
@@ -45,15 +44,28 @@
         table{
             border: 1px dotted black !important;
         }
+        .CodeMirror {
+            border: 1px solid black;
+        }
+        #reasoner li .CodeMirror {
+            height: auto;
+        }
+        #reasoner li .CodeMirror-scroll {
+            overflow-y: hidden;
+            overflow-x: auto;
+        }
     </style>
 <!--###END_HEAD###-->
 </head>
 <body>
 <!--###BEGIN_CONTENT###-->
-<h1>Reasoning Configurator</h1>
-        <p>
-            Here you can configure the Reasoner.
-        </p>
+    <h1>Reasoning Configurator</h1>
+    <p>Here you can configure the Reasoner.</p>
+    <p>A detailed howto is available on the 
+        <a href="http://marmotta.apache.org/kiwi/reasoner.html">Marmotta Webpage (KiWi Reasoner)</a>
+        and collection of example reasoning programs is available 
+        <a href="http://wiki.apache.org/marmotta/Reasoner/ExamplePrograms">in the Wiki</a>.
+    </p> 
         <div id="reasoner">
             <h4>Loading reasoning configurator</h4>
         </div>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/559d2e67/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
----------------------------------------------------------------------
diff --git a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
index ad4c3f9..9d88207 100644
--- a/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
+++ b/platform/marmotta-reasoner-kiwi/src/main/resources/web/admin/widget/conf_reasoner.js
@@ -29,13 +29,17 @@
     var title_input;
     var program_input;
     var list;
+    
+    CodeMirror.commands.autocomplete = function(cm) {
+        CodeMirror.showHint(cm, CodeMirror.hint.skwrl);
+    };
 
     $.fn.reasoning_config = function(options) {
         var settings = {
             host: 'http://localhost:8080/LMF/',
             samples :{
-                skos:"@prefix: skos: <http://www.w3.org/2004/02/skos/core#>\n($1 skos:broader $2) -> ($1 skos:broaderTransitive $2)\n($1 skos:narrower $2) -> ($1 skos:narrowerTransitive $2)\n($1 skos:broaderTransitive $2), ($2 skos:broaderTransitive $3) -> ($1 skos:broaderTransitive $3)\n($1 skos:narrowerTransitive $2), ($2 skos:narrowerTransitive $3) -> ($1 skos:narrowerTransitive $3)\n($1 skos:broader $2) -> ($2 skos:narrower $1)\n($1 skos:narrower $2) -> ($2 skos:broader $1)\n($1 skos:broader $2) -> ($1 skos:related $2)\n($1 skos:narrower $2) -> ($1 skos:related $2)\n($1 skos:related $2) -> ($2 skos:related $1)",
-                rdfs:"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n($1 rdfs:subClassOf $2), ($2 rdfs:subClassOf $3) -> ($1 rdfs:subClassOf $3)\n($1 rdfs:subPropertyOf $2), ($2 rdfs:subPropertyOf $3) -> ($1 rdfs:subPropertyOf $3)\n($1 rdf:type $2), ($2 rdfs:subClassOf $3) -> ($1 rdf:type $3)\n($p rdfs:range $r), ($1 $p $2) -> ($2 rdf:type $r)\n($p rdfs:domain $d), ($1 $p $2) -> ($1 rdf:type $d)"
+                skos:"@prefix: skos: <http://www.w3.org/2004/02/skos/core#>\n\n($1 skos:broader $2) -> ($1 skos:broaderTransitive $2)\n($1 skos:narrower $2) -> ($1 skos:narrowerTransitive $2)\n($1 skos:broaderTransitive $2), ($2 skos:broaderTransitive $3) -> ($1 skos:broaderTransitive $3)\n($1 skos:narrowerTransitive $2), ($2 skos:narrowerTransitive $3) -> ($1 skos:narrowerTransitive $3)\n($1 skos:broader $2) -> ($2 skos:narrower $1)\n($1 skos:narrower $2) -> ($2 skos:broader $1)\n($1 skos:broader $2) -> ($1 skos:related $2)\n($1 skos:narrower $2) -> ($1 skos:related $2)\n($1 skos:related $2) -> ($2 skos:related $1)",
+                rdfs:"@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\n($1 rdfs:subClassOf $2), ($2 rdfs:subClassOf $3) -> ($1 rdfs:subClassOf $3)\n($1 rdfs:subPropertyOf $2), ($2 rdfs:subPropertyOf $3) -> ($1 rdfs:subPropertyOf $3)\n($1 rdf:type $2), ($2 rdfs:subClassOf $3) -> ($1 rdf:type $3)\n($p rdfs:range $r), ($1 $p $2) -> ($2 rdf:type $r)\n($p rdfs:domain $d), ($1 $p $2) -> ($1 rdf:type $d)"
             },
             loader:"../../core/public/img/ajax-loader_small.gif"
         }
@@ -104,13 +108,14 @@
                     button.bind("click",function(){
                         do_remove($(this).attr('name'));
                     });
-                    var title = $("<h4></h4>").text(name);
-                    var pr = $("<pre style='width:863px;font-size:11px;margin:0;'></pre>").text(ps[i].rules);
+                    var title = $("<h4>").text(name);
+                    var pr = $("<div>");
                     li.append(title);
                     li.append(pr);
                     li.append(button);
                     li.append('<img class="loader" src="'+settings.loader+'" style="display:none;float:right;margin:5px"></div>');
                     list.append(li);
+                    createCodeMirror(pr, ps[i].rules, true);
                 }
             }
 
@@ -120,6 +125,41 @@
                 list.html("<li>no programs loaded</li>");
             }
         }
+        
+        function createCodeMirror(target, content, readOnly) {
+            target = $(target)[0];
+            if (target._cmEditor || false) {
+                removeCodeMirror(target);
+            }
+            if (readOnly) {
+                target._cmEditor = new CodeMirror(target, {
+                    readOnly: true,
+                    lineNumbers: true,
+                    matchBrackets: true,
+                    mode: "skwrl"
+                });
+                target._cmEditor.toTextArea = function() {}; // To avoid errors because of a missing function in removeCodeMirror()
+            } else {
+                target._cmEditor = CodeMirror.fromTextArea(target, {
+                    readOnly: false,
+                    lineNumbers : true,
+                    matchBrackets : true,
+                    extraKeys: {"Ctrl-Space": "autocomplete"},
+                    mode : "skwrl"
+                });
+            }
+            if (content !== undefined) {
+                target._cmEditor.setValue(content);
+                if (!readOnly)
+                    target._cmEditor.save();
+            }
+        }
+        function removeCodeMirror(target) {
+            if (target._cmEditor || false) {
+                target._cmEditor.toTextArea();
+                target._cmEditor = null;
+            }
+        }
 
         var write = function(programs) {
             div.html("");
@@ -144,7 +184,7 @@
             var button2 = $("<button style='position:relative;left:50%;margin-top:10px;margin-left:-50px;'></button>").text("clear");
             button2.bind("click",function(){
                 title_input.val("");
-                program_input.val("");
+                createCodeMirror(program_input, "");
             });
 
             table.append(tr1);
@@ -161,11 +201,11 @@
                 var x = $(this).val();
                 if(x=="---"){
                     title_input.val("");
-                    program_input.val("");
+                    createCodeMirror(program_input, "");
                     return;
                 }
                 title_input.val(x);
-                program_input.val(settings.samples[x]);
+                createCodeMirror(program_input, settings.samples[x]);
             });
             var sam_div = $('<div style="position: relative; float: right; margin-bottom: 5px; margin-top: -20px;"><span style="font-size:12px;margin-right:5px">Samples:</span>');
             sam_div.append(sam);
@@ -179,6 +219,8 @@
             div.append(button);
             div.append('<img class="loader" src="'+settings.loader+'" style="display:none;float:right;margin:5px"></div>');
 
+            createCodeMirror(program_input)
+            
             writePrograms(programs);
         }