Skip to content

Commit 86c4bea

Browse files
committed
Fixed JSON loader structure from Jinja
Signed-off-by: Diogo Pereira <diogo.pereira@swirldslabs.com>
1 parent c5681f9 commit 86c4bea

2 files changed

Lines changed: 99 additions & 40 deletions

File tree

commons/static_site_generator.py

Lines changed: 96 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
def generate_site(data, output_file='./_site/index.html'):
44
env = Environment(loader=FileSystemLoader('templates'))
55
template = env.get_template('kaban_board.html')
6-
output = template.render(data)
6+
7+
# Extract unique statuses from the tasks list
8+
unique_statuses = sorted({task["status"] for task in data["tasks"]})
9+
10+
# Add statuses to the data dictionary
11+
data_with_statuses = {**data, "statuses": unique_statuses}
12+
13+
# Render template with updated data
14+
output = template.render(data_with_statuses)
715

816
with open(output_file, 'w') as f:
917
f.write(output)
@@ -13,42 +21,93 @@ def generate_site(data, output_file='./_site/index.html'):
1321
'title': 'Version Two',
1422
'github_user': 'octocat',
1523
'team': 'Platform Engineering',
16-
'tasks': {
17-
'Backlog': [
18-
],
19-
'New': [
20-
{
21-
"assignees": [
22-
"coolAssignee"
23-
],
24-
"content": {
25-
"body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`",
26-
"number": 241,
27-
"repository": "pandas/coolrepo",
28-
"title": "cool title",
29-
"type": "Issue",
30-
"url": "https://github.com/pandas/coolrepo/issues/241"
31-
},
32-
"id": "PVTI_lADOBgkjhkjhjjh",
33-
"labels": [
34-
"Bug"
35-
],
36-
"linked pull requests": [
37-
"https://github.com/pandas/coolrepo/pull/242"
38-
],
39-
"repository": "https://github.com/pandas/coolrepo",
40-
"status": "Done",
41-
"title": "Cool Pandas Task"
42-
}
43-
],
44-
'In-Progress': [
45-
],
46-
'Blocked': [
47-
],
48-
'Done': [
49-
]
50-
}
24+
'tasks': [
25+
{
26+
"assignees": ["coolAssignee"],
27+
"content": {
28+
"body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`",
29+
"number": 241,
30+
"repository": "pandas/coolrepo",
31+
"title": "cool title",
32+
"type": "Issue",
33+
"url": "https://github.com/pandas/coolrepo/issues/241"
34+
},
35+
"id": "PVTI_lADOBgkjhkjhjjh",
36+
"labels": ["Bug"],
37+
"linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"],
38+
"repository": "https://github.com/pandas/coolrepo",
39+
"status": "New",
40+
"title": "Cool Pandas Task 1"
41+
},
42+
{
43+
"assignees": ["coolAssignee"],
44+
"content": {
45+
"body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`",
46+
"number": 241,
47+
"repository": "pandas/coolrepo",
48+
"title": "cool title",
49+
"type": "Issue",
50+
"url": "https://github.com/pandas/coolrepo/issues/241"
51+
},
52+
"id": "PVTI_lADOBgkjhkjhjjh",
53+
"labels": ["Bug"],
54+
"linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"],
55+
"repository": "https://github.com/pandas/coolrepo",
56+
"status": "Backlog",
57+
"title": "Cool Pandas Task 2"
58+
},
59+
{
60+
"assignees": ["coolAssignee"],
61+
"content": {
62+
"body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`",
63+
"number": 241,
64+
"repository": "pandas/coolrepo",
65+
"title": "cool title",
66+
"type": "Issue",
67+
"url": "https://github.com/pandas/coolrepo/issues/241"
68+
},
69+
"id": "PVTI_lADOBgkjhkjhjjh",
70+
"labels": ["Bug"],
71+
"linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"],
72+
"repository": "https://github.com/pandas/coolrepo",
73+
"status": "In Progress",
74+
"title": "Cool Pandas Task 3"
75+
},
76+
{
77+
"assignees": ["coolAssignee"],
78+
"content": {
79+
"body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`",
80+
"number": 241,
81+
"repository": "pandas/coolrepo",
82+
"title": "cool title",
83+
"type": "Issue",
84+
"url": "https://github.com/pandas/coolrepo/issues/241"
85+
},
86+
"id": "PVTI_lADOBgkjhkjhjjh",
87+
"labels": ["Bug"],
88+
"linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"],
89+
"repository": "https://github.com/pandas/coolrepo",
90+
"status": "Blocked",
91+
"title": "Cool Pandas Task 4"
92+
},
93+
{
94+
"assignees": ["coolAssignee"],
95+
"content": {
96+
"body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`",
97+
"number": 241,
98+
"repository": "pandas/coolrepo",
99+
"title": "cool title",
100+
"type": "Issue",
101+
"url": "https://github.com/pandas/coolrepo/issues/241"
102+
},
103+
"id": "PVTI_lADOBgkjhkjhjjh",
104+
"labels": ["Bug"],
105+
"linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"],
106+
"repository": "https://github.com/pandas/coolrepo",
107+
"status": "Done",
108+
"title": "Cool Pandas Task 5"
109+
}
110+
]
51111
}
52112

53-
54113
generate_site(data)

templates/kaban_board.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ <h1 class="mb-3 text-center">{{ title }}</h1>
5151
<!-- Kanban Board -->
5252
<div class="row row-cols-1 row-cols-md-5 g-3">
5353
{% set counter = 0 %}
54-
{% for status in ["Backlog", "New", "In-Progress", "Blocked", "Done"] %}
54+
{% for status in statuses %}
5555
<div class="col">
5656
<div class="kanban-column">
5757
<div class="kanban-header text-primary text-center">{{ status }}</div>
58-
{% for task in tasks[status] %}
58+
{% for task in tasks if task.status == status %}
5959

6060
<div class="kanban-card">
61-
{% set card_id = "card-" ~ counter %}
61+
{% set card_id = "card-" ~ status | lower | replace(" ", "-") ~ "-" ~ counter %}
6262
{% set counter = counter + 1 %}
6363
<div class="d-flex align-items-start gap-2">
6464
<a

0 commit comments

Comments
 (0)