Skip to content

Commit 29ef9a4

Browse files
committed
Merge branch 'master' of github.com:lcnetdev/bfe
2 parents 36b64fe + 1e937ef commit 29ef9a4

File tree

6 files changed

+244
-201
lines changed

6 files changed

+244
-201
lines changed

src/bfe.js

Lines changed: 186 additions & 150 deletions
Large diffs are not rendered by default.

src/bfeapi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ exports.publish = function (data, rdfxml, savename, bfelog, callback){
125125
document.body.scrollTop = document.documentElement.scrollTop = 0;
126126
bfelog.addMsg(new Error(), "INFO", "Published " + publishdata[0].name);
127127
var $messagediv = $('<div>', {id: "bfeditor-messagediv",class: 'alert alert-info' });
128-
$messagediv.append('<strong>Description submitted for posting:</strong><a href=' + config.basedbURI + "/" + publishdata[0].objid+'>'+publishdata[0].lccn+'</a>');
128+
var displayText = publishdata[0].lccn !== undefined ? publishdata[0].lccn : publishdata[0].objid;
129+
$messagediv.append('<strong>Description submitted for posting:</strong><a href=' + config.basedbURI + "/" + publishdata[0].objid+'>'+displayText+'</a>');
129130
$('#bfeditor-formdiv').empty();
130131
$('#save-btn').remove();
131132
$messagediv.insertBefore('.nav-tabs');

src/bfestore.js

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ bfe.define('src/bfestore', ['require', 'exports'], function (require, exports) {
8888
adminTriple.s = bnode;
8989
adminTriple.p = 'http://id.loc.gov/ontologies/bibframe/creationDate';
9090
var d = new Date(bfeditor.bfestore.created);
91-
adminTriple.o = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
91+
adminTriple.o = d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2);
92+
adminTriple.otype = 'literal';
93+
bfeditor.bfestore.store.push(adminTriple);
94+
95+
adminTriple = {};
96+
adminTriple.s = bnode;
97+
adminTriple.p = 'http://id.loc.gov/ontologies/bibframe/changeDate';
98+
var modifiedDate = new Date().toUTCString();
99+
adminTriple.o = new Date(modifiedDate).toJSON().split(/\./)[0];
92100
adminTriple.otype = 'literal';
93101
bfeditor.bfestore.store.push(adminTriple);
94102

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

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

268-
exports.store2rdfxml = function (jsonld, callback) {
269-
exports.store2jsonldnormalized(jsonld, function (expanded) {
270-
jsonld.toRDF(expanded, {
271-
format: 'application/nquads'
272-
}, function (err, nquads) {
273-
//json2turtle(nquads, callback);
274-
var parser = N3.Parser();
275-
var turtlestore = N3.Store();
276-
parser.parse(nquads, function (error, triple, theprefixes) {
277-
if (triple) {
278-
turtlestore.addTriple(triple);
279-
} else {
280-
turtlestore.addPrefixes(theprefixes);
281-
var turtleWriter = N3.Writer({
282-
prefixes: {
283-
bf: 'http://id.loc.gov/ontologies/bibframe/',
284-
bflc: 'http://id.loc.gov/ontologies/bflc/',
285-
madsrdf: "http://www.loc.gov/mads/rdf/v1#",
286-
pmo: 'http://performedmusicontology.org/ontology/',
287-
rdf: "http://www.w3.org/1999/02/22-rdf-sydntax-ns#",
288-
rdfs: "http://www.w3.org/2000/01/rdf-schema#",
289-
xsd: "http://www.w3.org/2001/XMLSchema#",
290-
datatypes: "http://id.loc.gov/datatypes/",
291-
lclocal: "http://id.loc.gov/ontologies/lclocal/"
276+
exports.store2rdfxml = function (expanded, callback) {
277+
jsonld.toRDF(expanded, {
278+
format: 'application/nquads'
279+
}, function (err, nquads) {
280+
//json2turtle(nquads, callback);
281+
var parser = N3.Parser();
282+
var turtlestore = N3.Store();
283+
parser.parse(nquads, function (error, triple, theprefixes) {
284+
if (triple) {
285+
turtlestore.addTriple(triple);
286+
} else {
287+
turtlestore.addPrefixes(theprefixes);
288+
var turtleWriter = N3.Writer({
289+
prefixes: {
290+
bf: 'http://id.loc.gov/ontologies/bibframe/',
291+
bflc: 'http://id.loc.gov/ontologies/bflc/',
292+
madsrdf: "http://www.loc.gov/mads/rdf/v1#",
293+
pmo: 'http://performedmusicontology.org/ontology/',
294+
rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
295+
rdfs: "http://www.w3.org/2000/01/rdf-schema#",
296+
xsd: "http://www.w3.org/2001/XMLSchema#",
297+
datatypes: "http://id.loc.gov/datatypes/",
298+
lclocal: "http://id.loc.gov/ontologies/lclocal/"
299+
}
300+
});
301+
turtleWriter.addTriples(turtlestore.getTriples(null, null, null));
302+
turtleWriter.end(function (error, result) {
303+
var input = {};
304+
input.n3 = result;
305+
$.ajax({
306+
url: config.url + "/profile-edit/server/n3/rdfxml",
307+
type: "POST",
308+
data: JSON.stringify(input),
309+
processData: false,
310+
contentType: "application/json",
311+
success: function (rdfxml) {
312+
var data = new XMLSerializer().serializeToString(rdfxml);
313+
callback(data);
314+
},
315+
error: function (XMLHttpRequest, status, err) {
316+
bfeditor.bfelog.addMsg(new Error(), 'ERROR', err);
292317
}
293318
});
294-
turtleWriter.addTriples(turtlestore.getTriples(null, null, null));
295-
turtleWriter.end(function (error, result) {
296-
var input = {};
297-
input.n3 = result;
298-
$.ajax({
299-
url: config.url + "/profile-edit/server/n3/rdfxml",
300-
type: "POST",
301-
data: JSON.stringify(input),
302-
processData: false,
303-
contentType: "application/json",
304-
success: function (rdfxml) {
305-
var data = new XMLSerializer().serializeToString(rdfxml);
306-
$("#rdfxml .panel-body pre").text(data);
307-
},
308-
error: function (XMLHttpRequest, status, err) {
309-
bfeditor.bfelog.addMsg(new Error(), 'ERROR', err);
310-
}
311-
});
312-
});
313-
}
314-
});
319+
});
320+
}
315321
});
316322
});
317323
callback;

static/js/config-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var config = {
5555
"basedbURI": baseDBURI,
5656
"resourceURI": resourceURI,
5757
"buildContext": buildcontext,
58-
"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'],
58+
"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'],
5959
"buildContextForWorksEndpoint": workContext,
6060
"enableUserTemplates" :enableusertemplates,
6161
"enableLoadMarc": loadmarc,

static/js/config-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var config = {
5959
"basedbURI": baseDBURI,
6060
"resourceURI": resourceURI,
6161
"buildContext": buildcontext,
62-
"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'],
62+
"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'],
6363
"buildContextForWorksEndpoint": workContext,
6464
"enableUserTemplates" :enableusertemplates,
6565
"enableLoadMarc": loadmarc,

static/js/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var config = {
5555
"basedbURI": baseDBURI,
5656
"resourceURI": resourceURI,
5757
"buildContext": buildcontext,
58-
"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'],
58+
"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'],
5959
"buildContextForWorksEndpoint": workContext,
6060
"enableUserTemplates" :enableusertemplates,
6161
"enableLoadMarc": loadmarc,

0 commit comments

Comments
 (0)