From 2eaf54df355ca77b33ff77d1b59cb2771019a2c3 Mon Sep 17 00:00:00 2001 From: 0xMarcio Date: Wed, 7 Oct 2026 15:18:29 +0200 Subject: [PATCH] Add conditional GitHub sponsorship links --- .github/FUNDING.yml | 1 + .github/workflows/site.yml | 16 ++++++++++++++++ scripts/brand.py | 2 ++ scripts/build_pages.py | 13 ++++++++++--- templates/index.html | 2 +- 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000000..4dc892a0d9b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: 0xMarcio diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index f846edb5eb4..c9a35aadaf8 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -38,6 +38,22 @@ jobs: - name: Build site data run: python3 scripts/build_site.py + - name: Check sponsorship availability + timeout-minutes: 1 + continue-on-error: true + env: + GH_TOKEN: ${{ github.token }} + run: | + sponsor_enabled=false + if sponsor_public=$(gh api graphql \ + -f query='query { user(login: "0xMarcio") { sponsorsListing { isPublic } } }' \ + --jq '.data.user.sponsorsListing.isPublic // false'); then + if [ "$sponsor_public" = "true" ]; then + sponsor_enabled=true + fi + fi + echo "POCINDEX_SPONSORS_ENABLED=$sponsor_enabled" >> "$GITHUB_ENV" + - name: Build homepage and CVE pages run: python3 scripts/build_pages.py diff --git a/scripts/brand.py b/scripts/brand.py index ada769c3d77..f152ea0f97a 100644 --- a/scripts/brand.py +++ b/scripts/brand.py @@ -53,3 +53,5 @@ SOURCES_LINE = ( 'first epss' ) REPO_LINK = f'github.com/{SLUG}' +# Rendered beside REPO_LINK only once the Sponsors profile is public. +SPONSOR_LINK = 'sponsor' diff --git a/scripts/build_pages.py b/scripts/build_pages.py index 2e21e61b38a..bf6cbbe10e1 100644 --- a/scripts/build_pages.py +++ b/scripts/build_pages.py @@ -31,7 +31,7 @@ from urllib.parse import unquote, urlsplit ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir) sys.path.insert(0, os.path.join(ROOT, "scripts")) -from brand import BRAND, DESCRIPTION, FONTS, REPO_LINK, SITE, SLUG, SOURCES_LINE, SUBTITLE, TITLE, host +from brand import BRAND, DESCRIPTION, FONTS, REPO_LINK, SITE, SLUG, SOURCES_LINE, SPONSOR_LINK, SUBTITLE, TITLE, host DOCS = os.path.join(ROOT, "docs") RELATED = 6 @@ -355,9 +355,16 @@ def header(count: int | None = None) -> str: """ +def project_links() -> str: + """Show the sponsor link only when the workflow confirms a public profile.""" + if os.environ.get("POCINDEX_SPONSORS_ENABLED") != "true": + return REPO_LINK + return f"{REPO_LINK} · {SPONSOR_LINK}" + + def footer(tail: str = 'Back to the index') -> str: return (f'") + f"{SOURCES_LINE}{tail}{project_links()}") def page(entry: dict, data: dict) -> str: @@ -747,7 +754,7 @@ def homepage(cves: list, kev: dict, trending: dict) -> str: brand=esc(BRAND), title=esc(TITLE), subtitle=esc(SUBTITLE), description=esc(DESCRIPTION), site=esc(SITE), fonts=FONTS, stylesheet_url=asset_url("style.css"), script_url=asset_url("logic.js"), - sources_line=SOURCES_LINE, repo_link=REPO_LINK, website_schema=json_ld(website), + sources_line=SOURCES_LINE, project_links=project_links(), website_schema=json_ld(website), total_cves=f"{trending['total_cves']:,}", with_pocs=f"{len(indexed):,}", kev=f"{len(kev):,}", landed_rows=trend_rows(trending.get("landed"), True), generated=esc(generated.strftime("%Y-%m-%d %H:%M UTC")), diff --git a/templates/index.html b/templates/index.html index 5260b46daef..db65901e1e0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -107,7 +107,7 @@
${sources_line} index built ${generated} - ${repo_link} + ${project_links}