Monorepo for Tangled tangled.org

appview: allows a default knot to be configured #991

open opened by willdot.net targeting master from willdot.net/tangled-fork: default-knot

This follows on from the work carried out in #836

I've added a select box in the Knots settings page which pulls in the users knots and also adds in knot1.tangled.sh. When the user selects one of these options, it will save to their profile in the database. NOTE: I haven't yet implemented adding that to the AT record because I'm not sure on how the lexicon setup works yet!

Then when users go to create a new repo / fork, if there is a value in their profile for the default knot, then that will pre select the knot to use for the new repo / fork.

This is a duplicate of https://tangled.org/tangled.org/core/pulls/858/ which had to be closed because there were merge conflicts which couldn't be resolved due to the origin fork being deleted ๐Ÿ™ˆ

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dadhhalkfcq3gucaq25hjqon/sh.tangled.repo.pull/3mcrzfonnxs22
+199 -80
Interdiff #3 โ†’ #4
appview/db/db.go

This file has not been changed.

appview/db/profile.go

This patch was likely rebased, as context lines do not match.

appview/knots/knots.go

This file has not been changed.

appview/models/profile.go

This file has not been changed.

appview/pages/pages.go

This file has not been changed.

appview/pages/templates/knots/index.html

This file has not been changed.

+35 -28
appview/pages/templates/layouts/fragments/topbar.html
··· 53 53 /> 54 54 <span class="hidden md:inline">{{ $user | resolve | truncateAt30 }}</span> 55 55 </summary> 56 + <div class="absolute right-0 mt-4 rounded bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700 shadow-lg z-50 text-sm" style="width: 14rem;"> 56 - <div class="absolute right-0 mt-4 p-4 rounded bg-white dark:bg-gray-800 dark:text-white border border-gray-200 dark:border-gray-700 shadow-lg z-50" style="width: 14rem;"> 57 57 {{ $active := .Active.Did }} 58 + {{ $linkStyle := "flex items-center gap-3 px-4 py-2 hover:no-underline hover:bg-gray-50 hover:dark:bg-gray-700/50" }} 58 - 59 - <div class="pb-2 mb-2 border-b border-gray-200 dark:border-gray-700"> 60 - <div class="flex items-center gap-2"> 61 - <img src="{{ tinyAvatar $active }}" alt="" class="rounded-full h-8 w-8 flex-shrink-0 border border-gray-300 dark:border-gray-700" /> 62 - <div class="flex-1 overflow-hidden"> 63 - <p class="font-medium text-sm truncate">{{ $active | resolve }}</p> 64 - <p class="text-xs text-green-600 dark:text-green-400">active</p> 65 - </div> 66 - </div> 67 - </div> 68 59 69 60 {{ $others := .Accounts | otherAccounts $active }} 70 61 {{ if $others }} 62 + <div class="text-sm text-gray-500 dark:text-gray-400 px-3 py-1 pt-2">switch account</div> 63 + {{ range $others }} 71 - <div class="pb-2 mb-2 border-b border-gray-200 dark:border-gray-700"> 72 - <p class="text-xs text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-1">Switch Account</p> 73 - {{ range $others }} 74 64 <button 75 65 type="button" 76 66 hx-post="/account/switch" 77 67 hx-vals='{"did": "{{ .Did }}"}' 78 68 hx-swap="none" 69 + class="{{$linkStyle}} w-full text-left pl-3" 79 - class="flex items-center gap-2 w-full py-1.5 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-left" 80 70 > 71 + <img src="{{ tinyAvatar .Did }}" alt="" class="rounded-full size-6 flex-shrink-0 border border-gray-300 dark:border-gray-700" /> 72 + <span class="truncate flex-1">{{ .Did | resolve }}</span> 81 - <img src="{{ tinyAvatar .Did }}" alt="" class="rounded-full h-6 w-6 flex-shrink-0 border border-gray-300 dark:border-gray-700" /> 82 - <span class="text-sm truncate flex-1">{{ .Did | resolve }}</span> 83 73 </button> 74 + {{ end }} 84 - {{ end }} 85 - </div> 86 75 {{ end }} 87 76 77 + <a href="/login?mode=add_account" class="{{$linkStyle}} pl-3"> 78 + <div class="size-6 rounded-full bg-gray-100 dark:bg-gray-700 flex items-center justify-center"> 79 + {{ i "plus" "size-3" }} 80 + </div> 81 + 82 + <div class="text-left flex-1 min-w-0 block truncate"> 83 + add account 84 + </div> 88 - <a href="/login?mode=add_account" class="flex items-center gap-2 py-1 text-sm"> 89 - {{ i "plus" "w-4 h-4 flex-shrink-0" }} 90 - <span>Add another account</span> 91 85 </a> 92 86 87 + <div class="border-t border-gray-200 dark:border-gray-700"> 88 + <a href="/{{ $active }}" class="{{$linkStyle}}"> 89 + {{ i "user" "size-4" }} 90 + profile 91 + </a> 92 + <a href="/{{ $active }}?tab=repos" class="{{$linkStyle}}"> 93 + {{ i "book-marked" "size-4" }} 94 + repositories 95 + </a> 96 + <a href="/{{ $active }}?tab=strings" class="{{$linkStyle}}"> 97 + {{ i "line-squiggle" "size-4" }} 98 + strings 99 + </a> 100 + <a href="/settings" class="{{$linkStyle}}"> 101 + {{ i "cog" "size-4" }} 102 + settings 103 + </a> 93 - <div class="pt-2 mt-2 border-t border-gray-200 dark:border-gray-700 space-y-1"> 94 - <a href="/{{ $active }}" class="block py-1 text-sm">profile</a> 95 - <a href="/{{ $active }}?tab=repos" class="block py-1 text-sm">repositories</a> 96 - <a href="/{{ $active }}?tab=strings" class="block py-1 text-sm">strings</a> 97 - <a href="/settings" class="block py-1 text-sm">settings</a> 98 104 <a href="#" 99 105 hx-post="/logout" 100 106 hx-swap="none" 107 + class="{{$linkStyle}} text-red-400 hover:text-red-400 hover:bg-red-100 dark:hover:bg-red-700/20 pb-2"> 108 + {{ i "log-out" "size-4" }} 101 - class="block py-1 text-sm text-red-400 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300"> 102 109 logout 103 110 </a> 104 111 </div>
appview/pages/templates/repo/fork.html

