|
5 | 5 | OWNER = "Undiluted7027" |
6 | 6 | REPO = "allos-agent-sdk" |
7 | 7 | README_PATH = "README.md" |
| 8 | +IMAGES_PER_ROW = 10 |
| 9 | + |
8 | 10 | url = f"https://api.github.com/repos/{OWNER}/{REPO}/stargazers" |
9 | 11 | headers = {"Accept": "application/vnd.github.v3.star+json"} |
10 | 12 | params = {"per_page": 100, "page": 1} |
| 13 | + |
11 | 14 | print("Fetching first 100 stargazers...") |
12 | 15 | response = requests.get(url, headers=headers, params=params) |
13 | 16 | response.raise_for_status() |
14 | 17 | data = response.json() |
15 | | -stargazers_md = [] |
| 18 | + |
| 19 | +stargazers_html = [] |
16 | 20 | for entry in data: |
17 | 21 | user = entry["user"] |
18 | 22 | login = user["login"] |
19 | 23 | html_url = user["html_url"] |
20 | | - avatar_url = f"{html_url}.png?size=50" |
21 | | - stargazers_md.append(f"[]({html_url})") |
| 24 | + avatar_url = user["avatar_url"] + "&s=50" # Add size parameter |
22 | 25 |
|
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!* ⭐" |
25 | 33 | 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 |
29 | 46 |
|
30 | | -# Join avatars |
31 | | -stars_section = " ".join(stargazers_md) |
32 | 47 | new_content = f"<!-- STARGAZERS:START -->\n{stars_section}\n<!-- STARGAZERS:END -->" |
33 | | -# Update README.md |
| 48 | + |
| 49 | +# Update README |
34 | 50 | with open(README_PATH, "r", encoding="utf-8") as f: |
35 | 51 | readme = f.read() |
| 52 | + |
36 | 53 | updated = re.sub( |
37 | 54 | r"<!-- STARGAZERS:START -->.*<!-- STARGAZERS:END -->", |
38 | 55 | new_content, |
39 | 56 | readme, |
40 | 57 | flags=re.DOTALL, |
41 | 58 | ) |
| 59 | + |
42 | 60 | with open(README_PATH, "w", encoding="utf-8") as f: |
43 | 61 | f.write(updated) |
44 | | -print("✅ README updated with latest stargazers!") |
| 62 | + |
| 63 | +print(f"✅ README updated with {len(stargazers_html)} stargazers!") |
0 commit comments