Skip to content

Commit

Permalink
Fix bugs in ACL control. New rdf. New chat pane.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Berners-Lee committed Mar 22, 2016
1 parent 68eb73b commit 8538594
Show file tree
Hide file tree
Showing 10 changed files with 591 additions and 426 deletions.
4 changes: 3 additions & 1 deletion js/init/panes.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ tabulator.loadScript("js/panes/argument/argumentPane.js"); // A posistion in an

tabulator.loadScript("js/panes/transaction/pane.js");
tabulator.loadScript("js/panes/transaction/period.js");
tabulator.loadScript("js/panes/chat/chatPane.js");


tabulator.loadScript("js/panes/trip/tripPane.js");
tabulator.loadScript("js/panes/airPane.js");
Expand All @@ -84,14 +86,14 @@ tabulator.loadScript("js/panes/imagePane.js"); // Basic image view


tabulator.loadScript("js/panes/classInstancePane.js"); // Should be above dataContentPane
tabulator.loadScript("js/panes/dynamic/dynamicPanes.js"); // warp etc
tabulator.loadScript("js/panes/slideshow/slideshowPane.js");

tabulator.loadScript("js/panes/humanReadablePane.js"); // A web page as a web page -- how to escape to tabr?
tabulator.loadScript("js/panes/dataContentPane.js"); // Prefered for a data file
tabulator.loadScript("js/panes/n3Pane.js");
tabulator.loadScript("js/panes/RDFXMLPane.js");

tabulator.loadScript("js/panes/dynamic/dynamicPanes.js"); // warp etc

// User configured:
tabulator.loadScript("js/panes/form/pane.js");
Expand Down
744 changes: 434 additions & 310 deletions js/mashup/mashlib-alpha.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion js/panes/classInstancePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
**
** This outline pane lists the members of a class
*/

