From 7f88e080ccf2906187656509534482289607718b Mon Sep 17 00:00:00 2001 From: Nathan Falvey Date: Thu, 5 Mar 2026 13:55:08 +0000 Subject: [PATCH] feat: :sparkles: Added new organisation tracking and some basic badges. Edited the repos table so it contains a badge displaying last commit time, and created a new table displaying current owned organisations. --- update_profile.py | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/update_profile.py b/update_profile.py index c4fe76d..89fc002 100644 --- a/update_profile.py +++ b/update_profile.py @@ -42,6 +42,7 @@ def collect_gitea_data(): version_info = do_request(f"{GITEA_URL}/api/v1/version", headers=headers) version_string = version_info.get("version", "Unknown") if version_info else "Unknown" repos_info = do_request(f"{GITEA_URL}/api/v1/users/{USERNAME}/repos?type=owner", headers=headers) + organisations_info = do_request(f"{GITEA_URL}/api/v1/users/{USERNAME}/orgs", headers=headers) repos = [] if repos_info is not None: for repo in repos_info: @@ -56,13 +57,26 @@ def collect_gitea_data(): "release_count": repo.get("release_count", 0), }) + organisations = [] + if organisations_info is not None: + for org in organisations_info: + organisations.append({ + "name": org.get("name", "N/A"), + "id": org.get("id", "N/A"), + "private": org.get("private", False), + "description": org.get("description", "N/A"), + "full_name": org.get("full_name", "N/A"), + }) + return { "username": USERNAME, "version": version_string, "uptime": get_uptime(), "repos": repos or [], + "organisations": organisations or [], } + def do_readme_parse(): data = collect_gitea_data() # does all the API calls and collects the data into a structured format, collected once to avoid multiple API calls during the README build process, this data will be used to populate the README template with the relevant information about the Gitea instance and the user's repositories. storage_used = sum(repo["size"] for repo in data["repos"]) @@ -70,21 +84,23 @@ def do_readme_parse(): username = data["username"].capitalize() if data["username"] else "Unknown User" + md = f"# {username}'s Developer Hub\n\n" md += f"## Welcome to {username}'s Gitea Developer Hub! This is a collection of repositories and projects that I have created and maintained on my Gitea instance. Here you can find various projects that I have worked on, ranging from personal projects to open-source contributions.\n\n" if data["repos"]: md += f"### 📂 Repository Breakdown\n\n" - tab_headers = ["Name", "Language", "Size", "Releases", "Private", "Archived", "Access Link"] + tab_headers = ["Name", "Language", "Size", "Releases", "Private", "Archived", "Access Link", "Last Commit"] tab_rows = [] for repo in data["repos"]: tab_rows.append([ repo["name"], - repo["language"], + repo["language"] if len(repo["language"]) > 1 else "N/A", format_bytes(repo["size"]), repo["release_count"]if repo["release_count"] > 0 else "None", "Yes" if repo["private"] else "No", "Yes" if repo["archived"] else "No", - f"[View]({GITEA_URL}/{USERNAME}/{repo['name']})" + f"[View]({GITEA_URL}/{USERNAME}/{repo['name']})", + f"![Gitea Last Commit](https://img.shields.io/gitea/last-commit/{USERNAME}/{repo['name']}?gitea_url=https%3A%2F%2Fgitea.nathan-falvey.synology.me&style=flat-square)" ]) md += tabulate.tabulate(tab_rows, headers=tab_headers, tablefmt="pipe") md += "\n\n" @@ -94,9 +110,30 @@ def do_readme_parse(): md += f"**Total Storage Used:** {format_bytes(storage_used)}\n\n" if languages_used: md += f"### **Languages Used:**\n\n" + md += "```\n" for lang in languages_used: - md += f"- **{lang}**\n" + if len(lang) > 1: # Filter out empty or invalid language entries + md += f"- **{lang}**\n" + + md += "```" + md += "\n" + + if data["organisations"]: + md += f"### 🏢 Owned Organisation Breakdown\n\n" + tab_headers = ["Name", "Description", "Private", "Access Link"] + tab_rows = [] + for org in data["organisations"]: + tab_rows.append([ + org["name"], + org["description"] if len(org["description"]) > 1 else "N/A", + "Yes" if org["private"] else "No", + f"[View]({GITEA_URL}/{org['name']})" + ]) + md += tabulate.tabulate(tab_rows, headers=tab_headers, tablefmt="pipe") + md += "\n\n" + + md += "\n"