Pi66

git.pi66.xyz
A web interface for the pi66.xyz Git server
git clone https://git.pi66.xyz/git.pi66.xyz

src/plugins/license_builder.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
from models import Repo
from progress import progress, progress_done


def create_license_pages(api, repos: list[Repo]):
    total = len(repos)
    for i, repo in enumerate(repos, 1):
        progress("License", i, total)
        try:
            html = api.jinja_handler(api.config, '{% extends "License.html" %}', plugins={
                "repo_name": repo.name,
                "repo_desc": repo.desc,
                "page_title": f"Pi66 - {repo.name} - License",
                "metadata_content": repo.desc or "A web interface for the pi66.xyz Git server",
                "license_content": repo.license if repo.license else "No license file found.",
            })

            dest = os.path.join(api.config.tree.draft_dest if api.mode == "draft" else api.config.tree.release_dest, f"{repo.name.lower()}/license.html")
            api.save_html(html, dest)
        except Exception as e:
            api.log.warn(f"Error building license for {repo.name}: {e}")
    progress_done("License", total)