This file has not been changed.

+3 -5
appview/pages/templates/repo/fragments/diff.html
··· 23 23 {{ block "subsCheckbox" $ }} {{ end }} 24 24 25 25 <!-- top bar --> 26 + <div class="sticky top-0 z-30 bg-slate-100 dark:bg-gray-900 flex items-center gap-2 col-span-full h-12 p-2 {{ if $root }}mt-4{{ end }}"> 26 - <div class="sticky top-0 z-30 flex items-center gap-2 col-span-full h-12 p-2 {{ if $root }}mt-4{{ end }}"> 27 27 <!-- left panel toggle --> 28 28 {{ template "filesToggle" . }} 29 29 ··· 31 31 {{ $stat := $diff.Stats }} 32 32 {{ $count := len $diff.ChangedFiles }} 33 33 {{ template "repo/fragments/diffStatPill" $stat }} 34 + <span class="text-xs text-gray-600 dark:text-gray-400 hidden md:inline-flex">{{ $count }} changed file{{ if ne $count 1 }}s{{ end }}</span> 34 - <span class="text-xs text-gray-600 dark:text-gray-400">{{ $count }} changed file{{ if ne $count 1 }}s{{ end }}</span> 35 35 36 36 {{ if $root }} 37 37 {{ if $root.IsInterdiff }} ··· 70 70 {{ template "collapseToggle" }} 71 71 72 72 <!-- diff options --> 73 + {{ template "repo/fragments/diffOpts" $opts }} 73 - <div class="hidden md:block"> 74 - {{ template "repo/fragments/diffOpts" $opts }} 75 - </div> 76 74 77 75 <!-- right panel toggle --> 78 76 {{ block "subsToggle" $ }} {{ end }}
appview/pages/templates/repo/new.html

