From 0d408d5dc3df326f79f14726fbb911a1945c0e2d Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 14 May 2025 12:37:55 -0400 Subject: [PATCH] feat: make work on home and local --- app.py | 19 ++++++++++++++++--- scripts/index.js | 7 +++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 2ac2d86..e72f5a1 100644 --- a/app.py +++ b/app.py @@ -1,14 +1,19 @@ #!/usr/bin/env python3 +import getpass import os from dataclasses import dataclass +from pathlib import Path from flask import Flask, jsonify, render_template, send_from_directory app = Flask(__name__, static_folder=None) -GIT_REPO_PATH = "/home/frozenpipe/dev" -EXPORT_MARKER = "readme.md" +GIT_REPO_PATH = str(Path.home() / "dev") +EXPORT_MARKER = "git-daemon-export-ok" +if getpass.getuser() == "ec2-user": + GIT_REPO_PATH = "/srv/git" + EXPORT_MARKER = "git-daemon-export-ok" @dataclass @@ -52,9 +57,17 @@ def get_repositories(): description = "No description available" except _ as _: pass + + display_name = item + if display_name.lower().endswith(".git"): + display_name = display_name[:-4] + repositories.append( Repository( - name=item, description=description, path=repo_path, exported=exported + name=display_name, + description=description, + path=repo_path, + exported=exported, ) ) diff --git a/scripts/index.js b/scripts/index.js index 1470c53..6737697 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -39,7 +39,10 @@ window.typechars = function (e) { function renderRepoDescription(repoLink) { const postsContainer = document.getElementById("repos"); const repoId = repoLink.getAttribute("data-repo-id"); - const repoName = repoLink.textContent; + let repoName = repoLink.textContent; + if (repoName.toLowerCase().endsWith('.git')) { + repoName = repoName.slice(0, -4); + } postsContainer.innerHTML = ""; @@ -58,7 +61,7 @@ function renderRepoDescription(repoLink) { const cloneUrl = document.createElement("div"); cloneUrl.style.marginTop = "15px"; - cloneUrl.innerHTML = `git clone https://git.barrettruth.com/git/${repoName}`; + cloneUrl.innerHTML = `git clone \nhttps://git.barrettruth.com/git/${repoName}`; post.appendChild(cloneUrl); const viewNote = document.createElement("div");