Skip to content

Commit 63db87d

Browse files
committed
WIP implementation of webrings
1 parent e62663a commit 63db87d

19 files changed

+358
-35
lines changed

components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ declare module 'vue' {
2626
SpotifyPlayer: typeof import('./src/components/custom-elements/SpotifyPlayer.vue')['default']
2727
'UserbarBadge.ce': typeof import('./src/components/custom-elements/UserbarBadge.ce.vue')['default']
2828
VaButton: typeof import('vuestic-ui')['VaButton']
29+
VaForm: typeof import('vuestic-ui')['VaForm']
30+
VaInput: typeof import('vuestic-ui')['VaInput']
31+
VaModal: typeof import('vuestic-ui')['VaModal']
32+
VaSelect: typeof import('vuestic-ui')['VaSelect']
2933
'WebampPlayer.ce': typeof import('./src/components/custom-elements/WebampPlayer.ce.vue')['default']
3034
}
3135
}

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="">
33
<head>
44
<meta charset="UTF-8">
5-
<link rel="icon" href="/favicon.ico">
5+
<link rel="icon" href="/src/assets/favicon.ico">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Vite App</title>
88
</head>

lexicons/ring.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"member": {
3636
"type": "object",
3737
"description": "Represents a webring invitation.",
38+
"required": [
39+
"membership"
40+
],
3841
"properties": {
3942
"membership": {
4043
"type": "string",

lexicons/ring.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ defs:
2828
type: object
2929
description: >-
3030
Represents a webring invitation.
31+
required:
32+
- membership
3133
properties:
3234
membership:
3335
type: string

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@atcute/cid": "^1.0.2",
2525
"@atcute/client": "^2.0.6",
2626
"@atcute/oauth-browser-client": "^1.0.7",
27+
"@atcute/tid": "^1.0.1",
2728
"@atproto/syntax": "^0.3.1",
2829
"@mdx-js/mdx": "^3.1.0",
2930
"@noble/hashes": "^1.6.1",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ watchImmediate(prefersDark, prefersDark => {
4242
<VaButton preset="secondary" to="/">Home</VaButton>
4343
<VaButton preset="secondary" to="/edit">Create Page</VaButton>
4444
<VaButton preset="secondary" to="/page/did:plc:nmc77zslrwafxn75j66mep6o/test.mdx">Test Page</VaButton>
45+
<VaButton preset="secondary" to="/rings">My @rings</VaButton>
4546
</template>
4647
</VaNavbar>
4748
</template>

src/assets/favicon.ico

124 KB
Binary file not shown.

src/components/SignInGate.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ watchImmediate(user, user => {
2828
cancel-text="Cancel"
2929
@ok="authenticateIfNecessary(handle).finally(() => open = false)"
3030
>
31-
<VaInput v-model="handle" placeholder="Handle" />
31+
<VaInput v-model="handle" label="@handle" placeholder="e.g. you.bsky.social" />
3232
</VaModal>
3333

3434
</template>

src/lib/atproto/atweb-client.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { KittyAgent } from './kitty-agent';
22
import { parseAtUri } from '../utils';
3-
import type { At, IoGithubAtwebFile } from '@atcute/client/lexicons';
3+
import type { At, IoGithubAtwebFile, IoGithubAtwebRing } from '@atcute/client/lexicons';
44
import { parse as parseMime } from 'file-type-mime';
55
import { toString as ui8ToString, fromString as ui8FromString } from 'uint8arrays';
66
import { user, type Account, type User } from './signed-in-user';
77
import { getDidAndPds } from './pds-helpers';
88
import { AtUri } from '@atproto/syntax';
99
import { filepathToRkey } from './rkey';
1010
import { lookupMime } from '../mime';
11+
import { now as tidNow } from '@atcute/tid';
1112

1213
export class AtwebClient {
1314
get agent(): KittyAgent {
@@ -64,4 +65,63 @@ export class AtwebClient {
6465

6566
return { ...result, rkey };
6667
}
68+
69+
async createRing(
70+
name: string,
71+
creatorMainPage: string,
72+
): Promise<{ cid: At.CID; uri: AtUri; }> {
73+
const tid = tidNow();
74+
75+
const membership = await this.agent.create({
76+
collection: 'io.github.atweb.ringMembership',
77+
repo: this.user.did,
78+
rkey: tid,
79+
record: {
80+
$type: 'io.github.atweb.ringMembership',
81+
ring: AtUri.make(this.user.did, 'io.github.atweb.ring', tid).toString(),
82+
mainPage: AtUri.make(this.user.did, 'io.github.atweb.page', filepathToRkey(creatorMainPage)).toString(),
83+
createdAt: new Date().toISOString(),
84+
}
85+
});
86+
87+
const result = await this.agent.create({
88+
collection: 'io.github.atweb.ring',
89+
repo: this.user.did,
90+
rkey: tid,
91+
record: {
92+
$type: 'io.github.atweb.ring',
93+
name: name,
94+
members: [{
95+
membership: membership.uri,
96+
}],
97+
createdAt: new Date().toISOString(),
98+
}
99+
});
100+
101+
return { ...result, uri: new AtUri(result.uri) };
102+
}
103+
104+
async updateRing(
105+
rkey: string,
106+
ring: IoGithubAtwebRing.Record,
107+
swapRecord?: string,
108+
) {
109+
await this.agent.put({
110+
collection: 'io.github.atweb.ring',
111+
repo: this.user.did,
112+
rkey,
113+
record: ring,
114+
swapRecord
115+
});
116+
}
117+
118+
async deleteRing(
119+
rkey: string
120+
) {
121+
await this.agent.delete({
122+
collection: 'io.github.atweb.ring',
123+
repo: this.user.did,
124+
rkey,
125+
});
126+
}
67127
}

0 commit comments

Comments
 (0)