Skip to content

Commit

Permalink
Attach pane basically works, right hand panel (view attached thing) i…
Browse files Browse the repository at this point in the history
…s a bit of a kludge. Re-added the image pane, as the atach pane uses it.
  • Loading branch information
Tim Berners-Lee committed Nov 18, 2012
1 parent 5f7e711 commit b45d4dc
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 25 deletions.
8 changes: 6 additions & 2 deletions js/init/panes.js
Expand Up @@ -46,8 +46,13 @@ tabulator.loadScript("js/panes/paneUtils.js");
tabulator.loadScript("js/panes/issue/pane.js");
tabulator.loadScript("js/panes/transaction/pane.js");
tabulator.loadScript("js/panes/trip/tripPane.js");
tabulator.loadScript("js/panes/dataContentPane.js");
tabulator.loadScript("js/panes/airPane.js");

// Content views

tabulator.loadScript("js/panes/imagePane.js"); // Basic image view

tabulator.loadScript("js/panes/dataContentPane.js"); // Prefered
tabulator.loadScript("js/panes/n3Pane.js");
tabulator.loadScript("js/panes/RDFXMLPane.js");

Expand All @@ -74,7 +79,6 @@ tabulator.loadScript("js/panes/pubsPane.js");

tabulator.loadScript("js/panes/microblogPane/microblogPane.js");

// tabulator.loadScript("js/panes/imagePane.js");

