Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lcnetdev/bfe
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkhess committed May 24, 2019
2 parents 36b64fe + 1e937ef commit 29ef9a4
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 201 deletions.
336 changes: 186 additions & 150 deletions src/bfe.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/bfeapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ exports.publish = function (data, rdfxml, savename, bfelog, callback){
document.body.scrollTop = document.documentElement.scrollTop = 0;
bfelog.addMsg(new Error(), "INFO", "Published " + publishdata[0].name);
var $messagediv = $('<div>', {id: "bfeditor-messagediv",class: 'alert alert-info' });
$messagediv.append('<strong>Description submitted for posting:</strong><a href=' + config.basedbURI + "/" + publishdata[0].objid+'>'+publishdata[0].lccn+'</a>');
var displayText = publishdata[0].lccn !== undefined ? publishdata[0].lccn : publishdata[0].objid;
$messagediv.append('<strong>Description submitted for posting:</strong><a href=' + config.basedbURI + "/" + publishdata[0].objid+'>'+displayText+'</a>');
$('#bfeditor-formdiv').empty();
$('#save-btn').remove();
$messagediv.insertBefore('.nav-tabs');
Expand Down
100 changes: 53 additions & 47 deletions src/bfestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ bfe.define('src/bfestore', ['require', 'exports'], function (require, exports) {
adminTriple.s = bnode;
adminTriple.p = 'http://id.loc.gov/ontologies/bibframe/creationDate';
var d = new Date(bfeditor.bfestore.created);
adminTriple.o = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
adminTriple.o = d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2);
adminTriple.otype = 'literal';
bfeditor.bfestore.store.push(adminTriple);

adminTriple = {};
adminTriple.s = bnode;
adminTriple.p = 'http://id.loc.gov/ontologies/bibframe/changeDate';
var modifiedDate = new Date().toUTCString();
adminTriple.o = new Date(modifiedDate).toJSON().split(/\./)[0];
adminTriple.otype = 'literal';
bfeditor.bfestore.store.push(adminTriple);

Expand Down Expand Up @@ -184,7 +192,7 @@ bfe.define('src/bfestore', ['require', 'exports'], function (require, exports) {
adminTriple.guid = shortUUID(guid());
adminTriple.s = 'http://id.loc.gov/vocabulary/organizations/dlc';
adminTriple.p = 'http://www.w3.org/2000/01/rdf-schema#label';
adminTriple.o = 'DLC';
adminTriple.o = 'dlc';
adminTriple.otype = 'literal';
bfeditor.bfestore.store.push(adminTriple);

Expand Down Expand Up @@ -265,53 +273,51 @@ bfe.define('src/bfestore', ['require', 'exports'], function (require, exports) {
return exports.store;
};

exports.store2rdfxml = function (jsonld, callback) {
exports.store2jsonldnormalized(jsonld, function (expanded) {
jsonld.toRDF(expanded, {
format: 'application/nquads'
}, function (err, nquads) {
//json2turtle(nquads, callback);
var parser = N3.Parser();
var turtlestore = N3.Store();
parser.parse(nquads, function (error, triple, theprefixes) {
if (triple) {
turtlestore.addTriple(triple);
} else {
turtlestore.addPrefixes(theprefixes);
var turtleWriter = N3.Writer({
prefixes: {
bf: 'http://id.loc.gov/ontologies/bibframe/',
bflc: 'http://id.loc.gov/ontologies/bflc/',
madsrdf: "http://www.loc.gov/mads/rdf/v1#",
pmo: 'http://performedmusicontology.org/ontology/',
rdf: "http://www.w3.org/1999/02/22-rdf-sydntax-ns#",
rdfs: "http://www.w3.org/2000/01/rdf-schema#",
xsd: "http://www.w3.org/2001/XMLSchema#",
datatypes: "http://id.loc.gov/datatypes/",
lclocal: "http://id.loc.gov/ontologies/lclocal/"
exports.store2rdfxml = function (expanded, callback) {
jsonld.toRDF(expanded, {
format: 'application/nquads'
}, function (err, nquads) {
//json2turtle(nquads, callback);
var parser = N3.Parser();
var turtlestore = N3.Store();
parser.parse(nquads, function (error, triple, theprefixes) {
if (triple) {
turtlestore.addTriple(triple);
} else {
turtlestore.addPrefixes(theprefixes);
var turtleWriter = N3.Writer({
prefixes: {
bf: 'http://id.loc.gov/ontologies/bibframe/',
bflc: 'http://id.loc.gov/ontologies/bflc/',
madsrdf: "http://www.loc.gov/mads/rdf/v1#",
pmo: 'http://performedmusicontology.org/ontology/',
rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
rdfs: "http://www.w3.org/2000/01/rdf-schema#",
xsd: "http://www.w3.org/2001/XMLSchema#",
datatypes: "http://id.loc.gov/datatypes/",
lclocal: "http://id.loc.gov/ontologies/lclocal/"
}
});
turtleWriter.addTriples(turtlestore.getTriples(null, null, null));
turtleWriter.end(function (error, result) {
var input = {};
input.n3 = result;
$.ajax({
url: config.url + "/profile-edit/server/n3/rdfxml",
type: "POST",
data: JSON.stringify(input),
processData: false,
contentType: "application/json",
success: function (rdfxml) {
var data = new XMLSerializer().serializeToString(rdfxml);
callback(data);
},
error: function (XMLHttpRequest, status, err) {
bfeditor.bfelog.addMsg(new Error(), 'ERROR', err);
}
});
turtleWriter.addTriples(turtlestore.getTriples(null, null, null));
turtleWriter.end(function (error, result) {
var input = {};
input.n3 = result;
$.ajax({
url: config.url + "/profile-edit/server/n3/rdfxml",
type: "POST",
data: JSON.stringify(input),
processData: false,
contentType: "application/json",
success: function (rdfxml) {
var data = new XMLSerializer().serializeToString(rdfxml);
$("#rdfxml .panel-body pre").text(data);
},
error: function (XMLHttpRequest, status, err) {
bfeditor.bfelog.addMsg(new Error(), 'ERROR', err);
}
});
});
}
});
});
}
});
});
callback;
Expand Down
2 changes: 1 addition & 1 deletion static/js/config-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var config = {
"basedbURI": baseDBURI,
"resourceURI": resourceURI,
"buildContext": buildcontext,
"buildContextFor": ['id.loc.gov/authorities/names/','id.loc.gov/authorities/subjects/','id.loc.gov/vocabulary/relators/','id.loc.gov/resources/works/', 'id.loc.gov/bfentities/providers/','id.loc.gov/entities/providers/','id.loc.gov/authorities/genreForms'],
"buildContextFor": ['id.loc.gov/authorities/names/','id.loc.gov/authorities/subjects/','http://id.loc.gov/authorities/childrensSubjects','id.loc.gov/vocabulary/relators/','id.loc.gov/resources/works/', 'id.loc.gov/bfentities/providers/','id.loc.gov/entities/providers/','id.loc.gov/authorities/genreForms'],
"buildContextForWorksEndpoint": workContext,
"enableUserTemplates" :enableusertemplates,
"enableLoadMarc": loadmarc,
Expand Down
2 changes: 1 addition & 1 deletion static/js/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var config = {
"basedbURI": baseDBURI,
"resourceURI": resourceURI,
"buildContext": buildcontext,
"buildContextFor": ['id.loc.gov/authorities/names/','id.loc.gov/authorities/subjects/','id.loc.gov/vocabulary/relators/','id.loc.gov/resources/works/', 'id.loc.gov/bfentities/providers/','id.loc.gov/entities/providers/','id.loc.gov/authorities/genreForms'],
"buildContextFor": ['id.loc.gov/authorities/names/','id.loc.gov/authorities/subjects/','http://id.loc.gov/authorities/childrensSubjects','id.loc.gov/vocabulary/relators/','id.loc.gov/resources/works/', 'id.loc.gov/bfentities/providers/','id.loc.gov/entities/providers/','id.loc.gov/authorities/genreForms'],
"buildContextForWorksEndpoint": workContext,
"enableUserTemplates" :enableusertemplates,
"enableLoadMarc": loadmarc,
Expand Down
2 changes: 1 addition & 1 deletion static/js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var config = {
"basedbURI": baseDBURI,
"resourceURI": resourceURI,
"buildContext": buildcontext,
"buildContextFor": ['id.loc.gov/authorities/names/','id.loc.gov/authorities/subjects/','id.loc.gov/vocabulary/relators/','id.loc.gov/resources/works/', 'id.loc.gov/bfentities/providers/','id.loc.gov/entities/providers/','id.loc.gov/authorities/genreForms'],
"buildContextFor": ['id.loc.gov/authorities/names/','id.loc.gov/authorities/subjects/','http://id.loc.gov/authorities/childrensSubjects','id.loc.gov/vocabulary/relators/','id.loc.gov/resources/works/', 'id.loc.gov/bfentities/providers/','id.loc.gov/entities/providers/','id.loc.gov/authorities/genreForms'],
"buildContextForWorksEndpoint": workContext,
"enableUserTemplates" :enableusertemplates,
"enableLoadMarc": loadmarc,
Expand Down

0 comments on commit 29ef9a4

Please sign in to comment.