format/prettier

This commit is contained in:
Cory McWilliams 2024-04-13 20:07:39 -04:00
parent 8007e71e1d
commit c52331a23a
8 changed files with 242 additions and 107 deletions

View File

@ -33,7 +33,9 @@ class TfTabConnectionsElement extends LitElement {
render_connection_summary(connection) {
if (connection.address && connection.port) {
return html`<div><small>${connection.address}:${connection.port}</small></div>`;
return html`<div>
<small>${connection.address}:${connection.port}</small>
</div>`;
} else if (connection.tunnel) {
return html`<div>room peer</div>`;
} else {
@ -137,7 +139,11 @@ class TfTabConnectionsElement extends LitElement {
<ul class="w3-ul w3-border">
${this.connections
.filter((x) => x.tunnel === undefined)
.map((x) => html` <li class="w3-bar">${this.render_connection(x)}</li> `)}
.map(
(x) => html`
<li class="w3-bar">${this.render_connection(x)}</li>
`
)}
</ul>
<h2>Stored Connections</h2>
<ul class="w3-ul w3-border">

View File

@ -2,4 +2,4 @@ async function main() {
await app.setDocument(utf8Decode(getFile('index.html')));
}
main();
main();

View File

@ -1,23 +1,36 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">
<link rel="stylesheet" href="fontawesome.min.css">
<link rel="stylesheet" href="regular.min.css">
<link rel="stylesheet" href="solid.min.css">
<link rel="stylesheet" href="brands.min.css">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="w3.css" />
<link rel="stylesheet" href="fontawesome.min.css" />
<link rel="stylesheet" href="regular.min.css" />
<link rel="stylesheet" href="solid.min.css" />
<link rel="stylesheet" href="brands.min.css" />
<style>
body,h1,h2,h3,h4,h5 {font-family: "Poppins", sans-serif}
body {font-size: 16px;}
img {margin-bottom: -8px;}
.mySlides {display: none;}
body,
h1,
h2,
h3,
h4,
h5 {
font-family: 'Poppins', sans-serif;
}
body {
font-size: 16px;
}
img {
margin-bottom: -8px;
}
.mySlides {
display: none;
}
</style>
<base target="_top">
<base target="_top" />
</head>
<body class="w3-content w3-black" style="max-width:1500px;">
<body class="w3-content w3-black" style="max-width: 1500px">
<!-- The App Section -->
<div class="w3-padding-64 w3-white">
<div class="w3-row-padding">
@ -25,48 +38,92 @@
<h1 class="w3-jumbo">
<b>😎 Tilde Friends</b>
</h1>
<h1 class="w3-xxlarge w3-text-green"><b>Make apps and friends from the comfort of your web browser.</b></h1>
<p>Tilde Friends is a platform for building, running, and sharing web applications.</p>
<p>Available for lots of devices:
<h1 class="w3-xxlarge w3-text-green">
<b>Make apps and friends from the comfort of your web browser.</b>
</h1>
<p>
Tilde Friends is a platform for building, running, and sharing web
applications.
</p>
<p>
Available for lots of devices:
<i class="fa-brands fa-linux w3-xlarge"></i>
<i class="fa-brands fa-android w3-xlarge"></i>
<i class="fa-brands fa-apple w3-xlarge"></i>
<i class="fa fa-mobile-screen w3-xlarge"></i>
<i class="fa-brands fa-windows w3-xlarge"></i>
</p>
<a class="w3-button w3-black w3-padding-large" href="https://dev.tildefriends.net/cory/tildefriends/releases"><i class="fa fa-download"></i> Download</a>
<a class="w3-button w3-black w3-padding-large" href="https://www.tildefriends.net/~cory/apps/"><i class="fa fa-link"></i> Try It</a>
<a class="w3-button w3-black w3-padding-large" href="https://dev.tildefriends.net/"><i class="fa fa-mug-hot"></i> Code</a>
<a
class="w3-button w3-black w3-padding-large"
href="https://dev.tildefriends.net/cory/tildefriends/releases"
><i class="fa fa-download"></i> Download</a
>
<a
class="w3-button w3-black w3-padding-large"
href="https://www.tildefriends.net/~cory/apps/"
><i class="fa fa-link"></i> Try It</a
>
<a
class="w3-button w3-black w3-padding-large"
href="https://dev.tildefriends.net/"
><i class="fa fa-mug-hot"></i> Code</a
>
</div>
<div class="w3-col l4 m6">
<img src="tildefriends.png" class="w3-image w3-right w3-hide-small">
<img src="tildefriends.png" class="w3-image w3-right w3-hide-small" />
</div>
</div>
</div>
<!-- Getting Starting Section -->
<div class="w3-indigo w3-center">
<div class="w3-row-padding w3-padding-64 ">
<div class="w3-jumbo"><i class="fa fa-rocket"></i> <b>Getting Started</b></div>
<div class="w3-row-padding w3-padding-64">
<div class="w3-jumbo">
<i class="fa fa-rocket"></i> <b>Getting Started</b>
</div>
<div>
<h2>First-time user checklist:</h2>
<ol type="1" style="text-align: left">
<li><a href="https://dev.tildefriends.net/cory/tildefriends/releases">Download</a>
Tilde Friends and run your own instance, or use
<a href="https://www.tildefriends.net/">https://www.tildefriends.net/</a>.</li>
<li>Create an account to identify yourself with that instance by username and password.</li>
<li>Create an SSB identity in the <b>ssb</b> app. This will generate a keypair used to
identify yourself to other users and sign your messages so that they can be verified as from you.</li>
<li>Describe yourself in your profile in the <b>ssb</b> app. Give yourself a name and an avatar if you like.</li>
<li>Connect to others. You will automatically discover peers on the
same instance and same network if there are any. Or use
<a href="https://github.com/staltz/ssb-room/blob/master/FAQ.md">rooms</a>
and pubs to reach more distant users.
<a href="https://www.tildefriends.net/~cory/room/">tildefriends.net itself</a>
operates as a room, so you can connect and see who else is online and establish
a connection.</li>
<li>
<a href="https://dev.tildefriends.net/cory/tildefriends/releases"
>Download</a
>
Tilde Friends and run your own instance, or use
<a href="https://www.tildefriends.net/"
>https://www.tildefriends.net/</a
>.
</li>
<li>
Create an account to identify yourself with that instance by
username and password.
</li>
<li>
Create an SSB identity in the <b>ssb</b> app. This will generate a
keypair used to identify yourself to other users and sign your
messages so that they can be verified as from you.
</li>
<li>
Describe yourself in your profile in the <b>ssb</b> app. Give
yourself a name and an avatar if you like.
</li>
<li>
Connect to others. You will automatically discover peers on the
same instance and same network if there are any. Or use
<a href="https://github.com/staltz/ssb-room/blob/master/FAQ.md"
>rooms</a
>
and pubs to reach more distant users.
<a href="https://www.tildefriends.net/~cory/room/"
>tildefriends.net itself</a
>
operates as a room, so you can connect and see who else is online
and establish a connection.
</li>
<li>Follow people to grow your network.</li>
<li>Use the <b>edit</b> link at the top of any page to start modifying and making apps.</li>
<li>
Use the <b>edit</b> link at the top of any page to start modifying
and making apps.
</li>
</ol>
</div>
</div>
@ -74,21 +131,30 @@
<!-- SSB Section -->
<div class="w3-light-grey">
<div class="w3-row-padding w3-padding-64 ">
<div class="w3-row-padding w3-padding-64">
<div class="w3-col l4 m6 s4">
<a href="https://scuttlebutt.nz/"><img class="w3-image w3-round-large" src="ssb.png" alt="Secure Scuttlebutt"></a>
<a href="https://scuttlebutt.nz/"
><img
class="w3-image w3-round-large"
src="ssb.png"
alt="Secure Scuttlebutt"
/></a>
</div>
<div class="w3-col l8 m6" style="height: auto">
<h1 class="w3-jumbo"><b>Built for Sharing</b></h1>
<p>
Tilde Friends participates in the <a href="https://scuttlebutt.nz/">Secure Scuttlebutt</a> distributed social network.
Tilde Friends participates in the
<a href="https://scuttlebutt.nz/">Secure Scuttlebutt</a> distributed
social network.
</p>
<p>
Share apps with friends. Discover new apps made by enemies. Post pictures of your coffee. Or just lurk.
Share apps with friends. Discover new apps made by enemies. Post
pictures of your coffee. Or just lurk.
</p>
<p>
The social network integration provides tools for connecting with other people world-wide
while still allowing apps and everything to operate offline.
The social network integration provides tools for connecting with
other people world-wide while still allowing apps and everything to
operate offline.
</p>
</div>
</div>
@ -99,14 +165,16 @@
<div class="w3-row-padding">
<div class="w3-col l8 m6">
<h1 class="w3-jumbo"><b>Edit Anything</b></h1>
<i class="fa fa-pen-to-square w3-left w3-jumbo w3-text-gray" style="padding: 32px"></i>
<i
class="fa fa-pen-to-square w3-left w3-jumbo w3-text-gray"
style="padding: 32px"
></i>
<p>
See that <code><b>edit</b></code> link near the top left corner of this page? It's there for
every Tilde Friends app, so you can modify and see your changes right away.
</p>
<p>
It's kind of like a wiki, but for code!
See that <code><b>edit</b></code> link near the top left corner of
this page? It's there for every Tilde Friends app, so you can modify
and see your changes right away.
</p>
<p>It's kind of like a wiki, but for code!</p>
</div>
</div>
</div>
@ -115,16 +183,22 @@
<div class="w3-padding-64 w3-grey">
<div class="w3-row-padding">
<div class="w3-col">
<h1 class="w3-jumbo" style="text-align: right"><b>Sandbox Security</b></h1>
<i class="fa fa-road-barrier w3-right w3-jumbo w3-text-yellow" style="padding: 32px"></i>
<h1 class="w3-jumbo" style="text-align: right">
<b>Sandbox Security</b>
</h1>
<i
class="fa fa-road-barrier w3-right w3-jumbo w3-text-yellow"
style="padding: 32px"
></i>
<p>
Tilde Friends tries to make sure apps can be trusted using similar techniques to how web
browsers and operating systems do it.
Tilde Friends tries to make sure apps can be trusted using similar
techniques to how web browsers and operating systems do it.
</p>
<p>
This is all a work in progress, and it varies by platform, so don't give it all your
innermost secrets yet, but do kick its tires and
<a href="mailto:cory@tildefriends.net">share</a> any surprises you find.
This is all a work in progress, and it varies by platform, so don't
give it all your innermost secrets yet, but do kick its tires and
<a href="mailto:cory@tildefriends.net">share</a> any surprises you
find.
</p>
</div>
</div>
@ -134,10 +208,16 @@
<div class="w3-container w3-padding-64 w3-light-grey w3-center">
<h1 class="w3-jumbo"><b>Trusted Technology</b></h1>
<p>Tilde Friends is built using boring, trusted tech.</p>
<p>Though of course for building Tilde Friends apps, you are free to use whatever fits.</p>
<p>
Though of course for building Tilde Friends apps, you are free to use
whatever fits.
</p>
<div class="w3-row" style="margin-top:64px">
<a href="https://en.wikipedia.org/wiki/C_(programming_language)" class="w3-col s3">
<div class="w3-row" style="margin-top: 64px">
<a
href="https://en.wikipedia.org/wiki/C_(programming_language)"
class="w3-col s3"
>
<i class="fa fa-c w3-text-blue w3-jumbo"></i>
<p>C</p>
</a>
@ -155,7 +235,7 @@
</a>
</div>
<div class="w3-row" style="margin-top:64px">
<div class="w3-row" style="margin-top: 64px">
<a href="https://www.zlib.net/" class="w3-col s3">
<i class="fa fa-file-zipper w3-text-cyan w3-jumbo"></i>
<p>zlib</p>
@ -166,15 +246,18 @@
</a>
<a href="https://www.openssl.org/" class="w3-col s3">
<i class="fa fa-shield-halved w3-text-green w3-jumbo"></i>
<p>OpenSSL </p>
<p>OpenSSL</p>
</a>
<a href="https://github.com/ianlancetaylor/libbacktrace" class="w3-col s3">
<a
href="https://github.com/ianlancetaylor/libbacktrace"
class="w3-col s3"
>
<i class="fa fa-burst w3-text-pink w3-jumbo"></i>
<p>libbacktrace</p>
</a>
</div>
<div class="w3-row" style="margin-top:64px">
<div class="w3-row" style="margin-top: 64px">
<a href="https://codemirror.net/docs/changelog/" class="w3-col s3">
<i class="fa fa-keyboard w3-text-indigo w3-jumbo"></i>
<p>CodeMirror</p>
@ -196,7 +279,10 @@
<!-- Footer -->
<footer class="w3-container w3-padding-32 w3-blue-grey w3-center w3-xlarge">
<p class="w3-medium">This page and Tilde Friends itself was made by Cory mostly in coffee shops and a local pizza place.</p>
<p class="w3-medium">
This page and Tilde Friends itself was made by Cory mostly in coffee
shops and a local pizza place.
</p>
</footer>
</body>
</html>
</html>

View File

@ -145,7 +145,11 @@ function socket(request, response, client) {
action: 'session',
credentials: credentials,
identities: await ssb.getIdentities(credentials?.session?.name),
identity: await core.getActiveIdentity(credentials?.session?.name, packageOwner, packageName),
identity: await core.getActiveIdentity(
credentials?.session?.name,
packageOwner,
packageName
),
parentApp: parentApp,
id: blobId,
}),

View File

@ -81,16 +81,16 @@
<h1 ?hidden=${this.name === undefined}>Welcome, ${this.name}.</h1>
<div style="display: flex; flex-direction: row; width: 100%">
<input type="radio" name="tab" id="login" value="Login" ?checked=${this.tab == 'login'} @change=${() => self.tab = 'login'}></input>
<input type="radio" name="tab" id="login" value="Login" ?checked=${this.tab == 'login'} @change=${() => (self.tab = 'login')}></input>
<label for="login" id="login_label">Login</label>
<input type="radio" name="tab" id="register" value="Register" ?checked=${this.tab == 'register'} @change=${() => self.tab = 'register'}></input>
<input type="radio" name="tab" id="register" value="Register" ?checked=${this.tab == 'register'} @change=${() => (self.tab = 'register')}></input>
<label for="register" id="register_label">Register</label>
<input type="radio" name="tab" id="guest" value="Guest" ?checked=${this.tab == 'guest'} @change=${() => self.tab = 'guest'}></input>
<input type="radio" name="tab" id="guest" value="Guest" ?checked=${this.tab == 'guest'} @change=${() => (self.tab = 'guest')}></input>
<label for="guest" id="guest_label">Guest</label>
<input type="radio" name="tab" id="change" value="Change Password" ?checked=${this.tab == 'change'} @change=${() => self.tab = 'change'}></input>
<input type="radio" name="tab" id="change" value="Change Password" ?checked=${this.tab == 'change'} @change=${() => (self.tab = 'change')}></input>
<label for="change" id="change_label">Change Password</label>
</div>

View File

@ -121,11 +121,17 @@ class TfNavigationElement extends LitElement {
*/
render_login() {
if (this?.credentials?.session?.name) {
return html`<a class="w3-bar-item w3-right" id="login" href="/login/logout?return=${url() + hash()}"
return html`<a
class="w3-bar-item w3-right"
id="login"
href="/login/logout?return=${url() + hash()}"
>logout ${this.credentials.session.name}</a
>`;
} else {
return html`<a class="w3-bar-item w3-right" id="login" href="/login?return=${url() + hash()}"
return html`<a
class="w3-bar-item w3-right"
id="login"
href="/login?return=${url() + hash()}"
>login</a
>`;
}
@ -146,8 +152,11 @@ class TfNavigationElement extends LitElement {
<select
@change=${this.set_active_identity}
class="w3-button w3-cyan w3-bar-item w3-right"
style="max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap">
${this.identities.map(x => html`<option ?selected=${x === this.identity}>${x}</option>`)}
style="max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap"
>
${this.identities.map(
(x) => html`<option ?selected=${x === this.identity}>${x}</option>`
)}
</select>
`;
} else {
@ -155,7 +164,8 @@ class TfNavigationElement extends LitElement {
<link type="text/css" rel="stylesheet" href="/static/w3.css" />
<button
@click=${this.create_identity}
class="w3-button w3-blue w3-right">
class="w3-button w3-blue w3-right"
>
Create an Identity
</button>
`;
@ -226,9 +236,7 @@ class TfNavigationElement extends LitElement {
display: inline-block;
}
</style>
<div
class="w3-black w3-bar"
>
<div class="w3-black w3-bar">
<span
class="w3-bar-item"
style="cursor: pointer"
@ -237,7 +245,8 @@ class TfNavigationElement extends LitElement {
>
<span
class="w3-bar-item"
style=${'white-space: nowrap' + (this.show_version ? '' : '; display: none')}
style=${'white-space: nowrap' +
(this.show_version ? '' : '; display: none')}
title=${this.version?.name +
' ' +
Object.entries(this.version || {})
@ -280,20 +289,21 @@ class TfNavigationElement extends LitElement {
@click=${() => (self.show_permissions = !self.show_permissions)}
>🎛</a
>
${status.message ? html`
<span
class="w3-bar-item"
style="vertical-align: top; white-space: pre; color: ${this
.status.color ?? kErrorColor}"
>${this.status.message}</span
>
` : undefined}
${status.message
? html`
<span
class="w3-bar-item"
style="vertical-align: top; white-space: pre; color: ${this
.status.color ?? kErrorColor}"
>${this.status.message}</span
>
`
: undefined}
${this.render_permissions()}
${Object.keys(this.spark_lines)
.sort()
.map((x) => this.spark_lines[x])}
${this.render_login()}
${this.render_identity()}
${this.render_login()} ${this.render_identity()}
</div>
`;
}

View File

@ -272,7 +272,13 @@ function broadcast(message) {
* @param {*} argv
* @returns
*/
function broadcastAppEventToUser(user, packageOwner, packageName, eventName, argv) {
function broadcastAppEventToUser(
user,
packageOwner,
packageName,
eventName,
argv
) {
let promises = [];
for (let process of Object.values(gProcesses)) {
if (
@ -533,21 +539,40 @@ async function getProcessBlob(blobId, key, options) {
url: options?.url,
},
};
process.sendIdentities = async function() {
process.sendIdentities = async function () {
process.app.send({
action: 'identities',
identities: await ssb.getIdentities(process?.credentials?.session?.name),
identity: await getActiveIdentity(process?.credentials?.session?.name, options.packageOwner, options.packageName),
identities: await ssb.getIdentities(
process?.credentials?.session?.name
),
identity: await getActiveIdentity(
process?.credentials?.session?.name,
options.packageOwner,
options.packageName
),
});
};
process.setActiveIdentity = async function(identity) {
if (process?.credentials?.session?.name && options.packageOwner && options.packageName) {
await new Database(process?.credentials?.session?.name).set(`id:${options.packageOwner}:${options.packageName}`, identity);
process.setActiveIdentity = async function (identity) {
if (
process?.credentials?.session?.name &&
options.packageOwner &&
options.packageName
) {
await new Database(process?.credentials?.session?.name).set(
`id:${options.packageOwner}:${options.packageName}`,
identity
);
}
process.sendIdentities();
broadcastAppEventToUser(process?.credentials?.session?.name, options.packageOwner, options.packageName, 'setActiveIdentity', [identity]);
broadcastAppEventToUser(
process?.credentials?.session?.name,
options.packageOwner,
options.packageName,
'setActiveIdentity',
[identity]
);
};
process.createIdentity = async function() {
process.createIdentity = async function () {
if (
process.credentials &&
process.credentials.session &&
@ -557,7 +582,7 @@ async function getProcessBlob(blobId, key, options) {
await process.sendIdentities();
return id;
}
}
};
if (process.credentials?.permissions?.administration) {
imports.core.globalSettingsDescriptions = function () {
let settings = Object.assign({}, k_global_settings);
@ -655,8 +680,13 @@ async function getProcessBlob(blobId, key, options) {
});
}
};
imports.ssb.setActiveIdentity = id => process.setActiveIdentity(id);
imports.ssb.getActiveIdentity = () => getActiveIdentity(process.credentials?.session?.name, options.packageOwner, options.packageName);
imports.ssb.setActiveIdentity = (id) => process.setActiveIdentity(id);
imports.ssb.getActiveIdentity = () =>
getActiveIdentity(
process.credentials?.session?.name,
options.packageOwner,
options.packageName
);
imports.ssb.getOwnerIdentities = function () {
if (options.packageOwner) {
return ssb.getIdentities(options.packageOwner);
@ -1502,7 +1532,6 @@ function storePermission(user, packageOwner, packageName, permission, allow) {
}
}
async function getActiveIdentity(user, packageOwner, packageName) {
if (user && packageOwner && packageName) {
let id = await new Database(user).get(`id:${packageOwner}:${packageName}`);

View File

@ -474,7 +474,7 @@ static JSValue _httpd_auth_query(JSContext* context, JSValueConst this_val, int
JSValue settings_value = settings ? JS_ParseJSON(context, settings, strlen(settings), NULL) : JS_UNDEFINED;
JSValue permissions = JS_GetPropertyStr(context, settings_value, "permissions");
JSValue user_permissions = JS_GetPropertyStr(context, permissions, name_string);
int length = !JS_IsUndefined(user_permissions) ? tf_util_get_length(context, user_permissions) : 0 ;
int length = !JS_IsUndefined(user_permissions) ? tf_util_get_length(context, user_permissions) : 0;
for (int i = 0; i < length; i++)
{
JSValue permission = JS_GetPropertyUint32(context, user_permissions, i);