Skip to content

Commit

Permalink
add readme, minor gui adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Jan 8, 2025
1 parent ed0f315 commit 2dda392
Showing 6 changed files with 89 additions and 9 deletions.
4 changes: 2 additions & 2 deletions apps/gui/src/lib/components/partials/ProfileCompact.svelte
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@
<div class="flex flex-nowrap">
<div class="flex-shrink mr-2">
{#if profile?.photo}
<span class="overflow-hidden max-w-8 h-auto">
<img src={profile.photo} alt={profile.photo} class="w-10 h-10 rounded-full" />
<span class="overflow-hidden">
<img src={profile.photo} alt={profile.photo} class="w-10 h-10 block rounded-full" />
</span>
{:else}
<span class="rounded-full overflow-hidden inline-block">
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
</div>
{:else}
<div class="bg-red-500 text-white p-4 rounded-lg">
<p class="text-lg font-bold">NIP-11 requires attentions</p>
<p class="text-lg font-bold">NIP-11 requires attention</p>
</div>
{/if}

Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
export let relayUrl: string;
const busy: Writable<boolean> = writable(false);
const speed: Writable<number | null> = writable(null);
const success: Writable<boolean | null> = writable(null);
const speedometerWidth: Writable<number> = writable(400);
@@ -17,16 +18,19 @@
let resizeObserver: ResizeObserver;
onMount(async () => {
busy.set(true);
nocap = new Nocap(relayUrl);
nocap.on('change', (value: any) => {
console.log('onchange value', value);
});
nocap.useAdapters([WebsocketAdapter]);
const result = await nocap.check('open' as CheckKey);
console.log('speedcard result', result)
busy.set(false);
speed.set(result.open.duration);
success.set(result.open.data)
nocap = null;
if (container) {
resizeObserver = new ResizeObserver(entries => {
@@ -65,7 +69,7 @@
<Card.Title>Speed</Card.Title>
</Card.Header>
<Card.Content class="speedometer-container">
{#if $success}
{#if $success === true && $busy === false}
<div bind:this={container} class="text-center">
{#if value}
<Speedometer
@@ -115,7 +119,11 @@
{/if}
</div>
{:else}
Could not connect.
{#if $busy}
<div>Speed test commencing...</div>
{:else}
<div>Could not connect.</div>
{/if}
{/if}
</Card.Content>
<Card.Footer>
1 change: 1 addition & 0 deletions apps/gui/src/lib/config/dataTable/relays.ts
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ export const tableFormatters: Formatters = {
return `<a class="text-lg" href="/relays/${formatRelayUrl(relay)}">${iconHtml}${formatted}</a>`;
},
dd: (dd: DD ) => {
if(!dd?.lat || !dd?.lon) return '';
return `<span class="text-xs font-bold white/50">${dd.lat.toFixed(3)}, ${dd.lon.toFixed(3)}</span>`
},
lastSeen: (lastSeen) => {
61 changes: 61 additions & 0 deletions libraries/schemata-js-ajv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# @nostrwatch/schemata-js-ajv

A simple library written in Typescript for validating nostr JSON payloads. Presently support validation of notes, several kinds, NIP-11 information documents and some protocol messages. Implements [`@nostrwatch/schemata`](../schemata/)

# important notes

- Very early development
- a lot of false negatives and positives.
- Less than 5 note kinds have been implemented.
- API requires some work.

# install
```
pnpm install @nostrwatch/schemata-js-ajv
```

# usage
```
import { validateNip11, validateMessage, validateNote } from '@nostrwatch/schemata-js-ajv'
const nip11Valid = await validateNip11({ title: "my relay", software: "...", ....})
const relayMessageValid = validateMessage(['NOTICE', this is a notice], 'relay')
const kind1Valid = validateNote({ ... })
```

example success result
```json
{
"status": "success",
"hash": "93dcf578",
"result": {
"valid": true,
"errors": [],
"warnings": []
}
}
```

example fail result
```json
{
"status": "success",
"hash": "3a15ab64",
"result": {
"valid": false,
"errors": [
{
"instancePath": "/contact",
"schemaPath": "#/properties/contact/type",
"keyword": "type",
"params": {
"type": "string"
},
"message": "must be string"
}
],
"warnings": []
}
}
```

18 changes: 14 additions & 4 deletions libraries/schemata/nips/nip-11/schema.yaml
Original file line number Diff line number Diff line change
@@ -24,6 +24,11 @@ properties:
type: number
description: "An array of NIPs that the relay supports."
errorMessage: "Supported NIPs must be an array of numbers."
relay_countries:
type: array
items:
- type: string
pattern: "^[A-Z]{2}$"
software:
type: string
description: "The software that the relay is running."
@@ -33,14 +38,19 @@ properties:
description: "The version of the software that the relay is running."
errorMessage: "Version must be a string."
retention:
allOf:
- $ref: "#/$defs/retent"
description: "The retention policy of the relay."
errorMessage: "Retention must be an object with kinds, count, and time."
type: array
items:
- allOf:
- $ref: "#/$defs/retent"
description: "The retention policy of the relay."
errorMessage: "Retention must be an object with kinds, count, and time."
relay_country:
type: array
items:
type: string
banner:
type: string
pattern: "^https?://"
icon:
type: string
pattern: "^https?://"

0 comments on commit 2dda392

Please sign in to comment.