From 5c2dbaf41e726980bf25193f9a4e14dcf677755d Mon Sep 17 00:00:00 2001 From: "pdewey.com"
Date: Fri, 2 Jan 2026 20:03:11 -0500 Subject: [PATCH] pds.solanaceae.net config and nix flake for building --- .gitignore | 4 +- README.md | 2 +- config.ts | 51 +++++++++++++ flake.lock | 26 +++++++ flake.nix | 125 ++++++++++++++++++++++++++++++++ index.html | 6 +- public/favicon.ico | Bin 15406 -> 15406 bytes public/moo.webp | 0 src/App.svelte | 15 +--- src/lib/AccountComponent.svelte | 102 +++++++++++++------------- src/lib/PostComponent.svelte | 46 ++++++------ vite.config.ts | 5 +- 12 files changed, 287 insertions(+), 95 deletions(-) create mode 100644 config.ts create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 public/moo.webp diff --git a/.gitignore b/.gitignore index 991a625..3d601a2 100644 --- a/.gitignore +++ b/.gitignore @@ -151,5 +151,5 @@ dist .yarn/install-state.gz .pnp.* -# Config files -config.ts \ No newline at end of file +# deno cache +.deno-cache diff --git a/README.md b/README.md index 8416cb9..debd3b6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ An example of a caddy file you can use handle @pds { reverse_proxy http://localhost:3000 } - + # If none matches goes to landing page handle /* { root * /srv/landing diff --git a/config.ts b/config.ts new file mode 100644 index 0000000..a3a3afd --- /dev/null +++ b/config.ts @@ -0,0 +1,51 @@ +/** + * Configuration module for the PDS Dashboard + */ +export class Config { + /** + * The base URL of the PDS (Personal Data Server). + * @default none + */ + static readonly PDS_URL: string = "https://pds.solanaceae.net"; + + /** + * Theme to be used + * @default "default" + */ + static readonly THEME: string = "dark"; + + /** + * The base URL of the frontend service for linking to replies/quotes/accounts etc. + * @default "https://deer.social" // or https://bsky.app if you're boring + */ + // static readonly FRONTEND_URL: string = "https://deer.social"; + static readonly FRONTEND_URL: string = "https://reddwarf.app"; + + /** + * The base URL of the frontend service for linking to user profiles. + * @default "https://deer.social/profile" or whatever. (needs /profile since aturi doesn't use that path) + */ + static readonly FRONTEND_PROFILE_URL: string = "https://aturi.to"; + + /** + * Maximum number of posts to fetch from the PDS per request + * Should be around 20 for about 10 users on the pds + * The more users you have, the lower the number should be + * since sorting is slow and is done on the frontend + * @default 20 + */ + static readonly MAX_POSTS: number = 20; + + /** + * Footer text for the dashboard, you probably want to change this. Supports HTML. + * @default "Source (github mirror)" + */ + static readonly FOOTER_TEXT: string = + "Source (Forked with <3 from selfhosted.social)"; + + /** + * Whether to show the posts with timestamps that are in the future. + * @default false + */ + static readonly SHOW_FUTURE_POSTS: boolean = false; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3fcda22 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1767273430, + "narHash": "sha256-kDpoFwQ8GLrPiS3KL+sAwreXrph2KhdXuJzo5+vSLoo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "76eec3925eb9bbe193934987d3285473dbcfad50", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..992e9d4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,125 @@ +{ + description = "PDS Dashboard Flake"; + inputs = { nixpkgs.url = "nixpkgs/nixpkgs-unstable"; }; + outputs = { nixpkgs, ... }: + let + forAllSystems = function: + nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] + (system: function nixpkgs.legacyPackages.${system}); + in { + devShells = forAllSystems + (pkgs: { default = pkgs.mkShell { packages = with pkgs; [ deno ]; }; }); + + packages = forAllSystems (pkgs: + let + deps = pkgs.stdenv.mkDerivation { + name = "pds-dash-deps"; + src = ./.; + + nativeBuildInputs = [ pkgs.deno ]; + + buildPhase = '' + export DENO_DIR=$out + export DENO_NO_UPDATE_CHECK=1 + deno install --frozen + ''; + + installPhase = '' + echo "Dependencies cached in $out" + ''; + + outputHashMode = "recursive"; + outputHashAlgo = "sha256"; + outputHash = "sha256-SQbclPzhmcrsTHvYBoYC53zcedorb7yE5w63xGNoZpw="; + }; + in { + default = pkgs.stdenv.mkDerivation { + pname = "pds-dash"; + version = "0.1.0"; + src = ./.; + + nativeBuildInputs = [ pkgs.deno ]; + + configurePhase = '' + runHook preConfigure + if [ ! -f config.ts ]; then + echo "Error: config.ts not found." + exit 1 + fi + + # Copy dependencies to a writable location + export DENO_DIR="$TMPDIR/deno-cache" + mkdir -p "$DENO_DIR" + cp -r ${deps}/* "$DENO_DIR/" + chmod -R +w "$DENO_DIR" + export DENO_NO_UPDATE_CHECK=1 + # Install dependencies (will use the local cache) + deno install --frozen + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + export DENO_DIR="$TMPDIR/deno-cache" + export DENO_NO_UPDATE_CHECK=1 + deno task build + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r dist/* $out/ + + runHook postInstall + ''; + }; + }); + + apps = forAllSystems (pkgs: { + # build static files for production use + default = { + type = "app"; + program = toString (pkgs.writeShellScript "build-pds-dash" '' + set -e + echo "Building pds-dash..." + RESULT=$(nix build .#default --no-link --print-out-paths 2>&1 | grep -v "^warning:" | tail -1) + echo "Build complete!" + echo "Output is in: $RESULT" + echo "To serve the built files:" + echo " python3 -m http.server --directory $RESULT 8080" + ''); + }; + + # deno dev server + dev = { + type = "app"; + program = toString (pkgs.writeShellScript "dev-pds-dash" '' + set -e + + if [ ! -f config.ts ]; then + echo "Error: config.ts not found." + exit 1 + fi + + # Setup cleanup trap to remove deno cache on exit + cleanup() { + echo "Cleaning up .deno-cache..." + rm -rf "$PWD/.deno-cache" + echo "Done!" + } + trap cleanup EXIT INT TERM + + echo "Installing dependencies..." + export DENO_DIR="$PWD/.deno-cache" + export DENO_NO_UPDATE_CHECK=1 + ${pkgs.deno}/bin/deno install + + echo "Starting development server..." + ${pkgs.deno}/bin/deno task dev + ''); + }; + }); + }; +} diff --git a/index.html b/index.html index 88a793b..736ded7 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,13 @@ - +
-c5
zpu`2AKyC<3nzzzwLUfGv#OSvmyU?-Kgy Home to {accountsData.length} accounts Home to {accountsData.length} accounts Help support the PDS {@html Config.FOOTER_TEXT}
@@ -126,7 +126,10 @@
id="replyingText"
style="text-decoration: underline;"
href="{Config.FRONTEND_URL}/profile/{post.replyingUri.repo}/post/{post
- .replyingUri.rkey}">replying to {replyingHandle ? `@${replyingHandle}` : post.replyingUri.repo}replying to {replyingHandle
+ ? `@${replyingHandle}`
+ : post.replyingUri.repo}
{/if}
{#if post.quotingUri}
@@ -137,17 +140,19 @@
>
{/if}
&pYigmmGZ{2z1|Gq<~-=o(J#JB@gf9ySY;{1=FzyIHP{O14sReS!g+r01h@-;jD
zFIc+a|C6ULLB%e(Y-s45|G%zv)Bo8EpZ#CB^uzzUrlbFF-hBv`KXLlfzyJS#*%E0d
z%m4rXHU9knQ~34!kCmIYANqaz{Pq9KHXQn2-MRGt@rw`sKYjJ#|K)49!F3ME0#My?
z@YtpQU%&nMfAY-r|Gkq={cq_y`v31gkj(%8r_Nsf|Lf16bVBz3|Nmd={l_oUw(q<0
zVa}4v|9hrf{6AsZo&U4uKmR{@=EMJu?MMGtHg5diHF@3tYquYR{SB$Z{{6pp>ml4d
zA3lBizjEz
Ms^<2Di>*AEz$N#SaxecrP(c%D97OnmBf6
ATProto PDS
-
{:else}
- {#if statusEmoji}
-
- {/if}
+ {#if statusEmoji}
+
+ {/if}
+ id="avatar"
+ alt="unknown avatar of {account.displayName}"
+ src="/unknown.png"
+ />
+
{/if}