Added a simple browser client

This commit is contained in:
Pieter Colpaert 2015-07-14 19:23:35 +02:00
parent 25b1c4032b
commit b330e0e74c
5 changed files with 6734 additions and 1 deletions

View File

@ -2,7 +2,7 @@ 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. 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.
© 2014 - MMLab - Ghent University - iMinds © 2014, 2015 - MMLab - Ghent University - iMinds
Source code: https://github.com/MMLab/TurtleValidator Source code: https://github.com/MMLab/TurtleValidator
Install: Install:
@ -14,3 +14,12 @@ Examples:
$ ttl <path-to-file> $ ttl <path-to-file>
$ curl http://data.linkeddatafragments.org/dbpedia -H "accept: text/turtle" | ttl $ curl http://data.linkeddatafragments.org/dbpedia -H "accept: text/turtle" | ttl
$ ttl http://triples.demo.thedatatank.com/demo.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.

4
public/css/style.css Normal file
View File

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

22
public/index.html Normal file
View File

@ -0,0 +1,22 @@
<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>

19
public/js/app.js Normal file
View File

@ -0,0 +1,19 @@
$("#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.");
}
});
});

6679
public/js/ttl.js Normal file

File diff suppressed because it is too large Load Diff