Skip to content

Commit

Permalink
Updated links menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
thomiceli committed Mar 15, 2023
1 parent e95a1b6 commit 79a7a9a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
22 changes: 16 additions & 6 deletions internal/web/gist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:https://"+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:https://"+config.C.SSH.Domain+":"+config.C.SSH.Port+"/"+userName+"/"+gistName+".git")
}
}

setData(ctx, "httpCloneUrl", "http:https://"+ctx.Request().Host+"/"+userName+"/"+gistName+".git")
setData(ctx, "httpCopyUrl", "http:https://"+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+":https://"+config.C.HTTP.Domain+":"+config.C.HTTP.Port+"/"+userName+"/"+gistName+".git")
}
setData(ctx, "httpCopyUrl", httpProtocol+":https://"+config.C.HTTP.Domain+":"+config.C.HTTP.Port+"/"+userName+"/"+gistName)

setData(ctx, "currentUrl", template.URL(ctx.Request().URL.Path))

Expand Down
3 changes: 3 additions & 0 deletions public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
20 changes: 12 additions & 8 deletions templates/base/gist_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,23 @@ <h1 class="text-2xl font-bold leading-tight break-all">
<div class="flex rounded-md shadow-sm">
<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">
<span id="gist-menu-title">Clone via HTTP</span>
<span id="gist-menu-title"></span>
<svg xmlns="http:https://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" />
</svg>
</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="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>
<p class="text-xs font-normal text-gray-400">Clone with Git using HTTP basic authentication.</p>
</div>
<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>
<p class="text-xs font-normal text-gray-400">Clone with Git using an SSH key.</p>
</div>
{{ if .httpCloneUrl }}
<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>
<p class="text-xs font-normal text-gray-400">Clone with Git using HTTP basic authentication.</p>
</div>
{{ end }}
{{ 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>
<p class="text-xs font-normal text-gray-400">Embed this gist in your website. (soon)</p>
</div>
Expand All @@ -167,7 +171,7 @@ <h1 class="text-2xl font-bold leading-tight break-all">
</div>
</div>
<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>
<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:https://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-5 h-5">
Expand Down
2 changes: 1 addition & 1 deletion templates/pages/ssh_keys.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<header class="pb-4">
<div>
<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>
</header>
<main>
Expand Down

0 comments on commit 79a7a9a

Please sign in to comment.