From 1b16fd399f4838cd1358b7c83d58cdfe69e0b3cf Mon Sep 17 00:00:00 2001 From: Falko Schindler Date: Thu, 24 Oct 2024 08:21:43 +0200 Subject: [PATCH] update README.md automatically --- README.md | 8 ++++++-- fetch_sponsors.py | 22 ++++++++++++++++++++-- website/main_page.py | 4 ++-- website/sponsors.json | 8 +------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ba4d2569a..da99c4777 100644 --- a/README.md +++ b/README.md @@ -109,10 +109,14 @@ because of their great performance and ease of use. Maintenance of this project is made possible by all the [contributors](https://github.com/zauberzeug/nicegui/graphs/contributors) and [sponsors](https://github.com/sponsors/zauberzeug). If you would like to support this project and have your avatar or company logo appear below, please [sponsor us](https://github.com/sponsors/zauberzeug). 💖 +

- Lechler GmbH - daviborges666 + Lechler GmbH + Zhifeng + None + Davi Borges

+ Consider this low-barrier form of contribution yourself. Your [support](https://github.com/sponsors/zauberzeug) is much appreciated. diff --git a/fetch_sponsors.py b/fetch_sponsors.py index 3ff9ec016..1bc0fad15 100755 --- a/fetch_sponsors.py +++ b/fetch_sponsors.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import json import os +import re from pathlib import Path import requests @@ -70,6 +71,7 @@ 'tier_is_one_time': tier['isOneTime'], 'created_at': sponsor['createdAt'], }) +sponsors.sort(key=lambda s: s['created_at']) contributors = [] page = 1 @@ -93,8 +95,24 @@ print(f'Total contributors for NiceGUI: {len(contributors)}') Path('website/sponsors.json').write_text(json.dumps({ - 'website': [s['login'] for s in sponsors if s['tier_amount'] >= 100 and not s['tier_is_one_time']], - 'readme': [s['login'] for s in sponsors if s['tier_amount'] >= 25 and not s['tier_is_one_time']], + 'top': [s['login'] for s in sponsors if s['tier_amount'] >= 100 and not s['tier_is_one_time']], 'total': len(sponsors), 'contributors': len(contributors), }, indent=2) + '\n') + +sponsor_html = '

\n' +for sponsor in sponsors: + if sponsor['tier_amount'] >= 25 and not sponsor['tier_is_one_time']: + sponsor_html += f' {sponsor[\n' +sponsor_html += '

' +readme_path = Path('README.md') +readme_content = readme_path.read_text() +updated_content = re.sub( + r'.*?', + f'\n{sponsor_html}\n', + readme_content, + flags=re.DOTALL, +) +readme_path.write_text(updated_content) + +print('README.md and sponsors.json updated successfully.') diff --git a/website/main_page.py b/website/main_page.py index af255d933..b2f3d3b3e 100644 --- a/website/main_page.py +++ b/website/main_page.py @@ -174,12 +174,12 @@ def create() -> None: ui.markdown(f''' our top {'sponsor' if SPONSORS['total'] == 1 else 'sponsors'} ''') - for sponsor in SPONSORS['website']: + for sponsor in SPONSORS['top']: with ui.link(target=f'https://github.com/{sponsor}').classes('row items-center gap-2'): ui.image(f'https://github.com/{sponsor}.png').classes('w-12 h-12 border') ui.label(f'@{sponsor}') ui.markdown(f''' - as well as {SPONSORS['total'] - len(SPONSORS['website'])} other [sponsors](https://github.com/sponsors/zauberzeug) + as well as {SPONSORS['total'] - len(SPONSORS['top'])} other [sponsors](https://github.com/sponsors/zauberzeug) and {SPONSORS['contributors']} [contributors](https://github.com/zauberzeug/nicegui/graphs/contributors). ''').classes('bold-links arrow-links') with ui.link(target='https://github.com/sponsors/zauberzeug').style('color: black !important') \ diff --git a/website/sponsors.json b/website/sponsors.json index 688f48cdf..15ee0d84c 100644 --- a/website/sponsors.json +++ b/website/sponsors.json @@ -1,13 +1,7 @@ { - "website": [ + "top": [ "daviborges666" ], - "readme": [ - "Zhifeng2019", - "daviborges666", - "lechler-gmbh", - "sereneturtlefox" - ], "total": 18, "contributors": 125 }