From 06d48162d079f89b43a207075672a80603a13a69 Mon Sep 17 00:00:00 2001 From: Diogo Pereira Date: Wed, 30 Apr 2025 22:08:02 -0700 Subject: [PATCH 1/6] Added github JSON loader Signed-off-by: Diogo Pereira --- src/static_site_generator.py | 104 ++++------------------------ templates/kaban_board.html | 130 ++++++++++++++++++----------------- 2 files changed, 80 insertions(+), 154 deletions(-) diff --git a/src/static_site_generator.py b/src/static_site_generator.py index c2ee73a..99eb855 100644 --- a/src/static_site_generator.py +++ b/src/static_site_generator.py @@ -1,108 +1,28 @@ from jinja2 import Environment, FileSystemLoader +import json # Example data -dummy_data = { +seed_data = { 'title': 'Version Two', 'github_user': 'octocat', 'team': 'Platform Engineering', - 'tasks': [ - { - "assignees": ["coolAssignee"], - "content": { - "body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`", - "number": 241, - "repository": "pandas/coolrepo", - "title": "cool title", - "type": "Issue", - "url": "https://github.com/pandas/coolrepo/issues/241" - }, - "id": "PVTI_lADOBgkjhkjhjjh", - "labels": ["Bug"], - "linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"], - "repository": "https://github.com/pandas/coolrepo", - "status": "New", - "title": "Cool Pandas Task 1" - }, - { - "assignees": ["coolAssignee"], - "content": { - "body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`", - "number": 241, - "repository": "pandas/coolrepo", - "title": "cool title", - "type": "Issue", - "url": "https://github.com/pandas/coolrepo/issues/241" - }, - "id": "PVTI_lADOBgkjhkjhjjh", - "labels": ["Bug"], - "linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"], - "repository": "https://github.com/pandas/coolrepo", - "status": "Backlog", - "title": "Cool Pandas Task 2" - }, - { - "assignees": ["coolAssignee"], - "content": { - "body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`", - "number": 241, - "repository": "pandas/coolrepo", - "title": "cool title", - "type": "Issue", - "url": "https://github.com/pandas/coolrepo/issues/241" - }, - "id": "PVTI_lADOBgkjhkjhjjh", - "labels": ["Bug"], - "linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"], - "repository": "https://github.com/pandas/coolrepo", - "status": "In Progress", - "title": "Cool Pandas Task 3" - }, - { - "assignees": ["coolAssignee"], - "content": { - "body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`", - "number": 241, - "repository": "pandas/coolrepo", - "title": "cool title", - "type": "Issue", - "url": "https://github.com/pandas/coolrepo/issues/241" - }, - "id": "PVTI_lADOBgkjhkjhjjh", - "labels": ["Bug"], - "linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"], - "repository": "https://github.com/pandas/coolrepo", - "status": "Blocked", - "title": "Cool Pandas Task 4" - }, - { - "assignees": ["coolAssignee"], - "content": { - "body": "https://dummy_url/test#L42\n\nRename from `X` to `Y`", - "number": 241, - "repository": "pandas/coolrepo", - "title": "cool title", - "type": "Issue", - "url": "https://github.com/pandas/coolrepo/issues/241" - }, - "id": "PVTI_lADOBgkjhkjhjjh", - "labels": ["Bug"], - "linked pull requests": ["https://github.com/pandas/coolrepo/pull/242"], - "repository": "https://github.com/pandas/coolrepo", - "status": "Done", - "title": "Cool Pandas Task 5" - } - ] + 'tasks': [] } -def generate_site(data=dummy_data, output_file='./_site/index.html'): +def generate_site(output_file='./_site/index.html'): env = Environment(loader=FileSystemLoader('templates')) template = env.get_template('kaban_board.html') - + with open('output.items.json', 'r') as file: + gh_json = json.load(file) + + + seed_data["tasks"] = gh_json + # Extract unique statuses from the tasks list - unique_statuses = sorted({task["status"] for task in data["tasks"]}) + unique_statuses = sorted({task["status"] for task in seed_data["tasks"]}) # Add statuses to the data dictionary - data_with_statuses = {**data, "statuses": unique_statuses} + data_with_statuses = {**seed_data, "statuses": unique_statuses} # Render template with updated data output = template.render(data_with_statuses) diff --git a/templates/kaban_board.html b/templates/kaban_board.html index d55f0b3..2a7759c 100644 --- a/templates/kaban_board.html +++ b/templates/kaban_board.html @@ -41,88 +41,94 @@

{{ title }}

-
- + +
- {% set counter = 0 %} {% for status in statuses %} -
-
-
{{ status }}
- {% for task in tasks if task.status == status %} - -
- {% set card_id = "card-" ~ status | lower | replace(" ", "-") ~ "-" ~ counter %} - {% set counter = counter + 1 %} -
- - 🟢 #{{ task.content.number }} - - +
+
+
{{ status }}
+ + {% for task in tasks if task.status == status %} + {% set card_id = "card-" ~ status | lower | replace(" ", "-") ~ "-" ~ loop.index0 %} + +
+ +
+
+ + 📦 Repository: + + {{ task.content.repository }} + +
-
- -
- - 📦 Repository: - - {{ task.content.repository }} - - -
-
👤 Assignee: {{ task.assignees | join(', ') }}
-
🏷️ Labels: {{ task.labels | join(', ') }}
-
📌 Status: {{ task.status }}
- +
👤 Assignee: {{ task.assignees | join(', ') }}
+
🏷️ Labels: {{ task.labels | join(', ') }}
+
📌 Status: {{ task.status }}
+
- {% endfor %}
+ {% endfor %}
- {% endfor %} +
+ {% endfor %}
-