Skip to content

Commit

Permalink
Squashed commit
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Brown <[email protected]>
Co-authored-by: Sandwich <[email protected]>
Co-authored-by: dskvr <[email protected]>
  • Loading branch information
3 people committed Apr 13, 2024
1 parent 0140843 commit abc3ed7
Show file tree
Hide file tree
Showing 318 changed files with 14,252 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
build
*lock*
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: deploy
on:
- push
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: build
run: |
ls -la
yarn install
yarn build
- name: get-npm-version
id: package-version
uses: martinbeentjes/[email protected]

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}

- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hostsa

- name: Deploy with rsync
run: |
TARGET_DIR="/var/www/html/${{ steps.package-version.outputs.current-version}}"
rsync -a --rsync-path="mkdir -p $TARGET_DIR && rsync" ./build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:$TARGET_DIR
- name: Update symlink
run: |
sudo rm -f /var/www/html/latest
sudo ln -sf /var/www/html/${{ steps.package-version.outputs.current-version}} /var/www/html/latest
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.DS_Store
node_modules
build
.svelte-kit
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
yarn.lock
pnpm-lock.yaml
3 changes: 3 additions & 0 deletions .vscode
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"css.customData": [".vscode/tailwind.json"]
}
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#builder
FROM node:alpine as builder
WORKDIR /usr/src/app
COPY . ./
RUN yarn install
RUN yarn build
#server
FROM nginx:alpine
COPY --from=builder /usr/src/app/build /usr/share/nginx/html
110 changes: 109 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,109 @@
# myrelay.site
# myrelay.page

Your relay is awesome, its landing page should be too.

_**A nostr.watch R&D project made possible by [OpenSats](https://opensats.org)**_

<img width="1019" alt="Screen Shot 2024-04-10 at 5 26 19 AM" src="https://github.com/sandwichfarm/myrelay.page/assets/299465/338cd5d3-21a5-492a-8e2d-ac1d128acfa2">

## why
That websocket URI representing your relay is floating all over the internet now. Its canonical `https` shouldn't be a `500`, a blank page or some random page. + I both need to do this to eat my own dog food and it's something I've wanted to do since early 2023.

## overview
SvelteKit CSR site with SSR disabled that implements `ndk`, `nostr-zap` and `@nostrwatch/nocap`. Utilizes `NIP-65`, `NIP-66`, `NIP-78` and `NIP-115`.

**Why SvelteKit if no SSR?**: No justification other than habit. Convert it in a PR and I won't complain.

## todo
- general
- [x] `tailwind`
- [x] `shadcn-svelete` UI components
- [x] progressive load w/skeletons
- [x] NIP-07 support
- [ ] NIP-46 support
- [ ] mobile compat
- blocks
- [x] nip-11
- [x] operator profile/feed
- [x] map
- [x] relay feed
- [ ] speed test (need to patch @nostrwatch/nocap)
- stateful meta-data
- [x] nip-11
- [x] operator profile
- [x] operator notes
- [x] notes from relay
- [ ] long-form content feed
- [x] NIP-19 encoded nevent jumps
- [x] relay Geodata
- [ ] NIP-66 Monitor Data
- [x] seen by monitors
- [x] round-trip time of monitors
- [ ] map reactiveness
- [ ] ssl
- [ ] uptime
- parsing
- [x] notes: images
- [x] notes: videos
- [ ] notes: spotify
- [ ] notes: tidal
- [ ] notes: NIP-19 encoded `nostr:` links
- authed User Interactivity
- [x] login
- [x] add relay to relay list [`10002`]
- [x] zap relay operator
- [ ] follow relay operator
- [x] "People you follow who are here"
- [ ] "Notes you have here"
- no-build customization via NIP-78
- general
- [ ] theme import
- [x] show/hide blocks
- [x] order blocks
- [ ] per block customization
- [ ] hide login
- [ ] disable join
- runtime-imported CSR blocks (svelte)
- [ ] http/https
- [ ] custom block imports
- [ ] custom block options
- [ ] git
- [ ] custom block imports
- [ ] custom block options
- [ ] blossom
- [ ] custom block imports
- [ ] custom block options
- internationalization (i18n)
- [ ] i18n mapped language
- [ ] NIP-78 overrides

## dev

_early alpha_, things will change, history will be full of haphazard commit messages, force pushes to reset history eminent ... but have at it.

### build

```
pnpm install
pnpm build
```

Artifacts will end up in the `build` directory. You just neeed to serve them.

### docker
```
docker build .
```

### notes
You can test relays on localhost by appending `?url=wss://relay.snort.social` for instance.

Image is not yet on a registry.

### serving from canonical

Depending on your relay software, you'll need to do some proxying to direct websocket, NIP-11 and/or NIP-05 traffic to your relay, and `https` traffic without `application/nostr+json` to a page.

#### nginx/caddy/haproxy
_examples soon_, see https://relaypag.es for a live example

22 changes: 22 additions & 0 deletions caddy/strfry/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$YOUR_RELAY_URL {

#...other stuff

@websocket {
header Upgrade websocket
}
reverse_proxy @websocket http://127.0.0.1:7777 {
header_up X-Real-IP {remote_host}
}

@nostrJson header Accept application/nostr+json
reverse_proxy @nostrJson http://127.0.0.1:7777 {
header_down Content-Type "application/nostr+json; charset=utf-8"
}

