Tucker McKnight
Add clone buttons and homepage buttons to index Fix some Js errors and make buttons use classes instead of IDs since there are multiple of them on the index page. Some style changes.
3
setCheckbox(currentTheme, document.getElementById('dark-mode-switch'))
3
if (setCheckbox) {
setCheckbox(currentTheme, document.getElementById('dark-mode-switch'))
}
18 19 20 21 22
const createClonePopover = () => {
div.id = "clone-popover"
<span class='clone overflow-hidden input-group-text'>${window.cloneUrl}</span>
<button data-copy-text='${window.cloneUrl}' class='btn btn-primary shadow-none text-white' id='copy-button'>Copy</button>
const popoverBtn = document.getElementById("clone-popover-btn")
18 19 20 21 22
const createClonePopover = (popoverBtn, url) => {
// div.id = "clone-popover"
<span class='clone overflow-hidden input-group-text'>${url || window.cloneUrl}</span>
<button data-copy-text='${url || window.cloneUrl}' class='btn btn-primary shadow-none text-white' id='copy-button'>Copy</button>
// const popoverBtn = document.querySelector(".clone-popover-btn")
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
document.body.addEventListener('click', (event) => {
const target = event.target
// If they didn't click the #clone-popover-btn or if we're not inside of
// popover, or if we *are* inside of a popover but a different one than the
// current one, then close the popover.
const parentPopover = target.closest(".popover")
if (
target.id !== "clone-popover-btn"
&& (
parentPopover === null
|| parentPopover !== bsPopover.tip)
) {
bsPopover.hide()
}
})
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
window.popovers.push(bsPopover)
99 100 101 102
if (document.getElementById('clone-popover-btn')) {
createClonePopover()
}
document.querySelector("#copy-button").addEventListener('click', copyCommand)
99 100 101 102
window.popovers ||= []
document.querySelectorAll('.clone-popover-btn').forEach((button) => {
createClonePopover(button, button.dataset['copyText'])
})
document.querySelectorAll(".copy-button").forEach((button) => {
button.addEventListener('click', copyCommand)
})
document.addEventListener('click', (event) => {
const target = event.target
// If they didn't click the .clone-popover-btn or if we're not inside of
// popover, or if we *are* inside of a popover but a different one than the
// current one, then close the popover.
const parentPopover = target.closest(".popover")
if (
!target.classList.contains("clone-popover-btn")
&& parentPopover === null
) {
window.popovers.forEach(popover => popover.hide())
}
})
13
<button data-copy-text='${data.patchInfo.commit.hash}' class="btn btn-info shadow-none" id="copy-button">Copy</button>
13
<button data-copy-text='${data.patchInfo.commit.hash}' class="btn btn-info shadow-none copy-button">Copy</button>
40
<span class="font-monospace fw-bold"><a href="${data.reposPath}/${slugify(data.patchInfo.repoName)}/branches/${slugify(data.patchInfo.branchName)}/files/${slugify(hunk.fileName)}.html">${hunk.fileName}:${hunk.lineNumber}</a></span>
40
<span class="font-monospace fw-bold"><a href="${data.reposPath}/${slugify(data.patchInfo.repoName)}/branches/${slugify(data.patchInfo.branchName)}/files/${hunk.fileName.split('/').map((filePart) => slugify(filePart)).join('/')}">${hunk.fileName}:${hunk.lineNumber}</a></span>
1
const currentBadge = currentBranch === branch.name ? '<div class="badge rounded-pill bg-primary mx-1">current</div>' : ''
1
const currentBadge = currentBranch === branch.name ? '<div class="badge rounded-pill bg-secondary mx-1">current</div>' : ''
112
<a class="nav-link ${data.navTab === 'home' ? 'active' : ''}" aria-current="page" href="${nav.repoCurrentBranchHome()}">ReadMe</a>
112
<a class="nav-link ${data.navTab === 'home' ? 'active' : ''}" aria-current="page" href="${nav.repoCurrentBranchHome()}">Home</a>
14
<span class="bezel-gray px-1"><a href="${data.reposPath}/${data.fileInfo.repoName}/branches/${data.fileInfo.branchName}/files">🏠 ./</a></span>${
14
<span class="bezel-gray px-1"><a href="${data.reposPath}/${data.fileInfo.repoName}/branches/${data.fileInfo.branchName}/files">./</a></span>${
71
return `<a href="${data.reposPath}/${slugify(data.fileInfo.repoName)}/branches/${slugify(data.fileInfo.branchName)}/patches/${annotation.sha}">${annotation.sha.substr(0, 6)}</a> ${annotation.author}`
71
return `<a href="${data.reposPath}/${slugify(data.fileInfo.repoName)}/branches/${slugify(data.fileInfo.branchName)}/commits/${annotation.sha}">${annotation.sha.substr(0, 6)}</a> ${annotation.author}`
11
<span>🏠 ./</span>
11
<span>./</span>
15 16 17 18
<h1>Tucker's Repositories</h1>
<div class="mx-2 card bezel-gray" style="width: 18rem;">
<h2 class="card-title fs-5">${repo.name}</h2>
<a href="${data.reposPath}/${slugify(repo.name)}/branches/${repo.defaultBranch}" class="btn btn-primary text-white">Go to ${repo.name}</a>
15 16 17 18
<h1>${data.reposConfig.defaultTemplateConfiguration?.allRepositoriesPageTitle || "All Repositories"}</h1>
<div class="m-2 card bezel-gray flex-grow-1" style="flex-basis: 20rem;">
<div class="card-header">
<a class="card-title fs-5" href="${data.reposPath}/${slugify(repo.name)}/branches/${repo.defaultBranch}">${repo.name}</a>
</div>
</div>
<div class="card-footer">
<a href="${data.reposPath}/${slugify(repo.name)}/branches/${repo.defaultBranch}" class="mx-1 my-2 btn btn-primary text-white">Go to site</a>
<button class="mx-1 my-2 btn btn-outline-secondary shadow-none dropdown-toggle clone-popover-btn" data-copy-text="${repo.cloneUrl}">Clone</button>
${(data.reposConfig.repos[repo.name].defaultTemplateConfiguration?.homepageButtons || []).map((button) => {
return `<a class="mx-1 my-2 btn btn-outline-secondary shadow-none" href="${button.url}" ${button.newTab ? 'target="_blank"' : ''}>${button.text}${button.newTab ? ' <span>⧉</span>' : ''}</a>`
}).join('')}
35
35
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
<script src="${data.reposPath}/frontend/main-frontend.bundle.js"></script>
57
<button class="btn btn-info btn-lg dropdown-toggle" id="clone-popover-btn">Clone</button>
57
<button class="btn btn-info btn-lg dropdown-toggle clone-popover-btn">Clone</button>
142
142
"defaultTemplateConfiguration": {
"additionalProperties": false,
"properties": {
"allRepositoriesPageTitle": {
"type": "string"
}
},
"type": "object"
},
234 235 236 237 238 239 240
.badge.bg-primary {
background: linear-gradient(color.adjust($primary, $lightness: 10%), $primary);
box-shadow: -1px -3px 4px inset color.adjust($primary, $lightness: -30%);
.badge.bg-info {
background: linear-gradient(color.adjust($info, $lightness: 10%), $info);
box-shadow: -1px -3px 4px inset color.adjust($info, $lightness: -30%);
}
234 235 236 237 238 239 240
@each $color, $value in $bezel-colors {
.badge.bg-#{$color} {
background: linear-gradient(color.adjust($value, $lightness: 10%), $value);
box-shadow: -1px -3px 4px inset color.adjust($value, $lightness: -30%);
}
// .badge.bg-primary {
// background: linear-gradient(color.adjust($primary, $lightness: 10%), $primary);
// box-shadow: -1px -3px 4px inset color.adjust($primary, $lightness: -30%);
// }
//
// .badge.bg-info {
// background: linear-gradient(color.adjust($info, $lightness: 10%), $info);
// box-shadow: -1px -3px 4px inset color.adjust($info, $lightness: -30%);
// }
41
41
defaultTemplateConfiguration?: {
allRepositoriesPageTitle?: string,
},