Skip to content

Commit 130cba6

Browse files
committed
Add contributors page
1 parent db385b7 commit 130cba6

File tree

6 files changed

+68
-15
lines changed

6 files changed

+68
-15
lines changed

.github/workflows/deploy_website.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ jobs:
2929
uses: actions/checkout@v4
3030

3131
- name: Install Hugo CLI
32-
env:
33-
HUGO_VERSION:
3432
run: |
3533
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.124.1/hugo_extended_0.124.1_linux-amd64.deb \
3634
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.hugo_build.lock
22
content/status.md
3+
content/contributors.md
34
public/
45
resources/_gen/
56
.DS_Store

.pre-commit-config.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ repos:
3030
hooks:
3131
- id: black
3232

33-
- repo: https://github.com/pre-commit/mirrors-prettier
34-
rev: ffb6a759a979008c0e6dff86e39f4745a2d9eac4 # frozen: v3.1.0
35-
hooks:
36-
- id: prettier
37-
files: \.(css|html|md|yml|yaml)
38-
args: [--prose-wrap=preserve]
39-
exclude: ^{{cookiecutter.__translations_repo_name}}/
40-
4133
- repo: https://github.com/asottile/pyupgrade
4234
rev: 32151ac97cbfd7f9dcd22e49516fb32266db45b4 # frozen: v3.16.0
4335
hooks:

assets/css/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.navbar-logo-text {
22
font-family: "Lato";
33
}
4+
5+
.dashboard {
6+
text-align: center;
7+
}

config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ params:
3939
url: /about/
4040
- title: Translate
4141
url: /translate/
42+
- title: Status
43+
url: /status/
44+
- title: Contributors
45+
url: /contributors/
4246
footer:
4347
logo: logo.svg
4448
socialmediatitle: ""

scripts/update_dashboard.py

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,60 @@ def get_project_translators(self, project_name: str) -> dict:
128128
return results
129129

130130

131-
def generate_md_file(data: dict) -> None:
131+
def generate_card(
132+
name: str,
133+
img_link: str,
134+
) -> str:
135+
"""
136+
Generate a card in TOML format.
137+
"""
138+
toml_card_template = """[[item]]
139+
type = 'card'
140+
classcard = 'text-center'
141+
body = '''{{{{< image >}}}}
142+
src = '{img_link}'
143+
alt = 'Avatar of {name}'
144+
{{{{< /image >}}}}
145+
{name}'''"""
146+
return toml_card_template.format(
147+
img_link=img_link,
148+
name=name,
149+
)
150+
151+
152+
def generate_contributors_md_file(data: dict) -> None:
153+
script_path = Path(__file__).resolve()
154+
parent_dir = script_path.parent.parent / "content"
155+
content = """---
156+
title: Translation Contributors
157+
draft: false
158+
---
159+
160+
"""
161+
162+
for crowdin_project in sorted(data, key=lambda x: x.lower()):
163+
content += f"\n## {crowdin_project}\n"
164+
content += '\n{{< grid columns="2 3 4 5" >}}\n\n'
165+
translators = data[crowdin_project]["translators"]
166+
for _, contributors in translators.items():
167+
if contributors:
168+
for contributor in contributors:
169+
content += "\n\n"
170+
content += generate_card(
171+
name=contributor["name"], img_link=contributor["img_link"]
172+
)
173+
content += "\n\n"
174+
175+
content += "\n{{< /grid >}}"
176+
177+
new_file_path = parent_dir / "contributors.md"
178+
content += f"\n\n---\n\nLast updated: {datetime.now().strftime('%Y-%m-%d')}\n"
179+
180+
with open(new_file_path, "w") as f:
181+
f.write(content)
182+
183+
184+
def generate_dashboard_md_file(data: dict) -> None:
132185
"""Generate a markdown file for the dashboard."""
133186
script_path = Path(__file__).resolve()
134187
parent_dir = script_path.parent.parent / "content"
@@ -158,10 +211,10 @@ def generate_md_file(data: dict) -> None:
158211
print(language_id)
159212
url = f"https://scientific-python.crowdin.com/u/projects/{project_id}/l/{language_id}"
160213
content += f"""<tr>
161-
<td><a href='{url}'>{data[crowdin_project]['status'][language_id]['language_name']} ({language_id})</a></td>
214+
<td><a href='{url}'>{status[language_id]['language_name']} ({language_id})</a></td>
162215
<td>{len(data[crowdin_project]['translators'][language_id])}</td>
163-
<td>{data[crowdin_project]['status'][language_id]['progress']}</td>
164-
<td>{data[crowdin_project]['status'][language_id]['approval']}</td>
216+
<td>{status[language_id]['progress']}</td>
217+
<td>{status[language_id]['approval']}</td>
165218
</tr>"""
166219

167220
content += "\n</table>\n\n"
@@ -191,7 +244,8 @@ def main() -> None:
191244
"translators": translators,
192245
"project_id": project_id,
193246
}
194-
generate_md_file(data)
247+
generate_dashboard_md_file(data)
248+
generate_contributors_md_file(data)
195249
except Exception as e:
196250
print(f"Error: {e}")
197251
traceback.print_exc()

0 commit comments

Comments
 (0)