Compare commits

...

31 Commits
v1.0 ... master

Author SHA1 Message Date
Felix Lohmeier b903fd1f24 backlink to GitHub 2020-04-29 22:12:36 +02:00
Felix Lohmeier cc3e8a7c47 full attribution 2020-04-29 18:04:23 +02:00
Felix Lohmeier 2dfaa1589f update README 2020-04-29 17:58:42 +02:00
Felix Lohmeier 06efe98436 set fix height 2020-04-29 17:42:07 +02:00
Felix Lohmeier 047cf20e9c style textarea 2020-04-29 17:18:49 +02:00
Felix Lohmeier 0146f5ed3e resize textarea 2020-04-29 17:02:21 +02:00
Felix Lohmeier d1d3f10398 add example and download buttons 2020-04-29 16:22:45 +02:00
Felix Lohmeier 9a31ad1016 get value from codemirror editor (fix) 2020-04-29 16:09:29 +02:00
Felix Lohmeier 7b6f4e98e2 get value from codemirror editor 2020-04-29 16:07:45 +02:00
Felix Lohmeier 8556cd02de replace lined-textarea with codemirror 2020-04-29 15:43:06 +02:00
Felix Lohmeier e21e440bea removed lined-textarea 2020-04-29 15:22:06 +02:00
Felix Lohmeier 49168dba1f
Delete .gitignore 2020-04-29 14:05:06 +02:00
Felix Lohmeier 982c09ce16 replace cdn includes with local files 2020-04-29 14:04:01 +02:00
Felix Lohmeier 4e80bea6d1 remove command-line utility 2020-04-29 14:03:30 +02:00
Felix Lohmeier e7d5e5eda1 reduced to web version 2020-04-29 13:33:39 +02:00
Miel Vander Sande b1df716e69 Added different statuscodes & dev server 2019-01-10 12:43:45 +01:00
mielvds 03ccb2f154
Merge pull request #4 from bartoszWesolowski/added-line-numbers-to-input-field
Added line numbers to input field
2019-01-09 14:25:05 +01:00
Miel Vander Sande e701af4433 Updated N3.js 2018-06-14 13:19:16 +02:00
mielvds df0755da80
Update package.json 2018-05-31 16:32:47 +02:00
Pieter Colpaert 7578142cc0 Added multiple file support to README 2018-02-16 11:22:26 +01:00
Pieter Colpaert 3588565038 Update N3.js 2018-02-16 11:16:18 +01:00
Bartosz Wesolowski 1a9277b17c Added line numbers to text area. 2017-11-18 14:12:34 +01:00
Bartosz Wesolowski 41660a58fc Included lined-textarea lib from: https://github.com/aw20/JQueryLinedText 2017-11-18 14:10:04 +01:00
Pelle Jacobs 3b60ed473a Add multiple files support 2017-11-02 14:09:15 +01:00
Pieter Colpaert 6ef022c8f8 Merge pull request #2 from DieterDePaepe/fixes
Various fixes.
2016-11-29 11:30:33 +01:00
Dieter De Paepe d282c57354 Add proper styling. 2016-11-29 11:28:00 +01:00
Dieter De Paepe a15fcadc21 Ignore ttl.js. 2016-11-29 11:27:36 +01:00
Dieter De Paepe 55080ccd18 Update affiliation, add LICENSE. 2016-11-29 11:06:12 +01:00
Dieter De Paepe 5f4bd66d36 Properly escape html in error or warning. 2016-11-29 10:55:57 +01:00
Miel Vander Sande aa23ef52eb Update version nr 2015-11-26 10:01:28 +01:00
Miel Vander Sande e7e0d597a5 Added https support 2015-11-26 10:00:40 +01:00
19 changed files with 19730 additions and 6877 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
node_modules

26
LICENSE Normal file
View File

