Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EditorConfig is awesome: https://editorconfig.org

# top-most EditorConfig file
root = true

[*]
max_line_length=120
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
.idea
/VersionTwo.iml
*/**/*.iml

# Ruff stuff:
.ruff_cache/

# PyPI configuration file
.pypirc


**/**.DS_Store
_site/*
!_site/.gitkeep


133 changes: 96 additions & 37 deletions commons/static_site_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
def generate_site(data, output_file='./_site/index.html'):
env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template('kaban_board.html')
output = template.render(data)

# Extract unique statuses from the tasks list
unique_statuses = sorted({task["status"] for task in data["tasks"]})

# Add statuses to the data dictionary
data_with_statuses = {**data, "statuses": unique_statuses}

# Render template with updated data
output = template.render(data_with_statuses)

with open(output_file, 'w') as f:
f.write(output)
Expand All @@ -13,42 +21,93 @@ def generate_site(data, output_file='./_site/index.html'):
'title': 'Version Two',
'github_user': 'octocat',
'team': 'Platform Engineering',
'tasks': {
'Backlog': [
],
'New': [
{
"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"
}
],
'In-Progress': [
],
'Blocked': [
],
'Done': [
]
}
'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"
}
]
}


generate_site(data)
114 changes: 114 additions & 0 deletions src/version_two_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import argparse


class VersionTwoConfig:
def __init__(self):
parser = argparse.ArgumentParser(
prog='VersionTwo',
description="Render an HTML page from a collection of GitHub Issues and Pull Requests"
)

parser.add_argument(
"--include-user",
dest="include_user",
action="append",
type=str,
nargs="+",
help="Include all issues and PRs for the provided user [Required Parameter]",)

parser.add_argument(
"--include-repository",
dest="include_repository",
action="append",
type=str,
nargs="+",
help="Include all issues and PRs from the specified repository",)

parser.add_argument(
"--include-organization-repository",
dest="include_organization_repository",
action="append",
type=str,
nargs="+",
help="Include all issues and PRs from the specified organization/repository",)

parser.add_argument(
"--include-label",
dest="include_label",
action="append",
type=str,
nargs="+",
help="Include all issues and PRs with the specified label",)

parser.add_argument(
"--exclude-organization",
dest="exclude_organization",
action="append",
type=str,
nargs="+",
help="Exclude all issues and PRs from the specified organization",)

parser.add_argument(
"--exclude-repository",
dest="exclude_repository",
action="append",
type=str,
nargs="+",
help="Exclude all issues and PRs from the specified repository",)

parser.add_argument(
"--exclude-organization-repository",
dest="exclude_organization_repository",
action="append",
type=str,
nargs="+",
help="Exclude all issues and PRs from the specified "
"organization/repository",)

parser.add_argument(
"--exclude-user",
dest="exclude_user",
action="append",
type=str,
nargs="+",
help="Exclude all issues and PRs for the provided user",)

parser.add_argument(
"--exclude-label",
dest="exclude_label",
action="append",
type=str,
nargs="+",
help="Exclude all issues and PRs with the specified label",)

parser.add_argument(
"--publish-board",
dest="publish_board",
action="store_const",
help="The organization/board to publish (add) the collection of GitHub Issues and Pull Requests",)

parsed_args = parser.parse_args()

self.include_user = parsed_args.include_user
self.include_repository = parsed_args.include_repository
self.include_organization_repository = parsed_args.include_organization_repository
self.include_label = parsed_args.include_label
self.exclude_organization = parsed_args.exclude_organization
self.exclude_repository = parsed_args.exclude_repository
self.exclude_organization_repository = parsed_args.exclude_organization_repository
self.exclude_user = parsed_args.exclude_user
self.exclude_label = parsed_args.exclude_label
self.publish_board = parsed_args.publish_board

def display_config(self):
print("Configuration:")
print(f"Include User: {self.include_user}")
print(f"Include Repository: {self.include_repository}")
print(f"Include Organization/Repository: {self.include_organization_repository}")
print(f"Include Label: {self.include_label}")
print(f"Exclude Organization: {self.exclude_organization}")
print(f"Exclude Repository: {self.exclude_repository}")
print(f"Exclude Organization/Repository: {self.exclude_organization_repository}")
print(f"Exclude User: {self.exclude_user}")
print(f"Exclude Label: {self.exclude_label}")
print(f"Publish Board: {self.publish_board}")
6 changes: 3 additions & 3 deletions templates/kaban_board.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ <h1 class="mb-3 text-center">{{ title }}</h1>
<!-- Kanban Board -->
<div class="row row-cols-1 row-cols-md-5 g-3">
{% set counter = 0 %}
{% for status in ["Backlog", "New", "In-Progress", "Blocked", "Done"] %}
{% for status in statuses %}
<div class="col">
<div class="kanban-column">
<div class="kanban-header text-primary text-center">{{ status }}</div>
{% for task in tasks[status] %}
{% for task in tasks if task.status == status %}

<div class="kanban-card">
{% set card_id = "card-" ~ counter %}
{% set card_id = "card-" ~ status | lower | replace(" ", "-") ~ "-" ~ counter %}
{% set counter = counter + 1 %}
<div class="d-flex align-items-start gap-2">
<a
Expand Down
10 changes: 10 additions & 0 deletions version_two.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from src.version_two_config import VersionTwoConfig


def main():
config = VersionTwoConfig()
config.display_config()


if __name__ == "__main__":
main()