tabulator.panes.register( {

icon: tabulator.Icon.src.icon_instances,

name: 'classInstance', // @@ 'folder'
name: 'classInstance',

label: function(subject) {
var n = tabulator.kb.each(
Expand Down
69 changes: 51 additions & 18 deletions js/panes/common/acl-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ tabulator.panes.utils.personTR = function(dom, pred, obj, options) {

var agent = obj;
var image = td1.appendChild(dom.createElement('img'));
td1.setAttribute('style','width:4em; padding:0.5em; height: 4em;')
td2.setAttribute('style', 'text-align:left;')
td3.setAttribute('style','width:2em; padding:0.5em; height: 4em;')
image.setAttribute('style', 'width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;')
tabulator.panes.utils.setImage(image, agent);

tabulator.panes.utils.setName(td2, agent);
if (options.deleteFunction){
tabulator.panes.utils.deleteButtonWithCheck(dom, td3, 'person', options.deleteFunction);
Expand Down Expand Up @@ -171,6 +175,29 @@ tabulator.panes.utils.ACLControlBox = function(subject, dom, noun, callback) {
}
}

//
var agentTriage = function(uri) {
var ns = tabulator.ns, kb = tabulator.kb, obj = $rdf.sym(uri);
var obj = $rdf.sym(uri)
var types = kb.findTypeURIs(obj);
console.log('Drop object types: ' + types)
if (ns.vcard('WebID').uri in types) return {pred: 'agent', obj: obj}
if (ns.vcard('Individual').uri in types || ns.foaf('Person').uri in types || ns.foaf('Agent').uri in types) {
var pref = kb.any(obj, ns.foaf('preferredURI'))
if (pref) return { pred: 'agent', obj: $rdf.sym(pref)}
return { pred: 'agent', obj: obj}
}
if (ns.vcard('Group').uri in types) {
return { pred: 'agentClass', obj: obj} // @@ note vcard membership not RDFs
}
if (ns.solid('AppProvider').uri in types) {
return { pred: 'origin', obj: obj}
}
if (ns.solid('AppProviderClass').uri in types) {
return { pred: 'originClass', obj: obj}
}
}

box.saveBack = function(callback){
var kb2 = $rdf.graph()
if (!box.isContainer) {
Expand Down Expand Up @@ -201,7 +228,7 @@ tabulator.panes.utils.ACLControlBox = function(subject, dom, noun, callback) {
var row = box.appendChild(dom.createElement('tr'));
row.combo = combo;
row.setAttribute('style', 'color: '
+ (kToColor[k] || 'black') + ';')
+ (options.modify ? (kToColor[k] || 'black'): '#888') + ';')

var left = row.appendChild(dom.createElement('td'));

Expand All @@ -221,27 +248,28 @@ tabulator.panes.utils.ACLControlBox = function(subject, dom, noun, callback) {
middleTable.removeChild(middleTable.NoneTR);
delete middleTable.NoneTR;
}
var opt = {
deleteFunction: function deletePerson(){
var arr = byCombo[combo];
for (var b=0; b < arr.length; b++) {
if (arr[b][0] === pred && arr[b][1] === obj ) {
arr.splice(b, 1); // remove from ACL
break;
}
};
// @@@ save byCombo back to ACLDoc
middleTable.removeChild(tr);
var opt = {}
if (options.modify) {
opt.deleteFunction = function deletePerson(){
var arr = byCombo[combo];
for (var b=0; b < arr.length; b++) {
if (arr[b][0] === pred && arr[b][1] === obj ) {
arr.splice(b, 1); // remove from ACL
break;
}
};
box.saveBack(function(ok){
if (ok) {
middleTable.removeChild(tr);
} // @@ else?
});
}
}
var tr = middleTable.appendChild(
tabulator.panes.utils.personTR(
dom, $rdf.sym(pred), $rdf.sym(obj), opt));
};




var syncCombo = function(combo) {
var arr = byCombo[combo];
if (arr && arr.length) {
Expand Down Expand Up @@ -334,13 +362,17 @@ tabulator.panes.utils.ACLControlBox = function(subject, dom, noun, callback) {
console.log("Dropped URI list (2): " + uris);
if (uris) {
uris.map(function(u){
var res = agentTriage(u); // eg 'agent', 'origin', agentClass'
if (!res) {
console.log("Error: Drop fails to drop appropriate thing! " + u)
return;
}
if (!(combo in byCombo)) {
byCombo[combo] = [];
}
// @@@ Find out - person or group? - if group, use agentClass
removeAgentFromCombos(u); // Combos are mutually distinct
byCombo[combo].push(['agent', u]);
console.log('setting access by ' + u + ' to ' + subject)
byCombo[combo].push([res.pred, res.obj.uri]);
console.log('ACL: setting access to ' + subject + ' by ' + res.pred + ': ' + res.obj)
box.saveBack(function(ok){
if (ok) {
thisEle.style.backgroundColor = 'white'; // restore look to before drag
Expand Down Expand Up @@ -493,6 +525,7 @@ tabulator.panes.utils.ACLControlBox = function(subject, dom, noun, callback) {
box.mainByCombo = ACLControlEditable(box, targetDoc, targetACLDoc, kb, {modify: true}); // yes can edit
box.divider = box.appendChild(dom.createElement('tr'))
box.notice = box.divider.appendChild(dom.createElement('td'))
box.notice.style = 'font-size: 80%; color: #888;'
box.offer = box.divider.appendChild(dom.createElement('td'))
box.notice.setAttribute('colspan', '2');

Expand Down
86 changes: 41 additions & 45 deletions js/panes/common/discussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
var WF = $rdf.Namespace('http://www.w3.org/2005/01/wf/flow#');
var DC = $rdf.Namespace('http://purl.org/dc/elements/1.1/');
var DCT = $rdf.Namespace('http://purl.org/dc/terms/');

options = options || {};

var newestFirst = !!options.newestFirst;

var messageBodyStyle = 'width: 90%; font-size:100%; \
background-color: white; border: 0.07em solid gray; padding: 0.15em; margin: 0.1em 1em 0.1em 1em'
// 'font-size: 100%; margin: 0.1em 1em 0.1em 1em; background-color: white; white-space: pre-wrap; padding: 0.1em;'

var div = dom.createElement("div")
var messageTable; // Shared by initial build and addMessageFromBindings

var me_uri = tabulator.preferences.get('me');
var me = me_uri? kb.sym(me_uri) : null;

var updater = new tabulator.rdf.sparqlUpdate(kb);
var updater = tabulator.updater || tabulator.updater || new tabulator.rdf.sparqlUpdate(kb);

var anchor = function(text, term) {
var a = dom.createElement('a');
Expand All @@ -39,15 +39,15 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
div.appendChild(pre);
pre.appendChild(dom.createTextNode(message));
return pre
}
}

var console = {
log: function(message) {mention(message, 'color: #111;')},
warn: function(message) {mention(message, 'color: #880;')},
error: function(message) {mention(message, 'color: #800;')}
};


// Form for a new message
//
var newMessageForm = function() {
Expand All @@ -59,14 +59,14 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
form.appendChild(middle);
form.appendChild(rhs);
form.AJAR_date = "9999-01-01T00:00:00Z"; // ISO format for field sort

var sendMessage = function() {
// titlefield.setAttribute('class','pendingedit');
// titlefield.disabled = true;
field.setAttribute('class','pendingedit');
field.disabled = true;
sts = [];

var now = new Date();
var timestamp = ''+ now.getTime();
var dateStamp = $rdf.term(now);
Expand All @@ -88,7 +88,7 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
'?date': dateStamp,
'?creator': me};
addMessageFromBindings(bindings);

field.value = ''; // clear from out for reuse
field.setAttribute('class','');
field.disabled = false;
Expand All @@ -115,15 +115,15 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt

return form;
};

var nick = function(person) {
var s = tabulator.kb.any(person, tabulator.ns.foaf('nick'));
if (s) return ''+s.value
return ''+tabulator.Util.label(person);
}

/////////////////////////////////////////////////////////////////////////

var syncMessages = function(about, messageTable) {
var displayed = {};
for (var ele = messageTable.firstChild; ele ;ele = ele.nextSibling) {
Expand Down Expand Up @@ -152,9 +152,9 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
}

var addMessageFromBindings = function(bindings) {
return addMessage(bindings['?msg']);
return addMessage(bindings['?msg']);
}

var deleteMessage = function(message) {
deletions = kb.statementsMatching(message).concat(
kb.statementsMatching(undefined, undefined, message));
Expand All @@ -166,7 +166,7 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
};
});
};

var addMessage = function(message) {
var tr = dom.createElement('tr');
var date = kb.any(message, DCT('created'));
Expand All @@ -189,32 +189,32 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
if (!done) {
messageTable.appendChild(tr);
}

var td1 = dom.createElement('td');
tr.appendChild(td1);

var creator = kb.any(message, ns.foaf('maker'));
var nickAnchor = td1.appendChild(anchor(nick(creator), creator));
tabulator.fetcher.nowOrWhenFetched($rdf.uri.docpart(creator.uri), undefined, function(ok, body){
nickAnchor.textContent = nick(creator);
});
td1.appendChild(dom.createElement('br'));
td1.appendChild(anchor(tabulator.panes.utils.shortDate(dateString), message));

var td2 = dom.createElement('td');
tr.appendChild(td2);
var pre = dom.createElement('p')
var pre = dom.createElement('p')
pre.setAttribute('style', messageBodyStyle)
td2.appendChild(pre);
pre.textContent = kb.any(message, ns.sioc('content')).value;
pre.textContent = kb.any(message, ns.sioc('content')).value;

var td3 = dom.createElement('td');
tr.appendChild(td3);

var delButton = dom.createElement('button');
td3.appendChild(delButton);
delButton.textContent = "-";

tr.setAttribute('class', 'hoverControl'); // See tabbedtab.css (sigh global CSS)
delButton.setAttribute('class', 'hoverControlHide');
delButton.setAttribute('style', 'color: red;');
Expand All @@ -232,7 +232,7 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
td3.appendChild(sureButton).addEventListener('click', function(e) {
td3.removeChild(sureButton);
td3.removeChild(cancelButton);
deleteMessage(message);
deleteMessage(message);
}, false);
}, false);
};
Expand All @@ -252,23 +252,22 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
messageTable.appendChild(tr); // not newestFirst
}
};
var msg = kb.any(subject, WF('message'));

var query, msg = kb.any(subject, WF('message'));
if (msg != undefined) {
var str = ''
// Do this with a live query to pull in messages from web
var query = new $rdf.Query('Messages');
var v = {};
['msg', 'title', 'date', 'creator', 'content'].map(function(x){
query.vars.push(v[x]=$rdf.variable(x))});
query.pat.add(subject, WF('message'), v['msg']);
// query.pat.add(v['msg'], ns.dc('title'), v['title']);
query.pat.add(v['msg'], ns.dct('created'), v['date']);
query.pat.add(v['msg'], ns.foaf('maker'), v['creator']);
query.pat.add(v['msg'], ns.sioc('content'), v['content']);
var esc = tabulator.Util.escapeForXML;
// dump("\nquery.pat = "+query.pat+"\n");

if (options.query){
query = options.query
} else {
query = new $rdf.Query('Messages');
var v = {};
['msg', 'date', 'creator', 'content'].map(function(x){
query.vars.push(v[x]=$rdf.variable(x))});
query.pat.add(subject, WF('message'), v['msg']);
query.pat.add(v['msg'], ns.dct('created'), v['date']);
query.pat.add(v['msg'], ns.foaf('maker'), v['creator']);
query.pat.add(v['msg'], ns.sioc('content'), v['content']);
}
kb.query(query, addMessageFromBindings);
}
/*
Expand All @@ -285,14 +284,11 @@ tabulator.panes.utils.messageArea = function(dom, kb, subject, messageStore, opt
});
}, false);
div.appendChild(refreshButton);
*/
*/
div.refresh = function() {
syncMessages(subject, messageTable);
};


return div;
};



1 change: 1 addition & 0 deletions js/panes/common/icons/noun_15177.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8538594

Please sign in to comment.