@ -0,0 +1,26 @@
The MIT License (MIT)
Copyright (c):
* N3.js: Ruben Verborgh
* Bootstrap: Twitter, Inc and The Bootstrap Authors
* jQuery: JS Foundation and other contributors, https://js.foundation/
* TurtleValidator: IDLab - Ghent University - imec
* CodeMirror: Marijn Haverbeke <marijnh@gmail.com> and others
* Remix: Felix Lohmeier
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,25 +1,5 @@
TurtleValidator
===========
RDF NTriples/Turtle validator using Ruben Verborgh's [N3 NodeJS library](https://github.com/RubenVerborgh/N3.js). Validate Turtle and Ntriples documents on syntax and XSD datatype errors through command line.
# Turtle Web Editor
© 2014, 2015 - MMLab - Ghent University - iMinds
Source code: https://github.com/MMLab/TurtleValidator
Online text editor with [Turtle](https://en.wikipedia.org/wiki/Turtle_(syntax)) syntax highlighting and validation. This is a remix of [IDLab Turtle Validator](https://github.com/IDLabResearch/TurtleValidator) using [Codemirror](https://codemirror.net).
Install:
npm install -g turtle-validator
Examples:
$ ttl <path-to-file>
$ curl http://data.linkeddatafragments.org/dbpedia -H "accept: text/turtle" | ttl
$ ttl http://triples.demo.thedatatank.com/demo.ttl
## Or install the browser client
```bash
npm install
browserify lib/validator.js -o public/js/ttl.js
```
Then use it in your browser using the index.html in the public folder.
Deployed on GitHub Pages: <https://felixlohmeier.github.io/turtle-web-editor/>

View File

@ -1,56 +0,0 @@
#!/usr/bin/env node
/*! @license ©2014 Miel Vander Sande - Multimedia Lab / iMinds / Ghent University */
/* Command-line utility to validate Turtle files. */
var N3 = require('n3'),
fs = require('fs'),
N3Util = N3.Util,
http = require('http'),
url = require('url'),
fs = require('fs'),
validate = require('./lib/validator.js');
var help = function () {
// In all other cases, let's help the user and return some help
console.log('RDF NTriples/Turtle validator using Ruben Verborgh\'s N3 nodejs library');
console.log('© 2014 - MMLab - Ghent University - iMinds');
console.log('Source code: https://github.com/MMLab/TurtleValidator');
console.log('');
console.log('Examples:');
console.log('');
console.log(' $ ttl <path-to-file>');
console.log(' $ curl http://data.linkeddatafragments.org/dbpedia -H "accept: text/turtle" | ttl');
console.log(' $ ttl http://triples.demo.thedatatank.com/demo.ttl');
};
var args = process.argv.slice(2);
if (args.length > 1 || (args.length > 0 && (args[0] === "-h" || args[0] === "--help")))
return help();
if (args.length === 0) {
validate(process.stdin, showValidation);
} else if (args.length > 0) {
// Create a stream from the file, whether it is a local file or a http stream
var parsedUrl = url.parse(args[0]);
if (parsedUrl.protocol === 'http:')
http.get(parsedUrl.href, function (res) {
validate(res, showValidation);
}).on('error', function (e) {
console.log("Got error: " + e.message);
});
else
validate(fs.createReadStream(parsedUrl.href), showValidation);
}
// Use stdio as an input stream
function showValidation(feedback) {
feedback.errors.forEach(function (error) {
console.log(error);
});
feedback.warnings.forEach(function (warning) {
console.log(warning);
});
console.log("Validator finished with " + feedback.warnings.length + " warnings and " + feedback.errors.length + " errors.");
}

5
css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

349
css/codemirror.css Normal file
View File

@ -0,0 +1,349 @@
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
direction: ltr;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror-cursor {
border-left: 1px solid black;
border-right: none;
width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
width: auto;
border: 0 !important;
background: #7e7;
}
.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-fat-cursor-mark {
background-color: rgba(20, 255, 20, 0.5);
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
}
.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;
background-color: #7e7;
}
@-moz-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@-webkit-keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
@keyframes blink {
0% {}
50% { background-color: transparent; }
100% {}
}
/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: 0;
overflow: hidden;
}
.CodeMirror-ruler {
border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.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,
.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, .cm-s-default .cm-type {color: #085;}
.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-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
.CodeMirror-composing { border-bottom: 2px solid; }
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 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;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
min-height: 100%;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: -30px;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
background: none !important;
border: none !important;
}
.CodeMirror-gutter-background {
position: absolute;
top: 0; bottom: 0;
z-index: 4;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
}
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: contextual;
font-variant-ligatures: contextual;
}
.CodeMirror-wrap pre.CodeMirror-line,
.CodeMirror-wrap pre.CodeMirror-line-like {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
padding: 0.1px; /* Force widget margins to stay inside of the container */
}
.CodeMirror-widget {}
.CodeMirror-rtl pre { direction: rtl; }
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
div.CodeMirror-dragcursors {
visibility: visible;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
.cm-searching {
background-color: #ffa;
background-color: rgba(255, 255, 0, .4);
}
/* 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-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }

39
index.html Normal file
View File

@ -0,0 +1,39 @@
<html>
<head>
<title>Turtle Web Editor</title>
<script src="js/jquery-2.1.4.min.js"></script>
<script src="js/ttl.js"></script>
<script src="js/codemirror.js"></script>
<script src="js/turtle.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/codemirror.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
.CodeMirror {
border: 1px solid #eee;
height: 70%;
}
</style>
</head>
<body>
<div class="container">
<h1>Turtle Web Editor</h1>
<p>Online text editor with <a href="https://en.wikipedia.org/wiki/Turtle_(syntax)">Turtle</a> syntax highlighting and validation. This is a remix of <a href="https://github.com/IDLabResearch/TurtleValidator">IDLab Turtle Validator</a> using <a href="https://codemirror.net">Codemirror</a>. The code is <a href="https://github.com/felixlohmeier/turtle-web-editor">on GitHub</a>.
<form>
<div class="form-group">
<textarea class="area" id="ta_turtle"></textarea>
</div>
<div class="form-group">
<input type="button" id="btn_example" class="btn btn-default" value="Load Example"/>
<input type="button" id="btn_validate" class="btn btn-default" value="Validate!"/>
<input type="button" id="btn_download" class="btn btn-default" value="Download"/>
</div>
</form>
<ul id="errors"></ul>
<ul id="warnings"></ul>
<p id="results"></p>
<script src="js/app.js"></script>
</div>
</body>
</html>

62
js/app.js Normal file
View File

@ -0,0 +1,62 @@
$("#btn_validate").click( function () {
$("#warnings").html("");
$("#errors").html("");
$("#results").html("");
validate(editor.getValue(), function (feedback) {
$.each(feedback.warnings, function (index, warning) {
$("#warnings").append($('<li id="warning' + index + '">').text(warning));
});
$.each(feedback.errors, function (index, error) {
$("#errors").append($('<li id="error' + index + '">').text(error));
});
if (feedback.errors.length === 0 && feedback.warnings.length === 0) {
$("#results").append("Congrats! Your syntax is correct.");
}
});
});
var editor = CodeMirror.fromTextArea(document.getElementById("ta_turtle"), {
lineNumbers: true,
mode: 'turtle',
viewportMargin: Infinity,
theme: 'default'
});
var example =
['@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .',
'@prefix dc: <http://purl.org/dc/elements/1.1/> .',
'@prefix ex: <http://example.org/stuff/1.0/> .',
'<http://www.w3.org/TR/rdf-syntax-grammar>',
' dc:title "RDF/XML Syntax Specification (Revised)" ;',
' ex:editor [',
' ex:fullname "Dave Beckett";',
' ex:homePage <http://purl.org/net/dajobe/>',
' ] .'
].join('\n');
$("#btn_example").click( function () {
editor.setValue(example);
});
$("#btn_download").click( function () {
var textToWrite = editor.getValue();
var textToWrite = textToWrite.replace(/\n/g, "\r\n");
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = "FILENAME.ttl";
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Turtle Web Editor Content";
window.URL = window.URL || window.webkitURL;
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
downloadLink.click();
});
function destroyClickedElement(event) {
document.body.removeChild(event.target);
}

7
js/bootstrap.min.js vendored Normal file

File diff suppressed because one or more lines are too long

9767
js/codemirror.js Normal file

File diff suppressed because it is too large Load Diff

4
js/jquery-2.1.4.min.js vendored Normal file

File diff suppressed because one or more lines are too long

9467
js/ttl.js Normal file

File diff suppressed because it is too large Load Diff

1
js/turtle.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("turtle",function(t){var i,c=t.indentUnit;function e(t){return new RegExp("^(?:"+t.join("|")+")$","i")}e([]);var l=e(["@prefix","@base","a"]),u=/[*+\-<>=&|]/;function a(t,e){var r,n=t.next();if(i=null,"<"!=n||t.match(/^[\s\u00a0=]/,!1)){if('"'==n||"'"==n)return e.tokenize=(r=n,function(t,e){for(var n,o=!1;null!=(n=t.next());){if(n==r&&!o){e.tokenize=a;break}o=!o&&"\\"==n}return"string"}),e.tokenize(t,e);if(/[{}\(\),\.;\[\]]/.test(n))return i=n,null;if("#"==n)return t.skipToEnd(),"comment";if(u.test(n))return t.eatWhile(u),null;if(":"==n)return"operator";if(t.eatWhile(/[_\w\d]/),":"==t.peek())return"variable-3";var o=t.current();return l.test(o)?"meta":"A"<=n&&n<="Z"?"comment":"keyword"}return t.match(/^[^\s\u00a0>]*>?/),"atom"}function o(t,e,n){t.context={prev:t.context,indent:t.indent,col:n,type:e}}function r(t){t.indent=t.context.indent,t.context=t.context.prev}return{startState:function(){return{tokenize:a,context:null,indent:0,col:0}},token:function(t,e){if(t.sol()&&(e.context&&null==e.context.align&&(e.context.align=!1),e.indent=t.indentation()),t.eatSpace())return null;var n=e.tokenize(t,e);if("comment"!=n&&e.context&&null==e.context.align&&"pattern"!=e.context.type&&(e.context.align=!0),"("==i)o(e,")",t.column());else if("["==i)o(e,"]",t.column());else if("{"==i)o(e,"}",t.column());else if(/[\]\}\)]/.test(i)){for(;e.context&&"pattern"==e.context.type;)r(e);e.context&&i==e.context.type&&r(e)}else"."==i&&e.context&&"pattern"==e.context.type?r(e):/atom|string|variable/.test(n)&&e.context&&(/[\}\]]/.test(e.context.type)?o(e,"pattern",t.column()):"pattern"!=e.context.type||e.context.align||(e.context.align=!0,e.context.col=t.column()));return n},indent:function(t,e){var n=e&&e.charAt(0),o=t.context;if(/[\]\}]/.test(n))for(;o&&"pattern"==o.type;)o=o.prev;var r=o&&n==o.type;return o?"pattern"==o.type?o.col:o.align?o.col+(r?0:1):o.indent+(r?0:c):0},lineComment:"#"}}),t.defineMIME("text/turtle","turtle")});

View File

@ -1,41 +0,0 @@
var N3 = require('n3'),
N3Util = N3.Util;
var validate = function (turtleStream, callback) {
var parser = N3.Parser();
var errorCount = 0, warningCount = 0;
var regexp = {
'dateTime' : /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])?T(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)??(Z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?$/,
'double' : /[-+]?\d*([.]\d+)?/,
'float' : /[-+]?\d*[.]\d+/,
'int' : /^[-+]?(0|[1-9]\d*)$/
};
var feedback = { warnings : [], errors : []};
parser.parse(turtleStream, function(error, triple, prefixes) {
if (error) {
feedback.errors.push(error);
}
if (triple) {
if (N3Util.isLiteral(triple.object)) {
var value = N3Util.getLiteralValue(triple.object);
var type = N3Util.getLiteralType(triple.object);
type = type.replace('http://www.w3.org/2001/XMLSchema#', '');
if (regexp[type] && !regexp[type].test(value)) {
feedback.warnings.push('WARNING: xsd:', type, 'does not validate for literal. {', triple.subject, triple.predicate, triple.object, '}');
}
}
} else {
callback(feedback);
}
});
};
if (typeof window !== 'undefined') {
window.validate = validate;
}
module.exports = validate;

View File

@ -1,32 +0,0 @@
{
"name": "turtle-validator",
"version": "1.0.0",
"description": "This command line tool validates Turtle documents and does XSD datatype checks",
"main": "TurtleValidator.js",
"bin": {
"ttl": "./TurtleValidator.js"
},
"dependencies": {
"n3": "^0.4.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/mmlab/TurtleValidator.git"
},
"keywords": [
"Turtle",
"RDF",
"Semantic",
"Web"
],
"author": "Miel Vander Sande",
"license": "MIT",
"bugs": {
"url": "https://github.com/mmlab/TurtleValidator/issues"
},
"homepage": "https://github.com/mmlab/TurtleValidator"
}

View File

@ -1,4 +0,0 @@
textarea {
width: 100%;
height: 50%;
}

View File

@ -1,22 +0,0 @@
<html>
<head>
<title>Turtle validator</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="js/ttl.js"></script>
<link rel="stylesheet" href="css/style.css">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<h1>MMLab Turtle Validator</h1>
<h2>Paste your turtle file in here and press validate</h2>
<form>
<textarea class="area" id="ta_turtle"></textarea>
<input type="button" id="btn_validate" value="Validate!"/>
</form>
<p id="errors"></p>
<p id="warnings"></p>
<p id="results"></p>
<script src="js/app.js"></script>
</body>
</html>

View File

@ -1,19 +0,0 @@
$("#btn_validate").click( function () {
$("#warnings").html("");
$("#errors").html("");
$("#results").html("");
validate($("#ta_turtle").val(), function (feedback) {
$.each(feedback.warnings, function (index, warning) {
$("#warnings").append('<p id="warning' + index + '">' + warning + '<br/>');
});
$.each(feedback.errors, function (index, error) {
$("#errors").append('<p id="error' + index + '">' + error + '<br/>');
});
if (feedback.errors.length === 0 && feedback.warnings.length === 0) {
$("#results").append("Congrats! We've validated your output and it contains 0 errors or warnings.");
}
});
});

File diff suppressed because it is too large Load Diff