Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A basic preferences global Pane that allows the user to indicate whether they're a Power User and/or a Developer #157

Merged
merged 11 commits into from
Aug 26, 2019
109 changes: 72 additions & 37 deletions dashboard/basicPreferences.source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const kb = UI.store
export const basicPreferencesPane: PaneDefinition = {
icon: UI.icons.iconBase + 'noun_Sliders_341315_000000.svg',
name: 'basicPreferences',
label: () => null,
label: (subject) => {
megoth marked this conversation as resolved.
Show resolved Hide resolved
return null
},

// Render the pane
// The subject should be the logged in user.
Expand All @@ -21,50 +23,83 @@ export const basicPreferencesPane: PaneDefinition = {

const formArea = container.appendChild(dom.createElement('div'))

/* Preferences
**
** Things like whether to color text by author webid, to expand image URLs inline,
** expanded inline image height. ...
** In general, preferences can be set per user, per user/app combo, per instance,
** and per instance/user combo. (Seee the long chat pane preferences for an example.)
** Here in the basic preferences, we are only setting per-user defaults.
*/

const preferencesFormText = `

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix solid: <http://www.w3.org/ns/solid/terms#>.
@prefix ui: <http://www.w3.org/ns/ui#>.
@prefix : <#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix solid: <http://www.w3.org/ns/solid/terms#>.
@prefix ui: <http://www.w3.org/ns/ui#>.
@prefix : <#>.

:this
<http://purl.org/dc/elements/1.1/title> "Basic preferences" ;
a ui:Form ;
ui:parts ( :personalInformationHeading :privateComment :categorizeUser ).

:personalInformationHeading a ui:Heading; ui:contents "Personal information".
:privateComment a ui:Comment; ui:contents "This information is private.".
:categorizeUser a ui:Classifier; ui:label "Level of user"; ui:property rdf:type ; ui:category solid:User.
`

const ontologyData = `
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix solid: <http://www.w3.org/ns/solid/terms#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix schema: <http:/schema.org/>.
@prefix ui: <http://www.w3.org/ns/ui#>.
@prefix vcard: <http://www.w3.org/2006/vcard/ns#>.
@prefix : <#>.

:this
<http://purl.org/dc/elements/1.1/title> "Basic preferences" ;
a ui:Form ;
ui:part :powerUser, :developerUser;
ui:parts ( :powerUser :developerUser ).
solid:User a rdfs:Class;
rdfs:label "user"@en, "utilisateur"@fr;
rdfs:comment """Any person who might use a Solid-based system""";
rdfs:subClassOf foaf:Person, schema:Person, vcard:Individual.

:powerUser a ui:BooleanField; ui:property solid:powerUser;
ui:label "Color user input by user".
:developerUser a ui:BooleanField; ui:property solid:developerUser;
ui:label "Expand image URLs inline".
:newestFirst a ui:BooleanField; ui:property solid:newestFirst;
ui:label "Newest messages at the top".
# Since these options are opt-in, it is a bit strange to have new users opt in
# That they are new users - also we do not use this class for anything specific
# yet
# solid:NewUser a rdfs:Class;
# rdfs:label "new user"@en;
# rdfs:comment """A person who might use a Solid-based system who has low
# level of familarity with technical details.""";
# rdfs:subClassOf solid:User.

:inlineImageHeightEms a ui:IntegerField; ui:property solid:inlineImageHeightEms;
ui:label "Inline image height (lines)".
solid:PowerUser a rdfs:Class;
rdfs:label "power user"@en;
rdfs:comment """A person who might use a Solid-based system
who is prepared to be given a more complex interface in order
to be provided with more pwerful features.""";
rdfs:subClassOf solid:User.

solid:Developer a rdfs:Class;
rdfs:label "Developer";
rdfs:comment """Any person who might use a Solid-based system,
who has software development skills.""";
rdfs:subClassOf solid:User.
`
const preferencesForm = kb.sym('https://solid.github.io/solid-panes/dashboard/basicPreferencesForm.ttl#this')
const preferencesFormDoc = preferencesForm.doc()
if (!kb.holds(undefined, undefined, undefined, preferencesFormDoc)) { // If not loaded already
(parse as any)(preferencesFormText, kb, preferencesFormDoc.uri, 'text/turtle', null) // Load form directly
function loadData (doc: NamedNode, turtle: String) {
doc = doc.doc() // remove # from URI if nec
if (!kb.holds(undefined, undefined, undefined, doc)) { // If not loaded already
(parse as any)(turtle, kb, doc.uri, 'text/turtle', null) // Load form directly
}
}
// todo make Statement type for fn below
// let preferenceProperties = kb.statementsMatching(null, ns.ui.property, null, preferencesFormDoc).map(function (st: any) { return st.object })
var me = UI.authn.currentUser()
// var context = {noun: 'chat room', me: me, statusArea: statusArea, div: formArea, dom, kb}
// container.appendChild(UI.preferences.renderPreferencesForm(me, mainClass, preferencesForm, context))
UI.widgets.appendForm(dom, formArea, {}, me, preferencesForm, me.doc(), complainIfBad)
const preferencesForm = kb.sym('urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597#this')
loadData(preferencesForm, preferencesFormText)

const ontologyExtra = kb.sym('urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597-ONT')
loadData(ontologyExtra, ontologyData)

async function doRender () {
const context = await UI.authn.logInLoadPreferences({ dom, div: container })
if (!context.preferencesFile) { // Could be CORS
console.log('Not doing private class preferences as no access to preferences file. ' + context.preferencesFileError)
return
}
const appendedForm = UI.widgets.appendForm(dom, formArea, {}, context.me, preferencesForm, context.preferencesFile, complainIfBad)
appendedForm.style.borderStyle = 'none'
}
doRender()

return container
}
}
Expand Down
3 changes: 1 addition & 2 deletions outline/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,7 @@ module.exports = function (doc) {
])
return [
{ paneName: 'home', label: 'Your stuff', icon: UI.icons.iconBase + 'noun_547570.svg' },
// TODO: Fix basicPreferences properly then reintroduce when ready
// { paneName: 'basicPreferences', label: 'Preferences', icon: UI.icons.iconBase + 'noun_Sliders_341315_00000.svg' },
{ paneName: 'basicPreferences', label: 'Preferences', icon: UI.icons.iconBase + 'noun_Sliders_341315_00000.svg' },
{ paneName: 'trustedApplications', label: 'Trusted Apps', icon: UI.icons.iconBase + 'noun_15177.svg.svg' },
{ paneName: 'editProfile', label: 'Edit your profile', icon: UI.icons.iconBase + 'noun_492246.svg' }
]
Expand Down
8 changes: 5 additions & 3 deletions profile/profilePane.source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ const thisPane: PaneDefinition = { // 'noun_638141.svg' not editing

function heading (str: string) {
var h = main.appendChild(dom.createElement('h3'))
h.setAttribute('style', 'color:' + highlightColor + ';')
h.setAttribute('style', 'font-size: 120%; color:' + highlightColor + ';')
h.textContent = str
return h
}

// Todo: only show this if there is
// Todo: only show this if there is vcard info
heading('Contact')
main.appendChild(paneDiv(dom, subject, 'contact'))
const contactDisplay = paneDiv(dom, subject, 'contact')
contactDisplay.border = '0em' // override form
main.appendChild(contactDisplay)

if (kb.holds(subject, ns.foaf('knows'))) {
heading('Solid Friends')
Expand Down
34 changes: 16 additions & 18 deletions versionInfo.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
module.exports = {
buildTime: "2019-08-12T11:47:20Z",
commit: "5102d70b5c3dabfe917d96f6f453a5e7ba01030a",
buildTime: "2019-08-20T14:34:34Z",
commit: "856c7d6d6b33468410d0ae904bf780167b8f34be",
npmInfo:
{
'solid-panes': '1.3.16-3',
npm: '6.10.0',
{ 'solid-panes': '1.4.0',
npm: '6.7.0',
ares: '1.15.0',
brotli: '1.0.7',
cldr: '35.1',
cldr: '34.0',
http_parser: '2.8.0',
icu: '64.2',
llhttp: '1.1.4',
modules: '72',
icu: '63.1',
llhttp: '1.1.1',
modules: '67',
napi: '4',
nghttp2: '1.39.1',
node: '12.7.0',
openssl: '1.1.1c',
tz: '2019a',
unicode: '12.1',
uv: '1.30.1',
v8: '7.5.288.22-node.16',
zlib: '1.2.11'
}
nghttp2: '1.34.0',
node: '11.10.1',
openssl: '1.1.1a',
tz: '2018e',
unicode: '11.0',
uv: '1.26.0',
v8: '7.0.276.38-node.17',
zlib: '1.2.11' }
};