solid-panes 3.5.13 → 3.5.14-bbf45639

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/lib/dashboard/basicPreferences.js +193 -264
  2. package/lib/dashboard/basicPreferences.js.map +1 -1
  3. package/lib/dashboard/dashboardPane.js +57 -79
  4. package/lib/dashboard/dashboardPane.js.map +1 -1
  5. package/lib/dashboard/homepage.js +98 -100
  6. package/lib/dashboard/homepage.js.map +1 -1
  7. package/lib/home/homePane.js +112 -103
  8. package/lib/home/homePane.js.map +1 -1
  9. package/lib/index.d.ts +2 -1
  10. package/lib/index.d.ts.map +1 -1
  11. package/lib/index.js +49 -89
  12. package/lib/index.js.map +1 -1
  13. package/lib/internal/internalPane.js +180 -200
  14. package/lib/internal/internalPane.js.map +1 -1
  15. package/lib/mainPage/footer.d.ts +3 -0
  16. package/lib/mainPage/footer.d.ts.map +1 -0
  17. package/lib/mainPage/footer.js +20 -0
  18. package/lib/mainPage/footer.js.map +1 -0
  19. package/lib/mainPage/header.d.ts +2 -0
  20. package/lib/mainPage/header.d.ts.map +1 -0
  21. package/lib/mainPage/header.js +142 -0
  22. package/lib/mainPage/header.js.map +1 -0
  23. package/lib/mainPage/index.d.ts +3 -0
  24. package/lib/mainPage/index.d.ts.map +1 -0
  25. package/lib/mainPage/index.js +63 -0
  26. package/lib/mainPage/index.js.map +1 -0
  27. package/lib/microblogPane/microblogPane.js +1 -1
  28. package/lib/outline/context.d.ts +2 -1
  29. package/lib/outline/context.d.ts.map +1 -1
  30. package/lib/outline/context.js +13 -17
  31. package/lib/outline/context.js.map +1 -1
  32. package/lib/outline/manager.js +13 -4
  33. package/lib/outline/manager.js.map +1 -1
  34. package/lib/outline/propertyViews.js +32 -46
  35. package/lib/outline/propertyViews.js.map +1 -1
  36. package/lib/outline/userInput.js +1 -1
  37. package/lib/outline/viewAsImage.js +22 -19
  38. package/lib/outline/viewAsImage.js.map +1 -1
  39. package/lib/outline/viewAsMbox.js +5 -15
  40. package/lib/outline/viewAsMbox.js.map +1 -1
  41. package/lib/pad/padPane.js +406 -451
  42. package/lib/pad/padPane.js.map +1 -1
  43. package/lib/profile/editProfile.view.js +101 -124
  44. package/lib/profile/editProfile.view.js.map +1 -1
  45. package/lib/profile/profile.dom.js +12 -17
  46. package/lib/profile/profile.dom.js.map +1 -1
  47. package/lib/registerPanes.js +1 -1
  48. package/lib/registerPanes.js.map +1 -1
  49. package/lib/sharing/sharingPane.js +33 -45
  50. package/lib/sharing/sharingPane.js.map +1 -1
  51. package/lib/tabbed/tabbedPane.js +87 -77
  52. package/lib/tabbed/tabbedPane.js.map +1 -1
  53. package/lib/trustedApplications/trustedApplications.dom.js +173 -182
  54. package/lib/trustedApplications/trustedApplications.dom.js.map +1 -1
  55. package/lib/trustedApplications/trustedApplications.test.js +1 -1
  56. package/lib/trustedApplications/trustedApplications.utils.js +30 -36
  57. package/lib/trustedApplications/trustedApplications.utils.js.map +1 -1
  58. package/lib/trustedApplications/trustedApplications.view.js +91 -99
  59. package/lib/trustedApplications/trustedApplications.view.js.map +1 -1
  60. package/lib/types.js +1 -4
  61. package/lib/types.js.map +1 -1
  62. package/lib/versionInfo.js +23 -28
  63. package/lib/versionInfo.js.map +1 -1
  64. package/package.json +13 -14
  65. package/src/index.ts +4 -3
  66. package/src/mainPage/footer.ts +19 -0
  67. package/src/mainPage/header.ts +75 -0
  68. package/src/mainPage/index.ts +20 -0
  69. package/src/outline/context.ts +2 -1
  70. package/src/outline/manager.js +1 -0
  71. package/src/versionInfo.ts +3 -3
@@ -1,466 +1,421 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _solidUi = require("solid-ui");
9
-
10
- var _rdflib = require("rdflib");
11
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var solid_ui_1 = require("solid-ui");
4
+ var rdflib_1 = require("rdflib");
12
5
  /* pad Pane
13
6
  **
14
7
  */
