Skip to content

Commit

Permalink
user registrqation form basically working (no validation etcyet)
Browse files Browse the repository at this point in the history
  • Loading branch information
danja committed Oct 15, 2013
1 parent d67a9e2 commit f21aff8
Show file tree
Hide file tree
Showing 15 changed files with 2,674 additions and 175 deletions.
83 changes: 62 additions & 21 deletions README.md
@@ -1,22 +1,34 @@
** Seki is a front-end to an independent SPARQL server using node.js **
## Seki is a front-end to an independent SPARQL server using node.js

No really, what is it?

It operates as a Web server, building queries from HTTP requests (from a browser or another service) and passing them to the SPARQL server, formatting the results (to HTML, JSON...) and passing them back to the client.
It operates as a Web server, building queries from HTTP requests (from a browser
or another service) and passing them to the SPARQL server, formatting the
results (to HTML, JSON...) and passing them back to the client.

*** Uses ***
### Uses

Generally speaking Seki could be used for pretty much any Web system that might otherwise use a HTTP server and database. Because an RDF/SPARQL server/DB is used for the backend, Seki is very webby at its core, meaning server-server communications (e.g. addressing remote Linked Data) will be simplified.
Primarily I'm developing Seki as a testbed to see what can be achieved using Web tech.

In the near term the plan is to clone various well-known kinds of apps and see what can be added thanks to the Semantic Web goodness. As most apps require the following in some form, this functionality is high on the todo list:
Generally speaking Seki could be used for pretty much any Web system that might
otherwise use a HTTP server and database. Because an RDF/SPARQL server/DB is
used for the backend, Seki is very webby at its core, meaning server-server
communications (e.g. addressing remote Linked Data) will be simplified.

In the near term the plan is to clone various well-known kinds of apps and see
what can be added thanks to the Semantic Web goodness. As most apps require the
following in some form, this functionality is high on the todo list:
* simple content managent (largely implemented)
* user access control (in-progress)

Also high on the list is to provide query federation facilities, to e.g. automatically catalog/annotate/expand documents.
Also high on the list is to provide query federation facilities, to e.g.
automatically catalog/annotate/expand documents.

Later the plan is to set Seki up as a general-purpose Web agent container, allow custom behaviour to be defined using pluggable scripts with declarative configuration.
Later the plan is to set Seki up as a general-purpose Web agent container, allow
custom behaviour to be defined using pluggable scripts with declarative
configuration.

*** Components ***
### Components

* Server
* Client
Expand All @@ -25,27 +37,52 @@ Later the plan is to set Seki up as a general-purpose Web agent container, allow
* User Manager (in progress)
* Plugin script runner (todo)

