an evil little hack i enjoy 

<a class="item" href="https://git.xn--scling-oua.cat.family/">[Gitweb]</a>
<script type="module">
const gitwebLink = document.querySelector(
'a[href="https://git.xn--scling-oua.cat.family/"]',
);

const editNavbar = function editNavbar() {
const navbarLeft = document.querySelector("#navbar .navbar-left");
const spacer = document.querySelector("#navbar .navbar-left div");
for (const e of [gitwebLink, spacer]) {
e.remove();
navbarLeft.prepend(e);
}
};

const editGitwebLink = function editGitwebLink() {
const pathParts = location.pathname.split("/");
if (pathParts[1] !== 'aescling' || pathParts[2] in [undefined, ""]) {
return;
}

const repo = pathparts[2];
const uri = gitwebLink.getAttribute("href");
gitwebLink.setAttribute("href", `${uri}${repo}.git`);
};

const main = function main() {
editNavbar();
editGitwebLink();
};

main();
</script>

re: an evil little hack i enjoy 

@aescling I'm stupid, what does this do?

re: an evil little hack i enjoy 

@vaporeon_ this is code from my forgejo instance. it does two things:

  1. move the gitweb link to the leftmost spot in the navigation bar (the custom template infrastructure allows you to add a link to the end, but i don’t want the link to be at the end of the navbar, i want it at the start. so i do some client side DOM manipulation)
  2. if the user is looking at a git repository, change the gitweb link to point to that repository

i would purrefur to just render it all server side but i’m not gonna hack on forgejo itself just fur small UI changes

re: an evil little hack i enjoy 

@vaporeon_ also the results of disabling JS doesn’t ruin anything, you just don’t get the dynamically generated gitweb URI and the link gets put in an awkward place on the navbar

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.