mashlib-jss 0.0.2 → 0.1.1
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.
- package/dist/103.mashlib.js +287 -0
- package/dist/103.mashlib.js.map +1 -0
- package/dist/103.mashlib.min.js +2 -0
- package/dist/103.mashlib.min.js.map +1 -0
- package/dist/140.mashlib.js +264 -0
- package/dist/140.mashlib.js.map +1 -0
- package/dist/140.mashlib.min.js +2 -0
- package/dist/140.mashlib.min.js.map +1 -0
- package/dist/156.mashlib.js +997 -0
- package/dist/156.mashlib.js.map +1 -0
- package/dist/156.mashlib.min.js +2 -0
- package/dist/156.mashlib.min.js.map +1 -0
- package/dist/172.mashlib.js +67 -0
- package/dist/172.mashlib.js.map +1 -0
- package/dist/172.mashlib.min.js +2 -0
- package/dist/172.mashlib.min.js.map +1 -0
- package/dist/196.mashlib.js +58 -0
- package/dist/196.mashlib.js.map +1 -0
- package/dist/196.mashlib.min.js +2 -0
- package/dist/196.mashlib.min.js.map +1 -0
- package/dist/21.mashlib.js +83 -0
- package/dist/21.mashlib.js.map +1 -0
- package/dist/21.mashlib.min.js +2 -0
- package/dist/21.mashlib.min.js.map +1 -0
- package/dist/289.mashlib.js +11 -0
- package/dist/289.mashlib.js.map +1 -0
- package/dist/289.mashlib.min.js +2 -0
- package/dist/289.mashlib.min.js.map +1 -0
- package/dist/315.mashlib.js +11 -0
- package/dist/315.mashlib.js.map +1 -0
- package/dist/315.mashlib.min.js +1 -0
- package/dist/321.mashlib.js +423 -0
- package/dist/321.mashlib.js.map +1 -0
- package/dist/321.mashlib.min.js +2 -0
- package/dist/321.mashlib.min.js.map +1 -0
- package/dist/322.mashlib.js +3480 -0
- package/dist/322.mashlib.js.map +1 -0
- package/dist/322.mashlib.min.js +2 -0
- package/dist/322.mashlib.min.js.map +1 -0
- package/dist/348.mashlib.js +441 -0
- package/dist/348.mashlib.js.map +1 -0
- package/dist/348.mashlib.min.js +2 -0
- package/dist/348.mashlib.min.js.map +1 -0
- package/dist/371.mashlib.js +438 -0
- package/dist/371.mashlib.js.map +1 -0
- package/dist/371.mashlib.min.js +2 -0
- package/dist/371.mashlib.min.js.map +1 -0
- package/dist/443.mashlib.js +11 -0
- package/dist/443.mashlib.js.map +1 -0
- package/dist/443.mashlib.min.js +2 -0
- package/dist/443.mashlib.min.js.map +1 -0
- package/dist/477.mashlib.js +4522 -0
- package/dist/477.mashlib.js.map +1 -0
- package/dist/477.mashlib.min.js +134 -0
- package/dist/477.mashlib.min.js.map +1 -0
- package/dist/49.mashlib.js +227 -0
- package/dist/49.mashlib.js.map +1 -0
- package/dist/49.mashlib.min.js +15 -0
- package/dist/49.mashlib.min.js.map +1 -0
- package/dist/529.mashlib.js +441 -0
- package/dist/529.mashlib.js.map +1 -0
- package/dist/529.mashlib.min.js +2 -0
- package/dist/529.mashlib.min.js.map +1 -0
- package/dist/587.mashlib.js +196 -0
- package/dist/587.mashlib.js.map +1 -0
- package/dist/587.mashlib.min.js +2 -0
- package/dist/587.mashlib.min.js.map +1 -0
- package/dist/711.mashlib.js +899 -0
- package/dist/711.mashlib.js.map +1 -0
- package/dist/711.mashlib.min.js +2 -0
- package/dist/711.mashlib.min.js.map +1 -0
- package/dist/712.mashlib.js +195 -0
- package/dist/712.mashlib.js.map +1 -0
- package/dist/712.mashlib.min.js +2 -0
- package/dist/712.mashlib.min.js.map +1 -0
- package/dist/714.mashlib.js +157 -0
- package/dist/714.mashlib.js.map +1 -0
- package/dist/714.mashlib.min.js +2 -0
- package/dist/714.mashlib.min.js.map +1 -0
- package/dist/751.mashlib.js +253 -0
- package/dist/751.mashlib.js.map +1 -0
- package/dist/751.mashlib.min.js +2 -0
- package/dist/751.mashlib.min.js.map +1 -0
- package/dist/758.mashlib.js +318 -0
- package/dist/758.mashlib.js.map +1 -0
- package/dist/758.mashlib.min.js +2 -0
- package/dist/758.mashlib.min.js.map +1 -0
- package/dist/804.mashlib.js +517 -0
- package/dist/804.mashlib.js.map +1 -0
- package/dist/804.mashlib.min.js +2 -0
- package/dist/804.mashlib.min.js.map +1 -0
- package/dist/841.mashlib.js +113 -113
- package/dist/841.mashlib.js.map +1 -1
- package/dist/841.mashlib.min.js +7 -7
- package/dist/841.mashlib.min.js.map +1 -1
- package/dist/bookmark-test.html +89 -0
- package/dist/mashlib.js +1588 -14338
- package/dist/mashlib.js.map +1 -1
- package/dist/mashlib.min.js +15 -160
- package/dist/mashlib.min.js.map +1 -1
- package/dist/test-bookmarks.ttl +20 -0
- package/package.json +1 -1
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(self["webpackChunkMashlib"] = self["webpackChunkMashlib"] || []).push([[103],{
|
|
3
|
+
|
|
4
|
+
/***/ 9003
|
|
5
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
|
|
7
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* harmony import */ var solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5138);
|
|
12
|
+
/* harmony import */ var rdflib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8230);
|
|
13
|
+
/**
|
|
14
|
+
* ActivityStreams Pane - Vanilla JS rewrite
|
|
15
|
+
*
|
|
16
|
+
* Displays as:Note content as a styled card.
|
|
17
|
+
* Replaces the React-based activitystreams-pane package (~11MB -> ~3KB)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const ns = solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.ns;
|
|
23
|
+
|
|
24
|
+
// Styles for the note card
|
|
25
|
+
const styles = {
|
|
26
|
+
card: `
|
|
27
|
+
font-family: sans-serif;
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
border-radius: 4px;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
padding: 1em;
|
|
34
|
+
box-shadow: 0 1px 5px rgba(0,0,0,0.2);
|
|
35
|
+
transition: all .25s ease-in-out;
|
|
36
|
+
max-width: 632px;
|
|
37
|
+
`,
|
|
38
|
+
content: `
|
|
39
|
+
font-size: larger;
|
|
40
|
+
margin: 0.5em 0;
|
|
41
|
+
`,
|
|
42
|
+
date: `
|
|
43
|
+
color: rgba(0, 0, 0, 0.6);
|
|
44
|
+
margin: 0.5em 0;
|
|
45
|
+
`,
|
|
46
|
+
attribution: `
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
font-weight: bold;
|
|
50
|
+
`,
|
|
51
|
+
attributionLink: `
|
|
52
|
+
color: black;
|
|
53
|
+
text-decoration: none;
|
|
54
|
+
`,
|
|
55
|
+
attributionImage: `
|
|
56
|
+
margin-right: 5px;
|
|
57
|
+
width: 47px;
|
|
58
|
+
height: 47px;
|
|
59
|
+
border-radius: 5px;
|
|
60
|
+
object-fit: cover;
|
|
61
|
+
`
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Format a date as relative time (e.g., "2 hours ago")
|
|
66
|
+
*/
|
|
67
|
+
function timeAgo(date) {
|
|
68
|
+
const seconds = Math.floor((new Date() - date) / 1000);
|
|
69
|
+
const intervals = [{
|
|
70
|
+
label: 'year',
|
|
71
|
+
seconds: 31536000
|
|
72
|
+
}, {
|
|
73
|
+
label: 'month',
|
|
74
|
+
seconds: 2592000
|
|
75
|
+
}, {
|
|
76
|
+
label: 'week',
|
|
77
|
+
seconds: 604800
|
|
78
|
+
}, {
|
|
79
|
+
label: 'day',
|
|
80
|
+
seconds: 86400
|
|
81
|
+
}, {
|
|
82
|
+
label: 'hour',
|
|
83
|
+
seconds: 3600
|
|
84
|
+
}, {
|
|
85
|
+
label: 'minute',
|
|
86
|
+
seconds: 60
|
|
87
|
+
}];
|
|
88
|
+
for (const interval of intervals) {
|
|
89
|
+
const count = Math.floor(seconds / interval.seconds);
|
|
90
|
+
if (count >= 1) {
|
|
91
|
+
return `${count} ${interval.label}${count > 1 ? 's' : ''} ago`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return 'just now';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Format date for display
|
|
99
|
+
*/
|
|
100
|
+
function formatDate(date) {
|
|
101
|
+
if (!date) return null;
|
|
102
|
+
const formatted = date.toLocaleDateString(undefined, {
|
|
103
|
+
year: 'numeric',
|
|
104
|
+
month: '2-digit',
|
|
105
|
+
day: '2-digit',
|
|
106
|
+
hour: '2-digit',
|
|
107
|
+
minute: '2-digit'
|
|
108
|
+
});
|
|
109
|
+
return `${timeAgo(date)} · ${formatted}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Check if node is a Person type
|
|
114
|
+
*/
|
|
115
|
+
function isPerson(store, node) {
|
|
116
|
+
const types = store.findTypeURIs(node);
|
|
117
|
+
return types[ns.as('Person').uri] || types[ns.foaf('Person').uri] || types[ns.vcard('Individual').uri] || types[ns.schema('Person').uri];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Read person's image URL from store
|
|
122
|
+
*/
|
|
123
|
+
function readImageSrc(store, node) {
|
|
124
|
+
const image = store.anyValue(node, ns.as('image'));
|
|
125
|
+
if (image) {
|
|
126
|
+
return store.anyValue((0,rdflib__WEBPACK_IMPORTED_MODULE_1__.sym)(image), ns.as('url')) || null;
|
|
127
|
+
}
|
|
128
|
+
return store.anyValue(node, ns.foaf('img')) || store.anyValue(node, ns.vcard('hasPhoto')) || null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Read attribution (author) info from store
|
|
133
|
+
*/
|
|
134
|
+
function readAttribution(store, subject) {
|
|
135
|
+
const attributedTo = store.any(subject, ns.as('attributedTo'));
|
|
136
|
+
if (!attributedTo || !attributedTo.uri) {
|
|
137
|
+
return {
|
|
138
|
+
type: 'none'
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (isPerson(store, attributedTo)) {
|
|
142
|
+
const name = store.anyValue(attributedTo, ns.as('name')) || store.anyValue(attributedTo, ns.foaf('name')) || store.anyValue(attributedTo, ns.vcard('fn')) || store.anyValue(attributedTo, ns.schema('name')) || '';
|
|
143
|
+
return {
|
|
144
|
+
type: 'person',
|
|
145
|
+
webId: attributedTo.uri,
|
|
146
|
+
name,
|
|
147
|
+
imageSrc: readImageSrc(store, attributedTo)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
type: 'link',
|
|
152
|
+
uri: attributedTo.uri
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Read note data from store
|
|
158
|
+
*/
|
|
159
|
+
function readNote(store, subject) {
|
|
160
|
+
const content = store.any(subject, ns.as('content'));
|
|
161
|
+
const published = store.any(subject, ns.as('published'));
|
|
162
|
+
if (!content) return null;
|
|
163
|
+
return {
|
|
164
|
+
content: content.value,
|
|
165
|
+
published: published ? new Date(published.value) : null,
|
|
166
|
+
attribution: readAttribution(store, subject)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Create the attribution element
|
|
172
|
+
*/
|
|
173
|
+
function createAttributionElement(doc, attribution) {
|
|
174
|
+
const container = doc.createElement('div');
|
|
175
|
+
container.setAttribute('style', styles.attribution);
|
|
176
|
+
if (attribution.type === 'none') {
|
|
177
|
+
return container;
|
|
178
|
+
}
|
|
179
|
+
if (attribution.type === 'link') {
|
|
180
|
+
const link = doc.createElement('a');
|
|
181
|
+
link.setAttribute('href', attribution.uri);
|
|
182
|
+
link.setAttribute('style', styles.attributionLink);
|
|
183
|
+
link.textContent = attribution.uri;
|
|
184
|
+
container.appendChild(link);
|
|
185
|
+
return container;
|
|
186
|
+
}
|
|
187
|
+
if (attribution.type === 'person') {
|
|
188
|
+
if (attribution.imageSrc) {
|
|
189
|
+
const img = doc.createElement('img');
|
|
190
|
+
img.setAttribute('src', attribution.imageSrc);
|
|
191
|
+
img.setAttribute('alt', attribution.name);
|
|
192
|
+
img.setAttribute('style', styles.attributionImage);
|
|
193
|
+
container.appendChild(img);
|
|
194
|
+
}
|
|
195
|
+
const link = doc.createElement('a');
|
|
196
|
+
link.setAttribute('href', attribution.webId);
|
|
197
|
+
link.setAttribute('style', styles.attributionLink);
|
|
198
|
+
link.textContent = attribution.name || attribution.webId;
|
|
199
|
+
link.addEventListener('mouseover', () => {
|
|
200
|
+
link.style.textDecoration = 'underline';
|
|
201
|
+
});
|
|
202
|
+
link.addEventListener('mouseout', () => {
|
|
203
|
+
link.style.textDecoration = 'none';
|
|
204
|
+
});
|
|
205
|
+
container.appendChild(link);
|
|
206
|
+
}
|
|
207
|
+
return container;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Create the note card element
|
|
212
|
+
*/
|
|
213
|
+
function createNoteCard(doc, note) {
|
|
214
|
+
const card = doc.createElement('div');
|
|
215
|
+
card.setAttribute('style', styles.card);
|
|
216
|
+
|
|
217
|
+
// Attribution (author)
|
|
218
|
+
card.appendChild(createAttributionElement(doc, note.attribution));
|
|
219
|
+
|
|
220
|
+
// Content
|
|
221
|
+
const content = doc.createElement('p');
|
|
222
|
+
content.setAttribute('style', styles.content);
|
|
223
|
+
content.textContent = note.content;
|
|
224
|
+
card.appendChild(content);
|
|
225
|
+
|
|
226
|
+
// Date
|
|
227
|
+
if (note.published) {
|
|
228
|
+
const dateEl = doc.createElement('p');
|
|
229
|
+
dateEl.setAttribute('style', styles.date);
|
|
230
|
+
dateEl.textContent = formatDate(note.published);
|
|
231
|
+
card.appendChild(dateEl);
|
|
232
|
+
}
|
|
233
|
+
return card;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The ActivityStreams Pane
|
|
238
|
+
*/
|
|
239
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
|
240
|
+
icon: solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.icons.iconBase + 'noun_15695.svg',
|
|
241
|
+
name: 'activitystreams',
|
|
242
|
+
label: function (subject, context) {
|
|
243
|
+
const store = context.session.store;
|
|
244
|
+
const types = store.findTypeURIs(subject);
|
|
245
|
+
if (types[ns.as('Note').uri]) {
|
|
246
|
+
return 'Note';
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
},
|
|
250
|
+
render: function (subject, context) {
|
|
251
|
+
const doc = context.dom;
|
|
252
|
+
const store = context.session.store;
|
|
253
|
+
const container = doc.createElement('div');
|
|
254
|
+
const note = readNote(store, subject);
|
|
255
|
+
if (!note) {
|
|
256
|
+
const msg = doc.createElement('p');
|
|
257
|
+
msg.textContent = 'Unable to read note content.';
|
|
258
|
+
container.appendChild(msg);
|
|
259
|
+
return container;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Render initial card
|
|
263
|
+
container.appendChild(createNoteCard(doc, note));
|
|
264
|
+
|
|
265
|
+
// If attribution is just a link, try to fetch and update
|
|
266
|
+
if (note.attribution.type === 'link') {
|
|
267
|
+
const attributionNode = (0,rdflib__WEBPACK_IMPORTED_MODULE_1__.sym)(note.attribution.uri);
|
|
268
|
+
store.fetcher.load(attributionNode).then(() => {
|
|
269
|
+
// Re-read attribution after fetch
|
|
270
|
+
const updatedAttribution = readAttribution(store, subject);
|
|
271
|
+
if (updatedAttribution.type === 'person') {
|
|
272
|
+
note.attribution = updatedAttribution;
|
|
273
|
+
container.innerHTML = '';
|
|
274
|
+
container.appendChild(createNoteCard(doc, note));
|
|
275
|
+
}
|
|
276
|
+
}).catch(() => {
|
|
277
|
+
// Keep original link attribution on error
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
return container;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
/***/ }
|
|
285
|
+
|
|
286
|
+
}]);
|
|
287
|
+
//# sourceMappingURL=103.mashlib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"103.mashlib.js","mappings":";;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEkC;AACN;AAE5B,MAAME,EAAE,GAAGF,4CAAK;;AAEhB;AACA,MAAMG,MAAM,GAAG;EACbC,IAAI,EAAE;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;EACDC,OAAO,EAAE;AACX;AACA;AACA,GAAG;EACDC,IAAI,EAAE;AACR;AACA;AACA,GAAG;EACDC,WAAW,EAAE;AACf;AACA;AACA;AACA,GAAG;EACDC,eAAe,EAAE;AACnB;AACA;AACA,GAAG;EACDC,gBAAgB,EAAE;AACpB;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA,SAASC,OAAOA,CAAEJ,IAAI,EAAE;EACtB,MAAMK,OAAO,GAAGC,IAAI,CAACC,KAAK,CAAC,CAAC,IAAIC,IAAI,CAAC,CAAC,GAAGR,IAAI,IAAI,IAAI,CAAC;EAEtD,MAAMS,SAAS,GAAG,CAChB;IAAEC,KAAK,EAAE,MAAM;IAAEL,OAAO,EAAE;EAAS,CAAC,EACpC;IAAEK,KAAK,EAAE,OAAO;IAAEL,OAAO,EAAE;EAAQ,CAAC,EACpC;IAAEK,KAAK,EAAE,MAAM;IAAEL,OAAO,EAAE;EAAO,CAAC,EAClC;IAAEK,KAAK,EAAE,KAAK;IAAEL,OAAO,EAAE;EAAM,CAAC,EAChC;IAAEK,KAAK,EAAE,MAAM;IAAEL,OAAO,EAAE;EAAK,CAAC,EAChC;IAAEK,KAAK,EAAE,QAAQ;IAAEL,OAAO,EAAE;EAAG,CAAC,CACjC;EAED,KAAK,MAAMM,QAAQ,IAAIF,SAAS,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IACJ;IAEA,OAAO3B,SAAS;EAClB;AACF,CAAC,E","sources":["webpack://Mashlib/../../src/activitystreams/activitystreamsPane.js"],"sourcesContent":["/**\n * ActivityStreams Pane - Vanilla JS rewrite\n *\n * Displays as:Note content as a styled card.\n * Replaces the React-based activitystreams-pane package (~11MB -> ~3KB)\n */\n\nimport * as UI from 'solid-ui-jss'\nimport { sym } from 'rdflib'\n\nconst ns = UI.ns\n\n// Styles for the note card\nconst styles = {\n card: `\n font-family: sans-serif;\n display: flex;\n flex-wrap: wrap;\n border-radius: 4px;\n flex-direction: column;\n justify-content: center;\n padding: 1em;\n box-shadow: 0 1px 5px rgba(0,0,0,0.2);\n transition: all .25s ease-in-out;\n max-width: 632px;\n `,\n content: `\n font-size: larger;\n margin: 0.5em 0;\n `,\n date: `\n color: rgba(0, 0, 0, 0.6);\n margin: 0.5em 0;\n `,\n attribution: `\n display: flex;\n align-items: center;\n font-weight: bold;\n `,\n attributionLink: `\n color: black;\n text-decoration: none;\n `,\n attributionImage: `\n margin-right: 5px;\n width: 47px;\n height: 47px;\n border-radius: 5px;\n object-fit: cover;\n `\n}\n\n/**\n * Format a date as relative time (e.g., \"2 hours ago\")\n */\nfunction timeAgo (date) {\n const seconds = Math.floor((new Date() - date) / 1000)\n\n const intervals = [\n { label: 'year', seconds: 31536000 },\n { label: 'month', seconds: 2592000 },\n { label: 'week', seconds: 604800 },\n { label: 'day', seconds: 86400 },\n { label: 'hour', seconds: 3600 },\n { label: 'minute', seconds: 60 }\n ]\n\n for (const interval of intervals) {\n const count = Math.floor(seconds / interval.seconds)\n if (count >= 1) {\n return `${count} ${interval.label}${count > 1 ? 's' : ''} ago`\n }\n }\n return 'just now'\n}\n\n/**\n * Format date for display\n */\nfunction formatDate (date) {\n if (!date) return null\n const formatted = date.toLocaleDateString(undefined, {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit'\n })\n return `${timeAgo(date)} · ${formatted}`\n}\n\n/**\n * Check if node is a Person type\n */\nfunction isPerson (store, node) {\n const types = store.findTypeURIs(node)\n return types[ns.as('Person').uri] ||\n types[ns.foaf('Person').uri] ||\n types[ns.vcard('Individual').uri] ||\n types[ns.schema('Person').uri]\n}\n\n/**\n * Read person's image URL from store\n */\nfunction readImageSrc (store, node) {\n const image = store.anyValue(node, ns.as('image'))\n if (image) {\n return store.anyValue(sym(image), ns.as('url')) || null\n }\n return store.anyValue(node, ns.foaf('img')) ||\n store.anyValue(node, ns.vcard('hasPhoto')) ||\n null\n}\n\n/**\n * Read attribution (author) info from store\n */\nfunction readAttribution (store, subject) {\n const attributedTo = store.any(subject, ns.as('attributedTo'))\n\n if (!attributedTo || !attributedTo.uri) {\n return { type: 'none' }\n }\n\n if (isPerson(store, attributedTo)) {\n const name = store.anyValue(attributedTo, ns.as('name')) ||\n store.anyValue(attributedTo, ns.foaf('name')) ||\n store.anyValue(attributedTo, ns.vcard('fn')) ||\n store.anyValue(attributedTo, ns.schema('name')) ||\n ''\n return {\n type: 'person',\n webId: attributedTo.uri,\n name,\n imageSrc: readImageSrc(store, attributedTo)\n }\n }\n\n return { type: 'link', uri: attributedTo.uri }\n}\n\n/**\n * Read note data from store\n */\nfunction readNote (store, subject) {\n const content = store.any(subject, ns.as('content'))\n const published = store.any(subject, ns.as('published'))\n\n if (!content) return null\n\n return {\n content: content.value,\n published: published ? new Date(published.value) : null,\n attribution: readAttribution(store, subject)\n }\n}\n\n/**\n * Create the attribution element\n */\nfunction createAttributionElement (doc, attribution) {\n const container = doc.createElement('div')\n container.setAttribute('style', styles.attribution)\n\n if (attribution.type === 'none') {\n return container\n }\n\n if (attribution.type === 'link') {\n const link = doc.createElement('a')\n link.setAttribute('href', attribution.uri)\n link.setAttribute('style', styles.attributionLink)\n link.textContent = attribution.uri\n container.appendChild(link)\n return container\n }\n\n if (attribution.type === 'person') {\n if (attribution.imageSrc) {\n const img = doc.createElement('img')\n img.setAttribute('src', attribution.imageSrc)\n img.setAttribute('alt', attribution.name)\n img.setAttribute('style', styles.attributionImage)\n container.appendChild(img)\n }\n\n const link = doc.createElement('a')\n link.setAttribute('href', attribution.webId)\n link.setAttribute('style', styles.attributionLink)\n link.textContent = attribution.name || attribution.webId\n link.addEventListener('mouseover', () => {\n link.style.textDecoration = 'underline'\n })\n link.addEventListener('mouseout', () => {\n link.style.textDecoration = 'none'\n })\n container.appendChild(link)\n }\n\n return container\n}\n\n/**\n * Create the note card element\n */\nfunction createNoteCard (doc, note) {\n const card = doc.createElement('div')\n card.setAttribute('style', styles.card)\n\n // Attribution (author)\n card.appendChild(createAttributionElement(doc, note.attribution))\n\n // Content\n const content = doc.createElement('p')\n content.setAttribute('style', styles.content)\n content.textContent = note.content\n card.appendChild(content)\n\n // Date\n if (note.published) {\n const dateEl = doc.createElement('p')\n dateEl.setAttribute('style', styles.date)\n dateEl.textContent = formatDate(note.published)\n card.appendChild(dateEl)\n }\n\n return card\n}\n\n/**\n * The ActivityStreams Pane\n */\nexport default {\n icon: UI.icons.iconBase + 'noun_15695.svg',\n\n name: 'activitystreams',\n\n label: function (subject, context) {\n const store = context.session.store\n const types = store.findTypeURIs(subject)\n if (types[ns.as('Note').uri]) {\n return 'Note'\n }\n return null\n },\n\n render: function (subject, context) {\n const doc = context.dom\n const store = context.session.store\n const container = doc.createElement('div')\n\n const note = readNote(store, subject)\n\n if (!note) {\n const msg = doc.createElement('p')\n msg.textContent = 'Unable to read note content.'\n container.appendChild(msg)\n return container\n }\n\n // Render initial card\n container.appendChild(createNoteCard(doc, note))\n\n // If attribution is just a link, try to fetch and update\n if (note.attribution.type === 'link') {\n const attributionNode = sym(note.attribution.uri)\n store.fetcher.load(attributionNode).then(() => {\n // Re-read attribution after fetch\n const updatedAttribution = readAttribution(store, subject)\n if (updatedAttribution.type === 'person') {\n note.attribution = updatedAttribution\n container.innerHTML = ''\n container.appendChild(createNoteCard(doc, note))\n }\n }).catch(() => {\n // Keep original link attribution on error\n })\n }\n\n return container\n }\n}\n"],"names":["UI","sym","ns","styles","card","content","date","attribution","attributionLink","attributionImage","timeAgo","seconds","Math","floor","Date","intervals","label","interval","count","formatDate","formatted","toLocaleDateString","undefined","year","month","day","hour","minute","isPerson","store","node","types","findTypeURIs","as","uri","foaf","vcard","schema","readImageSrc","image","anyValue","readAttribution","subject","attributedTo","any","type","name","webId","imageSrc","readNote","published","value","createAttributionElement","doc","container","createElement","setAttribute","link","textContent","appendChild","img","addEventListener","style","textDecoration","createNoteCard","note","dateEl","icon","icons","iconBase","context","session","render","dom","msg","attributionNode","fetcher","load","then","updatedAttribution","innerHTML","catch"],"ignoreList":[],"sourceRoot":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkMashlib=self.webpackChunkMashlib||[]).push([[103],{9003(t,e,n){n.r(e),n.d(e,{default:()=>d});var i=n(5138),a=n(8230);const r=i.ns,o={card:"\n font-family: sans-serif;\n display: flex;\n flex-wrap: wrap;\n border-radius: 4px;\n flex-direction: column;\n justify-content: center;\n padding: 1em;\n box-shadow: 0 1px 5px rgba(0,0,0,0.2);\n transition: all .25s ease-in-out;\n max-width: 632px;\n ",content:"\n font-size: larger;\n margin: 0.5em 0;\n ",date:"\n color: rgba(0, 0, 0, 0.6);\n margin: 0.5em 0;\n ",attribution:"\n display: flex;\n align-items: center;\n font-weight: bold;\n ",attributionLink:"\n color: black;\n text-decoration: none;\n ",attributionImage:"\n margin-right: 5px;\n width: 47px;\n height: 47px;\n border-radius: 5px;\n object-fit: cover;\n "};function s(t){if(!t)return null;const e=t.toLocaleDateString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return`${function(t){const e=Math.floor((new Date-t)/1e3),n=[{label:"year",seconds:31536e3},{label:"month",seconds:2592e3},{label:"week",seconds:604800},{label:"day",seconds:86400},{label:"hour",seconds:3600},{label:"minute",seconds:60}];for(const t of n){const n=Math.floor(e/t.seconds);if(n>=1)return`${n} ${t.label}${n>1?"s":""} ago`}return"just now"}(t)} · ${e}`}function u(t,e){const n=t.anyValue(e,r.as("image"));return n?t.anyValue((0,a.sym)(n),r.as("url"))||null:t.anyValue(e,r.foaf("img"))||t.anyValue(e,r.vcard("hasPhoto"))||null}function l(t,e){const n=t.any(e,r.as("attributedTo"));if(!n||!n.uri)return{type:"none"};if(function(t,e){const n=t.findTypeURIs(e);return n[r.as("Person").uri]||n[r.foaf("Person").uri]||n[r.vcard("Individual").uri]||n[r.schema("Person").uri]}(t,n)){const e=t.anyValue(n,r.as("name"))||t.anyValue(n,r.foaf("name"))||t.anyValue(n,r.vcard("fn"))||t.anyValue(n,r.schema("name"))||"";return{type:"person",webId:n.uri,name:e,imageSrc:u(t,n)}}return{type:"link",uri:n.uri}}function c(t,e){const n=t.createElement("div");n.setAttribute("style",o.card),n.appendChild(function(t,e){const n=t.createElement("div");if(n.setAttribute("style",o.attribution),"none"===e.type)return n;if("link"===e.type){const i=t.createElement("a");return i.setAttribute("href",e.uri),i.setAttribute("style",o.attributionLink),i.textContent=e.uri,n.appendChild(i),n}if("person"===e.type){if(e.imageSrc){const i=t.createElement("img");i.setAttribute("src",e.imageSrc),i.setAttribute("alt",e.name),i.setAttribute("style",o.attributionImage),n.appendChild(i)}const i=t.createElement("a");i.setAttribute("href",e.webId),i.setAttribute("style",o.attributionLink),i.textContent=e.name||e.webId,i.addEventListener("mouseover",()=>{i.style.textDecoration="underline"}),i.addEventListener("mouseout",()=>{i.style.textDecoration="none"}),n.appendChild(i)}return n}(t,e.attribution));const i=t.createElement("p");if(i.setAttribute("style",o.content),i.textContent=e.content,n.appendChild(i),e.published){const i=t.createElement("p");i.setAttribute("style",o.date),i.textContent=s(e.published),n.appendChild(i)}return n}const d={icon:i.icons.iconBase+"noun_15695.svg",name:"activitystreams",label:function(t,e){return e.session.store.findTypeURIs(t)[r.as("Note").uri]?"Note":null},render:function(t,e){const n=e.dom,i=e.session.store,o=n.createElement("div"),s=function(t,e){const n=t.any(e,r.as("content")),i=t.any(e,r.as("published"));return n?{content:n.value,published:i?new Date(i.value):null,attribution:l(t,e)}:null}(i,t);if(!s){const t=n.createElement("p");return t.textContent="Unable to read note content.",o.appendChild(t),o}if(o.appendChild(c(n,s)),"link"===s.attribution.type){const e=(0,a.sym)(s.attribution.uri);i.fetcher.load(e).then(()=>{const e=l(i,t);"person"===e.type&&(s.attribution=e,o.innerHTML="",o.appendChild(c(n,s)))}).catch(()=>{})}return o}}}}]);
|
|
2
|
+
//# sourceMappingURL=103.mashlib.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"103.mashlib.min.js","mappings":"oJAUA,MAAMA,EAAKC,EAAAA,GAGLC,EAAS,CACbC,KAAM,gSAYNC,QAAS,qDAITC,KAAM,6DAINC,YAAa,6EAKbC,gBAAiB,sDAIjBC,iBAAkB,sHAoCpB,SAASC,EAAYJ,GACnB,IAAKA,EAAM,OAAO,KAClB,MAAMK,EAAYL,EAAKM,wBAAmBC,EAAW,CACnDC,KAAM,UACNC,MAAO,UACPC,IAAK,UACLC,KAAM,UACNC,OAAQ,YAEV,MAAO,GAjCT,SAAkBZ,GAChB,MAAMa,EAAUC,KAAKC,OAAO,IAAIC,KAAShB,GAAQ,KAE3CiB,EAAY,CAChB,CAAEC,MAAO,OAAQL,QAAS,SAC1B,CAAEK,MAAO,QAASL,QAAS,QAC3B,CAAEK,MAAO,OAAQL,QAAS,QAC1B,CAAEK,MAAO,MAAOL,QAAS,OACzB,CAAEK,MAAO,OAAQL,QAAS,MAC1B,CAAEK,MAAO,SAAUL,QAAS,KAG9B,IAAK,MAAMM,KAAYF,EAAW,CAChC,MAAMG,EAAQN,KAAKC,MAAMF,EAAUM,EAASN,SAC5C,GAAIO,GAAS,EACX,MAAO,GAAGA,KAASD,EAASD,QAAQE,EAAQ,EAAI,IAAM,QAE1D,CACA,MAAO,UACT,CAcYC,CAAQrB,QAAWK,GAC/B,CAgBA,SAASiB,EAAcC,EAAOC,GAC5B,MAAMC,EAAQF,EAAMG,SAASF,EAAM7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AAG,QAAQQ,KACf,OAEF,IACT,EAEA6B,OAAQ,SAAUhC,EAAS8B,GACzB,MAAMjB,EAAMiB,EAAQG,IACd1C,EAAQuC,EAAQC,QAAQxC,MACxB2B,EAAYL,EAAIE,cAAc,OAE9BD,EA3GV,SAAmBvB,EAAOS,GACxB,MAAMjC,EAAUwB,EAAMW,IAAIF,EAASrC,EAAGgC,GAAG,YACnC+B,EAAYnC,EAAMW,IAAIF,EAASrC,EAAGgC,GAAG,cAE3C,OAAK5B,EAEE,CACLA,QAASA,EAAQmE,MACjBR,UAAWA,EAAY,IAAI1C,KAAK0C,EAAUQ,OAAS,KACnDjE,YAAa8B,EAAgBR,EAAOS,IALjB,IAOvB,CAgGiBmC,CAAS5C,EAAOS,GAE7B,IAAKc,EAAM,CACT,MAAMsB,EAAMvB,EAAIE,cAAc,KAG9B,OAFAqB,EAAIhB,YAAc,+BAClBF,EAAUD,YAAYmB,GACflB,CACT,CAMA,GAHAA,EAAUD,YAAYL,EAAeC,EAAKC,IAGZ,SAA1BA,EAAK7C,YAAYmC,KAAiB,CACpC,MAAMiC,GAAkBzC,EAAAA,EAAAA,KAAIkB,EAAK7C,YAAYkC,KAC7CZ,EAAM+C,QAAQC,KAAKF,GAAiBG,KAAK,KAEvC,MAAMC,EAAqB1C,EAAgBR,EAAOS,GAClB,WAA5ByC,EAAmBrC,OACrBU,EAAK7C,YAAcwE,EACnBvB,EAAUwB,UAAY,GACtBxB,EAAUD,YAAYL,EAAeC,EAAKC,OAE3C6B,MAAM,OAGX,CAEA,OAAOzB,CACT,E","sources":["webpack://Mashlib/../../src/activitystreams/activitystreamsPane.js"],"sourcesContent":["/**\n * ActivityStreams Pane - Vanilla JS rewrite\n *\n * Displays as:Note content as a styled card.\n * Replaces the React-based activitystreams-pane package (~11MB -> ~3KB)\n */\n\nimport * as UI from 'solid-ui-jss'\nimport { sym } from 'rdflib'\n\nconst ns = UI.ns\n\n// Styles for the note card\nconst styles = {\n card: `\n font-family: sans-serif;\n display: flex;\n flex-wrap: wrap;\n border-radius: 4px;\n flex-direction: column;\n justify-content: center;\n padding: 1em;\n box-shadow: 0 1px 5px rgba(0,0,0,0.2);\n transition: all .25s ease-in-out;\n max-width: 632px;\n `,\n content: `\n font-size: larger;\n margin: 0.5em 0;\n `,\n date: `\n color: rgba(0, 0, 0, 0.6);\n margin: 0.5em 0;\n `,\n attribution: `\n display: flex;\n align-items: center;\n font-weight: bold;\n `,\n attributionLink: `\n color: black;\n text-decoration: none;\n `,\n attributionImage: `\n margin-right: 5px;\n width: 47px;\n height: 47px;\n border-radius: 5px;\n object-fit: cover;\n `\n}\n\n/**\n * Format a date as relative time (e.g., \"2 hours ago\")\n */\nfunction timeAgo (date) {\n const seconds = Math.floor((new Date() - date) / 1000)\n\n const intervals = [\n { label: 'year', seconds: 31536000 },\n { label: 'month', seconds: 2592000 },\n { label: 'week', seconds: 604800 },\n { label: 'day', seconds: 86400 },\n { label: 'hour', seconds: 3600 },\n { label: 'minute', seconds: 60 }\n ]\n\n for (const interval of intervals) {\n const count = Math.floor(seconds / interval.seconds)\n if (count >= 1) {\n return `${count} ${interval.label}${count > 1 ? 's' : ''} ago`\n }\n }\n return 'just now'\n}\n\n/**\n * Format date for display\n */\nfunction formatDate (date) {\n if (!date) return null\n const formatted = date.toLocaleDateString(undefined, {\n year: 'numeric',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit'\n })\n return `${timeAgo(date)} · ${formatted}`\n}\n\n/**\n * Check if node is a Person type\n */\nfunction isPerson (store, node) {\n const types = store.findTypeURIs(node)\n return types[ns.as('Person').uri] ||\n types[ns.foaf('Person').uri] ||\n types[ns.vcard('Individual').uri] ||\n types[ns.schema('Person').uri]\n}\n\n/**\n * Read person's image URL from store\n */\nfunction readImageSrc (store, node) {\n const image = store.anyValue(node, ns.as('image'))\n if (image) {\n return store.anyValue(sym(image), ns.as('url')) || null\n }\n return store.anyValue(node, ns.foaf('img')) ||\n store.anyValue(node, ns.vcard('hasPhoto')) ||\n null\n}\n\n/**\n * Read attribution (author) info from store\n */\nfunction readAttribution (store, subject) {\n const attributedTo = store.any(subject, ns.as('attributedTo'))\n\n if (!attributedTo || !attributedTo.uri) {\n return { type: 'none' }\n }\n\n if (isPerson(store, attributedTo)) {\n const name = store.anyValue(attributedTo, ns.as('name')) ||\n store.anyValue(attributedTo, ns.foaf('name')) ||\n store.anyValue(attributedTo, ns.vcard('fn')) ||\n store.anyValue(attributedTo, ns.schema('name')) ||\n ''\n return {\n type: 'person',\n webId: attributedTo.uri,\n name,\n imageSrc: readImageSrc(store, attributedTo)\n }\n }\n\n return { type: 'link', uri: attributedTo.uri }\n}\n\n/**\n * Read note data from store\n */\nfunction readNote (store, subject) {\n const content = store.any(subject, ns.as('content'))\n const published = store.any(subject, ns.as('published'))\n\n if (!content) return null\n\n return {\n content: content.value,\n published: published ? new Date(published.value) : null,\n attribution: readAttribution(store, subject)\n }\n}\n\n/**\n * Create the attribution element\n */\nfunction createAttributionElement (doc, attribution) {\n const container = doc.createElement('div')\n container.setAttribute('style', styles.attribution)\n\n if (attribution.type === 'none') {\n return container\n }\n\n if (attribution.type === 'link') {\n const link = doc.createElement('a')\n link.setAttribute('href', attribution.uri)\n link.setAttribute('style', styles.attributionLink)\n link.textContent = attribution.uri\n container.appendChild(link)\n return container\n }\n\n if (attribution.type === 'person') {\n if (attribution.imageSrc) {\n const img = doc.createElement('img')\n img.setAttribute('src', attribution.imageSrc)\n img.setAttribute('alt', attribution.name)\n img.setAttribute('style', styles.attributionImage)\n container.appendChild(img)\n }\n\n const link = doc.createElement('a')\n link.setAttribute('href', attribution.webId)\n link.setAttribute('style', styles.attributionLink)\n link.textContent = attribution.name || attribution.webId\n link.addEventListener('mouseover', () => {\n link.style.textDecoration = 'underline'\n })\n link.addEventListener('mouseout', () => {\n link.style.textDecoration = 'none'\n })\n container.appendChild(link)\n }\n\n return container\n}\n\n/**\n * Create the note card element\n */\nfunction createNoteCard (doc, note) {\n const card = doc.createElement('div')\n card.setAttribute('style', styles.card)\n\n // Attribution (author)\n card.appendChild(createAttributionElement(doc, note.attribution))\n\n // Content\n const content = doc.createElement('p')\n content.setAttribute('style', styles.content)\n content.textContent = note.content\n card.appendChild(content)\n\n // Date\n if (note.published) {\n const dateEl = doc.createElement('p')\n dateEl.setAttribute('style', styles.date)\n dateEl.textContent = formatDate(note.published)\n card.appendChild(dateEl)\n }\n\n return card\n}\n\n/**\n * The ActivityStreams Pane\n */\nexport default {\n icon: UI.icons.iconBase + 'noun_15695.svg',\n\n name: 'activitystreams',\n\n label: function (subject, context) {\n const store = context.session.store\n const types = store.findTypeURIs(subject)\n if (types[ns.as('Note').uri]) {\n return 'Note'\n }\n return null\n },\n\n render: function (subject, context) {\n const doc = context.dom\n const store = context.session.store\n const container = doc.createElement('div')\n\n const note = readNote(store, subject)\n\n if (!note) {\n const msg = doc.createElement('p')\n msg.textContent = 'Unable to read note content.'\n container.appendChild(msg)\n return container\n }\n\n // Render initial card\n container.appendChild(createNoteCard(doc, note))\n\n // If attribution is just a link, try to fetch and update\n if (note.attribution.type === 'link') {\n const attributionNode = sym(note.attribution.uri)\n store.fetcher.load(attributionNode).then(() => {\n // Re-read attribution after fetch\n const updatedAttribution = readAttribution(store, subject)\n if (updatedAttribution.type === 'person') {\n note.attribution = updatedAttribution\n container.innerHTML = ''\n container.appendChild(createNoteCard(doc, note))\n }\n }).catch(() => {\n // Keep original link attribution on error\n })\n }\n\n return container\n }\n}\n"],"names":["ns","UI","styles","card","content","date","attribution","attributionLink","attributionImage","formatDate","formatted","toLocaleDateString","undefined","year","month","day","hour","minute","seconds","Math","floor","Date","intervals","label","interval","count","timeAgo","readImageSrc","store","node","image","anyValue","as","sym","foaf","vcard","readAttribution","subject","attributedTo","any","uri","type","types","findTypeURIs","schema","isPerson","name","webId","imageSrc","createNoteCard","doc","note","createElement","setAttribute","appendChild","container","link","textContent","img","addEventListener","style","textDecoration","createAttributionElement","published","dateEl","icon","iconBase","context","session","render","dom","value","readNote","msg","attributionNode","fetcher","load","then","updatedAttribution","innerHTML","catch"],"ignoreList":[],"sourceRoot":""}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
(self["webpackChunkMashlib"] = self["webpackChunkMashlib"] || []).push([[140],{
|
|
2
|
+
|
|
3
|
+
/***/ 1939
|
|
4
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
/* harmony export */ slideshowPane: () => (/* binding */ slideshowPane)
|
|
10
|
+
/* harmony export */ });
|
|
11
|
+
/* harmony import */ var solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5138);
|
|
12
|
+
/* harmony import */ var _solid_better_simple_slideshow__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8100);
|
|
13
|
+
/* harmony import */ var _solid_better_simple_slideshow__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_solid_better_simple_slideshow__WEBPACK_IMPORTED_MODULE_1__);
|
|
14
|
+
/* slideshow Pane
|
|
15
|
+
**
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const ns = solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.ns;
|
|
20
|
+
const slideshowPane = {
|
|
21
|
+
icon: solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.icons.iconBase + 'noun_138712.svg',
|
|
22
|
+
name: 'slideshow',
|
|
23
|
+
audience: [ns.solid('PowerUser')],
|
|
24
|
+
// Does the subject deserve an slideshow pane?
|
|
25
|
+
label: function (subject, context) {
|
|
26
|
+
const store = context.session.store;
|
|
27
|
+
const ns = solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.ns;
|
|
28
|
+
const t = store.findTypeURIs(subject);
|
|
29
|
+
if (t[ns.ldp('Container').uri] || t[ns.ldp('BasicContainer').uri]) {
|
|
30
|
+
const contents = store.each(subject, ns.ldp('contains'));
|
|
31
|
+
let count = 0;
|
|
32
|
+
contents.forEach(function (file) {
|
|
33
|
+
if (solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.widgets.isImage(file)) count++;
|
|
34
|
+
});
|
|
35
|
+
return count > 0 ? 'Slideshow' : null;
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
// See https://github.com/leemark/better-simple-slideshow
|
|
40
|
+
// and follow instructions there
|
|
41
|
+
render: function (subject, context) {
|
|
42
|
+
const dom = context.dom;
|
|
43
|
+
const styleSheet = 'https://leemark.github.io/better-simple-slideshow/css/simple-slideshow-styles.css';
|
|
44
|
+
solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.widgets.addStyleSheet(dom, styleSheet);
|
|
45
|
+
const store = context.session.store;
|
|
46
|
+
const ns = solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.ns;
|
|
47
|
+
const div = dom.createElement('div');
|
|
48
|
+
div.setAttribute('class', 'bss-slides');
|
|
49
|
+
const t = store.findTypeURIs(subject);
|
|
50
|
+
let predicate;
|
|
51
|
+
if (t[ns.ldp('BasicContainer').uri] || t[ns.ldp('Container').uri]) {
|
|
52
|
+
predicate = ns.ldp('contains');
|
|
53
|
+
}
|
|
54
|
+
const images = store.each(subject, predicate); // @@ random order?
|
|
55
|
+
// @@ Ideally: sort by embedded time of image
|
|
56
|
+
images.sort(); // Sort for now by URI
|
|
57
|
+
for (let i = 0; i < images.length; i++) {
|
|
58
|
+
if (!solid_ui_jss__WEBPACK_IMPORTED_MODULE_0__.widgets.isImage(images[i])) continue;
|
|
59
|
+
const figure = div.appendChild(dom.createElement('figure'));
|
|
60
|
+
const img = figure.appendChild(dom.createElement('img'));
|
|
61
|
+
|
|
62
|
+
// get image with authenticated fetch
|
|
63
|
+
store.fetcher._fetch(images[i].uri).then(function (response) {
|
|
64
|
+
return response.blob();
|
|
65
|
+
}).then(function (myBlob) {
|
|
66
|
+
const objectURL = URL.createObjectURL(myBlob);
|
|
67
|
+
img.setAttribute('src', objectURL); // w640 h480 //
|
|
68
|
+
});
|
|
69
|
+
img.setAttribute('width', '100%');
|
|
70
|
+
figure.appendChild(dom.createElement('figcaption'));
|
|
71
|
+
}
|
|
72
|
+
const options = {
|
|
73
|
+
dom
|
|
74
|
+
};
|
|
75
|
+
setTimeout(function () {
|
|
76
|
+
_solid_better_simple_slideshow__WEBPACK_IMPORTED_MODULE_1___default()('.bss-slides', options);
|
|
77
|
+
}, 1000); // Must run after the code which called this
|
|
78
|
+
|
|
79
|
+
return div;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// ends
|
|
84
|
+
|
|
85
|
+
/***/ },
|
|
86
|
+
|
|
87
|
+
/***/ 8100
|
|
88
|
+
(module) {
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
var makeBSS = function (el, options) {
|
|
92
|
+
if (typeof document === 'undefined') {
|
|
93
|
+
var document = options.dom;
|
|
94
|
+
}
|
|
95
|
+
var $slideshows = document.querySelectorAll(el), // a collection of all of the slideshow
|
|
96
|
+
$slideshow = {},
|
|
97
|
+
Slideshow = {
|
|
98
|
+
init: function (el, options) {
|
|
99
|
+
this.counter = 0; // to keep track of current slide
|
|
100
|
+
this.el = el; // current slideshow container
|
|
101
|
+
this.$items = el.querySelectorAll('figure'); // a collection of all of the slides, caching for performance
|
|
102
|
+
this.numItems = this.$items.length; // total number of slides
|
|
103
|
+
options = options || {}; // if options object not passed in, then set to empty object
|
|
104
|
+
options.auto = options.auto || false; // if options.auto object not passed in, then set to false
|
|
105
|
+
this.opts = {
|
|
106
|
+
auto: (typeof options.auto === "undefined") ? false : options.auto,
|
|
107
|
+
speed: (typeof options.auto.speed === "undefined") ? 1500 : options.auto.speed,
|
|
108
|
+
pauseOnHover: (typeof options.auto.pauseOnHover === "undefined") ? false : options.auto.pauseOnHover,
|
|
109
|
+
fullScreen: (typeof options.fullScreen === "undefined") ? false : options.fullScreen,
|
|
110
|
+
swipe: (typeof options.swipe === "undefined") ? false : options.swipe
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
this.$items[0].classList.add('bss-show'); // add show class to first figure
|
|
114
|
+
this.injectControls(el);
|
|
115
|
+
this.addEventListeners(el);
|
|
116
|
+
if (this.opts.auto) {
|
|
117
|
+
this.autoCycle(this.el, this.opts.speed, this.opts.pauseOnHover);
|
|
118
|
+
}
|
|
119
|
+
if (this.opts.fullScreen) {
|
|
120
|
+
this.addFullScreen(this.el);
|
|
121
|
+
}
|
|
122
|
+
if (this.opts.swipe) {
|
|
123
|
+
this.addSwipe(this.el);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
showCurrent: function (i) {
|
|
127
|
+
// increment or decrement this.counter depending on whether i === 1 or i === -1
|
|
128
|
+
if (i > 0) {
|
|
129
|
+
this.counter = (this.counter + 1 === this.numItems) ? 0 : this.counter + 1;
|
|
130
|
+
} else {
|
|
131
|
+
this.counter = (this.counter - 1 < 0) ? this.numItems - 1 : this.counter - 1;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// remove .show from whichever element currently has it
|
|
135
|
+
// http://stackoverflow.com/a/16053538/2006057
|
|
136
|
+
[].forEach.call(this.$items, function (el) {
|
|
137
|
+
el.classList.remove('bss-show');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// add .show to the one item that's supposed to have it
|
|
141
|
+
this.$items[this.counter].classList.add('bss-show');
|
|
142
|
+
},
|
|
143
|
+
injectControls: function (el) {
|
|
144
|
+
// build and inject prev/next controls
|
|
145
|
+
// first create all the new elements
|
|
146
|
+
var spanPrev = document.createElement("span"),
|
|
147
|
+
spanNext = document.createElement("span"),
|
|
148
|
+
docFrag = document.createDocumentFragment();
|
|
149
|
+
|
|
150
|
+
// add classes
|
|
151
|
+
spanPrev.classList.add('bss-prev');
|
|
152
|
+
spanNext.classList.add('bss-next');
|
|
153
|
+
|
|
154
|
+
// add contents
|
|
155
|
+
spanPrev.innerHTML = '«';
|
|
156
|
+
spanNext.innerHTML = '»';
|
|
157
|
+
|
|
158
|
+
// append elements to fragment, then append fragment to DOM
|
|
159
|
+
docFrag.appendChild(spanPrev);
|
|
160
|
+
docFrag.appendChild(spanNext);
|
|
161
|
+
el.appendChild(docFrag);
|
|
162
|
+
},
|
|
163
|
+
addEventListeners: function (el) {
|
|
164
|
+
var that = this;
|
|
165
|
+
el.querySelector('.bss-next').addEventListener('click', function () {
|
|
166
|
+
that.showCurrent(1); // increment & show
|
|
167
|
+
}, false);
|
|
168
|
+
|
|
169
|
+
el.querySelector('.bss-prev').addEventListener('click', function () {
|
|
170
|
+
that.showCurrent(-1); // decrement & show
|
|
171
|
+
}, false);
|
|
172
|
+
|
|
173
|
+
el.onkeydown = function (e) {
|
|
174
|
+
e = e || window.event;
|
|
175
|
+
if (e.keyCode === 37) {
|
|
176
|
+
that.showCurrent(-1); // decrement & show
|
|
177
|
+
} else if (e.keyCode === 39) {
|
|
178
|
+
that.showCurrent(1); // increment & show
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
autoCycle: function (el, speed, pauseOnHover) {
|
|
183
|
+
var that = this,
|
|
184
|
+
interval = window.setInterval(function () {
|
|
185
|
+
that.showCurrent(1); // increment & show
|
|
186
|
+
}, speed);
|
|
187
|
+
|
|
188
|
+
if (pauseOnHover) {
|
|
189
|
+
el.addEventListener('mouseover', function () {
|
|
190
|
+
interval = clearInterval(interval);
|
|
191
|
+
}, false);
|
|
192
|
+
el.addEventListener('mouseout', function () {
|
|
193
|
+
interval = window.setInterval(function () {
|
|
194
|
+
that.showCurrent(1); // increment & show
|
|
195
|
+
}, speed);
|
|
196
|
+
}, false);
|
|
197
|
+
} // end pauseonhover
|
|
198
|
+
|
|
199
|
+
},
|
|
200
|
+
addFullScreen: function(el){
|
|
201
|
+
var that = this,
|
|
202
|
+
fsControl = document.createElement("span");
|
|
203
|
+
|
|
204
|
+
fsControl.classList.add('bss-fullscreen');
|
|
205
|
+
el.appendChild(fsControl);
|
|
206
|
+
el.querySelector('.bss-fullscreen').addEventListener('click', function () {
|
|
207
|
+
that.toggleFullScreen(el);
|
|
208
|
+
}, false);
|
|
209
|
+
},
|
|
210
|
+
addSwipe: function(el){
|
|
211
|
+
var that = this,
|
|
212
|
+
ht = new Hammer(el);
|
|
213
|
+
ht.on('swiperight', function(e) {
|
|
214
|
+
that.showCurrent(-1); // decrement & show
|
|
215
|
+
});
|
|
216
|
+
ht.on('swipeleft', function(e) {
|
|
217
|
+
that.showCurrent(1); // increment & show
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
toggleFullScreen: function(el){
|
|
221
|
+
// https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
|
|
222
|
+
if (!document.fullscreenElement && // alternative standard method
|
|
223
|
+
!document.mozFullScreenElement && !document.webkitFullscreenElement &&
|
|
224
|
+
!document.msFullscreenElement ) { // current working methods
|
|
225
|
+
if (document.documentElement.requestFullscreen) {
|
|
226
|
+
el.requestFullscreen();
|
|
227
|
+
} else if (document.documentElement.msRequestFullscreen) {
|
|
228
|
+
el.msRequestFullscreen();
|
|
229
|
+
} else if (document.documentElement.mozRequestFullScreen) {
|
|
230
|
+
el.mozRequestFullScreen();
|
|
231
|
+
} else if (document.documentElement.webkitRequestFullscreen) {
|
|
232
|
+
el.webkitRequestFullscreen(el.ALLOW_KEYBOARD_INPUT);
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
if (document.exitFullscreen) {
|
|
236
|
+
document.exitFullscreen();
|
|
237
|
+
} else if (document.msExitFullscreen) {
|
|
238
|
+
document.msExitFullscreen();
|
|
239
|
+
} else if (document.mozCancelFullScreen) {
|
|
240
|
+
document.mozCancelFullScreen();
|
|
241
|
+
} else if (document.webkitExitFullscreen) {
|
|
242
|
+
document.webkitExitFullscreen();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
} // end toggleFullScreen
|
|
246
|
+
|
|
247
|
+
}; // end Slideshow object .....
|
|
248
|
+
|
|
249
|
+
// make instances of Slideshow as needed
|
|
250
|
+
[].forEach.call($slideshows, function (el) {
|
|
251
|
+
$slideshow = Object.create(Slideshow);
|
|
252
|
+
$slideshow.init(el, options);
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
if ( true && module.exports) {
|
|
257
|
+
module.exports = makeBSS
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
/***/ }
|
|
262
|
+
|
|
263
|
+
}]);
|
|
264
|
+
//# sourceMappingURL=140.mashlib.js.map
|