From 53f9547cc5cf63a33c71e2389a541983c41b4098 Mon Sep 17 00:00:00 2001 From: Tasia Date: Thu, 22 Feb 2024 13:03:21 +0100 Subject: [PATCH 1/6] style(wiki): use core.js --- apps/wiki/core.css | 125 +++++++++++++++++++++++++++++++++++++ apps/wiki/index.html | 3 +- apps/wiki/tf-collection.js | 13 ++-- apps/wiki/tf-id-picker.js | 3 +- apps/wiki/tf-wiki-app.js | 15 +++-- apps/wiki/tf-wiki-doc.js | 5 +- 6 files changed, 149 insertions(+), 15 deletions(-) create mode 100644 apps/wiki/core.css diff --git a/apps/wiki/core.css b/apps/wiki/core.css new file mode 100644 index 000000000..389dcb6c2 --- /dev/null +++ b/apps/wiki/core.css @@ -0,0 +1,125 @@ +/* + * Tilde Friends core stylesheet + * This is a prototype; things may change based on feedback. + * + * This Software is an external library that is part of + * Tilde Friends and is shared under the MIT license. + * A copy of the license is available at the end of this file. + * + * Inject this file in your app at core.css + * and use this tag to import it: + * + * + * Revision 0 / 2024 M02 19 + */ + +body { + color: white; + font-family: sans-serif; +} + +button, .button { + border: none; + border-radius: 8px; + padding: 8px 12px; + text-align: center; + text-decoration: none; + display: inline-block; + margin: 4px; +} + +button:hover, .button:hover { + filter: brightness(0.75); +} + +button.red, .button.red { + background-color: #bd1e24; + color: white; +} + +button.green, .button.green { + background-color: #18922d; + color: white; +} + +button.blue, .button.blue { + background-color: #0067a7; + color: white; +} + +button.yellow, .button.yellow { + background-color: #ee9600; + color: black; +} + +a:link { + color: #268bd2; +} + +a:visited { + color: #6c71c4; +} + +a:hover { + color: #859900; +} + +a:active { + color: #2aa198; +} + +table { + border-collapse: collapse; + width: 100%; +} + +td, th { + border: 1px solid #ffffff40; + text-align: left; + padding: 8px; +} + +tr:nth-child(even) { + background-color: #ffffff20; +} + +.flex { + display: flex; +} + +.flex-column { + display: flex; + flex-direction: column; +} + +.flex-row { + display: flex; + flex-direction: row; +} + +.inline-flex-row { + display: inline-flex; + flex-direction: row; +} + +/* +Copyright 2024- Cory McWilliams & Tasia Iso + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ \ No newline at end of file diff --git a/apps/wiki/index.html b/apps/wiki/index.html index bfcdec3ba..6671b6473 100644 --- a/apps/wiki/index.html +++ b/apps/wiki/index.html @@ -2,8 +2,9 @@ + - + diff --git a/apps/wiki/tf-collection.js b/apps/wiki/tf-collection.js index 1337602ee..655dfe01c 100644 --- a/apps/wiki/tf-collection.js +++ b/apps/wiki/tf-collection.js @@ -65,28 +65,29 @@ class TfCollectionElement extends LitElement { render() { let self = this; return html` - - ${Object.values(this.collection ?? {}).sort((x, y) => x.name.localeCompare(y.name)).map(x => html``)} - + - - + + - + `; } diff --git a/apps/wiki/tf-id-picker.js b/apps/wiki/tf-id-picker.js index ef9748c2f..dc668ea27 100644 --- a/apps/wiki/tf-id-picker.js +++ b/apps/wiki/tf-id-picker.js @@ -26,7 +26,8 @@ class TfIdentityPickerElement extends LitElement { render() { return html` - ${(this.ids ?? []).map(id => html``)} `; diff --git a/apps/wiki/tf-wiki-app.js b/apps/wiki/tf-wiki-app.js index 17ca2e303..cd4731441 100644 --- a/apps/wiki/tf-wiki-app.js +++ b/apps/wiki/tf-wiki-app.js @@ -240,7 +240,12 @@ class TfCollectionsAppElement extends LitElement { render() { let self = this; return html` + -
+
@@ -248,7 +249,7 @@ class TfWikiDocElement extends LitElement {
πŸ”’ document is private
-
+
-
+
+ Summary

${unsafeHTML(this.markdown(this.title(this.blob)))}

${unsafeHTML(this.markdown(this.summary(this.blob)))} diff --git a/apps/wiki/tildefriends.css b/apps/wiki/tildefriends.css index 23e50fe8d..e3276c2e0 100644 --- a/apps/wiki/tildefriends.css +++ b/apps/wiki/tildefriends.css @@ -100,3 +100,11 @@ tr:nth-child(even) { display: inline-flex; flex-direction: row; } + +.box { + background-color: #00000020; + border: 1px solid grey; + border-radius: 8px; + padding: 16px; + margin: 4px; +} From e361c3f975cda665a8a4a4ae84a87de153a0f8da Mon Sep 17 00:00:00 2001 From: Tasia Date: Thu, 22 Feb 2024 22:34:11 +0100 Subject: [PATCH 4/6] chore(wiki): the `button` class is now optional for input elements --- apps/wiki/tf-collection.js | 2 +- apps/wiki/tf-id-picker.js | 2 +- apps/wiki/tf-wiki-doc.js | 3 ++- apps/wiki/tildefriends.css | 44 +++++++++++++++++++++----------------- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/apps/wiki/tf-collection.js b/apps/wiki/tf-collection.js index 03fb91b04..ca60025f6 100644 --- a/apps/wiki/tf-collection.js +++ b/apps/wiki/tf-collection.js @@ -68,7 +68,7 @@ class TfCollectionElement extends LitElement { return html` - ${Object.values(this.collection ?? {}).sort((x, y) => x.name.localeCompare(y.name)).map(x => html``)} diff --git a/apps/wiki/tf-id-picker.js b/apps/wiki/tf-id-picker.js index ebc89b657..c1d447eec 100644 --- a/apps/wiki/tf-id-picker.js +++ b/apps/wiki/tf-id-picker.js @@ -27,7 +27,7 @@ class TfIdentityPickerElement extends LitElement { render() { return html` - ${(this.ids ?? []).map(id => html``)} `; diff --git a/apps/wiki/tf-wiki-doc.js b/apps/wiki/tf-wiki-doc.js index 5c7ce3adc..9ade7680d 100644 --- a/apps/wiki/tf-wiki-doc.js +++ b/apps/wiki/tf-wiki-doc.js @@ -262,12 +262,13 @@ class TfWikiDocElement extends LitElement {
πŸ”’ document is private
-
+
Summary diff --git a/apps/wiki/tildefriends.css b/apps/wiki/tildefriends.css index e3276c2e0..0c7d0e62d 100644 --- a/apps/wiki/tildefriends.css +++ b/apps/wiki/tildefriends.css @@ -17,7 +17,11 @@ body { font-family: sans-serif; } -button, .button { +button, +.button, +input[type=button], +input[type=submit], +select { border: none; border-radius: 8px; padding: 8px 12px; @@ -25,30 +29,30 @@ button, .button { text-decoration: none; display: inline-block; margin: 4px; -} -button:hover, .button:hover { - filter: brightness(0.75); -} + &.red { + background-color: #bd1e24; + color: white; + } -button.red, .button.red { - background-color: #bd1e24; - color: white; -} + &.green { + background-color: #18922d; + color: white; + } -button.green, .button.green { - background-color: #18922d; - color: white; -} + &.blue { + background-color: #0067a7; + color: white; + } -button.blue, .button.blue { - background-color: #0067a7; - color: white; -} + &.yellow { + background-color: #ee9600; + color: black; + } -button.yellow, .button.yellow { - background-color: #ee9600; - color: black; + &:hover { + filter: brightness(0.75); + } } a:link { From 7822b30dcb56ab5bfdbdf21035d3c9419d013b61 Mon Sep 17 00:00:00 2001 From: Tasia Date: Fri, 23 Feb 2024 10:25:51 +0100 Subject: [PATCH 5/6] Revert "build: Add prettier to the project" This reverts commit 41024ddb7961b04a5688bbc997cb74de6fab4763. --- core/auth.js | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/core/auth.js b/core/auth.js index befd13a29..489810b90 100644 --- a/core/auth.js +++ b/core/auth.js @@ -54,30 +54,8 @@ function makeJwt(payload) { id = ssb.createIdentity(':auth'); } - const final_payload = b64url( - base64Encode( - JSON.stringify( - Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval} - ) - ) - ) - ); - - const jwt = [ - b64url( - base64Encode( - JSON.stringify({ - alg: 'HS256', - typ: 'JWT' - }) - ) - ), - final_payload, - b64url( - ssb.hmacsha256sign(final_payload, ':auth', id) - ) - ].join('.'); - + let final_payload = b64url(base64Encode(JSON.stringify(Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval})))); + let jwt = [b64url(base64Encode(JSON.stringify({alg: 'HS256', typ: 'JWT'}))), final_payload, b64url(ssb.hmacsha256sign(final_payload, ':auth', id))].join('.'); return jwt; } @@ -141,9 +119,7 @@ function hashPassword(password) { * @returns TODOC */ function noAdministrator() { - return !core.globalSettings || - !core.globalSettings.permissions || - !Object.keys(core.globalSettings.permissions).some(function(name) { + return !core.globalSettings || !core.globalSettings.permissions || !Object.keys(core.globalSettings.permissions).some(function(name) { return core.globalSettings.permissions[name].indexOf("administration") != -1; }); } @@ -207,7 +183,6 @@ function isNameValid(name) { function handler(request, response) { // TODO(tasiaiso): split this function let session = getCookies(request.headers).session; - if (request.uri == "/login") { let formData = form.decodeForm(request.query); if (query(request.headers)?.permissions?.authenticated) { From 2d3e108fd97bb686b74526159657006134390376 Mon Sep 17 00:00:00 2001 From: Tasia Date: Fri, 23 Feb 2024 10:29:46 +0100 Subject: [PATCH 6/6] Reapply "build: Add prettier to the project" This reverts commit 7822b30dcb56ab5bfdbdf21035d3c9419d013b61. --- core/auth.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/core/auth.js b/core/auth.js index 489810b90..befd13a29 100644 --- a/core/auth.js +++ b/core/auth.js @@ -54,8 +54,30 @@ function makeJwt(payload) { id = ssb.createIdentity(':auth'); } - let final_payload = b64url(base64Encode(JSON.stringify(Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval})))); - let jwt = [b64url(base64Encode(JSON.stringify({alg: 'HS256', typ: 'JWT'}))), final_payload, b64url(ssb.hmacsha256sign(final_payload, ':auth', id))].join('.'); + const final_payload = b64url( + base64Encode( + JSON.stringify( + Object.assign({}, payload, {exp: (new Date().valueOf()) + kRefreshInterval} + ) + ) + ) + ); + + const jwt = [ + b64url( + base64Encode( + JSON.stringify({ + alg: 'HS256', + typ: 'JWT' + }) + ) + ), + final_payload, + b64url( + ssb.hmacsha256sign(final_payload, ':auth', id) + ) + ].join('.'); + return jwt; } @@ -119,7 +141,9 @@ function hashPassword(password) { * @returns TODOC */ function noAdministrator() { - return !core.globalSettings || !core.globalSettings.permissions || !Object.keys(core.globalSettings.permissions).some(function(name) { + return !core.globalSettings || + !core.globalSettings.permissions || + !Object.keys(core.globalSettings.permissions).some(function(name) { return core.globalSettings.permissions[name].indexOf("administration") != -1; }); } @@ -183,6 +207,7 @@ function isNameValid(name) { function handler(request, response) { // TODO(tasiaiso): split this function let session = getCookies(request.headers).session; + if (request.uri == "/login") { let formData = form.decodeForm(request.query); if (query(request.headers)?.permissions?.authenticated) {