diff --git a/internal/web/gist.go b/internal/web/gist.go index 9a18d56..21b5d55 100644 --- a/internal/web/gist.go +++ b/internal/web/gist.go @@ -31,14 +31,24 @@ func gistInit(next echo.HandlerFunc) echo.HandlerFunc { } setData(ctx, "gist", gist) - if config.C.SSH.Port == "22" { - setData(ctx, "ssh_clone_url", config.C.SSH.Domain+":"+userName+"/"+gistName+".git") - } else { - setData(ctx, "ssh_clone_url", "ssh://"+config.C.SSH.Domain+":"+config.C.SSH.Port+"/"+userName+"/"+gistName+".git") + if config.C.SSH.Enabled { + if config.C.SSH.Port == "22" { + setData(ctx, "sshCloneUrl", config.C.SSH.Domain+":"+userName+"/"+gistName+".git") + } else { + setData(ctx, "sshCloneUrl", "ssh://"+config.C.SSH.Domain+":"+config.C.SSH.Port+"/"+userName+"/"+gistName+".git") + } } - setData(ctx, "httpCloneUrl", "http://"+ctx.Request().Host+"/"+userName+"/"+gistName+".git") - setData(ctx, "httpCopyUrl", "http://"+ctx.Request().Host+"/"+userName+"/"+gistName) + httpProtocol := "http" + if ctx.Request().TLS != nil { + httpProtocol = "https" + } + setData(ctx, "httpProtocol", strings.ToUpper(httpProtocol)) + + if config.C.HTTP.Git { + setData(ctx, "httpCloneUrl", httpProtocol+"://"+config.C.HTTP.Domain+":"+config.C.HTTP.Port+"/"+userName+"/"+gistName+".git") + } + setData(ctx, "httpCopyUrl", httpProtocol+"://"+config.C.HTTP.Domain+":"+config.C.HTTP.Port+"/"+userName+"/"+gistName) setData(ctx, "currentUrl", template.URL(ctx.Request().URL.Path)) diff --git a/public/main.js b/public/main.js index b8d4749..4092926 100644 --- a/public/main.js +++ b/public/main.js @@ -92,6 +92,9 @@ document.addEventListener('DOMContentLoaded', () => { let gistmenubuttoncopy = document.getElementById('gist-menu-button-copy') let gistmenuinput = document.getElementById('gist-menu-input') let gistmenutitle = document.getElementById('gist-menu-title') + gistmenutitle.textContent = gistmenucopy.children[0].firstChild.textContent + gistmenuinput.value = gistmenucopy.children[0].dataset.link + gistmenutoggle.onclick = () => { gistmenucopy.classList.toggle('hidden') } diff --git a/templates/base/gist_header.html b/templates/base/gist_header.html index ae579b9..6c2f6f0 100644 --- a/templates/base/gist_header.html +++ b/templates/base/gist_header.html @@ -144,19 +144,23 @@
- +