Skip to content

Commit

Permalink
updated scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ali1k committed Oct 25, 2018
1 parent 84b17ff commit c6cdef4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 65 deletions.
29 changes: 8 additions & 21 deletions decksToRDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,17 @@ function convertToRDF(obj) {
//print turtle
let id = obj[idField];
console.log('#######'+id+'#########');
console.log(`
swR:${id} a swV:Deck .
`);
console.log(`swR:${id} a swV:Deck .`);
for(let prop in obj){
if(selected.indexOf(prop) !== -1){
//custom properties
if(prop === 'user'){
console.log(`
swR:${id} prv:createdBy swUserR:${obj[prop]} .
`);
console.log(`swR:${id} prv:createdBy swUserR:${obj[prop]} .`);
continue;
}
if(prop === 'contributors'){
obj[prop].forEach((item)=>{
console.log(`
swR:${id} swV:hasContibutor swUserR:${item.user} .
`);
console.log(`swR:${id} swV:hasContibutor swUserR:${item.user} .`);
});
continue;
}
Expand All @@ -73,13 +67,10 @@ swR:${id}-${item.id} a swV:DeckRevision ;
swV:abstract """${item.abstract ? encodeURIComponent(item.abstract) : '-'}""" ;
swV:theme """${item.theme}""" ;
swV:allowMarkdown """${item.allowMarkdown}""" ;
prv:createdBy swUserR:${item.user} .
`);
prv:createdBy swUserR:${item.user} .`);
if(item.tags.length){
item.tags.forEach((tag)=>{
console.log(`
swR:${id}-${item.id} swV:hasTag swTagR:${tag.id} .
`);
console.log(`swR:${id}-${item.id} swV:hasTag swTagR:${tag.id} .`);
});
}
item.contentItems.forEach((content)=>{
Expand All @@ -89,26 +80,22 @@ swR:${id}-${item.id} swV:hasContentItem <https://slidewiki.org/deck/${id}-${item
<https://slidewiki.org/deck/${id}-${item.id}/${content.kind}/${content.ref.id}-${content.ref.revision}> a swV:SlideRevisionUsedInDeck ;
swV:isRevisedFrom swSlideR:${content.ref.id} ;
swV:isEqualTo swSlideR:${content.ref.id}-${content.ref.revision} ;
swV:order """${content.order}""" .
`);
swV:order """${content.order}""" .`);
}else{
console.log(`
swR:${id}-${item.id} swV:hasContentItem <https://slidewiki.org/deck/${id}-${item.id}/${content.kind}/${content.ref.id}-${content.ref.revision}> .
<https://slidewiki.org/deck/${id}-${item.id}/${content.kind}/${content.ref.id}-${content.ref.revision}> a swV:DeckRevisionUsedInDeck ;
swV:isRevisedFrom swR:${content.ref.id} ;
swV:isEqualTo swR:${content.ref.id}-${content.ref.revision} ;
swV:order """${content.order}""" .
`);
swV:order """${content.order}""" .`);
}

});

});
continue;
}
console.log(`
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .
`);
console.log(`swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .`);
}
}
}
15 changes: 4 additions & 11 deletions slidesToRDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ swR:${id} a swV:Slide .
if(selected.indexOf(prop) !== -1){
//custom properties
if(prop === 'user'){
console.log(`
swR:${id} prv:createdBy swUserR:${obj[prop]} .
`);
console.log(`swR:${id} prv:createdBy swUserR:${obj[prop]} .`);
continue;
}
if(prop === 'contributors'){
obj[prop].forEach((item)=>{
console.log(`
swR:${id} swV:hasContibutor swUserR:${item.user} .
`);
console.log(`swR:${id} swV:hasContibutor swUserR:${item.user} .`);
});
continue;
}
Expand All @@ -67,15 +63,12 @@ swR:${id}-${item.id} a swV:SlideRevision ;
swV:timestamp """${item.timestamp}""" ;
swV:content """${encodeURIComponent(item.content)}""" ;
swV:speakernotes """${item.speakernotes ? item.speakernotes : '-'}""" ;
prv:createdBy swUserR:${item.user} .
`);
prv:createdBy swUserR:${item.user} .`);

});
continue;
}
console.log(`
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .
`);
console.log(`swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .`);
}
}
}
12 changes: 3 additions & 9 deletions tagsToRDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,15 @@ function convertToRDF(obj) {
//print turtle
let id = obj[idField];
console.log('#######'+id+'#########');
console.log(`
swR:${id} a swV:Tag .
`);
console.log(`swR:${id} a swV:Tag .`);
for(let prop in obj){
if(selected.indexOf(prop) !== -1){
//custom properties
if(prop === 'user'){
console.log(`
swR:${id} prv:createdBy swUserR:${obj[prop]} .
`);
console.log(`swR:${id} prv:createdBy swUserR:${obj[prop]} .`);
continue;
}
console.log(`
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .
`);
console.log(`swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .`);
}
}
}
16 changes: 4 additions & 12 deletions usergroupsToRDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,21 @@ const idField = '_id';
function convertToRDF(obj) {
//print turtle
let id = obj[idField];
console.log(`
swR:${id} a swV:UserGroup .
`);
console.log(`swR:${id} a swV:UserGroup .`);
for(let prop in obj){
if(selected.indexOf(prop) !== -1){
if(prop === 'creator'){
console.log(`
swR:${id} prv:createdBy swUserR:${obj[prop].userid} .
`);
console.log(`swR:${id} prv:createdBy swUserR:${obj[prop].userid} .`);
continue;
}
if(prop === 'members'){
obj[prop].forEach((item)=>{
console.log(`
swR:${id} swV:hasMember swUserR:${item.userid} .
`);
console.log(`swR:${id} swV:hasMember swUserR:${item.userid} .`);
});
continue;
}

console.log(`
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .
`);
console.log(`swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .`);
}
}
console.log('################');
Expand Down
14 changes: 2 additions & 12 deletions usersToRDF.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,10 @@ const mappings ={
function convertToRDF(obj) {
//print turtle
let id = obj[idField];
console.log(`
swR:${id} a swV:User .
`);
console.log(`swR:${id} a swV:User .`);
for(let prop in obj){
if(selected.indexOf(prop) !== -1){
if(prop === 'picture'){
console.log(`
swR:${id} swV:picture <${obj[prop]}> .
`);
continue;
}
console.log(`
swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .
`);
console.log(`swR:${id} swV:${prop} """${obj[prop] ? obj[prop] : '-'}""" .`);
}
}
console.log('################');
Expand Down

0 comments on commit c6cdef4

Please sign in to comment.