Skip to content

Commit a5a9459

Browse files
author
Tim Berners-Lee
committed
Add .iconBase etc for offline testing
1 parent e3b9fce commit a5a9459

2 files changed

Lines changed: 31 additions & 8 deletions

File tree

lib/iconBase.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ if (module.scriptURI) { // FF extension
88
module.scriptURI.slice(0, module.scriptURI.lastIndexOf('/')) + '/originalIcons/'
99
} else { // Node or browserify
1010
var iconsOnGithub = 'https://linkeddata.github.io/solid-ui/lib'
11-
module.exports.iconBase = iconsOnGithub + '/icons/'
12-
module.exports.originalIconBase = iconsOnGithub + '/originalIcons/'
13-
// module.exports.iconBase = __dirname + '/icons/'
14-
// module.exports.originalIconBase = __dirname + '/originalIcons/'
11+
12+
if (typeof $SolidTestEnvironment !== 'undefined' && $SolidTestEnvironment.iconBase ){
13+
module.exports.iconBase = $SolidTestEnvironment.iconBase
14+
module.exports.originalIconBase = $SolidTestEnvironment.originalIconBase
15+
} else {
16+
module.exports.iconBase = iconsOnGithub + '/icons/'
17+
module.exports.originalIconBase = iconsOnGithub + '/originalIcons/'
18+
}
1519
}
1620
console.log(' Icon base is: ' + module.exports.iconBase)

lib/signin.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,18 +322,25 @@ UI.widgets.registrationList = function(context, options) {
322322

323323

324324
for (var i=0; i< sts.length; i++){
325-
var cla = sts[i].subject
326-
var inst = sts[i].object
325+
var statement = sts[i]
326+
var cla = statement.subject
327+
var inst = statement.object
327328
if (false){
328329
var tr = table.appendChild(dom.createElement('tr'))
329330
var anchor = tr.appendChild(dom.createElement('a'))
330331
anchor.setAttribute('href', inst.uri)
331332
anchor.textContent = UI.utils.label(inst)
332333
} else {
333334
var deleteInstance = function(x){
334-
// @@@ TBD and added to opts
335+
kb.updater.update([statement], [], function(uri, ok, error_body){
336+
if (ok){
337+
console.log('Removed from index: ' + statement.subject)
338+
} else {
339+
console.log('Error: Cannot delete ' + statement + ': ' + error_body)
340+
}
341+
})
335342
}
336-
var opts = {}
343+
var opts = { deleteFunction: deleteInstance}
337344
var tr = UI.widgets.personTR(dom, ns.solid('instance'), inst, opts)
338345
table.appendChild(tr)
339346
}
@@ -423,6 +430,11 @@ UI.widgets.setACLUserPublic = function(docURI, me, options, callback) {
423430

424431
UI.widgets.offlineTestID = function() {
425432

433+
if (typeof $SolidTestEnvironment !== 'undefined' && $SolidTestEnvironment.username){ // Test setup
434+
console.log("Assuming the user is " + $SolidTestEnvironment.username);
435+
return $rdf.sym($SolidTestEnvironment.username)
436+
}
437+
426438
if (tabulator.mode == 'webapp' && typeof document !== 'undefined' &&
427439
document.location && ('' + document.location).slice(0,16) === 'http://localhost') {
428440
var div = document.getElementById('appTarget');
@@ -515,7 +527,12 @@ UI.widgets.checkUserSetMe = function(doc) {
515527

516528
UI.widgets.userCheckSite = 'https://databox.me/';
517529

530+
518531
UI.widgets.checkUser = function(doc, setIt) {
532+
533+
if (typeof $SolidTestEnvironment !== 'undefined' && $SolidTestEnvironment.username){ // Test setup
534+
return setIt($SolidTestEnvironment.username)
535+
}
519536
var userMirror = UI.store.any(doc, UI.ns.link('userMirror'));
520537
if (!userMirror) userMirror = doc;
521538
var kb = UI.store
@@ -604,6 +621,7 @@ UI.widgets.loginStatusBox = function(myDocument, listener) {
604621
me_uri = newid;
605622
me = me_uri && UI.store.sym(me_uri)
606623
var message = 'Your Web ID is now ' + me +' .';
624+
/*
607625
try {
608626
UI.log.alert(message);
609627
} catch(e) {
@@ -612,6 +630,7 @@ UI.widgets.loginStatusBox = function(myDocument, listener) {
612630
} catch (e) {
613631
};
614632
}
633+
*/
615634
box.refresh();
616635
if (listener) listener(newid);
617636
};

0 commit comments

Comments
 (0)