15
8
  var paneDef = {
16
- // icon: (module.__dirname || __dirname) + 'images/ColourOn.png',
17
- icon: _solidUi.icons.iconBase + 'noun_79217.svg',
18
- name: 'pad',
19
- audience: [_solidUi.ns.solid('PowerUser')],
20
- // Does the subject deserve an pad pane?
21
- label: function label(subject, context) {
22
- var t = context.session.store.findTypeURIs(subject);
23
-
24
- if (t['http://www.w3.org/ns/pim/pad#Notepad']) {
25
- return 'pad';
26
- }
27
-
28
- return null; // No under other circumstances
29
- },
30
- mintClass: _solidUi.ns.pad('Notepad'),
31
- mintNew: function mintNew(context, newPaneOptions) {
32
- var store = context.session.store;
33
- var updater = store.updater;
34
-
35
- if (newPaneOptions.me && !newPaneOptions.me.uri) {
36
- throw new Error('notepad mintNew: Invalid userid');
37
- }
38
-
39
- var newInstance = newPaneOptions.newInstance = newPaneOptions.newInstance || store.sym(newPaneOptions.newBase + 'index.ttl#this'); // const newInstance = kb.sym(newBase + 'pad.ttl#thisPad');
40
-
41
- var newPadDoc = newInstance.doc();
42
- store.add(newInstance, _solidUi.ns.rdf('type'), _solidUi.ns.pad('Notepad'), newPadDoc);
43
- store.add(newInstance, _solidUi.ns.dc('title'), 'Shared Notes', newPadDoc);
44
- store.add(newInstance, _solidUi.ns.dc('created'), new Date(), newPadDoc); // @@ TODO Remove casting
45
-
46
- if (newPaneOptions.me) {
47
- store.add(newInstance, _solidUi.ns.dc('author'), newPaneOptions.me, newPadDoc);
48
- } // kb.add(newInstance, ns.pad('next'), newInstance, newPadDoc);
49
- // linked list empty @@
50
-
51
-
52
- var chunk = store.sym(newInstance.uri + '_line0');
53
- store.add(newInstance, _solidUi.ns.pad('next'), chunk, newPadDoc); // Linked list has one entry
54
-
55
- store.add(chunk, _solidUi.ns.pad('next'), newInstance, newPadDoc);
56
- store.add(chunk, _solidUi.ns.dc('author'), newPaneOptions.me, newPadDoc);
57
- store.add(chunk, _solidUi.ns.sioc('content'), '', newPadDoc);
58
- return new Promise(function (resolve, reject) {
59
- if (!updater) {
60
- reject(new Error('Have no updater'));
61
- return;
62
- }
63
-
64
- updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (uri2, ok, message) {
65
- if (ok) {
66
- resolve(newPaneOptions);
67
- } else {
68
- reject(new Error('FAILED to save new tool at: ' + uri2 + ' : ' + message));
9
+ // icon: (module.__dirname || __dirname) + 'images/ColourOn.png',
10
+ icon: solid_ui_1.icons.iconBase + 'noun_79217.svg',
11
+ name: 'pad',
12
+ audience: [solid_ui_1.ns.solid('PowerUser')],
13
+ // Does the subject deserve an pad pane?
14
+ label: function (subject, context) {
15
+ var t = context.session.store.findTypeURIs(subject);
16
+ if (t['http://www.w3.org/ns/pim/pad#Notepad']) {
17
+ return 'pad';
69
18
  }
70
- });
71
- });
72
- },
73
- // and follow instructions there
74
- // @@ TODO Set better type for paneOptions
75
- render: function render(subject, context, paneOptions) {
76
- var dom = context.dom;
77
- var store = context.session.store; // Utility functions
78
-
79
- var complainIfBad = function complainIfBad(ok, message) {
80
- if (!ok) {
81
- div.appendChild(_solidUi.widgets.errorMessageBlock(dom, message, 'pink'));
82
- }
83
- };
84
-
85
- var clearElement = function clearElement(ele) {
86
- while (ele.firstChild) {
87
- ele.removeChild(ele.firstChild);
88
- }
89
-
90
- return ele;
91
- }; // Access control
92
- // Two constiations of ACL for this app, public read and public read/write
93
- // In all cases owner has read write control
94
-
95
-
96
- var genACLtext = function genACLtext(docURI, aclURI, allWrite) {
97
- var g = (0, _rdflib.graph)();
98
- var auth = (0, _rdflib.Namespace)('http://www.w3.org/ns/auth/acl#');
99
- var a = g.sym(aclURI + '#a1');
100
- var acl = g.sym(aclURI);
101
- var doc = g.sym(docURI);
102
- g.add(a, _solidUi.ns.rdf('type'), auth('Authorization'), acl);
103
- g.add(a, auth('accessTo'), doc, acl);
104
- g.add(a, auth('agent'), me, acl);
105
- g.add(a, auth('mode'), auth('Read'), acl);
106
- g.add(a, auth('mode'), auth('Write'), acl);
107
- g.add(a, auth('mode'), auth('Control'), acl);
108
- a = g.sym(aclURI + '#a2');
109
- g.add(a, _solidUi.ns.rdf('type'), auth('Authorization'), acl);
110
- g.add(a, auth('accessTo'), doc, acl);
111
- g.add(a, auth('agentClass'), _solidUi.ns.foaf('Agent'), acl);
112
- g.add(a, auth('mode'), auth('Read'), acl);
113
-
114
- if (allWrite) {
115
- g.add(a, auth('mode'), auth('Write'), acl);
116
- } // TODO: Figure out why `serialize` isn't on the type definition according to TypeScript:
117
-
118
-
119
- return (0, _rdflib.serialize)(acl, g, aclURI, 'text/turtle');
120
- };
121
- /**
122
- * @param docURI
123
- * @param allWrite
124
- * @param callbackFunction
125
- *
126
- * @returns {Promise<Response>}
127
- */
128
-
129
-
130
- var setACL = function setACL(docURI, allWrite, callbackFunction) {
131
- var aclDoc = store.any((0, _rdflib.sym)(docURI), (0, _rdflib.sym)('http://www.iana.org/assignments/link-relations/acl')); // @@ check that this get set by web.js
132
-
133
- if (!fetcher) {
134
- throw new Error('Have no fetcher');
135
- }
136
-
137
- if (aclDoc) {
138
- // Great we already know where it is
139
- var aclText = genACLtext(docURI, aclDoc.uri, allWrite);
140
- return fetcher.webOperation('PUT', aclDoc.uri, {
141
- data: aclText,
142
- contentType: 'text/turtle'
143
- }).then(function () {
144
- return callbackFunction(true);
145
- })["catch"](function (err) {
146
- callbackFunction(false, err.message);
147
- });
148
- } else {
149
- return fetcher.load(docURI)["catch"](function (err) {
150
- callbackFunction(false, 'Getting headers for ACL: ' + err);
151
- }).then(function () {
152
- var aclDoc = store.any((0, _rdflib.sym)(docURI), (0, _rdflib.sym)('http://www.iana.org/assignments/link-relations/acl'));
153
-
154
- if (!aclDoc) {
155
- // complainIfBad(false, "No Link rel=ACL header for " + docURI);
156
- throw new Error('No Link rel=ACL header for ' + docURI);
157
- }
158
-
159
- var aclText = genACLtext(docURI, aclDoc.uri, allWrite);
160
- return fetcher.webOperation('PUT', aclDoc.uri, {
161
- data: aclText,
162
- contentType: 'text/turtle'
163
- });
164
- }).then(function () {
165
- return callbackFunction(true);
166
- })["catch"](function (err) {
167
- callbackFunction(false, err.message);
168
- });
169
- }
170
- }; // Reproduction: spawn a new instance
171
- //
172
- // Viral growth path: user of app decides to make another instance
173
-
174
-
175
- var newInstanceButton = function newInstanceButton() {
176
- var button = div.appendChild(dom.createElement('button'));
177
- button.textContent = 'Start another pad';
178
- button.addEventListener('click', function () {
179
- return showBootstrap(subject, spawnArea, 'pad');
180
- });
181
- return button;
182
- }; // Option of either using the workspace system or just typing in a URI
183
-
184
-
185
- var showBootstrap = function showBootstrap(thisInstance, container, noun) {
186
- var div = clearElement(container);
187
- var appDetails = {
188
- noun: 'notepad'
189
- };
190
- div.appendChild(_solidUi.authn.newAppInstance(dom, appDetails, function (workspace, newBase) {
191
- // FIXME: not sure if this will work at all, just
192
- // trying to get the types to match - Michiel.
193
- return initializeNewInstanceInWorkspace(new _rdflib.NamedNode(workspace || newBase));
194
- }));
195
- div.appendChild(dom.createElement('hr')); // @@
196
-
197
- var p = div.appendChild(dom.createElement('p'));
198
- p.textContent = 'Where would you like to store the data for the ' + noun + '? ' + 'Give the URL of the directory where you would like the data stored.';
199
- var baseField = div.appendChild(dom.createElement('input'));
200
- baseField.setAttribute('type', 'text');
201
- baseField.size = 80 // really a string
202
- ;
203
- baseField.label = 'base URL';
204
- baseField.autocomplete = 'on';
205
- div.appendChild(dom.createElement('br')); // @@
206
-
207
- var button = div.appendChild(dom.createElement('button'));
208
- button.textContent = 'Start new ' + noun + ' at this URI';
209
- button.addEventListener('click', function (_e) {
210
- var newBase = baseField.value;
211
-
212
- if (newBase.slice(-1) !== '/') {
213
- newBase += '/';
19
+ return null; // No under other circumstances
20
+ },
21
+ mintClass: solid_ui_1.ns.pad('Notepad'),
22
+ mintNew: function (context, newPaneOptions) {
23
+ var store = context.session.store;
24
+ var updater = store.updater;
25
+ if (newPaneOptions.me && !newPaneOptions.me.uri) {
26
+ throw new Error('notepad mintNew: Invalid userid');
214
27
  }
215
-
216
- initializeNewInstanceAtBase(thisInstance, newBase);
217
- });
218
- }; // Create new document files for new instance of app
219
-
220
-
221
- var initializeNewInstanceInWorkspace = function initializeNewInstanceInWorkspace(ws) {
222
- // @@ TODO Clean up type for newBase
223
- var newBase = store.any(ws, _solidUi.ns.space('uriPrefix'));
224
-
225
- if (!newBase) {
226
- newBase = ws.uri.split('#')[0];
227
- } else {
228
- newBase = newBase.value;
229
- }
230
-
231
- if (newBase.slice(-1) !== '/') {
232
- _rdflib.log.error(appPathSegment + ': No / at end of uriPrefix ' + newBase); // @@ paramater?
233
-
234
-
235
- newBase = newBase + '/';
236
- }
237
-
238
- var now = new Date();
239
- newBase += appPathSegment + '/id' + now.getTime() + '/'; // unique id
240
-
241
- initializeNewInstanceAtBase(thisInstance, newBase);
242
- };
243
-
244
- var initializeNewInstanceAtBase = function initializeNewInstanceAtBase(thisInstance, newBase) {
245
- var here = (0, _rdflib.sym)(thisInstance.uri.split('#')[0]);
246
- var base = here; // @@ ???
247
-
248
- var newPadDoc = store.sym(newBase + 'pad.ttl');
249
- var newIndexDoc = store.sym(newBase + 'index.html');
250
- var toBeCopied = [{
251
- local: 'index.html',
252
- contentType: 'text/html'
253
- }];
254
- var newInstance = store.sym(newPadDoc.uri + '#thisPad'); // log.debug("\n Ready to put " + kb.statementsMatching(undefined, undefined, undefined, there)); //@@
255
-
256
- var agenda = [];
257
- var f; // @@ This needs some form of visible progress bar
258
-
259
- for (f = 0; f < toBeCopied.length; f++) {
260
- var item = toBeCopied[f];
261
-
262
- var fun = function copyItem(item) {
263
- agenda.push(function () {
264
- var newURI = newBase + item.local;
265
- console.log('Copying ' + base + item.local + ' to ' + newURI);
266
-
267
- var setThatACL = function setThatACL() {
268
- setACL(newURI, false, function (ok, message) {
269
- if (!ok) {
270
- complainIfBad(ok, 'FAILED to set ACL ' + newURI + ' : ' + message);
271
- console.log('FAILED to set ACL ' + newURI + ' : ' + message);
272
- } else {
273
- agenda.shift()(); // beware too much nesting
28
+ var newInstance = (newPaneOptions.newInstance =
29
+ newPaneOptions.newInstance ||
30
+ store.sym(newPaneOptions.newBase + 'index.ttl#this'));
31
+ // const newInstance = kb.sym(newBase + 'pad.ttl#thisPad');
32
+ var newPadDoc = newInstance.doc();
33
+ store.add(newInstance, solid_ui_1.ns.rdf('type'), solid_ui_1.ns.pad('Notepad'), newPadDoc);
34
+ store.add(newInstance, solid_ui_1.ns.dc('title'), 'Shared Notes', newPadDoc);
35
+ store.add(newInstance, solid_ui_1.ns.dc('created'), new Date(), newPadDoc); // @@ TODO Remove casting
36
+ if (newPaneOptions.me) {
37
+ store.add(newInstance, solid_ui_1.ns.dc('author'), newPaneOptions.me, newPadDoc);
38
+ }
39
+ // kb.add(newInstance, ns.pad('next'), newInstance, newPadDoc);
40
+ // linked list empty @@
41
+ var chunk = store.sym(newInstance.uri + '_line0');
42
+ store.add(newInstance, solid_ui_1.ns.pad('next'), chunk, newPadDoc); // Linked list has one entry
43
+ store.add(chunk, solid_ui_1.ns.pad('next'), newInstance, newPadDoc);
44
+ store.add(chunk, solid_ui_1.ns.dc('author'), newPaneOptions.me, newPadDoc);
45
+ store.add(chunk, solid_ui_1.ns.sioc('content'), '', newPadDoc);
46
+ return new Promise(function (resolve, reject) {
47
+ if (!updater) {
48
+ reject(new Error('Have no updater'));
49
+ return;
50
+ }
51
+ updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (uri2, ok, message) {
52
+ if (ok) {
53
+ resolve(newPaneOptions);
54
+ }
55
+ else {
56
+ reject(new Error('FAILED to save new tool at: ' + uri2 + ' : ' + message));
274
57
  }
275
- });
276
- };
277
-
278
- if (!store.fetcher) {
279
- throw new Error('Store has no fetcher');
58
+ });
59
+ });
60
+ },
61
+ // and follow instructions there
62
+ // @@ TODO Set better type for paneOptions
63
+ render: function (subject, context, paneOptions) {
64
+ var dom = context.dom;
65
+ var store = context.session.store;
66
+ // Utility functions
67
+ var complainIfBad = function (ok, message) {
68
+ if (!ok) {
69
+ div.appendChild(solid_ui_1.widgets.errorMessageBlock(dom, message, 'pink'));
70
+ }
71
+ };
72
+ var clearElement = function (ele) {
73
+ while (ele.firstChild) {
74
+ ele.removeChild(ele.firstChild);
280
75
  }
281
-
282
- store.fetcher.webCopy(base + item.local, newBase + item.local, item.contentType).then(function () {
283
- return _solidUi.authn.checkUser();
284
- }).then(function (webId) {
285
- me = webId;
286
- setThatACL();
287
- })["catch"](function (err) {
288
- console.log('FAILED to copy ' + base + item.local + ' : ' + err.message);
289
- complainIfBad(false, 'FAILED to copy ' + base + item.local + ' : ' + err.message);
76
+ return ele;
77
+ };
78
+ // Access control
79
+ // Two constiations of ACL for this app, public read and public read/write
80
+ // In all cases owner has read write control
81
+ var genACLtext = function (docURI, aclURI, allWrite) {
82
+ var g = (0, rdflib_1.graph)();
83
+ var auth = (0, rdflib_1.Namespace)('http://www.w3.org/ns/auth/acl#');
84
+ var a = g.sym(aclURI + '#a1');
85
+ var acl = g.sym(aclURI);
86
+ var doc = g.sym(docURI);
87
+ g.add(a, solid_ui_1.ns.rdf('type'), auth('Authorization'), acl);
88
+ g.add(a, auth('accessTo'), doc, acl);
89
+ g.add(a, auth('agent'), me, acl);
90
+ g.add(a, auth('mode'), auth('Read'), acl);
91
+ g.add(a, auth('mode'), auth('Write'), acl);
92
+ g.add(a, auth('mode'), auth('Control'), acl);
93
+ a = g.sym(aclURI + '#a2');
94
+ g.add(a, solid_ui_1.ns.rdf('type'), auth('Authorization'), acl);
95
+ g.add(a, auth('accessTo'), doc, acl);
96
+ g.add(a, auth('agentClass'), solid_ui_1.ns.foaf('Agent'), acl);
97
+ g.add(a, auth('mode'), auth('Read'), acl);
98
+ if (allWrite) {
99
+ g.add(a, auth('mode'), auth('Write'), acl);
100
+ }
101
+ // TODO: Figure out why `serialize` isn't on the type definition according to TypeScript:
102
+ return (0, rdflib_1.serialize)(acl, g, aclURI, 'text/turtle');
103
+ };
104
+ /**
105
+ * @param docURI
106
+ * @param allWrite
107
+ * @param callbackFunction
108
+ *
109
+ * @returns {Promise<Response>}
110
+ */
111
+ var setACL = function setACL(docURI, allWrite, callbackFunction) {
112
+ var aclDoc = store.any((0, rdflib_1.sym)(docURI), (0, rdflib_1.sym)('http://www.iana.org/assignments/link-relations/acl')); // @@ check that this get set by web.js
113
+ if (!fetcher) {
114
+ throw new Error('Have no fetcher');
115
+ }
116
+ if (aclDoc) {
117
+ // Great we already know where it is
118
+ var aclText = genACLtext(docURI, aclDoc.uri, allWrite);
119
+ return fetcher
120
+ .webOperation('PUT', aclDoc.uri, {
121
+ data: aclText,
122
+ contentType: 'text/turtle'
123
+ })
124
+ .then(function () { return callbackFunction(true); })
125
+ .catch(function (err) {
126
+ callbackFunction(false, err.message);
127
+ });
128
+ }
129
+ else {
130
+ return fetcher
131
+ .load(docURI)
132
+ .catch(function (err) {
133
+ callbackFunction(false, 'Getting headers for ACL: ' + err);
134
+ })
135
+ .then(function () {
136
+ var aclDoc = store.any((0, rdflib_1.sym)(docURI), (0, rdflib_1.sym)('http://www.iana.org/assignments/link-relations/acl'));
137
+ if (!aclDoc) {
138
+ // complainIfBad(false, "No Link rel=ACL header for " + docURI);
139
+ throw new Error('No Link rel=ACL header for ' + docURI);
140
+ }
141
+ var aclText = genACLtext(docURI, aclDoc.uri, allWrite);
142
+ return fetcher.webOperation('PUT', aclDoc.uri, {
143
+ data: aclText,
144
+ contentType: 'text/turtle'
145
+ });
146
+ })
147
+ .then(function () { return callbackFunction(true); })
148
+ .catch(function (err) {
149
+ callbackFunction(false, err.message);
150
+ });
151
+ }
152
+ };
153
+ // Reproduction: spawn a new instance
154
+ //
155
+ // Viral growth path: user of app decides to make another instance
156
+ var newInstanceButton = function () {
157
+ var button = div.appendChild(dom.createElement('button'));
158
+ button.textContent = 'Start another pad';
159
+ button.addEventListener('click', function () {
160
+ return showBootstrap(subject, spawnArea, 'pad');
290
161
  });
291
- });
162
+ return button;
292
163
  };
293
-
294
- fun(item);
295
- }
296
-
297
- agenda.push(function createNewPadDataFile() {
298
- store.add(newInstance, _solidUi.ns.rdf('type'), PAD('Notepad'), newPadDoc); // TODO @@ Remove casting of add
299
-
300
- store.add(newInstance, _solidUi.ns.dc('created'), new Date(), // @@ TODO Remove casting
301
- newPadDoc);
302
-
303
- if (me) {
304
- store.add(newInstance, _solidUi.ns.dc('author'), me, newPadDoc);
305
- }
306
-
307
- store.add(newInstance, PAD('next'), newInstance, newPadDoc); // linked list empty
308
- // Keep a paper trail @@ Revisit when we have non-public ones @@ Privacy
309
-
310
- store.add(newInstance, _solidUi.ns.space('inspiration'), thisInstance, padDoc);
311
- store.add(newInstance, _solidUi.ns.space('inspiration'), thisInstance, newPadDoc);
312
-
313
- if (!updater) {
314
- throw new Error('Have no updater');
315
- }
316
-
317
- updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (_uri2, ok, message) {
318
- if (ok) {
164
+ // Option of either using the workspace system or just typing in a URI
165
+ var showBootstrap = function showBootstrap(thisInstance, container, noun) {
166
+ var div = clearElement(container);
167
+ var appDetails = { noun: 'notepad' };
168
+ div.appendChild(solid_ui_1.authn.newAppInstance(dom, appDetails, function (workspace, newBase) {
169
+ // FIXME: not sure if this will work at all, just
170
+ // trying to get the types to match - Michiel.
171
+ return initializeNewInstanceInWorkspace(new rdflib_1.NamedNode(workspace || newBase));
172
+ }));
173
+ div.appendChild(dom.createElement('hr')); // @@
174
+ var p = div.appendChild(dom.createElement('p'));
175
+ p.textContent =
176
+ 'Where would you like to store the data for the ' +
177
+ noun +
178
+ '? ' +
179
+ 'Give the URL of the directory where you would like the data stored.';
180
+ var baseField = div.appendChild(dom.createElement('input'));
181
+ baseField.setAttribute('type', 'text');
182
+ baseField.size = 80 // really a string
183
+ ;
184
+ baseField.label = 'base URL';
185
+ baseField.autocomplete = 'on';
186
+ div.appendChild(dom.createElement('br')); // @@
187
+ var button = div.appendChild(dom.createElement('button'));
188
+ button.textContent = 'Start new ' + noun + ' at this URI';
189
+ button.addEventListener('click', function (_e) {
190
+ var newBase = baseField.value;
191
+ if (newBase.slice(-1) !== '/') {
192
+ newBase += '/';
193
+ }
194
+ initializeNewInstanceAtBase(thisInstance, newBase);
195
+ });
196
+ };
197
+ // Create new document files for new instance of app
198
+ var initializeNewInstanceInWorkspace = function (ws) {
199
+ // @@ TODO Clean up type for newBase
200
+ var newBase = store.any(ws, solid_ui_1.ns.space('uriPrefix'));
201
+ if (!newBase) {
202
+ newBase = ws.uri.split('#')[0];
203
+ }
204
+ else {
205
+ newBase = newBase.value;
206
+ }
207
+ if (newBase.slice(-1) !== '/') {
208
+ rdflib_1.log.error(appPathSegment + ': No / at end of uriPrefix ' + newBase); // @@ paramater?
209
+ newBase = newBase + '/';
210
+ }
211
+ var now = new Date();
212
+ newBase += appPathSegment + '/id' + now.getTime() + '/'; // unique id
213
+ initializeNewInstanceAtBase(thisInstance, newBase);
214
+ };
215
+ var initializeNewInstanceAtBase = function (thisInstance, newBase) {
216
+ var here = (0, rdflib_1.sym)(thisInstance.uri.split('#')[0]);
217
+ var base = here; // @@ ???
218
+ var newPadDoc = store.sym(newBase + 'pad.ttl');
219
+ var newIndexDoc = store.sym(newBase + 'index.html');
220
+ var toBeCopied = [{ local: 'index.html', contentType: 'text/html' }];
221
+ var newInstance = store.sym(newPadDoc.uri + '#thisPad');
222
+ // log.debug("\n Ready to put " + kb.statementsMatching(undefined, undefined, undefined, there)); //@@
223
+ var agenda = [];
224
+ var f; // @@ This needs some form of visible progress bar
225
+ for (f = 0; f < toBeCopied.length; f++) {
226
+ var item = toBeCopied[f];
227
+ var fun = function copyItem(item) {
228
+ agenda.push(function () {
229
+ var newURI = newBase + item.local;
230
+ console.log('Copying ' + base + item.local + ' to ' + newURI);
231
+ var setThatACL = function () {
232
+ setACL(newURI, false, function (ok, message) {
233
+ if (!ok) {
234
+ complainIfBad(ok, 'FAILED to set ACL ' + newURI + ' : ' + message);
235
+ console.log('FAILED to set ACL ' + newURI + ' : ' + message);
236
+ }
237
+ else {
238
+ agenda.shift()(); // beware too much nesting
239
+ }
240
+ });
241
+ };
242
+ if (!store.fetcher) {
243
+ throw new Error('Store has no fetcher');
244
+ }
245
+ store.fetcher
246
+ .webCopy(base + item.local, newBase + item.local, item.contentType)
247
+ .then(function () { return solid_ui_1.authn.checkUser(); })
248
+ .then(function (webId) {
249
+ me = webId;
250
+ setThatACL();
251
+ })
252
+ .catch(function (err) {
253
+ console.log('FAILED to copy ' + base + item.local + ' : ' + err.message);
254
+ complainIfBad(false, 'FAILED to copy ' + base + item.local + ' : ' + err.message);
255
+ });
256
+ });
257
+ };
258
+ fun(item);
259
+ }
260
+ agenda.push(function createNewPadDataFile() {
261
+ store.add(newInstance, solid_ui_1.ns.rdf('type'), PAD('Notepad'), newPadDoc);
262
+ // TODO @@ Remove casting of add
263
+ store.add(newInstance, solid_ui_1.ns.dc('created'), new Date(), // @@ TODO Remove casting
264
+ newPadDoc);
265
+ if (me) {
266
+ store.add(newInstance, solid_ui_1.ns.dc('author'), me, newPadDoc);
267
+ }
268
+ store.add(newInstance, PAD('next'), newInstance, newPadDoc); // linked list empty
269
+ // Keep a paper trail @@ Revisit when we have non-public ones @@ Privacy
270
+ store.add(newInstance, solid_ui_1.ns.space('inspiration'), thisInstance, padDoc);
271
+ store.add(newInstance, solid_ui_1.ns.space('inspiration'), thisInstance, newPadDoc);
272
+ if (!updater) {
273
+ throw new Error('Have no updater');
274
+ }
275
+ updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (_uri2, ok, message) {
276
+ if (ok) {
277
+ agenda.shift()();
278
+ }
279
+ else {
280
+ complainIfBad(ok, 'FAILED to save new notepad at: ' +
281
+ newPadDoc.uri +
282
+ ' : ' +
283
+ message);
284
+ console.log('FAILED to save new notepad at: ' +
285
+ newPadDoc.uri +
286
+ ' : ' +
287
+ message);
288
+ }
289
+ });
290
+ });
291
+ agenda.push(function () {
292
+ setACL(newPadDoc.uri, true, function (ok, body) {
293
+ complainIfBad(ok, 'Failed to set Read-Write ACL on pad data file: ' + body);
294
+ if (ok)
295
+ agenda.shift()();
296
+ });
297
+ });
298
+ agenda.push(function () {
299
+ // give the user links to the new app
300
+ var p = div.appendChild(dom.createElement('p'));
301
+ p.setAttribute('style', 'font-size: 140%;');
302
+ p.innerHTML =
303
+ "Your <a href='" +
304
+ newIndexDoc.uri +
305
+ "'><b>new notepad</b></a> is ready. " +
306
+ "<br/><br/><a href='" +
307
+ newIndexDoc.uri +
308
+ "'>Go to new pad</a>";
309
+ });
319
310
  agenda.shift()();
320
- } else {
321
- complainIfBad(ok, 'FAILED to save new notepad at: ' + newPadDoc.uri + ' : ' + message);
322
- console.log('FAILED to save new notepad at: ' + newPadDoc.uri + ' : ' + message);
323
- }
324
- });
325
- });
326
- agenda.push(function () {
327
- setACL(newPadDoc.uri, true, function (ok, body) {
328
- complainIfBad(ok, 'Failed to set Read-Write ACL on pad data file: ' + body);
329
- if (ok) agenda.shift()();
330
- });
331
- });
332
- agenda.push(function () {
333
- // give the user links to the new app
334
- var p = div.appendChild(dom.createElement('p'));
335
- p.setAttribute('style', 'font-size: 140%;');
336
- p.innerHTML = "Your <a href='" + newIndexDoc.uri + "'><b>new notepad</b></a> is ready. " + "<br/><br/><a href='" + newIndexDoc.uri + "'>Go to new pad</a>";
337
- });
338
- agenda.shift()(); // Created new data files.
339
- }; // Update on incoming changes
340
-
341
-
342
- var showResults = function showResults(exists) {
343
- console.log('showResults()');
344
- me = _solidUi.authn.currentUser();
345
-
346
- _solidUi.authn.checkUser().then(function (webId) {
347
- me = webId;
348
- });
349
-
350
- var title = store.any(subject, _solidUi.ns.dc('title')) || store.any(subject, _solidUi.ns.vcard('fn'));
351
-
352
- if (paneOptions.solo && typeof window !== 'undefined' && title) {
353
- window.document.title = title.value;
354
- }
355
-
356
- options.exists = exists;
357
- padEle = _solidUi.pad.notepad(dom, padDoc, subject, me, options);
358
- naviMain.appendChild(padEle);
359
- var partipationTarget = store.any(subject, _solidUi.ns.meeting('parentMeeting')) || subject;
360
-
361
- _solidUi.pad.manageParticipation(dom, naviMiddle2, padDoc, partipationTarget, me, options);
362
-
363
- if (!store.updater) {
364
- throw new Error('Store has no updater');
365
- }
366
-
367
- store.updater.setRefreshHandler(padDoc, padEle.reloadAndSync); // initiated =
368
- }; // Read or create empty data file
369
-
370
-
371
- var loadPadData = function loadPadData() {
372
- if (!fetcher) {
373
- throw new Error('Have no fetcher');
374
- }
375
-
376
- fetcher.nowOrWhenFetched(padDoc.uri, undefined, function (ok, body, response) {
377
- if (!ok) {
378
- if (response.status === 404) {
379
- // / Check explicitly for 404 error
380
- console.log('Initializing results file ' + padDoc);
381
-
382
- if (!updater) {
383
- throw new Error('Have no updater');
311
+ // Created new data files.
312
+ };
313
+ // Update on incoming changes
314
+ var showResults = function (exists) {
315
+ console.log('showResults()');
316
+ me = solid_ui_1.authn.currentUser();
317
+ solid_ui_1.authn.checkUser().then(function (webId) {
318
+ me = webId;
319
+ });
320
+ var title = store.any(subject, solid_ui_1.ns.dc('title')) || store.any(subject, solid_ui_1.ns.vcard('fn'));
321
+ if (paneOptions.solo && typeof window !== 'undefined' && title) {
322
+ window.document.title = title.value;
323
+ }
324
+ options.exists = exists;
325
+ padEle = solid_ui_1.pad.notepad(dom, padDoc, subject, me, options);
326
+ naviMain.appendChild(padEle);
327
+ var partipationTarget = store.any(subject, solid_ui_1.ns.meeting('parentMeeting')) || subject;
328
+ solid_ui_1.pad.manageParticipation(dom, naviMiddle2, padDoc, partipationTarget, me, options);
329
+ if (!store.updater) {
330
+ throw new Error('Store has no updater');
331
+ }
332
+ store.updater.setRefreshHandler(padDoc, padEle.reloadAndSync); // initiated =
333
+ };
334
+ // Read or create empty data file
335
+ var loadPadData = function () {
336
+ if (!fetcher) {
337
+ throw new Error('Have no fetcher');
384
338
  }
385
-
386
- updater.put(padDoc, [], 'text/turtle', function (_uri2, ok, message) {
387
- if (ok) {
388
- clearElement(naviMain);
389
- showResults(false);
390
- } else {
391
- complainIfBad(ok, 'FAILED to create results file at: ' + padDoc.uri + ' : ' + message);
392
- console.log('FAILED to craete results file at: ' + padDoc.uri + ' : ' + message);
393
- }
339
+ fetcher.nowOrWhenFetched(padDoc.uri, undefined, function (ok, body, response) {
340
+ if (!ok) {
341
+ if (response.status === 404) {
342
+ // / Check explicitly for 404 error
343
+ console.log('Initializing results file ' + padDoc);
344
+ if (!updater) {
345
+ throw new Error('Have no updater');
346
+ }
347
+ updater.put(padDoc, [], 'text/turtle', function (_uri2, ok, message) {
348
+ if (ok) {
349
+ clearElement(naviMain);
350
+ showResults(false);
351
+ }
352
+ else {
353
+ complainIfBad(ok, 'FAILED to create results file at: ' +
354
+ padDoc.uri +
355
+ ' : ' +
356
+ message);
357
+ console.log('FAILED to craete results file at: ' +
358
+ padDoc.uri +
359
+ ' : ' +
360
+ message);
361
+ }
362
+ });
363
+ }
364
+ else {
365
+ // Other error, not 404 -- do not try to overwite the file
366
+ complainIfBad(ok, 'FAILED to read results file: ' + body);
367
+ }
368
+ }
369
+ else {
370
+ // Happy read
371
+ clearElement(naviMain);
372
+ if (store.holds(subject, solid_ui_1.ns.rdf('type'), solid_ui_1.ns.wf('TemplateInstance'))) {
373
+ showBootstrap(subject, naviMain, 'pad');
374
+ }
375
+ showResults(true);
376
+ naviMiddle3.appendChild(newInstanceButton());
377
+ }
394
378
  });
395
- } else {
396
- // Other error, not 404 -- do not try to overwite the file
397
- complainIfBad(ok, 'FAILED to read results file: ' + body);
398
- }
399
- } else {
400
- // Happy read
401
- clearElement(naviMain);
402
-
403
- if (store.holds(subject, _solidUi.ns.rdf('type'), _solidUi.ns.wf('TemplateInstance'))) {
404
- showBootstrap(subject, naviMain, 'pad');
405
- }
406
-
407
- showResults(true);
408
- naviMiddle3.appendChild(newInstanceButton());
409
- }
410
- });
411
- }; // Body of Pane
412
-
413
-
414
- var appPathSegment = 'app-pad.timbl.com'; // how to allocate this string and connect to
415
-
416
- var fetcher = store.fetcher;
417
- var updater = store.updater;
418
- var me;
419
- var PAD = (0, _rdflib.Namespace)('http://www.w3.org/ns/pim/pad#');
420
- var thisInstance = subject;
421
- var padDoc = subject.doc();
422
- var padEle;
423
- var div = dom.createElement('div'); // Build the DOM
424
-
425
- var structure = div.appendChild(dom.createElement('table')); // @@ make responsive style
426
-
427
- structure.setAttribute('style', 'background-color: white; min-width: 94%; margin-right:3% margin-left: 3%; min-height: 13em;');
428
- var naviLoginoutTR = structure.appendChild(dom.createElement('tr'));
429
- naviLoginoutTR.appendChild(dom.createElement('td')); // naviLoginout1
430
-
431
- naviLoginoutTR.appendChild(dom.createElement('td'));
432
- naviLoginoutTR.appendChild(dom.createElement('td'));
433
- var naviTop = structure.appendChild(dom.createElement('tr')); // stuff
434
-
435
- var naviMain = naviTop.appendChild(dom.createElement('td'));
436
- naviMain.setAttribute('colspan', '3');
437
- var naviMiddle = structure.appendChild(dom.createElement('tr')); // controls
438
-
439
- var naviMiddle1 = naviMiddle.appendChild(dom.createElement('td'));
440
- var naviMiddle2 = naviMiddle.appendChild(dom.createElement('td'));
441
- var naviMiddle3 = naviMiddle.appendChild(dom.createElement('td'));
442
- var naviStatus = structure.appendChild(dom.createElement('tr')); // status etc
443
-
444
- var statusArea = naviStatus.appendChild(dom.createElement('div'));
445
- var naviSpawn = structure.appendChild(dom.createElement('tr')); // create new
446
-
447
- var spawnArea = naviSpawn.appendChild(dom.createElement('div'));
448
- var naviMenu = structure.appendChild(dom.createElement('tr'));
449
- naviMenu.setAttribute('class', 'naviMenu'); // naviMenu.setAttribute('style', 'margin-top: 3em;');
450
-
451
- naviMenu.appendChild(dom.createElement('td')); // naviLeft
452
-
453
- naviMenu.appendChild(dom.createElement('td'));
454
- naviMenu.appendChild(dom.createElement('td'));
455
- var options = {
456
- statusArea: statusArea,
457
- timingArea: naviMiddle1
458
- };
459
- loadPadData();
460
- return div;
461
- }
462
- }; // ends
463
-
464
- var _default = paneDef;
465
- exports["default"] = _default;
379
+ };
380
+ // Body of Pane
381
+ var appPathSegment = 'app-pad.timbl.com'; // how to allocate this string and connect to
382
+ var fetcher = store.fetcher;
383
+ var updater = store.updater;
384
+ var me;
385
+ var PAD = (0, rdflib_1.Namespace)('http://www.w3.org/ns/pim/pad#');
386
+ var thisInstance = subject;
387
+ var padDoc = subject.doc();
388
+ var padEle;
389
+ var div = dom.createElement('div');
390
+ // Build the DOM
391
+ var structure = div.appendChild(dom.createElement('table')); // @@ make responsive style
392
+ structure.setAttribute('style', 'background-color: white; min-width: 94%; margin-right:3% margin-left: 3%; min-height: 13em;');
393
+ var naviLoginoutTR = structure.appendChild(dom.createElement('tr'));
394
+ naviLoginoutTR.appendChild(dom.createElement('td')); // naviLoginout1
395
+ naviLoginoutTR.appendChild(dom.createElement('td'));
396
+ naviLoginoutTR.appendChild(dom.createElement('td'));
397
+ var naviTop = structure.appendChild(dom.createElement('tr')); // stuff
398
+ var naviMain = naviTop.appendChild(dom.createElement('td'));
399
+ naviMain.setAttribute('colspan', '3');
400
+ var naviMiddle = structure.appendChild(dom.createElement('tr')); // controls
401
+ var naviMiddle1 = naviMiddle.appendChild(dom.createElement('td'));
402
+ var naviMiddle2 = naviMiddle.appendChild(dom.createElement('td'));
403
+ var naviMiddle3 = naviMiddle.appendChild(dom.createElement('td'));
404
+ var naviStatus = structure.appendChild(dom.createElement('tr')); // status etc
405
+ var statusArea = naviStatus.appendChild(dom.createElement('div'));
406
+ var naviSpawn = structure.appendChild(dom.createElement('tr')); // create new
407
+ var spawnArea = naviSpawn.appendChild(dom.createElement('div'));
408
+ var naviMenu = structure.appendChild(dom.createElement('tr'));
409
+ naviMenu.setAttribute('class', 'naviMenu');
410
+ // naviMenu.setAttribute('style', 'margin-top: 3em;');
411
+ naviMenu.appendChild(dom.createElement('td')); // naviLeft
412
+ naviMenu.appendChild(dom.createElement('td'));
413
+ naviMenu.appendChild(dom.createElement('td'));
414
+ var options = { statusArea: statusArea, timingArea: naviMiddle1 };
415
+ loadPadData();
416
+ return div;
417
+ }
418
+ };
419
+ // ends
420
+ exports.default = paneDef;
466
421
  //# sourceMappingURL=padPane.js.map