Skip to content

Commit 7acdeb3

Browse files
author
Tim Berners-Lee
committed
Add pushpin and home icons and a few bug fixes
1 parent 9d0be39 commit 7acdeb3

5 files changed

Lines changed: 91 additions & 65 deletions

File tree

lib/icons/noun_547570.svg

Lines changed: 1 addition & 0 deletions
Loading

lib/icons/noun_562340.svg

Lines changed: 1 addition & 0 deletions
Loading

lib/pad.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ padModule.notepad = function (dom, padDoc, subject, me, options) {
557557
var retryTimeout = 1000; // ms
558558
var tryReload = function() {
559559
console.log("try reload - timeout = " + retryTimeout);
560-
updater.reload(kb, padDoc, function (ok, message, xhr) {
560+
updater.reload(updater.store, padDoc, function (ok, message, xhr) {
561561
reloading = false;
562562
if (ok) {
563563
checkAndSync();

lib/signin.js

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ UI.widgets.findAppInstances = function(context, klass) {
258258
UI.widgets.registrationControl = function(context, instance, klass) {
259259
return new Promise(function(resolve, reject){
260260
var kb = UI.store, ns = UI.ns, me = context.me, fetcher = UI.store.fetcher;
261+
var dom = context.dom
261262

262-
var box = context.dom.createElement('div');
263+
var box = dom.createElement('div');
263264
context.div.appendChild(box);
264265
return UI.widgets.ensureTypeIndexes(context)
265266
.then(function(indexes){
@@ -567,43 +568,39 @@ UI.widgets.checkUser = function(doc, setIt) {
567568
if (!userMirror) userMirror = doc;
568569
var kb = UI.store
569570
kb.fetcher.nowOrWhenFetched(userMirror.uri, undefined, function(ok, body) {
570-
var done = false;
571-
if (ok) {
572-
kb.each(undefined, UI.ns.link('requestedURI'), $rdf.uri.docpart(userMirror.uri))
573-
.map(function(request){
571+
if (!ok) {
572+
var message = "checkUser: Unable to load " + userMirror.uri + ": " + body;
573+
console.log(message)
574+
setIt(null)
575+
} else {
576+
var allUserHeaders = []
577+
var requests = kb.each(undefined, UI.ns.link('requestedURI'), $rdf.uri.docpart(userMirror.uri))
578+
requests.map(function(request){
574579

575-
var response = kb.any(request, UI.ns.link('response'));
580+
var response = kb.any(request, UI.ns.link('response'))
576581
if (response !== undefined) {
577-
var userHeaders = kb.each(response, UI.ns.httph('user'));
578-
if (userHeaders.length === 0) {
579-
console.log("CheckUser: non-solid server: trying "
580-
+ UI.widgets.userCheckSite);
581-
UI.widgets.checkUser(
582-
kb.sym(UI.widgets.userCheckSite), setIt)
583-
} else {
584-
userHeaders.map(function(userHeader){
585-
var username = userHeader.value.trim();
582+
var userHeaders = kb.each(response, UI.ns.httph('user'))
583+
allUserHeaders = allUserHeaders.concat(userHeaders)
584+
}
585+
})
586+
587+
if (allUserHeaders.length === 0 && userMirror.uri !== UI.widgets.userCheckSite) {
588+
console.log("CheckUser: non-solid server" + userMirror + ": trying "
589+
+ UI.widgets.userCheckSite);
590+
UI.widgets.checkUser(
591+
kb.sym(UI.widgets.userCheckSite), setIt)
592+
} else {
593+
594+
var username = allUserHeaders[0].value.trim();
586595
if (username.slice(0,4) !== 'dns:') { // dns: are pseudo-usernames from rww.io and don't count
587-
setIt(username);
588-
done = true;
589-
}
596+
setIt(username);
597+
} else {
598+
setIt(null)
599+
}
600+
}
601+
}
590602
});
591-
}
592-
}
593-
});
594-
} else {
595-
var message = "checkUser: Unable to load " + userMirror.uri + ": " + body;
596-
try { // Ugh
597-
console.log(message);
598-
UI.log.alert(message);
599-
} catch(e) {
600-
try {
601-
alert(message);
602-
} catch (e) {
603-
};
604-
}
605-
}
606-
});
603+
607604
};
608605

609606
// What ID does the user use to log into the given target?
@@ -641,30 +638,14 @@ UI.widgets.checkUserForTarget = function(context) {
641638

642639
// Login status box
643640
//
644-
// Shows
641+
// A big sign-up/sign in box or a logout box depending on the state
642+
//
645643
UI.widgets.loginStatusBox = function(myDocument, listener) {
646644
var me_uri = tabulator.preferences.get('me');
647645
var me = me_uri && UI.store.sym(me_uri);
648646

649647
var box = myDocument.createElement('div');
650648

651-
var logoutButton = function(me) {
652-
var logoutLabel = 'Web ID logout';
653-
if (me) {
654-
var nick = UI.store.any(me, UI.ns.foaf('nick')) ||
655-
UI.store.any(me, UI.ns.foaf('name'));
656-
if (nick) {
657-
logoutLabel = 'Logout ' + nick.value;
658-
};
659-
};
660-
var signOutButton = myDocument.createElement('input');
661-
signOutButton.className = 'WebIDCancelButton';
662-
signOutButton.setAttribute('type', 'button');
663-
signOutButton.setAttribute('value', logoutLabel);
664-
signOutButton.addEventListener('click', zapIt, false);
665-
return signOutButton;
666-
};
667-
668649
var setIt = function(newid) {
669650
tabulator.preferences.set('me',newid);
670651
me_uri = newid;
@@ -682,8 +663,6 @@ UI.widgets.loginStatusBox = function(myDocument, listener) {
682663
if (listener) listener(newid);
683664
};
684665

685-
var sisu = UI.widgets.signInOrSignUpBox(myDocument, setIt);
686-
687666
var zapIt = function() {
688667
tabulator.preferences.set('me','');
689668
var message = 'Your Web ID was ' + me + '. It has been forgotten.';
@@ -698,9 +677,26 @@ UI.widgets.loginStatusBox = function(myDocument, listener) {
698677
};
699678
}
700679
box.refresh();
701-
if (listener) listener(undefined);
680+
if (listener) listener(null);
702681
}
703682

683+
var logoutButton = function(me) {
684+
var logoutLabel = 'Web ID logout';
685+
if (me) {
686+
var nick = UI.store.any(me, UI.ns.foaf('nick')) ||
687+
UI.store.any(me, UI.ns.foaf('name'));
688+
if (nick) {
689+
logoutLabel = 'Logout ' + nick.value;
690+
};
691+
};
692+
var signOutButton = myDocument.createElement('input');
693+
signOutButton.className = 'WebIDCancelButton';
694+
signOutButton.setAttribute('type', 'button');
695+
signOutButton.setAttribute('value', logoutLabel);
696+
signOutButton.addEventListener('click', zapIt, false);
697+
return signOutButton;
698+
};
699+
704700
box.refresh = function() {
705701
var me_uri = tabulator.preferences.get('me') || '';
706702
var me = me_uri ? UI.store.sym(me_uri) : null;
@@ -709,7 +705,7 @@ UI.widgets.loginStatusBox = function(myDocument, listener) {
709705
if (me) {
710706
box.appendChild(logoutButton(me));
711707
} else {
712-
box.appendChild(UI.widgets.signInOrSignUpBox(myDocument, listener));
708+
box.appendChild(UI.widgets.signInOrSignUpBox(myDocument, setIt));
713709
};
714710
}
715711
box.me = me_uri;
@@ -892,7 +888,7 @@ UI.widgets.selectWorkspace = function(dom, appDetails, callbackWS) {
892888
button.textContent = "Continue";
893889
// button.setAttribute('style', style);
894890
var newBase = figureOutBase(selectedWorkspace);
895-
// @@ show the user the URI
891+
// @@ show the user the URI
896892
button.addEventListener('click', function(e){
897893
button.disabled = true;
898894
callbackWS(selectedWorkspace, newBase);

lib/widgets.js

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,8 @@ widgetModule.field[UI.ns.ui('Comment').uri] =
799799

800800
// /////////////////////////////////////////////////////////////////////////////
801801

802-
// Event Handler for making a tabulator
802+
// Event Handler for links within solid apps.
803+
//
803804
// Note that native links have consraints in Firefox, they
804805
// don't work with local files for instance (2011)
805806
//
@@ -813,10 +814,11 @@ widgetModule.openHrefInOutlineMode = function (e) {
813814
// dump('click on link to:' +uri+'\n')
814815
if (UI.outline){
815816
UI.outline.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
816-
} else if (window || window.UI || window.UI.outline ){
817+
} else if (window && window.UI && window.UI.outline ){
817818
window.UI.outline.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
819+
} else {
820+
console.log("ERROR: Can't access outline manager in this config")
818821
}
819-
console.log("ERROR: Can't acces outline manager in this config")
820822
//UI.outline.GotoSubject(UI.store.sym(uri), true, undefined, true, undefined)
821823
}
822824

@@ -1478,17 +1480,18 @@ widgetModule.makeSelectForNestedCategory = function (
14781480
/* Build a checkbox from a given statement
14791481
**
14801482
** If the source document is editable, make the checkbox editable
1481-
** originally in s
1483+
**
14821484
*/
14831485
widgetModule.buildCheckboxForm = function (dom, kb, lab, del, ins, form, store) {
14841486
var box = dom.createElement('div')
14851487
var tx = dom.createTextNode(lab)
14861488
var editable = UI.store.updater.editable(store.uri)
1487-
tx.className = 'question'
1489+
tx.style = 'colour: black; font-size: 100%; padding-left: 0.5 em; padding-right: 0.5 em;'
14881490
box.appendChild(tx)
14891491
var input = dom.createElement('input')
14901492
box.appendChild(input)
14911493
input.setAttribute('type', 'checkbox')
1494+
input.setAttribute('style', 'margin: 0.7em')
14921495

14931496
var state = kb.holds(ins.subject, ins.predicate, ins.object, store)
14941497
if (del) {
@@ -1507,19 +1510,20 @@ widgetModule.buildCheckboxForm = function (dom, kb, lab, del, ins, form, store)
15071510
if (!editable) return box
15081511

15091512
var boxHandler = function (e) {
1510-
tx.className = 'pendingedit' // Grey it out
1513+
tx.style = 'color: #bbb;'
15111514
var toInsert, toDelete
15121515
if (this.checked) {
15131516
toInsert = ins
15141517
toDelete = (del && negation) ? del : []
15151518
UI.store.updater.update(del && negation ? del : [], ins, function (uri, success, error_body) {
1516-
tx.className = 'question'
15171519
if (!success) {
1520+
tx.style = 'color: #black; background-color: #fee;'
15181521
box.appendChild(widgetModule.errorMessageBlock(dom,
15191522
'Error updating store (setting boolean, checked) :\n\n' + error_body))
15201523
input.checked = false // rollback UI
15211524
return
15221525
} else {
1526+
tx.style = 'color: #black;'
15231527
state = true
15241528
negation = false
15251529
}
@@ -1530,11 +1534,13 @@ widgetModule.buildCheckboxForm = function (dom, kb, lab, del, ins, form, store)
15301534
UI.store.updater.update(toDelete, toInsert, function (uri, success, error_body) {
15311535
tx.className = 'question'
15321536
if (!success) {
1537+
tx.style = 'color: #black; background-color: #fee;'
15331538
box.appendChild(widgetModule.errorMessageBlock(dom,
15341539
'Error updating store (unchecked):\n\n' + error_body))
15351540
input.checked = false // rollback UI
15361541
return
15371542
} else {
1543+
tx.style = 'color: #black;'
15381544
state = false
15391545
negation = !!del
15401546
}
@@ -1706,4 +1712,26 @@ widgetModule.index.twoLine['http://www.w3.org/ns/pim/trip#Trip'] = function (dom
17061712
return box
17071713
}
17081714

1715+
// Stick a stylesheet link the document if not already there
1716+
UI.widgets.addStyleSheet = function(dom, href) {
1717+
var links = dom.querySelectorAll('link');
1718+
for (i=0; i<links.length; i++){
1719+
if ((links[i].getAttribute('rel') ||'') === 'stylesheet'
1720+
&& (links[i].getAttribute('href') ||'') === href ) return ;
1721+
}
1722+
var link = dom.createElement("link")
1723+
link.setAttribute("rel", "stylesheet")
1724+
link.setAttribute("type", "text/css")
1725+
link.setAttribute("href", href)
1726+
dom.getElementsByTagName("head")[0].appendChild(link)
1727+
}
1728+
1729+
// Figure (or guess) whether this is an immage
1730+
// In future, containers may give content type information about contents too.
1731+
//
1732+
UI.widgets.isImage = function(file){
1733+
var imageExtensions = {'jpg': 1, 'png':1, 'jpeg':1, 'gif':1}
1734+
return (UI.ns.dct('Image') in UI.store.findTypeURIs(file)
1735+
|| file.uri.split('.').slice(-1)[0] in imageExtensions) // @@cheating
1736+
}
17091737
// ends

0 commit comments

Comments
 (0)