tabulator.loadScript("js/panes/socialPane.js");
//tabulator.loadScript("js/panes/social/pane.js");
Expand Down
90 changes: 76 additions & 14 deletions js/panes/attach/attachPane.js
Expand Up @@ -25,13 +25,22 @@ tabulator.panes.register( {
name: 'attachments',

// Does the subject deserve an issue pane?
//
// In this case we will render any thing which is in any subclass of
// certain classes, or also the certain classes themselves, as a
// triage tool for correlating many attachees with attachments.
// We also offer the pane for anything of any class which just has an attachment already.
//
label: function(subject) {
var kb = tabulator.kb;
var t = kb.findTypeURIs(subject);
if (t['http://www.w3.org/ns/pim/trip#Trip'] ||
var WF = $rdf.Namespace('http://www.w3.org/2005/01/wf/flow#');
if (t['http://www.w3.org/ns/pim/trip#Trip'] || // If in any subclass
subject.uri == 'http://www.w3.org/ns/pim/trip#Trip' ||
t['http://www.w3.org/2005/01/wf/flow#Task'] ||
t['http://www.w3.org/2000/10/swap/pim/qif#Transaction'] ||
subject.uri == 'http://www.w3.org/2000/10/swap/pim/qif#Transaction') return "attachments";
subject.uri == 'http://www.w3.org/2000/10/swap/pim/qif#Transaction' ||
kb.holds(subject, WF('attachment'))) return "attachments";
return null;
},

Expand Down Expand Up @@ -71,16 +80,14 @@ tabulator.panes.register( {

// Where can we write about this thing?
//
// Returns term for document of null
// Returns term for document or null
var findStore = function(kb, subject) {
var docURI = tabulator.rdf.Util.uri.docpart(subject.uri);
if (tabulator.sparql.editable(docURI, kb)) return kb.sym(docURI);
var store = kb.any(kb.sym(docURI), QU('annotationStore'));
// if (!store) complain("No store for "+docURI);
return store;
}





var div = dom.createElement("div");
Expand All @@ -104,7 +111,10 @@ tabulator.panes.register( {
//
var getMembersAndSort = function(subject) {

var sortBy = { 'http://www.w3.org/ns/pim/trip#Trip' : // @@ put this into the ontologies
var sortBy = {
'http://www.w3.org/2005/01/wf/flow#Task' :
'http://purl.org/dc/elements/1.1/created',
'http://www.w3.org/ns/pim/trip#Trip' : // @@ put this into the ontologies
'http://www.w3.org/2002/12/cal/ical#dtstart' ,
'http://www.w3.org/2000/10/swap/pim/qif#Transaction' :
'http://www.w3.org/2000/10/swap/pim/qif#date',
Expand Down Expand Up @@ -249,15 +259,27 @@ tabulator.panes.register( {
}
currentObject = x;
try {
if (x.uri.slice(-4) == ".pdf") { // @@@ KLUDGE! use metadata after HEAD

/*
var table = dom.createElement('table');
tabulator.outline.GotoSubject(x, true, undefined, false, undefined, table)
*/

if (x.uri.slice(-4) == ".pdf" || x.uri.slice(-4) == ".png" ||
x.uri.slice(-5) == ".jpeg") { // @@@ KLUDGE! use metadata after HEAD
preview.innerHTML = '<iframe height="100%" width="100%"src="'
+ x.uri + '">' + x.uri + '</iframe>';
} else {
preview.innerHTML = '<img src="'
+ x.uri + '">';
}
preview.innerHTML = '';
if (x.uri) kb.fetcher.nowOrWhenFetched(x.uri, undefined, function() {
var display = tabulator.outline.propertyTable(x); // ,table, pane
preview.appendChild(display);
});
};


} catch(e) {
preview.innerHTML = '<span color="red">' + "Error:" + '</span>';
preview.innerHTML = '<span style="background-color: pink;">' + "Error:" + e + '</span>'; // @@ enc
}
}

Expand Down Expand Up @@ -309,15 +331,55 @@ tabulator.panes.register( {

var objectList = tabulator.panes.utils.selectorPanel(dom, kb, objectType, predicate, true, objects, options, showObject, linkClicked);
objectList.setAttribute('style',
'background-color: #ffe; width: 27.5em; height: 100%; padding: 0em; overflow:scroll;'); //float:left
'background-color: #ffe; width: 30em; height: 100%; padding: 0em; overflow:scroll;'); //float:left
wrapper.appendChild(objectList);

//objectList.insertBefore(head, objectList.firstChild);

var preview = dom.createElement("div");
preview.setAttribute('style', 'background-color: black; padding: 0em; margin: 0; height: 100%; overflow:scroll;');
preview.setAttribute('style', /*background-color: black; */ 'padding: 0em; margin: 0; height: 100%; overflow:scroll;');
div.appendChild(preview);

if (subjects.length > 0 && multi) {
var stores = {};
for (var k=0; k<subjects.length; k++) {
var store = findStore(kb, subjects[k]);
if (store) stores[store.uri] = subjects[k];
//if (!store) complain("No store for "+subjects[k].uri);
};
for (var storeURI in stores) {
//var store = findStore(kb,subjects[subjectList.length-1]);
var store = kb.sym(storeURI);
var mintBox = dom.createElement('div');
mintBox.setAttribute('style', 'clear: left; margin-top:2em; background-color:#ccc; border-radius: 1em; padding: 2em; font-weight: bold;');
mintBox.textContent = "+ New in "+storeURI;
/*
var mintButton = dom.createElement('img');
mintBox.appendChild(mintButton);
mintButton.setAttribute('src', tabulator.Icon.src.icon_add_triple); @@ Invokes master handler
*/
mintBox.addEventListener('click', function(event) {
var thisForm = tabulator.panes.utils.promptForNew(
dom, kb, subject, predicate, subject, null, store,
function(ok, body){
if (!ok) {
//callback(ok, body); // @@ if ok, need some form of refresh of the select for the new thing
} else {
// Refresh @@
}
});
try {
div.insertBefore(thisForm, mintBox.nextSibling) // Sigh no insertAfter
} catch(e) {
div.appendChild(thisForm);
}
var newObject = thisForm.AJAR_subject;

}, false);
div.appendChild(mintBox);
};
};




Expand Down
15 changes: 14 additions & 1 deletion js/panes/dataContentPane.js
Expand Up @@ -80,6 +80,7 @@ tabulator.panes.dataContentPane = {

// Convert a set of statements into a nested tree of tables
function objectTree(obj) {
var res;
switch(obj.termType) {
case 'symbol':
var anchor = myDocument.createElement('a')
Expand All @@ -89,7 +90,19 @@ tabulator.panes.dataContentPane = {
return anchor;

case 'literal':
return myDocument.createTextNode(obj.value); // placeholder

if (!obj.datatype || !obj.datatype.uri) {
res = myDocument.createElement('div');
res.setAttribute('style', 'white-space: pre-wrap;');
res.textContent = obj.value;
return res
} else if (obj.datatype.uri == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral') {
res = myDocument.createElement('div');
res.setAttribute('class', 'embeddedXHTML');
res.innerHTML = obj.value; // Try that @@@ beware embedded dangerous code
return res;
};
return myDocument.createTextNode(obj.value); // placeholder - could be smarter,

case 'bnode':
if (obj.toNT() in doneBnodes) { // Break infinite recursion
Expand Down
2 changes: 1 addition & 1 deletion js/panes/paneUtils.js
Expand Up @@ -1316,7 +1316,7 @@ tabulator.panes.utils.selectorPanelRefresh = function(list, dom, kb, type,
selected = null;
} else {
if (selected) selected.setAttribute('style', style0);
item.setAttribute('style', style0 + 'background-color: #111; color:white;');
item.setAttribute('style', style0 + 'background-color: #ccc; color:black;');
selected = item;
}
callback(x, event, selected == item);
Expand Down
16 changes: 9 additions & 7 deletions js/tab/outline.js
Expand Up @@ -514,7 +514,7 @@ tabulator.OutlineObject = function(doc) {
par.replaceChild(table, placeholder) // Attempt to
}

function propertyTable(subject, table, pane) {
var propertyTable = this.propertyTable = function propertyTable(subject, table, pane) {
tabulator.log.debug("Property table for: "+ subject)
subject = kb.canon(subject)
// if (!pane) pane = tabulator.panes.defaultPane;
Expand All @@ -526,7 +526,9 @@ tabulator.OutlineObject = function(doc) {

/* This should be a beautiful system not a quick kludge - timbl
** Put link to inferenceWeb browsers for anything which is a proof
** @@@ This should just be an optional pane.
*/
/*
var classes = kb.each(subject, rdf('type'))
var i=0, n=classes.length;
for (i=0; i<n; i++) {
Expand All @@ -539,7 +541,7 @@ tabulator.OutlineObject = function(doc) {
tr1.appendChild(anchor)
}
}

*/
// table.appendChild(defaultPane.render(subject));
if (tr1.firstPane) {
if (typeof tabulator == 'undefined') alert('tabulator undefined')
Expand Down Expand Up @@ -1678,8 +1680,7 @@ tabulator.OutlineObject = function(doc) {

function expand(uri) {
if (arguments[3]) return true;//already fetched indicator
if (uri=="https://svn.csail.mit.edu/kennyluck/data") var debug=true;
var cursubj = kb.canon(subject) // canonical identifier may have changed
var cursubj = kb.canon(subject); // canonical identifier may have changed
tabulator.log.info('@@ expand: relevant subject='+cursubj+', uri='+uri+', already='+already)
var term = kb.sym(uri)
var docTerm = kb.sym(tabulator.rdf.Util.uri.docpart(uri))
Expand Down Expand Up @@ -1842,10 +1843,12 @@ tabulator.OutlineObject = function(doc) {
// expand -- flag -- open the subject rather tahn keep folded closed
// pane -- optional -- pane to be used for exanded display
// solo -- optional -- the window will be cleared out and only the subject displayed
// referer -- optional -- where did we hear about this from anyway?
// table -- option -- a table element in which to put the outline.

this.GotoSubject = function(subject, expand, pane, solo, referrer) {
this.GotoSubject = function(subject, expand, pane, solo, referrer, table) {
tabulator.log.error("@@ outline.js test 50 tabulator.log.error: $rdf.log.error)"+$rdf.log.error);
var table = myDocument.getElementById('outline');
if (!table) table = myDocument.getElementById('outline');
if (solo) tabulator.Util.emptyNode(table);

function GotoSubject_default(){
Expand All @@ -1872,7 +1875,6 @@ tabulator.OutlineObject = function(doc) {
return uri;
}
var td = GotoSubject_default();
// Was: DisplayOptions["outliner rotate left"].setupHere([table,subject],text,GotoSubject_default);
if (!td) td = GotoSubject_default(); //the first tr is required
if (expand) {
outline_expand(td, subject, pane);
Expand Down

0 comments on commit b45d4dc

Please sign in to comment.