root * /var/www/html
file_server

}


14 changes: 14 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://shadcn-svelte.com/schema.json",
"style": "default",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app.pcss",
"baseColor": "slate"
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
},
"typescript": true
}
7 changes: 7 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
myrelaypage:
image: myrelaypage
container_name: myrelaypage
restart: always
ports:
- "8080:80"
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
moduleNameMapper: {
'^\\$lib/(.*)$': '<rootDir>/src/lib/$1',
},
};
75 changes: 75 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "myrelay.site",
"type": "module",
"version": "0.1.0",
"main": "index.js",
"repository": "[email protected]:sandwichfarm/myrelay.site.git",
"author": "dskvr <[email protected]>",
"license": "MIT",
"scripts": {
"dev": "vite dev",
"build": "yarn prepare && vite build",
"prepare": "yarn build:themes",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test": "vitest",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"scn": "cross-env COMPONENTS_REGISTRY_URL=http://localhost:5173 pnpm shadcn-svelte",
"reset": "node ./reset.js",
"build:themes": "node ./scripts/build-themes.js"
},
"dependencies": {
"@emotion/css": "11.11.2",
"@internationalized/date": "3.5.2",
"@nostr-dev-kit/ndk": "2.6.1",
"@nostr-dev-kit/ndk-cache-dexie": "2.2.10",
"@sveltejs/kit": "2.5.4",
"@sveltejs/vite-plugin-svelte": "3.0.2",
"@unovis/svelte": "1.3.5",
"@unovis/ts": "1.3.5",
"bits-ui": "0.21.1",
"clsx": "2.1.0",
"cmdk-sv": "0.0.16",
"embla-carousel-svelte": "8.0.0",
"formsnap": "1.0.0",
"jsonpack": "1.1.5",
"lucide-svelte": "0.363.0",
"mode-watcher": "0.3.0",
"nostr-zap": "0.22.0",
"paneforge": "0.0.2",
"promise-deferred": "2.0.4",
"svelte": "4.2.12",
"svelte-geolocation": "0.3.0",
"svelte-i18n": "4.0.0",
"svelte-preprocess": "5.1.3",
"svelte-skeleton-loader": "0.1.4",
"svelte-sonner": "0.3.19",
"svelte-time": "0.8.2",
"sveltekit-superforms": "2.12.0",
"tailwind-merge": "2.2.2",
"tailwind-variants": "0.2.1",
"tseep": "1.2.1",
"vaul-svelte": "0.3.0",
"vite-plugin-mkcert": "1.17.5",
"vitest": "1.4.0",
"zod": "3.22.4"
},
"devDependencies": {
"@sveltejs/adapter-static": "3.0.1",
"@testing-library/jest-dom": "6.4.2",
"@testing-library/svelte": "4.1.0",
"autoprefixer": "^10.4.16",
"happy-dom": "14.5.1",
"jsdom": "24.0.0",
"postcss": "8.4.38",
"postcss-load-config": "^5.0.2",
"rollup-plugin-postcss": "4.0.2",
"svelte-bricks": "0.2.1",
"svelte-check": "3.6.9",
"tailwindcss": "^3.3.6",
"typescript": "5.4.3",
"vite-plugin-dynamic-import": "1.5.0"
}
}
8 changes: 8 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const tailwindcss = require("tailwindcss");
const autoprefixer = require("autoprefixer");

const config = {
plugins: [tailwindcss(),autoprefixer()]
};

module.exports = config;
53 changes: 53 additions & 0 deletions scripts/build-themes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import postcss from 'postcss';
import fs from 'fs/promises';
import path from 'path';
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
import postcssimport from "postcss-import";
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import customTailwindConfig from '../tailwind.config.themes.js';

const plugins = [
postcssimport(),
tailwindcss(),
autoprefixer()
];

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const sourceDir = path.join(__dirname, '../src/lib/assets/themes');
const outputDir = path.join(__dirname, '../static/themes');

async function processCssFile(filename) {
const inputPath = path.join(sourceDir, filename);
const outputPath = path.join(outputDir, filename);

try {
const css = await fs.readFile(inputPath);
const result = await postcss(plugins).process(css, { from: inputPath, to: outputPath });
await fs.writeFile(outputPath, result.css);
if (result.map) {
await fs.writeFile(`${outputPath}.map`, result.map.toString());
}
console.log(`Processed ${filename}`);
} catch (err) {
console.error(`Error processing ${filename}:`, err);
}
}

async function processAllCssFiles() {
try {
const files = await fs.readdir(sourceDir);
const cssFiles = files.filter(file => path.extname(file) === '.css');

for (const filename of cssFiles) {
await processCssFile(filename);
}
} catch (err) {
console.error('Error processing files:', err);
}
}

processAllCssFiles();
Loading

0 comments on commit abc3ed7

Please sign in to comment.