Skip to content

Commit b6665f1

Browse files
committed
chore: Updated stargazer script to render responsive tables in README
1 parent d544172 commit b6665f1

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

scripts/update_stars.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,59 @@
55
OWNER = "Undiluted7027"
66
REPO = "allos-agent-sdk"
77
README_PATH = "README.md"
8+
IMAGES_PER_ROW = 10
9+
810
url = f"https://api.github.com/repos/{OWNER}/{REPO}/stargazers"
911
headers = {"Accept": "application/vnd.github.v3.star+json"}
1012
params = {"per_page": 100, "page": 1}
13+
1114
print("Fetching first 100 stargazers...")
1215
response = requests.get(url, headers=headers, params=params)
1316
response.raise_for_status()
1417
data = response.json()
15-
stargazers_md = []
18+
19+
stargazers_html = []
1620
for entry in data:
1721
user = entry["user"]
1822
login = user["login"]
1923
html_url = user["html_url"]
20-
avatar_url = f"{html_url}.png?size=50"
21-
stargazers_md.append(f"[![{login}]({avatar_url})]({html_url})")
24+
avatar_url = user["avatar_url"] + "&s=50" # Add size parameter
2225

23-
if not stargazers_md:
24-
stars_section = "*No stargazers yet. Be the first!*"
26+
# ✅ USE HTML, NOT MARKDOWN!
27+
html_img = f'<a href="{html_url}"><img src="{avatar_url}" width="50" height="50" alt="{login}"/></a>'
28+
stargazers_html.append(html_img)
29+
30+
# Handle empty state
31+
if not stargazers_html:
32+
stars_section = "*No stargazers yet. Be the first!* ⭐"
2533
else:
26-
stars_section = " ".join(stargazers_md)
27-
# Optional: Add count
28-
stars_section = f"**{len(stargazers_md)} Amazing Stargazers:**\n\n{stars_section}"
34+
# Create table rows
35+
rows = []
36+
for i in range(0, len(stargazers_html), IMAGES_PER_ROW):
37+
row_items = stargazers_html[i : i + IMAGES_PER_ROW]
38+
cells = "".join([f"<td align='center'>{item}</td>" for item in row_items])
39+
rows.append(f"<tr>{cells}</tr>")
40+
41+
table = "<table>\n" + "\n".join(rows) + "\n</table>"
42+
43+
# Add count
44+
count_text = f"**{len(stargazers_html)} Amazing Stargazer{'s' if len(stargazers_html) != 1 else ''}:**\n\n"
45+
stars_section = count_text + table
2946

30-
# Join avatars
31-
stars_section = " ".join(stargazers_md)
3247
new_content = f"<!-- STARGAZERS:START -->\n{stars_section}\n<!-- STARGAZERS:END -->"
33-
# Update README.md
48+
49+
# Update README
3450
with open(README_PATH, "r", encoding="utf-8") as f:
3551
readme = f.read()
52+
3653
updated = re.sub(
3754
r"<!-- STARGAZERS:START -->.*<!-- STARGAZERS:END -->",
3855
new_content,
3956
readme,
4057
flags=re.DOTALL,
4158
)
59+
4260
with open(README_PATH, "w", encoding="utf-8") as f:
4361
f.write(updated)
44-
print("✅ README updated with latest stargazers!")
62+
63+
print(f"✅ README updated with {len(stargazers_html)} stargazers!")

0 commit comments

Comments
 (0)