feat: make work on home and local
This commit is contained in:
parent
64bca6e9cc
commit
0d408d5dc3
2 changed files with 21 additions and 5 deletions
19
app.py
19
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,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = `<code>git clone https://git.barrettruth.com/git/${repoName}</code>`;
|
||||
cloneUrl.innerHTML = `<code>git clone \nhttps://git.barrettruth.com/git/${repoName}</code>`;
|
||||
|
||||
post.appendChild(cloneUrl);
|
||||
const viewNote = document.createElement("div");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue