Skip to content

Commit 9325f13

Browse files
author
Tim Berners-Lee
committed
New 'home' pane (which applies to anything giving access to user's basic reference points) creaks into early life. Some bug fixes
1 parent 6530023 commit 9325f13

8 files changed

Lines changed: 276 additions & 47 deletions

File tree

attach/attachPane.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
** - Drag a document onto the pane to attach it @@
77
**
88
**
9-
** I am using in places single quotes strings like 'this'
10-
** where internationalizatio ("i18n") is not a problem, and double quoted
11-
** like "this" where th string is seen by the user and so I18n is an issue.
129
*/
1310

1411
var UI = require('solid-ui')
@@ -18,7 +15,7 @@ module.exports = {
1815

1916
name: 'attachments',
2017

21-
// Does the subject deserve an issue pane?
18+
// Does the subject deserve an attachments pane?
2219
//
2320
// In this case we will render any thing which is in any subclass of
2421
// certain classes, or also the certain classes themselves, as a
@@ -77,10 +74,8 @@ module.exports = {
7774
//
7875
// Returns term for document or null
7976
var findStore = function (kb, subject) {
80-
var docURI = UI.rdf.Util.uri.docpart(subject.uri)
81-
if (kb.updater.editable(docURI, kb)) return kb.sym(docURI)
82-
var store = kb.any(kb.sym(docURI), QU('annotationStore'))
83-
// if (!store) complain("No store for "+docURI)
77+
if (kb.updater.editable(subject.doc(), kb)) return subject.doc()
78+
var store = kb.any(subject.doc(), QU('annotationStore'))
8479
return store
8580
}
8681

@@ -134,7 +129,7 @@ module.exports = {
134129
var sortBy = getSortKey(subject)
135130
var u, x, key, uriHash = kb.findMemberURIs(subject)
136131
var pairs = [], subjects = []
137-
for (u in uriHash) { // @ protect against methods?
132+
for (u in uriHash) if (uriHash.hasOwnProperty(u)) {
138133
x = kb.sym(u)
139134
if (sortBy) {
140135
key = kb.any(x, sortBy)

contact/contactPane.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ module.exports = {
538538
context = { target: book, me: me, noun: 'address book',
539539
div: pane, dom: dom, statusRegion: statusBlock }
540540

541-
box.appendChild(UI.aclControl.ACLControlBox5(book, dom, 'book', kb, function (ok, body) {
541+
box.appendChild(UI.aclControl.ACLControlBox5(book.dir(), dom, 'book', kb, function (ok, body) {
542542
if (!ok) box.innerHTML = 'ACL control box Failed: ' + body
543543
}))
544544

home/app.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Find your stuff
2+
//
3+
// This is or was part of https://github.com/Linkeddata/solid-app-set/
4+
//
5+
6+
document.addEventListener('DOMContentLoaded', function () {
7+
8+
var UI = require('mashlib')
9+
10+
11+
var inputStyle = 'background-color: #eef; padding: 0.5em; border: .5em solid white; font-size: 150%; text-align: center;' // ;
12+
var kb = UI.store
13+
var fetcher = kb.fetcher
14+
var ns = UI.ns
15+
var dom = document
16+
var updater = kb.updater
17+
18+
var waitingForLogin = false
19+
20+
var uri = window.location.href
21+
var base = uri.slice(0, uri.lastIndexOf('/') + 1)
22+
23+
var scriptBase = 'https://linkeddata.github.io/solid-app-set/'
24+
25+
var div = document.getElementById('FormTarget')
26+
27+
// //////////////////////////////////// Getting logged in with a WebId
28+
29+
var setUser = function (webid) {
30+
if (webid) {
31+
tabulator.preferences.set('me', webid)
32+
console.log('(SetUser: Logged in as ' + webid + ')')
33+
me = kb.sym(webid)
34+
// @@ Here enable all kinds of stuff
35+
} else {
36+
tabulator.preferences.set('me', '')
37+
console.log('(SetUser: Logged out)')
38+
me = null
39+
}
40+
}
41+
42+
var me_uri = tabulator.preferences.get('me')
43+
var me = me_uri ? kb.sym(me_uri) : null
44+
45+
var userTest = $rdf.sym('https://databox.me/')
46+
47+
UI.widgets.checkUser(userTest, setUser)
48+
49+
var pane = UI.panes.home
50+
var target = me // @@ for now, in fact not relevant
51+
52+
// subject, expand, pane, solo, referrer, table
53+
UI.outline.GotoSubject(target, true, pane, true, undefined)
54+
// ////////////////////////////// Reproduction: spawn a new instance
55+
//
56+
// Viral growth path: user of app decides to make another instance
57+
//
58+
59+
var newInstanceButtonDiv = function () {
60+
return UI.widgets.newAppInstance(dom,
61+
{ noun: 'meeting',
62+
appPathSegment: appPathSegment},
63+
initializeNewInstanceInWorkspace)
64+
} // newInstanceButtonDiv
65+
66+
// /////////////////////// Create new document files for new instance of app
67+
68+
var initializeNewInstanceInWorkspace = function (ws, newBase) {
69+
70+
if (newBase.slice(-1) !== '/') {
71+
console.log(appPathSegment + ': No / at end of uriPrefix ' + newBase); // @@ paramater?
72+
newBase = newBase + '/'
73+
}
74+
var now = new Date()
75+
76+
initializeNewInstanceAtBase(null, newBase)
77+
}
78+
79+
var initializeNewInstanceAtBase = function (thisInstance, newBase) {
80+
var pane = UI.panes.byName('meeting')
81+
var newInstance = pane.mint(newBase)
82+
.then(function(newInstance){
83+
UI.outline.GotoSubject(newInstance, true, undefined, true);
84+
div.removeChild(d)
85+
})
86+
.catch(function(e){
87+
div.textContent = 'Error making new meeting: ' + e
88+
})
89+
}
90+
91+
var d = newInstanceButtonDiv() // Actually a div in which minting will happen
92+
var button = d.firstChild
93+
button.setAttribute('style', inputStyle)
94+
div.appendChild(d)
95+
})

home/homePane.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* Home Pane
2+
**
3+
** The home pane is avaiable everywhere and allows a user
4+
** to
5+
** - keep track of their stuff
6+
** - make new things, and possibly
7+
** - keep track of accounts and workspaces etc
8+
**
9+
*/
10+
11+
var UI = require('solid-ui')
12+
13+
module.exports = {
14+
icon: UI.icons.iconBase + 'noun_547570.svg', // noun_25830
15+
16+
name: 'home',
17+
18+
// Does the subject deserve an home pane?
19+
//
20+
// yes, always!
21+
//
22+
label: function (subject) {
23+
return "home"
24+
},
25+
26+
render: function (subject, dom) {
27+
28+
// ////////////////////////////////////////////////////////////////////////////
29+
30+
var complain = function complain (message) {
31+
var pre = dom.createElement('pre')
32+
pre.setAttribute('style', 'background-color: pink')
33+
div.appendChild(pre)
34+
pre.appendChild(dom.createTextNode(message))
35+
}
36+
37+
var showContent = function(){
38+
var context = {div: div, dom: dom, statusArea: div, me: me}
39+
40+
div.appendChild(dom.createElement('h4')).textContent = 'Private:'
41+
UI.widgets.registrationList(context, { private: true})
42+
43+
div.appendChild(dom.createElement('h4')).textContent = 'Public:'
44+
UI.widgets.registrationList(context, { public: true})
45+
}
46+
var thisPane = this
47+
var kb = UI.store
48+
var ns = UI.ns
49+
50+
var div = dom.createElement('div')
51+
52+
var me = tabulator.preferences.get('me')
53+
me = me? kb.sym(me) : null
54+
if (!me) {
55+
console.log('Waiting to find out id user users to access ' + subject.doc())
56+
UI.widgets.checkUser(subject.doc(), function (webid) {
57+
me = kb.sym(webid)
58+
console.log('Got user id: ' + me)
59+
showContent()
60+
})
61+
} else {
62+
showContent()
63+
}
64+
65+
return div
66+
}
67+
} // pane object
68+
69+
// ends

home/index.html

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head><title>Your Solid stuff </title>
4+
<link type="text/css" rel="stylesheet" href="https://linkeddata.github.io/solid-app-set/style/tabbedtab.css" />
5+
<style>
6+
body { margin: 10%; }
7+
input { background-color: #eef; padding: 0.5em; border: .5em solid white; font-size: 120%; };
8+
</style>
9+
10+
<script type="text/javascript" src="../../mashlib/dist/mashlib-prealpha.js"></script>
11+
<script type="text/javascript" >
12+
document.addEventListener('DOMContentLoaded', function () {
13+
14+
var UI = require('mashlib')
15+
16+
var inputStyle = 'background-color: #eef; padding: 0.5em; border: .5em solid white; font-size: 150%; text-align: center;' // ;
17+
var kb = UI.store
18+
var ns = UI.ns
19+
var dom = document
20+
var updater = kb.updater
21+
22+
var waitingForLogin = false
23+
24+
var uri = window.location.href
25+
var base = uri.slice(0, uri.lastIndexOf('/') + 1)
26+
27+
28+
29+
// //////////////////////////////////// Getting logged in with a WebId
30+
31+
var setUser = function (webid) {
32+
if (webid) {
33+
tabulator.preferences.set('me', webid)
34+
console.log('(SetUser: Logged in as ' + webid + ')')
35+
me = kb.sym(webid)
36+
UI.outline.GotoSubject(me, true, pane, true, undefined)
37+
38+
// @@ Here enable all kinds of stuff
39+
} else {
40+
tabulator.preferences.set('me', '')
41+
console.log('(SetUser: Logged out)')
42+
me = null
43+
}
44+
}
45+
46+
var me_uri = tabulator.preferences.get('me')
47+
var me = me_uri ? kb.sym(me_uri) : null
48+
49+
var userTest = $rdf.sym('https://databox.me/')
50+
51+
UI.widgets.checkUser(userTest, setUser)
52+
53+
var pane = UI.panes.home
54+
var target = me // @@ for now, in fact not relevant
55+
56+
// subject, expand, pane, solo, referrer, table
57+
58+
})
59+
60+
</script>
61+
62+
</head>
63+
<body>
64+
<h1>Your stuff</h1>
65+
<p>This is a Solid web app for finding your stuff in a linked data world</p>
66+
67+
<div class="TabulatorOutline" id="DummyUUID">
68+
<table id="outline"></table>
69+
</div>
70+
<div class="TabulatorOutline" id='FormTarget'>
71+
</div>
72+
</body>
73+
</html>

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ paneModule.register(require('./microblogPane/microblogPane.js'))
132132
// The sharing pane is fairly generic and administrative 201
133133
paneModule.register(require('./sharing/sharingPane.js'))
134134

135-
// The internals pane is always the last as it is the least user-friendly
135+
// The internals pane is always (almost?) the last as it is the least user-friendly
136136
paneModule.register(require('./internalPane.js'))
137+
// The home pame is a 2016 experiment. Always there.
138+
paneModule.register(require('./home/homePane.js'))
137139

138140
// ENDS

meeting/meetingPane.js

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,28 @@ module.exports = {
8888
topTR.setAttribute('style','height: 2em;') // spacer if notthing else
8989

9090
var me = null; // @@ Put code to find out logged in person
91-
var loginOutButton = UI.widgets.loginStatusBox(dom, function(webid){
92-
// sayt.parent.removeChild(sayt);
93-
if (webid) {
94-
tabulator.preferences.set('me', webid.uri);
95-
console.log("(Logged in as "+ webid+")")
96-
me = webid;
97-
topDiv.removeChild(loginOutButton);
98-
} else {
99-
tabulator.preferences.set('me', '');
100-
console.log("(Logged out)")
101-
me = null;
102-
}
103-
});
104-
loginOutButton.setAttribute('style', 'margin: 0.5em 1em;');
105-
topDiv.appendChild(loginOutButton);
91+
92+
UI.widgets.checkUser(subject.doc(), function(id){
93+
var loginOutButton = UI.widgets.loginStatusBox(dom, function(webid){
94+
// sayt.parent.removeChild(sayt);
95+
if (webid) {
96+
tabulator.preferences.set('me', webid.uri);
97+
console.log("(Logged in as "+ webid+")")
98+
me = webid;
99+
// topDiv.removeChild(loginOutButton);
100+
} else {
101+
tabulator.preferences.set('me', '');
102+
console.log("(Logged out)")
103+
me = null;
104+
}
105+
});
106+
loginOutButton.setAttribute('style', 'margin: 0.5em 1em;');
107+
topDiv.appendChild(loginOutButton);
108+
109+
})
110+
111+
112+
106113

107114

108115
var saveBackMeetingDoc = function(){
@@ -514,6 +521,13 @@ module.exports = {
514521
UI.widgets.appendForm(document, containerDiv, {}, meeting, form, meeting.doc(), complainIfBad)
515522
containerDiv.appendChild(tipDiv(
516523
'Drag URL-bar icons of web pages into the tab bar on the left to add new meeting materials.'))
524+
me = tabulator.preferences.get('me')
525+
me = me ? kb.sym(me) : null
526+
if (me){
527+
kb.add(meeting, ns.dc('author'), me, meetingDoc)
528+
}
529+
var context = { noun: 'meeting', me: me, statusArea: containerDiv, div: containerDiv, dom: dom}
530+
UI.widgets.registrationControl(context, meeting, ns.meeting('Meeting'))
517531
})
518532
}
519533
if (kb.holds(subject, ns.rdf('type'), ns.meeting('Tool'))) {

slideshow/slideshowPane.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,7 @@
33
*/
44
var UI = require('solid-ui')
55

6-
// todo: move these two
76

8-
// Stick a stylesheet link the document if not already there
9-
UI.widgets.addStyleSheet = function(dom, href) {
10-
var links = dom.querySelectorAll('link');
11-
for (i=0; i<links.length; i++){
12-
if ((links[i].getAttribute('rel') ||'') === 'stylesheet'
13-
&& (links[i].getAttribute('href') ||'') === href ) return ;
14-
}
15-
var link = dom.createElement("link")
16-
link.setAttribute("rel", "stylesheet")
17-
link.setAttribute("type", "text/css")
18-
link.setAttribute("href", href)
19-
dom.getElementsByTagName("head")[0].appendChild(link)
20-
}
21-
22-
UI.widgets.isImage = function(file){
23-
var imageExtensions = {'jpg': 1, 'png':1, 'jpeg':1, 'gif':1}
24-
return (UI.ns.dct('Image') in UI.store.findTypeURIs(file)
25-
|| file.uri.split('.').slice(-1)[0] in imageExtensions) // @@cheating
26-
}
277

288
// tabulator.loadScript("js/panes/slideshow/better-simple-slideshow/js/better-simple-slideshow.js");
299

@@ -55,7 +35,8 @@ module.exports = {
5535
// and follow instructions there
5636
render: function(subject, dom) {
5737

58-
UI.widgets.addStyleSheet(dom, tabulator.scriptBase + 'js/panes/slideshow/better-simple-slideshow/css/simple-slideshow-styles.css')
38+
var styleSheet = 'http://leemark.github.io/better-simple-slideshow/css/simple-slideshow-styles.css'
39+
UI.widgets.addStyleSheet(dom, styleSheet)
5940

6041
var kb = UI.store;
6142
var ns = UI.ns;

0 commit comments

Comments
 (0)