appview/state: Move /knots & /spindles under /settings #660

merged
opened by 5jiji.com targeting master from 5jiji.com/tangled-core: master

Closes https://tangled.org/@tangled.org/core/issues/248

I hope this go code is fine, because i have no damn clue how go works, so i just tried something and it worked If there is a better solution, i would like to know it!

NB: (I've checked if it compiled and worked, by removing commit '3ebdcd: knotserver: improve the logging situation', as for some reason, that commit is uncompilable (even your spindle is complaining))

+14 -2
appview/state/router.go
···
r.Mount("/settings", s.SettingsRouter())
r.Mount("/strings", s.StringsRouter(mw))
-
r.Mount("/knots", s.KnotsRouter())
-
r.Mount("/spindles", s.SpindlesRouter())
+
+
+
r.Mount("/knots", s.Redirect("/settings/knots"))
+
r.Mount("/spindles", s.Redirect("/settings/spindles"))
+
+
r.Mount("/settings/knots", s.KnotsRouter())
+
r.Mount("/settings/spindles", s.SpindlesRouter())
+
r.Mount("/notifications", s.NotificationsRouter(mw))
r.Mount("/signup", s.SignupRouter())
···
return r
}
+
func (s *State) Redirect(destination string) http.HandlerFunc {
+
return func(w http.ResponseWriter, r *http.Request) {
+
http.Redirect(w, r, destination, http.StatusFound)
+
}
+
}
+
// Core serves tangled.org/core go-import meta tags, and redirects
// to the core repository if accessed normally.
func (s *State) Core() http.HandlerFunc {
+3 -3
appview/pages/templates/knots/dashboard.html
···
<button
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
title="Delete knot"
-
hx-delete="/knots/{{ .Domain }}"
+
hx-delete="/settings/knots/{{ .Domain }}"
hx-swap="outerHTML"
hx-confirm="Are you sure you want to delete the knot '{{ .Domain }}'?"
hx-headers='{"shouldRedirect": "true"}'
···
<button
class="btn gap-2 group"
title="Retry knot verification"
-
hx-post="/knots/{{ .Domain }}/retry"
+
hx-post="/settings/knots/{{ .Domain }}/retry"
hx-swap="none"
hx-headers='{"shouldRefresh": "true"}'
>
···
<button
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
title="Remove member"
-
hx-post="/knots/{{ $root.Registration.Domain }}/remove"
+
hx-post="/settings/knots/{{ $root.Registration.Domain }}/remove"
hx-swap="none"
hx-vals='{"member": "{{$member}}" }'
hx-confirm="Are you sure you want to remove {{ $memberHandle }} from this knot?"
+1 -1
appview/pages/templates/knots/fragments/addMemberModal.html
···
{{ define "addKnotMemberPopover" }}
<form
-
hx-post="/knots/{{ .Domain }}/add"
+
hx-post="/settings/knots/{{ .Domain }}/add"
hx-indicator="#spinner"
hx-swap="none"
class="flex flex-col gap-2"
+3 -3
appview/pages/templates/knots/fragments/knotListing.html
···
{{ define "knotLeftSide" }}
{{ if .Registered }}
-
<a href="/knots/{{ .Domain }}" class="hover:no-underline flex items-center gap-2 min-w-0 max-w-[60%]">
+
<a href="/settings/knots/{{ .Domain }}" class="hover:no-underline flex items-center gap-2 min-w-0 max-w-[60%]">
{{ i "hard-drive" "w-4 h-4" }}
<span class="hover:underline">
{{ .Domain }}
···
<button
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
title="Delete knot"
-
hx-delete="/knots/{{ .Domain }}"
+
hx-delete="/settings/knots/{{ .Domain }}"
hx-swap="outerHTML"
hx-target="#knot-{{.Id}}"
hx-confirm="Are you sure you want to delete the knot '{{ .Domain }}'?"
···
<button
class="btn gap-2 group"
title="Retry knot verification"
-
hx-post="/knots/{{ .Domain }}/retry"
+
hx-post="/settings/knots/{{ .Domain }}/retry"
hx-swap="none"
hx-target="#knot-{{.Id}}"
>
+1 -1
appview/pages/templates/knots/index.html
···
<h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">register a knot</h2>
<p class="mb-2 dark:text-gray-300">Enter the hostname of your knot to get started.</p>
<form
-
hx-post="/knots/register"
+
hx-post="/settings/knots/register"
class="max-w-2xl mb-2 space-y-4"
hx-indicator="#register-button"
hx-swap="none"
+1 -1
appview/pages/templates/repo/fork.html
···
{{ end }}
</div>
</div>
-
<p class="text-sm text-gray-500 dark:text-gray-400">A knot hosts repository data. <a href="/knots" class="underline">Learn how to register your own knot.</a></p>
+
<p class="text-sm text-gray-500 dark:text-gray-400">A knot hosts repository data. <a href="/settings/knots" class="underline">Learn how to register your own knot.</a></p>
</fieldset>
<div class="space-y-2">
+1 -1
appview/pages/templates/repo/new.html
···
</div>
<p class="text-sm text-gray-500 dark:text-gray-400 mt-1">
A knot hosts repository data and handles Git operations.
-
You can also <a href="/knots" class="underline">register your own knot</a>.
+
You can also <a href="/settings/knots" class="underline">register your own knot</a>.
</p>
</div>
{{ end }}
+1 -1
docs/knot-hosting.md
···
You should now have a running knot server! You can finalize
your registration by hitting the `verify` button on the
-
[/knots](https://tangled.org/knots) page. This simply creates
+
[/settings/knots](https://tangled.org/settings/knots) page. This simply creates
a record on your PDS to announce the existence of the knot.
### custom paths
+3 -3
appview/pages/templates/spindles/dashboard.html
···
<button
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
title="Delete spindle"
-
hx-delete="/spindles/{{ .Instance }}"
+
hx-delete="/settings/spindles/{{ .Instance }}"
hx-swap="outerHTML"
hx-confirm="Are you sure you want to delete the spindle '{{ .Instance }}'?"
hx-headers='{"shouldRedirect": "true"}'
···
<button
class="btn gap-2 group"
title="Retry spindle verification"
-
hx-post="/spindles/{{ .Instance }}/retry"
+
hx-post="/settings/spindles/{{ .Instance }}/retry"
hx-swap="none"
hx-headers='{"shouldRefresh": "true"}'
>
···
<button
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
title="Remove member"
-
hx-post="/spindles/{{ $root.Spindle.Instance }}/remove"
+
hx-post="/settings/spindles/{{ $root.Spindle.Instance }}/remove"
hx-swap="none"
hx-vals='{"member": "{{$member}}" }'
hx-confirm="Are you sure you want to remove {{ resolve $member }} from this instance?"
+1 -1
appview/pages/templates/spindles/fragments/addMemberModal.html
···
{{ define "addSpindleMemberPopover" }}
<form
-
hx-post="/spindles/{{ .Instance }}/add"
+
hx-post="/settings/spindles/{{ .Instance }}/add"
hx-indicator="#spinner"
hx-swap="none"
class="flex flex-col gap-2"
+3 -3
appview/pages/templates/spindles/fragments/spindleListing.html
···
{{ define "spindleLeftSide" }}
{{ if .Verified }}
-
<a href="/spindles/{{ .Instance }}" class="hover:no-underline flex items-center gap-2 min-w-0 max-w-[60%]">
+
<a href="/settings/spindles/{{ .Instance }}" class="hover:no-underline flex items-center gap-2 min-w-0 max-w-[60%]">
{{ i "hard-drive" "w-4 h-4" }}
<span class="hover:underline">
{{ .Instance }}
···
<button
class="btn text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 gap-2 group"
title="Delete spindle"
-
hx-delete="/spindles/{{ .Instance }}"
+
hx-delete="/settings/spindles/{{ .Instance }}"
hx-swap="outerHTML"
hx-target="#spindle-{{.Id}}"
hx-confirm="Are you sure you want to delete the spindle '{{ .Instance }}'?"
···
<button
class="btn gap-2 group"
title="Retry spindle verification"
-
hx-post="/spindles/{{ .Instance }}/retry"
+
hx-post="/settings/spindles/{{ .Instance }}/retry"
hx-swap="none"
hx-target="#spindle-{{.Id}}"
>
+1 -1
appview/pages/templates/spindles/index.html
···
<h2 class="text-sm font-bold py-2 uppercase dark:text-gray-300">register a spindle</h2>
<p class="mb-2 dark:text-gray-300">Enter the hostname of your spindle to get started.</p>
<form
-
hx-post="/spindles/register"
+
hx-post="/settings/spindles/register"
class="max-w-2xl mb-2 space-y-4"
hx-indicator="#register-button"
hx-swap="none"