Skip to content

Commit fb83acf

Browse files
author
Tim Berners-Lee
committed
Tweaks to support green plus
1 parent 56d71d2 commit fb83acf

8 files changed

Lines changed: 43 additions & 47 deletions

File tree

src/authn/authn.ts

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { AppDetails, AuthenticationContext } from './types'
3030
import { PaneDefinition } from 'pane-registry'
3131
import * as debug from '../debug'
3232
import { graph, namedNode, NamedNode, Namespace, serialize, st, Statement, sym, UpdateManager } from 'rdflib'
33+
import { textInputStyle, buttonStyle, commentStyle } from '../style'
3334

3435
export { solidAuthClient }
3536

@@ -658,6 +659,7 @@ export function registrationControl (
658659
export function registrationList (context: AuthenticationContext, options: {
659660
private?: boolean
660661
public?: boolean
662+
type?: NamedNode
661663
}): Promise<AuthenticationContext> {
662664
const dom = context.dom as HTMLDocument
663665
const div = context.div as HTMLElement
@@ -689,16 +691,13 @@ export function registrationList (context: AuthenticationContext, options: {
689691

690692
for (let i = 0; i < sts.length; i++) {
691693
const statement: Statement = sts[i]
694+
if (options.type) { // now check terms:forClass
695+
if (!kb.holds(statement.subject, ns.solid('forClass'), options.type, statement.why)) {
696+
continue // skip irrelevant ones
697+
}
698+
}
692699
// const cla = statement.subject
693700
const inst = statement.object
694-
// if (false) {
695-
// const tr = table.appendChild(dom.createElement('tr'))
696-
// const anchor = tr.appendChild(dom.createElement('a'))
697-
// anchor.setAttribute('href', inst.uri)
698-
// anchor.textContent = utils.label(inst)
699-
// } else {
700-
// }
701-
702701
table.appendChild(widgets.personTR(dom, ns.solid('instance'), inst, {
703702
deleteFunction: function (_x) {
704703
kb.updater.update([statement], [], function (uri, ok, errorBody) {
@@ -710,7 +709,7 @@ export function registrationList (context: AuthenticationContext, options: {
710709
})
711710
}
712711
}))
713-
}
712+
} // registrationList
714713

715714
/*
716715
//const containers = kb.each(theClass, ns.solid('instanceContainer'));
@@ -915,7 +914,7 @@ function signInOrSignUpBox (
915914
debug.log('widgets.signInOrSignUpBox')
916915
box.setUserCallback = setUserCallback
917916
box.setAttribute('class', magicClassName)
918-
box.style = 'display:flex;'
917+
;(box as any).style = 'display:flex;' // @@ fix all typecasts like this
919918

920919
// Sign in button with PopUP
921920
const signInPopUpButton = dom.createElement('input') // multi
@@ -1204,29 +1203,22 @@ export function selectWorkspace (
12041203
let newBase = null
12051204

12061205
// A workspace specifically defined in the private preference file:
1207-
let w = kb
1208-
.statementsMatching(
1209-
id,
1210-
ns.space('workspace'), // Only trust preference file here
1211-
undefined,
1212-
preferencesFile
1213-
)
1214-
.map(function (st) {
1215-
return st.object
1216-
})
1206+
let w = kb.each(id, ns.space('workspace'), undefined, preferencesFile) // Only trust preference file here
12171207

12181208
// A workspace in a storage in the public profile:
12191209
const storages = kb.each(id, ns.space('storage')) // @@ No provenance requirement at the moment
1220-
storages.map(function (s) {
1221-
w = w.concat(kb.each(s, ns.ldp('contains')))
1222-
})
1210+
if (w.length === 0 && storages) {
1211+
say(`You don't seem to have any workspaces. You have ${storages.length} storage spaces.`)
1212+
storages.map(function (s) {
1213+
w = w.concat(kb.each(s, ns.ldp('contains')))
1214+
}).filter(file => ['public', 'private'].includes(file.id().toLowerCase()))
1215+
}
12231216

12241217
if (w.length === 1) {
12251218
say(`Workspace used: ${w[0].uri}`) // @@ allow user to see URI
12261219
newBase = figureOutBase(w[0])
12271220
// callbackWS(w[0], newBase)
12281221
} else if (w.length === 0) {
1229-
say(`You don't seem to have any workspaces. You have ${storages.length} storage spaces.`)
12301222
}
12311223

12321224
// Prompt for ws selection or creation
@@ -1243,10 +1235,13 @@ export function selectWorkspace (
12431235
box.appendChild(dom.createElement('hr')) // @@
12441236

12451237
const p = box.appendChild(dom.createElement('p'))
1246-
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.`
1238+
;(p as any).style = commentStyle
1239+
p.textContent = `Where would you like to store the data for the ${noun}?
1240+
Give the URL of the directory where you would like the data stored.`
12471241
// @@ TODO Remove the need to cast baseField to any
12481242
const baseField: any = box.appendChild(dom.createElement('input'))
12491243
baseField.setAttribute('type', 'text')
1244+
;(baseField as any).style = textInputStyle
12501245
baseField.size = 80 // really a string
12511246
baseField.label = 'base URL'
12521247
baseField.autocomplete = 'on'
@@ -1260,6 +1255,7 @@ export function selectWorkspace (
12601255
box.appendChild(dom.createElement('br')) // @@
12611256

12621257
const button = box.appendChild(dom.createElement('button'))
1258+
;(button as any).style = buttonStyle
12631259
button.textContent = `Start new ${noun} at this URI`
12641260
button.addEventListener('click', function (_event) {
12651261
let newBase = baseField.value
@@ -1294,10 +1290,8 @@ export function selectWorkspace (
12941290
tr.appendChild(col1)
12951291
}
12961292
col2 = dom.createElement('td')
1297-
style = kb.any(ws, ns.ui('style'))
1298-
if (style) {
1299-
style = style.value
1300-
} else {
1293+
style = kb.anyValue(ws, ns.ui('style'))
1294+
if (!style) {
13011295
// Otherwise make up arbitrary colour
13021296
const hash = function (x) {
13031297
return x.split('').reduce(function (a, b) {

src/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function newThingUI (createContext, dataBrowserContext, thePanes) {
167167
} // callbackWS
168168

169169
var pa = options.pane
170-
options.appPathSegment = 'edu.mit.solid.pane.' + pa.name
170+
options.appPathSegment = pa.name // was 'edu.mit.solid.pane.'
171171
options.noun = pa.mintClass ? UI.utils.label(pa.mintClass) : pa.name
172172

173173
if (!options.folder) {

src/icons/noun_Document_998605.svg

Lines changed: 1 addition & 0 deletions
Loading

src/icons/noun_copy_2018813.svg

Lines changed: 1 addition & 1 deletion
Loading

src/icons/noun_list_638112.svg

Lines changed: 1 addition & 0 deletions
Loading

src/style.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
'background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em; ',
1010
buttonStyle:
1111
'background-color: #fff; padding: 0.7em; border: .01em solid white; border-radius:0.2em; font-size: 100%;', // 'background-color: #eef;
12-
12+
commentStyle: 'padding: 0.7em; border: none; font-size: 100%;',
1313
iconStyle: 'width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;',
1414
classIconStyle: 'width: 3em; height: 3em; margin: 0.1em; border-radius: 0; border: 0.1em solid green; padding: 0.2em; background-color: #efe;', // combine with buttonStyle
1515

@@ -25,6 +25,7 @@ module.exports = {
2525

2626
formBorderColor: '#888888', // originall was brown now grey
2727
formHeadingColor: '#888888', // originall was brown now grey
28+
formHeadingStyle: 'font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em;', // originall was brown now grey
2829
formTextInput: 'font-size: 100%; margin: 0.1em; padding: 0.1em;', // originally used this
2930

3031
multilineTextInputStyle: 'font-size:100%; white-space: pre-wrap; background-color: #eef;' +

src/widgets/forms.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -420,19 +420,18 @@ forms.field[ns.ui('Multiple').uri] = function (
420420
}
421421

422422
var body = box.appendChild(dom.createElement('tr')) // 20191207
423-
var list // The RDF collection which keeps the ordered version or
424-
var values // Initial values - an array. Even when no list yet.
425-
426-
// var unsavedList = false // Flag that
423+
var list // The RDF collection which keeps the ordered version or null
424+
var values // Initial values - always an array. Even when no list yet.
427425
values = reverse ? kb.any(null, property, subject) : kb.any(subject, property)
428426
if (ordered) {
429-
list = values
427+
list = reverse ? kb.any(null, property, subject) : kb.any(subject, property)
430428
if (list) {
431429
values = list.elements
432430
} else {
433431
values = []
434432
}
435433
} else {
434+
values = reverse ? kb.each(null, property, subject) : kb.each(subject, property)
436435
list = null
437436
}
438437
// Add control on the bottom for adding more items
@@ -442,7 +441,7 @@ forms.field[ns.ui('Multiple').uri] = function (
442441
var img = tail.appendChild(dom.createElement('img'))
443442
img.setAttribute('src', plusIconURI) // plus sign
444443
img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em')
445-
img.title = 'Click to add one or more ' + utils.predicateLabel(property, reverse) // @@ use inverse label if
444+
img.title = 'Click to add one or more ' + utils.predicateLabel(property, reverse)
446445
var prompt = tail.appendChild(dom.createElement('span'))
447446
prompt.textContent =
448447
(values.length === 0 ? 'Add one or more ' : 'Add more ') +
@@ -742,6 +741,7 @@ forms.field[ns.ui('Choice').uri] = function (
742741
return error.errorMessageBlock(dom, "No 'from' for Choice: " + form)
743742
}
744743
var subForm = kb.any(form, ui('use')) // Optional
744+
var follow = kb.anyJS(form, ui('follow')) // data doc moves to new subject?
745745
var possible = []
746746
var possibleProperties
747747
var np = '--' + utils.label(property) + '-?'
@@ -778,11 +778,10 @@ forms.field[ns.ui('Choice').uri] = function (
778778
already,
779779
object,
780780
subForm,
781-
store,
781+
follow ? object.doc() : store,
782782
callbackFunction
783783
)
784784
}
785-
// box.appendChild(dom.createTextNode('Choice: subForm='+subForm))
786785
var possible2 = forms.sortByLabel(possible)
787786
if (kb.any(form, ui('canMintNew'))) {
788787
opts.mint = '* New *' // @@ could be better
@@ -833,10 +832,7 @@ forms.field[ns.ui('Comment').uri] = forms.field[
833832
var p = box.appendChild(dom.createElement(params.element))
834833
p.textContent = contents
835834

836-
var style = kb.any(form, ui('style'))
837-
if (style === undefined) {
838-
style = params.style ? params.style : ''
839-
}
835+
var style = kb.anyValue(form, ui('style')) || params.style || ''
840836
if (style) p.setAttribute('style', style)
841837

842838
return box
@@ -1286,6 +1282,9 @@ forms.makeSelectForOptions = function (
12861282
'.'
12871283
)
12881284
}
1285+
if (options.mint && !options.subForm) {
1286+
return error.errorMessageBlock(dom, "Selector: can't mint new with no subform.")
1287+
}
12891288
UI.log.debug('makeSelectForOptions: store=' + store)
12901289

12911290
var getActual = function () {
@@ -1632,7 +1631,7 @@ function buildCheckboxForm (dom, kb, lab, del, ins, form, store, tristate) {
16321631
input.state = state
16331632
input.textContent = {
16341633
true: checkMarkCharacter,
1635-
false: cancelCharacter,
1634+
false: tristate ? cancelCharacter : ' ', // Just use blank when not tristate
16361635
null: dashCharacter
16371636
}[displayState]
16381637
}

src/widgets/forms/fieldParams.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ns from '../../ns'
2-
import { formHeadingColor } from '../../style'
2+
import { formHeadingColor, formHeadingStyle } from '../../style'
33

44
export type FieldParamsObject = {
55
size?: number, // input element size attribute
@@ -105,6 +105,6 @@ export const fieldParams: { [ fieldUri: string ]: FieldParamsObject } = {
105105
},
106106
[ns.ui('Heading').uri]: {
107107
element: 'h3',
108-
style: `font-size: 110%; color: ${formHeadingColor};`
108+
style: `font-size: 110%; font-weight: bold; color: ${formHeadingColor}; padding: 0.2em;`
109109
}
110110
}

0 commit comments

Comments
 (0)