Updated links menu items

This commit is contained in:
Thomas Miceli 2023-03-15 11:47:17 +01:00
parent e95a1b6840
commit 79a7a9a32f
No known key found for this signature in database
GPG key ID: D86C6F6390AF050F
4 changed files with 32 additions and 15 deletions

View file

@ -31,14 +31,24 @@ func gistInit(next echo.HandlerFunc) echo.HandlerFunc {
} }
setData(ctx, "gist", gist) setData(ctx, "gist", gist)
if config.C.SSH.Port == "22" { if config.C.SSH.Enabled {
setData(ctx, "ssh_clone_url", config.C.SSH.Domain+":"+userName+"/"+gistName+".git") if config.C.SSH.Port == "22" {
} else { setData(ctx, "sshCloneUrl", config.C.SSH.Domain+":"+userName+"/"+gistName+".git")
setData(ctx, "ssh_clone_url", "ssh://"+config.C.SSH.Domain+":"+config.C.SSH.Port+"/"+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") httpProtocol := "http"
setData(ctx, "httpCopyUrl", "http://"+ctx.Request().Host+"/"+userName+"/"+gistName) 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)) setData(ctx, "currentUrl", template.URL(ctx.Request().URL.Path))

3
public/main.js vendored
View file

@ -92,6 +92,9 @@ document.addEventListener('DOMContentLoaded', () => {
let gistmenubuttoncopy = document.getElementById('gist-menu-button-copy') let gistmenubuttoncopy = document.getElementById('gist-menu-button-copy')
let gistmenuinput = document.getElementById('gist-menu-input') let gistmenuinput = document.getElementById('gist-menu-input')
let gistmenutitle = document.getElementById('gist-menu-title') let gistmenutitle = document.getElementById('gist-menu-title')
gistmenutitle.textContent = gistmenucopy.children[0].firstChild.textContent
gistmenuinput.value = gistmenucopy.children[0].dataset.link
gistmenutoggle.onclick = () => { gistmenutoggle.onclick = () => {
gistmenucopy.classList.toggle('hidden') gistmenucopy.classList.toggle('hidden')
} }

View file

@ -144,19 +144,23 @@
<div class="flex rounded-md shadow-sm"> <div class="flex rounded-md shadow-sm">
<div class="relative"> <div class="relative">
<button type="button" id="gist-menu-toggle" class="relative text-xs inline-flex items-center space-x-2 rounded-l-md border border-gray-600 bg-gray-800 px-2 py-1.5 text-sm font-medium text-slate-300 hover:bg-gray-700 hover:border-gray-500 hover:text-slate-300 focus:border-primary-500 focus:outline-none focus:ring-1 focus:ring-primary-500 leading-3 focus-within:z-10 -mr-px"> <button type="button" id="gist-menu-toggle" class="relative text-xs inline-flex items-center space-x-2 rounded-l-md border border-gray-600 bg-gray-800 px-2 py-1.5 text-sm font-medium text-slate-300 hover:bg-gray-700 hover:border-gray-500 hover:text-slate-300 focus:border-primary-500 focus:outline-none focus:ring-1 focus:ring-primary-500 leading-3 focus-within:z-10 -mr-px">
<span id="gist-menu-title">Clone via HTTP</span> <span id="gist-menu-title"></span>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" /> <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
</svg> </svg>
</button> </button>
<div class="absolute left-0 z-10 mt-2 w-56 origin-top-left bg-gray-800 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1"> <div class="absolute left-0 z-10 mt-2 w-56 origin-top-left bg-gray-800 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" role="menu" aria-orientation="vertical" aria-labelledby="menu-button" tabindex="-1">
<div class="py-1 cursor-pointer border-1 rounded-md border-gray-700 hidden" id="gist-menu-copy" role="none"> <div class="py-1 cursor-pointer border-1 rounded-md border-gray-700 hidden" id="gist-menu-copy" role="none">
<div class="text-slate-300 block px-4 py-2 text-sm hover:bg-gray-700 gist-menu-item" role="menuitem" id="gist-menu-http" data-link="{{ .httpCloneUrl }}"><p>Clone via HTTP</p> {{ if .httpCloneUrl }}
<p class="text-xs font-normal text-gray-400">Clone with Git using HTTP basic authentication.</p> <div class="text-slate-300 block px-4 py-2 text-sm hover:bg-gray-700 gist-menu-item" role="menuitem" id="gist-menu-http" data-link="{{ .httpCloneUrl }}"><p>Clone via {{ .httpProtocol }}</p>
</div> <p class="text-xs font-normal text-gray-400">Clone with Git using HTTP basic authentication.</p>
<div class="text-slate-300 block px-4 py-2 text-sm hover:bg-gray-700 gist-menu-item" role="menuitem" id="gist-menu-ssh" data-link="{{ .ssh_clone_url }}"><p>Clone via SSH</p> </div>
<p class="text-xs font-normal text-gray-400">Clone with Git using an SSH key.</p> {{ end }}
</div> {{ if .sshCloneUrl }}
<div class="text-slate-300 block px-4 py-2 text-sm hover:bg-gray-700 gist-menu-item" role="menuitem" id="gist-menu-ssh" data-link="{{ .sshCloneUrl }}"><p>Clone via SSH</p>
<p class="text-xs font-normal text-gray-400">Clone with Git using an SSH key.</p>
</div>
{{ end }}
<div class="text-slate-300 block px-4 py-2 text-sm hover:bg-gray-700 gist-menu-item" role="menuitem" id="gist-menu-embed" data-link="(soon)"><p>Embed</p> <div class="text-slate-300 block px-4 py-2 text-sm hover:bg-gray-700 gist-menu-item" role="menuitem" id="gist-menu-embed" data-link="(soon)"><p>Embed</p>
<p class="text-xs font-normal text-gray-400">Embed this gist in your website. (soon)</p> <p class="text-xs font-normal text-gray-400">Embed this gist in your website. (soon)</p>
</div> </div>
@ -167,7 +171,7 @@
</div> </div>
</div> </div>
<div class="relative flex flex-grow items-stretch focus-within:z-10"> <div class="relative flex flex-grow items-stretch focus-within:z-10">
<input id="gist-menu-input" value="{{ .httpCloneUrl }}" class="block code bg-gray-900 w-full rounded-none border border-gray-600 focus:border-primary-500 focus:ring-primary-500 focus:outline-none focus:ring-1 text-xs px-2"> <input id="gist-menu-input" value="" class="block code bg-gray-900 w-full rounded-none border border-gray-600 focus:border-primary-500 focus:ring-primary-500 focus:outline-none focus:ring-1 text-xs px-2">
</div> </div>
<button id="gist-menu-button-copy" type="button" class="relative text-xs -ml-px inline-flex items-center space-x-2 rounded-r-md border border-gray-600 bg-gray-800 px-2 py-1 text-sm font-medium text-slate-300 hover:bg-gray-700 hover:border-gray-500 hover:text-slate-300 focus:border-primary-500 focus:outline-none focus:ring-1 focus:ring-primary-500 leading-3"> <button id="gist-menu-button-copy" type="button" class="relative text-xs -ml-px inline-flex items-center space-x-2 rounded-r-md border border-gray-600 bg-gray-800 px-2 py-1 text-sm font-medium text-slate-300 hover:bg-gray-700 hover:border-gray-500 hover:text-slate-300 focus:border-primary-500 focus:outline-none focus:ring-1 focus:ring-primary-500 leading-3">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">

View file

@ -3,7 +3,7 @@
<header class="pb-4"> <header class="pb-4">
<div> <div>
<h1 class="text-2xl font-bold leading-tight">SSH Keys</h1> <h1 class="text-2xl font-bold leading-tight">SSH Keys</h1>
<p class="text-sm text-gray-400 italic">Used only to pull/push gists using Git via SSH</p> <p class="text-sm text-gray-400 italic">Used only to push gists using Git via SSH</p>
</div> </div>
</header> </header>
<main> <main>