···56}
5758type FollowStats struct {
59- Followers int
60- Following int
61}
6263func GetFollowerFollowingCount(e Execer, did string) (FollowStats, error) {
64- followers, following := 0, 0
65 err := e.QueryRow(
66 `SELECT
67 COUNT(CASE WHEN subject_did = ? THEN 1 END) AS followers,
···122123 for rows.Next() {
124 var did string
125- var followers, following int
126 if err := rows.Scan(&did, &followers, &following); err != nil {
127 return nil, err
128 }
···56}
5758type FollowStats struct {
59+ Followers int64
60+ Following int64
61}
6263func GetFollowerFollowingCount(e Execer, did string) (FollowStats, error) {
64+ var followers, following int64
65 err := e.QueryRow(
66 `SELECT
67 COUNT(CASE WHEN subject_did = ? THEN 1 END) AS followers,
···122123 for rows.Next() {
124 var did string
125+ var followers, following int64
126 if err := rows.Scan(&did, &followers, &following); err != nil {
127 return nil, err
128 }
···5 "log/slog"
6 "net/http"
7 "path"
08 "strconv"
9 "time"
10···160}
161162func (s *Strings) dashboard(w http.ResponseWriter, r *http.Request) {
163+ http.Redirect(w, r, fmt.Sprintf("/%s?tab=strings", chi.URLParam(r, "user")), http.StatusFound)
000000000000000000000000000000000000000000000000000000000164}
165166func (s *Strings) edit(w http.ResponseWriter, r *http.Request) {
+53-12
docs/hacking.md
···48redis-server
49```
5051-## running a knot
5253An end-to-end knot setup requires setting up a machine with
54`sshd`, `AuthorizedKeysCommand`, and git user, which is
55quite cumbersome. So the nix flake provides a
56`nixosConfiguration` to do so.
5758-To begin, grab your DID from http://localhost:3000/settings.
59-Then, set `TANGLED_VM_KNOT_OWNER` and
60-`TANGLED_VM_SPINDLE_OWNER` to your DID.
000000000000000000000000000006162-If you don't want to [set up a spindle](#running-a-spindle),
63-you can use any placeholder value.
0006465-You can now start a lightweight NixOS VM like so:
000006667```bash
68nix run --impure .#vm
···74with `ssh` exposed on port 2222.
7576Once the services are running, head to
77-http://localhost:3000/knots and hit verify (and similarly,
78-http://localhost:3000/spindles to verify your spindle). It
79-should verify the ownership of the services instantly if
80-everything went smoothly.
8182You can push repositories to this VM with this ssh config
83block on your main machine:
···97git push local-dev main
98```
99100-## running a spindle
101102The above VM should already be running a spindle on
103`localhost:6555`. Head to http://localhost:3000/spindles and
···119# litecli has a nicer REPL interface:
120litecli /var/lib/spindle/spindle.db
121```
00000
···48redis-server
49```
5051+## running knots and spindles
5253An end-to-end knot setup requires setting up a machine with
54`sshd`, `AuthorizedKeysCommand`, and git user, which is
55quite cumbersome. So the nix flake provides a
56`nixosConfiguration` to do so.
5758+<details>
59+ <summary><strong>MacOS users will have to setup a Nix Builder first</strong></summary>
60+61+ In order to build Tangled's dev VM on macOS, you will
62+ first need to set up a Linux Nix builder. The recommended
63+ way to do so is to run a [`darwin.linux-builder`
64+ VM](https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder)
65+ and to register it in `nix.conf` as a builder for Linux
66+ with the same architecture as your Mac (`linux-aarch64` if
67+ you are using Apple Silicon).
68+69+ > IMPORTANT: You must build `darwin.linux-builder` somewhere other than inside
70+ > the tangled repo so that it doesn't conflict with the other VM. For example,
71+ > you can do
72+ >
73+ > ```shell
74+ > cd $(mktemp -d buildervm.XXXXX) && nix run nixpkgs#darwin.linux-builder
75+ > ```
76+ >
77+ > to store the builder VM in a temporary dir.
78+ >
79+ > You should read and follow [all the other intructions][darwin builder vm] to
80+ > avoid subtle problems.
81+82+ Alternatively, you can use any other method to set up a
83+ Linux machine with `nix` installed that you can `sudo ssh`
84+ into (in other words, root user on your Mac has to be able
85+ to ssh into the Linux machine without entering a password)
86+ and that has the same architecture as your Mac. See
87+ [remote builder
88+ instructions](https://nix.dev/manual/nix/2.28/advanced-topics/distributed-builds.html#requirements)
89+ for how to register such a builder in `nix.conf`.
9091+ > WARNING: If you'd like to use
92+ > [`nixos-lima`](https://github.com/nixos-lima/nixos-lima) or
93+ > [Orbstack](https://orbstack.dev/), note that setting them up so that `sudo
94+ > ssh` works can be tricky. It seems to be [possible with
95+ > Orbstack](https://github.com/orgs/orbstack/discussions/1669).
9697+</details>
98+99+To begin, grab your DID from http://localhost:3000/settings.
100+Then, set `TANGLED_VM_KNOT_OWNER` and
101+`TANGLED_VM_SPINDLE_OWNER` to your DID. You can now start a
102+lightweight NixOS VM like so:
103104```bash
105nix run --impure .#vm
···111with `ssh` exposed on port 2222.
112113Once the services are running, head to
114+http://localhost:3000/knots and hit verify. It should
115+verify the ownership of the services instantly if everything
116+went smoothly.
0117118You can push repositories to this VM with this ssh config
119block on your main machine:
···133git push local-dev main
134```
135136+### running a spindle
137138The above VM should already be running a spindle on
139`localhost:6555`. Head to http://localhost:3000/spindles and
···155# litecli has a nicer REPL interface:
156litecli /var/lib/spindle/spindle.db
157```
158+159+If for any reason you wish to disable either one of the
160+services in the VM, modify [nix/vm.nix](/nix/vm.nix) and set
161+`services.tangled-spindle.enable` (or
162+`services.tangled-knot.enable`) to `false`.