Monorepo for Tangled tangled.org

appview/pages: Strip HTTP port from SSH clone URLs #749

merged opened by evan.jarrett.net targeting master from evan.jarrett.net/core: ssh-strip-port

Summary#

Fixes SSH clone URL display to show correct format without HTTP API port.

SSH URLs were displaying with the HTTP API port:

git@localhost:6000:evan.jarrett.net/atcr-test

Strip the HTTP port from hostnames in SSH URL so that it becomes:

git@localhost:evan.jarrett.net/atcr-test

Note: even better would be if we knew what port the knot was listening on and add that to the url.

Changes#

  • Added stripPort template helper function to appview/pages/funcmap.go
  • Updated appview/pages/templates/repo/empty.html to use stripPort filter
  • Updated appview/pages/templates/repo/fragments/cloneDropdown.html to use stripPort filter
Labels
bugfix
assignee

None yet.

Participants 2
AT URI
at://did:plc:pddp4xt5lgnv2qsegbzzs4xg/sh.tangled.repo.pull/3m4rp2s4s3e22
+9 -3
Diff #0
+6
appview/pages/funcmap.go
··· 38 38 "contains": func(s string, target string) bool { 39 39 return strings.Contains(s, target) 40 40 }, 41 + "stripPort": func(hostname string) string { 42 + if strings.Contains(hostname, ":") { 43 + return strings.Split(hostname, ":")[0] 44 + } 45 + return hostname 46 + }, 41 47 "mapContains": func(m any, key any) bool { 42 48 mapValue := reflect.ValueOf(m) 43 49 if mapValue.Kind() != reflect.Map {
+1 -1
appview/pages/templates/repo/empty.html
··· 35 35 36 36 <p><span class="{{$bullet}}">1</span>First, generate a new <a href="https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key" class="underline">SSH key pair</a>.</p> 37 37 <p><span class="{{$bullet}}">2</span>Then add the public key to your account from the <a href="/settings" class="underline">settings</a> page.</p> 38 - <p><span class="{{$bullet}}">3</span>Configure your remote to <code>git@{{ $knot }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code></p> 38 + <p><span class="{{$bullet}}">3</span>Configure your remote to <code>git@{{ $knot | stripPort }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code></p> 39 39 <p><span class="{{$bullet}}">4</span>Push!</p> 40 40 </div> 41 41 </div>
+2 -2
appview/pages/templates/repo/fragments/cloneDropdown.html
··· 48 48 <code 49 49 class="flex-1 px-3 py-2 text-sm bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100 rounded-l select-all cursor-pointer whitespace-nowrap overflow-x-auto" 50 50 onclick="window.getSelection().selectAllChildren(this)" 51 - data-url="git@{{ $knot }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}" 52 - >git@{{ $knot }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code> 51 + data-url="git@{{ $knot | stripPort }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}" 52 + >git@{{ $knot | stripPort }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code> 53 53 <button 54 54 onclick="copyToClipboard(this, this.previousElementSibling.getAttribute('data-url'))" 55 55 class="px-3 py-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 border-l border-gray-300 dark:border-gray-600"

History

1 round 1 comment
sign up or login to add to the discussion
evan.jarrett.net submitted #0
1 commit
expand
appview/pages: Strip HTTP port from SSH clone URLs
expand 1 comment

lgtm!

even better would be if we knew what port the knot was listening on and add that to the url.

this one is slightly trickier, for example, the dev knot is configured to work on 6000, but qemu is configured to expose SSH over 2222. probably need to scan ports to figure it out otherwise? i know forgejo just lets the end user declare the port to be displayed on the UI, could do something similar.

pull request successfully merged