Skip to content

Commit

Permalink
update README.md automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Oct 24, 2024
1 parent de0ec07 commit 1b16fd3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). 💖

<!-- SPONSORS -->
<p align="center">
<a href="https://github.com/lechler-gmbh"><img src="https://github.com/lechler-gmbh.png" width="50px" alt="Lechler GmbH" /></a>
<a href="https://github.com/daviborges666"><img src="https://github.com/daviborges666.png" width="50px"alt="daviborges666" /></a>
<a href="https://github.com/lechler-gmbh"><img src="https://github.com/lechler-gmbh.png" width="50px" alt="Lechler GmbH" /></a>
<a href="https://github.com/Zhifeng2019"><img src="https://github.com/Zhifeng2019.png" width="50px" alt="Zhifeng" /></a>
<a href="https://github.com/sereneturtlefox"><img src="https://github.com/sereneturtlefox.png" width="50px" alt="None" /></a>
<a href="https://github.com/daviborges666"><img src="https://github.com/daviborges666.png" width="50px" alt="Davi Borges" /></a>
</p>
<!-- SPONSORS -->

Consider this low-barrier form of contribution yourself.
Your [support](https://github.com/sponsors/zauberzeug) is much appreciated.
Expand Down
22 changes: 20 additions & 2 deletions fetch_sponsors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import json
import os
import re
from pathlib import Path

import requests
Expand Down Expand Up @@ -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
Expand All @@ -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 = '<p align="center">\n'
for sponsor in sponsors:
if sponsor['tier_amount'] >= 25 and not sponsor['tier_is_one_time']:
sponsor_html += f' <a href="{sponsor["url"]}"><img src="{sponsor["url"]}.png" width="50px" alt="{sponsor["name"]}" /></a>\n'
sponsor_html += '</p>'
readme_path = Path('README.md')
readme_content = readme_path.read_text()
updated_content = re.sub(
r'<!-- SPONSORS -->.*?<!-- SPONSORS -->',
f'<!-- SPONSORS -->\n{sponsor_html}\n<!-- SPONSORS -->',
readme_content,
flags=re.DOTALL,
)
readme_path.write_text(updated_content)

print('README.md and sponsors.json updated successfully.')
4 changes: 2 additions & 2 deletions website/main_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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') \
Expand Down
8 changes: 1 addition & 7 deletions website/sponsors.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"website": [
"top": [
"daviborges666"
],
"readme": [
"Zhifeng2019",
"daviborges666",
"lechler-gmbh",
"sereneturtlefox"
],
"total": 18,
"contributors": 125
}

0 comments on commit 1b16fd3

Please sign in to comment.