![Block Diagram](https://github.com/danja/seki/raw/master/docs/other/seki-full.png)
![Block
Diagram](https://github.com/danja/seki/raw/master/docs/other/seki-full.png)

For updates see [Seki on G+](https://plus.google.com/b/102910670341143019851/102910670341143019851/posts)
For updates see [Seki on
G+](https://plus.google.com/b/102910670341143019851/102910670341143019851/posts)

Also [TODO List](https://workflowy.com/shared/dd5976b2-b48f-9096-0357-105f34b4d6ed/)
Also [TODO
List](https://workflowy.com/shared/dd5976b2-b48f-9096-0357-105f34b4d6ed/)

Note 2013-08-27 : packaging etc. still in progress, but I have managed to get a live instance running on OpenShift (Red Hat's hosting service) at http://seki-hyperdata.rhcloud.com/welcome, backed by a Fuseki store hosted at http://fuseki-hyperdata.rhcloud.com/ (using https://github.com/semfact/openshift-fuseki ). The live Seki code is structured differently than that in git here, but as that version works (!) I'll merge it back in here asap.
Note 2013-08-27 : packaging etc. still in progress, but I have managed to get a
live instance running on OpenShift (Red Hat's hosting service) at
http://seki-hyperdata.rhcloud.com/welcome, backed by a Fuseki store hosted at
http://fuseki-hyperdata.rhcloud.com/ (using
https://github.com/semfact/openshift-fuseki ). The live Seki code is structured
differently than that in git here, but as that version works (!) I'll merge it
back in here asap.

Note 2013-08-15 : currently trying to package as npm and tidy up dependencies - may be a messfor a little while
Note 2013-08-15 : currently trying to package as npm and tidy up dependencies -
may be a messfor a little while

If (were it live) you pointed a browser at http://hyperdata.org/seki/Hello it would take "http://hyperdata.org/seki/Hello" to build a query to find out about that resource - in the data store it will have a title, content etc. - which then get turned into HTML to show in the browser.
If (were it live) you pointed a browser at http://hyperdata.org/seki/Hello it
would take "http://hyperdata.org/seki/Hello" to build a query to find out about
that resource - in the data store it will have a title, content etc. - which
then get turned into HTML to show in the browser.

There is a form to allow POSTing, inserting title, content etc. for a given resource into the RDF store (there's no authentication as yet). Files can also be served from the filesystem.
There is a form to allow POSTing, inserting title, content etc. for a given
resource into the RDF store (there's no authentication as yet). Files can also
be served from the filesystem.

It has been built against a Fuseki server, which uses protocols/query syntax according to the latest SPARQL 1.1 drafts, and so it should be reusable with any SPARQL server.
It has been built against a Fuseki server, which uses protocols/query syntax
according to the latest SPARQL 1.1 drafts, and so it should be reusable with any
SPARQL server.

(Note that the current version includes a little SAX-based XML SPARQL results to JSON converter, this was for demo purposes (don't ask!) - future versions *may* use JSON SPARQL results directly).
(Note that the current version includes a little SAX-based XML SPARQL results to
JSON converter, this was for demo purposes (don't ask!) - future versions *may*
use JSON SPARQL results directly).

At present it considers all resources to be information resources - the ones that get displayed are instances of sioc:Post. Descriptions of those resources are contained in little named graphs (named by the resources in question). The Fuseki config includes _#dataset tdb:unionDefaultGraph true_ so SPARQL queries can be applied over a (virtual) merge of all the named graphs.
At present it considers all resources to be information resources - the ones
that get displayed are instances of sioc:Post. Descriptions of those resources
are contained in little named graphs (named by the resources in question). The
Fuseki config includes _#dataset tdb:unionDefaultGraph true_ so SPARQL queries
can be applied over a (virtual) merge of all the named graphs.

After the tutorial version is stable the plan is to use it as an experimental Read/Write Data Web testbed, e.g. adding support for the linked data API, RDF affordances play.
After the tutorial version is stable the plan is to use it as an experimental
Read/Write Data Web testbed, e.g. adding support for the linked data API, RDF
affordances play.

See contents.txt in individual folders for description.

Expand All @@ -61,15 +98,19 @@ the Fuseki server (SPARQL endpoint) will be accessible at http://localhost:3030/

localhost:8888/store/ will proxy to the store

Exploring data from Fuseki, first select the /seki dataset through the Control Panel, then go to the query panel
Exploring data from Fuseki, first select the /seki dataset through the Control
Panel, then go to the query panel
with e.g.
SELECT * WHERE { GRAPH ?graph { ?s ?p ?o } }

----

2013-10-07

Added bits for [Grunt](http://gruntjs.com/), [Vows](http://vowsjs.org/) plus [grunt-vows](https://github.com/CMTegner/grunt-vows), also [APIeasy](https://github.com/flatiron/api-easy), though not yet runnable, related scripts will be in /bin (also will set up 'npm test').
Added bits for [Grunt](http://gruntjs.com/), [Vows](http://vowsjs.org/) plus
[grunt-vows](https://github.com/CMTegner/grunt-vows), also
[APIeasy](https://github.com/flatiron/api-easy), though not yet runnable,
related scripts will be in /bin (also will set up 'npm test').

[docco-husky]() used for source doc generation.

Expand Down
Binary file modified data/SekiDB/GOSP.dat
Binary file not shown.
Binary file modified data/SekiDB/GPOS.dat
Binary file not shown.
Binary file modified data/SekiDB/GSPO.dat
Binary file not shown.
Binary file modified data/SekiDB/OSPG.dat
Binary file not shown.
Binary file modified data/SekiDB/POSG.dat
Binary file not shown.
Binary file modified data/SekiDB/SPOG.dat
Binary file not shown.
Binary file modified data/SekiDB/node2id.dat
Binary file not shown.
Binary file modified data/SekiDB/nodes.dat
Binary file not shown.
23 changes: 18 additions & 5 deletions handlers/RegistrationHandler.js
Expand Up @@ -55,21 +55,34 @@ RegistrationHandler.prototype = {

// console.log(post_body);
// turn the POST parameters into a map (JSON object)
var bodyMap = qs.parse(post_body);

log.debug("parsed post_body \n" + JSON.stringify(post_body));
// var bodyMap = qs.parse(post_body);
var bodyMap = JSON.parse(post_body);

log.debug("replaceMap \n" + JSON.stringify(bodyMap));

// VALIDATE MESSAGE
var options = { "format" : 'application/nquads' };

var processor = new jsonld.JsonLdProcessor();
// try - catch

processor.normalize(bodyMap, options,
function(err, turtle) {
if(err) {
log.debug("JsonLd parse error "+err);
};
log.debug("POSTed Turtle = "+turtle);
var client = new StoreClient(); // is same as in JSONHandler
var headers = {
"Location" : config.uriBase+"/users/"+bodyMap["login"],
"Content-type" : "text/html; charset=utf-8"
};
var callback = function(){ // hmm, 303 not 201 Created
sekiResponse.writeHead(303, headers); // 201 Created
sekiResponse.end();
};
client.sendTurtle(config.uriBase+"/users", turtle, callback) ;


}
);
return;
Expand Down
93 changes: 45 additions & 48 deletions www/admin/register.html
Expand Up @@ -8,76 +8,73 @@
<link rel="stylesheet" href="../css/seki-general.css" />
<script src="../js/underscore-min.js"></script>
<script src="../js/jquery/jquery-1.10.2.js"></script>
<script src="../js/backbone-min.js"></script>
<script src="../js/backbone.js"></script>
<script src="../js/backbone-forms.js"></script>
</head>
<body>
<div id="formContainer">

<!-- script src="js/jquery/jquery-ui-1.10.3.custom.min.js"></script>
<script src="js/jquery/ui/minified/jquery.ui.dialog.min.js"></script -->

<!-- script src="../js/register.js"></script -->

<!-- script src="../create/deps/vie-min.js"></script -->
<!-- script src="../js/jquery.rdfquery.min.js"></script -->

<script src="../js/backbone-forms.min.js"></script>

<script src="../js/backbone-forms-list.min.js"></script>
</div>


<!--script src="../js/vie-widgets.js"></script -->

<script>
<script>
jQuery(document).ready(function() {
var User = Backbone.Model.extend({
url: "/users/register",
schema: {
login: 'Text',
name: 'Text',
fullname: 'Text',
email: 'Text',
password: 'Password',
profile: 'FOAF'
profile: 'Text'
},
data: {
login: 'danja',
name: 'Danny',
fullname: 'Text',
email: 'Text',
password: 'Password',
profile: 'Text'
}
});

// { validators: ['required', 'email'] }

var user = new User();

var context = {
"login": "http://purl.org/stuff/usermanagement#login",
"password": "http://purl.org/stuff/usermanagement#password",
"fullname": "http://purl.org/stuff/usermanagement#fullname",
"email": "http://purl.org/stuff/usermanagement#email",
"profile": "http://purl.org/stuff/usermanagement#profile"
};



var form = new Backbone.Form({
url: '/users/register',
model: user
}).render();

$('#formholder').append(form.el);

$('#formContainer').append(form.el);

$('#formContainer').append("<input id='submit' type='submit' value='Register' name='submit' />");


$('#submit').click(function() {

form.commit();
user.set('@context',context);
user.set('@id', "http://hyperdata.org/users/"+user.get("login"));
user.set('@type', "http://purl.org/stuff/usermanagement#User");
console.log(user);
user.save();
});

});

</script>

</head>
<body>
<div class="example">
<div id="formholder" class="well"></div>
</div>
<br/>
<!--
<div id="new-user">
<h2>Register</h2>
<form id="register" action="/users/register" method="post">
<br/> Login
<input id="login" name="login" value="danny"/>
<br/> Full Name
<input id="fullname" name="fullname" value="Danny Ayers" />
<br/> email
<input id="email" name="email" value="danny.ayers@gmail.com"/>
<br/> password
<input id="password" name="password" value="sasha" />
<br/> password
<input id="passwordconfirm" name="passwordconfirm" value="sasha" />
<br/> FOAF Profile
<input id="profile" name="profile" value="http://dannyayers.com/foaf.rdf" />
<br/>
- input id="context" name="context" class="hidden" value="this is the context" / -
<input type="submit" value="Post"/>
</form>
</div>
-->
<div id="context">this is the context</div>
</body>
</html>
1 change: 0 additions & 1 deletion www/js/backbone-forms-list.min.js

This file was deleted.

0 comments on commit f21aff8

Please sign in to comment.