This file has not been changed.

+12 -4
appview/pages/templates/repo/pulls/pull.html
··· 8 8 9 9 {{ define "mainLayout" }} 10 10 <div class="px-1 flex-grow flex flex-col gap-4"> 11 + <div class="max-w-full md:max-w-screen-lg mx-auto"> 11 - <div class="max-w-screen-lg mx-auto"> 12 12 {{ block "contentLayout" . }} 13 13 {{ block "content" . }}{{ end }} 14 14 {{ end }} ··· 51 51 {{ end }} 52 52 53 53 {{ define "repoContentLayout" }} 54 + <div class="grid grid-cols-1 md:grid-cols-10 gap-4 w-full"> 54 - <div class="grid grid-cols-1 md:grid-cols-10 gap-4"> 55 55 <section class="bg-white col-span-1 md:col-span-8 dark:bg-gray-800 p-6 rounded relative w-full mx-auto dark:text-white h-full flex-shrink"> 56 56 {{ block "repoContent" . }}{{ end }} 57 57 </section> ··· 246 246 {{ $lastIdx := index . 2 }} 247 247 {{ $root := index . 3 }} 248 248 {{ $round := $item.RoundNumber }} 249 + <div class=" 250 + {{ if eq $round 0 }}rounded-b{{ else }}rounded{{ end }} 251 + px-6 py-4 pr-2 pt-2 252 + {{ if eq $root.ActiveRound $round }} 253 + bg-blue-100 dark:bg-blue-900 border-b border-blue-200 dark:border-blue-700 254 + {{ else }} 255 + bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 256 + {{ end }} 257 + flex gap-2 sticky top-0 z-20"> 249 - <div class="{{ if eq $round 0 }}rounded-b{{ else }}rounded{{ end }} px-6 py-4 pr-2 pt-2 {{ if eq $root.ActiveRound $round }}bg-blue-100 dark:bg-blue-900/50 border-b border-blue-200 dark:border-blue-700{{ else }}bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700{{ end }} flex gap-2 sticky top-0 z-20"> 250 258 <!-- left column: just profile picture --> 251 259 <div class="flex-shrink-0 pt-2"> 252 260 <img ··· 286 294 <div class="flex gap-2 items-center"> 287 295 {{ if ne $root.ActiveRound $round }} 288 296 <a class="btn-flat flex items-center gap-2 no-underline hover:no-underline text-sm" 297 + href="/{{ $root.RepoInfo.FullName }}/pulls/{{ $root.Pull.PullId }}/round/{{ $round }}?{{ safeUrl $root.DiffOpts.Encode }}#round-#{{ $round }}"> 289 - href="/{{ $root.RepoInfo.FullName }}/pulls/{{ $root.Pull.PullId }}/round/{{ $round }}?{{ safeUrl $root.DiffOpts.Encode }}"> 290 298 {{ i "diff" "w-4 h-4" }} 291 299 diff 292 300 </a>
+1 -1
appview/pulls/opengraph.go
··· 199 199 currentX += commentTextWidth + 40 200 200 201 201 // Draw files changed 202 + err = statusStatsArea.DrawLucideIcon("file-diff", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, iconColor) 202 - err = statusStatsArea.DrawLucideIcon("static/icons/file-diff", currentX, statsY+iconBaselineOffset-iconSize/2+5, iconSize, iconColor) 203 203 if err != nil { 204 204 log.Printf("failed to draw file diff icon: %v", err) 205 205 }
+1 -1
appview/pulls/pulls.go
··· 228 228 reactionMap, err := db.GetReactionMap(s.db, 20, pull.AtUri()) 229 229 if err != nil { 230 230 log.Println("failed to get pull reactions") 231 - s.pages.Notice(w, "pulls", "Failed to load pull. Try again later.") 232 231 } 233 232 234 233 userReactions := map[models.ReactionKind]bool{} ··· 1875 1874 record := pull.AsRecord() 1876 1875 record.PatchBlob = blob.Blob 1877 1876 record.CreatedAt = time.Now().Format(time.RFC3339) 1877 + record.Source.Sha = newSourceRev 1878 1878 1879 1879 _, err = comatproto.RepoPutRecord(r.Context(), client, &comatproto.RepoPutRecord_Input{ 1880 1880 Collection: tangled.RepoPullNSID,
+64 -19
appview/repo/archive.go
··· 2 2 3 3 import ( 4 4 "fmt" 5 + "io" 5 6 "net/http" 6 7 "net/url" 7 8 "strings" 8 9 9 - "tangled.org/core/api/tangled" 10 - xrpcclient "tangled.org/core/appview/xrpcclient" 11 - 12 - indigoxrpc "github.com/bluesky-social/indigo/xrpc" 13 10 "github.com/go-chi/chi/v5" 14 - "github.com/go-git/go-git/v5/plumbing" 15 11 ) 16 12 17 13 func (rp *Repo) DownloadArchive(w http.ResponseWriter, r *http.Request) { ··· 29 25 scheme = "https" 30 26 } 31 27 host := fmt.Sprintf("%s://%s", scheme, f.Knot) 32 - xrpcc := &indigoxrpc.Client{ 33 - Host: host, 34 - } 35 28 didSlashRepo := f.DidSlashRepo() 29 + 30 + // build the xrpc url 31 + u, err := url.Parse(host) 32 + if err != nil { 33 + l.Error("failed to parse host URL", "err", err) 36 - archiveBytes, err := tangled.RepoArchive(r.Context(), xrpcc, "tar.gz", "", ref, didSlashRepo) 37 - if xrpcerr := xrpcclient.HandleXrpcErr(err); xrpcerr != nil { 38 - l.Error("failed to call XRPC repo.archive", "err", xrpcerr) 39 34 rp.pages.Error503(w) 40 35 return 41 36 } 37 + 38 + u.Path = "/xrpc/sh.tangled.repo.archive" 39 + query := url.Values{} 40 + query.Set("format", "tar.gz") 41 + query.Set("prefix", r.URL.Query().Get("prefix")) 42 + query.Set("ref", ref) 43 + query.Set("repo", didSlashRepo) 44 + u.RawQuery = query.Encode() 45 + 46 + xrpcURL := u.String() 47 + 48 + // make the get request 49 + resp, err := http.Get(xrpcURL) 50 + if err != nil { 51 + l.Error("failed to call XRPC repo.archive", "err", err) 52 + rp.pages.Error503(w) 53 + return 54 + } 55 + 56 + // pass through headers from upstream response 57 + if contentDisposition := resp.Header.Get("Content-Disposition"); contentDisposition != "" { 58 + w.Header().Set("Content-Disposition", contentDisposition) 59 + } 60 + if contentType := resp.Header.Get("Content-Type"); contentType != "" { 61 + w.Header().Set("Content-Type", contentType) 62 + } 63 + if contentLength := resp.Header.Get("Content-Length"); contentLength != "" { 64 + w.Header().Set("Content-Length", contentLength) 65 + } 66 + if link := resp.Header.Get("Link"); link != "" { 67 + if resolvedRef, err := extractImmutableLink(link); err == nil { 68 + newLink := fmt.Sprintf("<%s/%s/archive/%s.tar.gz>; rel=\"immutable\"", 69 + rp.config.Core.AppviewHost, f.DidSlashRepo(), resolvedRef) 70 + w.Header().Set("Link", newLink) 71 + } 72 + } 73 + 74 + // stream the archive data directly 75 + if _, err := io.Copy(w, resp.Body); err != nil { 76 + l.Error("failed to write response", "err", err) 77 + } 78 + } 79 + 80 + func extractImmutableLink(linkHeader string) (string, error) { 81 + trimmed := strings.TrimPrefix(linkHeader, "<") 82 + trimmed = strings.TrimSuffix(trimmed, ">; rel=\"immutable\"") 83 + 84 + parsedLink, err := url.Parse(trimmed) 85 + if err != nil { 86 + return "", err 87 + } 88 + 89 + resolvedRef := parsedLink.Query().Get("ref") 90 + if resolvedRef == "" { 91 + return "", fmt.Errorf("no ref found in link header") 92 + } 93 + 94 + return resolvedRef, nil 42 - // Set headers for file download, just pass along whatever the knot specifies 43 - safeRefFilename := strings.ReplaceAll(plumbing.ReferenceName(ref).Short(), "/", "-") 44 - filename := fmt.Sprintf("%s-%s.tar.gz", f.Name, safeRefFilename) 45 - w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename)) 46 - w.Header().Set("Content-Type", "application/gzip") 47 - w.Header().Set("Content-Length", fmt.Sprintf("%d", len(archiveBytes))) 48 - // Write the archive data directly 49 - w.Write(archiveBytes) 50 95 }
appview/repo/repo.go

This file has not been changed.

+11 -22
appview/state/profile.go
··· 162 162 l.Error("failed to create timeline", "err", err) 163 163 } 164 164 165 - // populate commit counts in the timeline, using the punchcard 166 - now := time.Now() 167 - for _, p := range profile.Punchcard.Punches { 168 - years := now.Year() - p.Date.Year() 169 - months := int(now.Month() - p.Date.Month()) 170 - monthsAgo := years*12 + months 171 - if monthsAgo >= 0 && monthsAgo < len(timeline.ByMonth) { 172 - timeline.ByMonth[monthsAgo].Commits += p.Count 173 - } 174 - } 175 - 176 165 s.pages.ProfileOverview(w, pages.ProfileOverviewParams{ 177 166 LoggedInUser: s.oauth.GetMultiAccountUser(r), 178 167 Card: profile, ··· 616 605 s.updateProfile(profile, w, r) 617 606 } 618 607 608 + func (s *State) updateProfile(profile *models.Profile, w http.ResponseWriter, r *http.Request) { 609 + 610 + 611 + 612 + 613 + 614 + 615 + 616 + s.updateProfile(profile, w, r) 617 + } 618 + 619 619 func (s *State) UpdateProfileDefaultKnot(w http.ResponseWriter, r *http.Request) { 620 620 err := r.ParseForm() 621 621 if err != nil { ··· 657 657 } 658 658 659 659 func (s *State) updateProfile(profile *models.Profile, w http.ResponseWriter, r *http.Request) { 660 - 661 - 662 - 663 - 664 - 665 - 666 - 667 - s.updateProfile(profile, w, r) 668 - } 669 - 670 - func (s *State) updateProfile(profile *models.Profile, w http.ResponseWriter, r *http.Request) { 671 660 user := s.oauth.GetMultiAccountUser(r) 672 661 tx, err := s.db.BeginTx(r.Context(), nil)
appview/state/router.go

This file has not been changed.

appview/state/state.go

This file has not been changed.

+33
docs/DOCS.md
··· 693 693 MY_ENV_VAR: "MY_ENV_VALUE" 694 694 ``` 695 695 696 + By default, the following environment variables set: 697 + 698 + - `CI` - Always set to `true` to indicate a CI environment 699 + - `TANGLED_PIPELINE_ID` - The AT URI of the current pipeline 700 + - `TANGLED_REPO_KNOT` - The repository's knot hostname 701 + - `TANGLED_REPO_DID` - The DID of the repository owner 702 + - `TANGLED_REPO_NAME` - The name of the repository 703 + - `TANGLED_REPO_DEFAULT_BRANCH` - The default branch of the 704 + repository 705 + - `TANGLED_REPO_URL` - The full URL to the repository 706 + 707 + These variables are only available when the pipeline is 708 + triggered by a push: 709 + 710 + - `TANGLED_REF` - The full git reference (e.g., 711 + `refs/heads/main` or `refs/tags/v1.0.0`) 712 + - `TANGLED_REF_NAME` - The short name of the reference 713 + (e.g., `main` or `v1.0.0`) 714 + - `TANGLED_REF_TYPE` - The type of reference, either 715 + `branch` or `tag` 716 + - `TANGLED_SHA` - The commit SHA that triggered the pipeline 717 + - `TANGLED_COMMIT_SHA` - Alias for `TANGLED_SHA` 718 + 719 + These variables are only available when the pipeline is 720 + triggered by a pull request: 721 + 722 + - `TANGLED_PR_SOURCE_BRANCH` - The source branch of the pull 723 + request 724 + - `TANGLED_PR_TARGET_BRANCH` - The target branch of the pull 725 + request 726 + - `TANGLED_PR_SOURCE_SHA` - The commit SHA of the source 727 + branch 728 + 696 729 ### Steps 697 730 698 731 The `steps` field allows you to define what steps should run
+4
knotserver/git/git.go
··· 76 76 return &g, nil 77 77 } 78 78 79 + func (g *GitRepo) Hash() plumbing.Hash { 80 + return g.h 81 + } 82 + 79 83 // re-open a repository and update references 80 84 func (g *GitRepo) Refresh() error { 81 85 refreshed, err := PlainOpen(g.path)
+35
knotserver/xrpc/repo_archive.go
··· 4 4 "compress/gzip" 5 5 "fmt" 6 6 "net/http" 7 + "net/url" 7 8 "strings" 8 9 9 10 "github.com/go-git/go-git/v5/plumbing" 10 11 12 + "tangled.org/core/api/tangled" 11 13 "tangled.org/core/knotserver/git" 12 14 xrpcerr "tangled.org/core/xrpc/errors" 13 15 ) ··· 47 49 repoParts := strings.Split(repo, "/") 48 50 repoName := repoParts[len(repoParts)-1] 49 51 52 + immutableLink, err := x.buildImmutableLink(repo, format, gr.Hash().String(), prefix) 53 + if err != nil { 54 + x.Logger.Error( 55 + "failed to build immutable link", 56 + "err", err.Error(), 57 + "repo", repo, 58 + "format", format, 59 + "ref", gr.Hash().String(), 60 + "prefix", prefix, 61 + ) 62 + } 63 + 50 64 safeRefFilename := strings.ReplaceAll(plumbing.ReferenceName(ref).Short(), "/", "-") 51 65 52 66 var archivePrefix string ··· 59 73 filename := fmt.Sprintf("%s-%s.tar.gz", repoName, safeRefFilename) 60 74 w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename)) 61 75 w.Header().Set("Content-Type", "application/gzip") 76 + w.Header().Set("Link", fmt.Sprintf("<%s>; rel=\"immutable\"", immutableLink)) 62 77 63 78 gw := gzip.NewWriter(w) 64 79 defer gw.Close() ··· 79 94 return 80 95 } 81 96 } 97 + 98 + func (x *Xrpc) buildImmutableLink(repo string, format string, ref string, prefix string) (string, error) { 99 + scheme := "https" 100 + if x.Config.Server.Dev { 101 + scheme = "http" 102 + } 103 + 104 + u, err := url.Parse(scheme + "://" + x.Config.Server.Hostname + "/xrpc/" + tangled.RepoArchiveNSID) 105 + if err != nil { 106 + return "", err 107 + } 108 + 109 + params := url.Values{} 110 + params.Set("repo", repo) 111 + params.Set("format", format) 112 + params.Set("ref", ref) 113 + params.Set("prefix", prefix) 114 + 115 + return fmt.Sprintf("%s?%s", u.String(), params.Encode()), nil 116 + }

History

8 rounds 9 comments
sign up or login to add to the discussion
1 commit
expand
appview: allow default knot to be saved as a preference and then used when creating a new repo
no conflicts, ready to merge
expand 0 comments
1 commit
expand
appview: allow default knot to be saved as a preference and then used when creating a new repo
expand 0 comments
1 commit
expand
appview: allow default knot to be saved as a preference and then used when creating a new repo
expand 0 comments
1 commit
expand
appview: allows a default knot to be selected from knots available to the user
expand 5 comments

@oppi.li While attempting to implement something else related to profiles, I've noticed that UpsertProfile(...) herehttps://tangled.org/tangled.org/core/blob/master/appview/db/profile.go#L133 also gets called as part of a JS ingester here https://tangled.org/tangled.org/core/blob/master/appview/ingester.go#L352 which means the DefaultKnot field will be overwritten with an empty string when a profile event is ingested. Am I understanding that correctly?

So instead I should probably not use the UpsertProfile(...) but use a smaller scoped function that just sets the Default Knot field?

ah that is correct, the default knot will be overwritten by that call. i suppose that is one of the drawbacks of overloading models.Profile! instead of cloning UpsertProfile to add this as an exception, perhaps this is an indication that we need to avoid using the profile table/model for this. what do you think about creating a preferences table for stuff like this? we already have notification_preferences, we could do something similar for knots.

i see you have a PR open for punchcard work as well, which would fit quite well in a punchcard_preferences table.

Yh I'm 100% down for using that approach. While I was implementing the punchcard PR I had this nagging feeling in me that this and other things belonged in some sort of separate "preferences" table so splitting them out into things like knot_preferences or punchcard_preferences is the right answer for me.

I'll redo that for this PR and then do the same of the other PR and hopefully it will prevent the merge conflicts I was dreading ๐Ÿ™ˆ

yeah! knot_preferences and punchcard_preferences seems okay for now. thanks for keeping at this by the way, and sorry for the slow review cycle!

No worries! I don't expect immediate reviews ๐Ÿ˜

I've refactored to use a new knot_preferences table for this PR. I had some merge conflicts with master though, so rebased that although took me a couple attempts to get everything nice and neat, hence so many rounds ๐Ÿ™ˆ

2 commits
expand
appview: allows a default knot to be configured
appview: allows a default knot to be selected from knots available to the user
expand 0 comments
1 commit
expand
appview: allows a default knot to be configured
expand 2 comments

the code itself works pretty nicely now. so i've noticed a couple issues (apologies for not looking more closely earlier!):

  • the default-knot selector only iterates over knots that the user is an admin of, whereas they should be able to choose any knot that they are a member of as the default. you can use s.enforcer.GetKnotsForUser(...) to get a list of knots that a user has access to
  • the HTML change adds knot1.tangled.sh as an explicit case, this is not necessary if the above is implemented
  • the HTML template currently triggers a request when the select changes, could we make this more like how the spindle selector works? a form with a button to submit.

I was looking for ages trying to find somewhere that did something similar. I don't use spindles so never saw that ๐Ÿ™ˆ A much better approach.

Also good shout on the knots for a user. Reading the code now, I understand what the registrations are now.

Anyhow, I've updated the PR and squashed everything so it should be good to test now.

Please note, that I have yet to figure out how to get multiple Knots running locally, and since I don't get knot1.tangled.sh locally I had to hard code some things in to test it worked, which is less than ideal.

1 commit
expand
appview: allows a default knot to be configured
expand 0 comments
1 commit
expand
appview: allows a default knot to be configured
expand 2 comments

i get this error at runtime:

2026/01/20 04:58:12 profile err 5 values for 6 columns
2026/01/20 04:58:12 failed to update profile 5 values for 6 columns

this sql query is incorrect:

		`insert or replace into profile (
			did,
			description,
			include_bluesky,
			location,
			pronouns,
			default_knot
		)
		values (?, ?, ?, ?, ?)`,

there should be 6 ? placeholders!

Ah crap, someone needs to create a lint tool that detects that ๐Ÿคฆโ€โ™‚๏ธ

Fixed.