Skip to content

feat: Added github JSON loader and Fixed JS Search #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
104 changes: 12 additions & 92 deletions src/static_site_generator.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
130 changes: 68 additions & 62 deletions templates/kaban_board.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,88 +41,94 @@ <h1 class="mb-3 text-center">{{ title }}</h1>
<!-- <div class="col-md-4">
<p><strong>Team:</strong> {{ team }}</p>
</div> -->
<div class="col-md-4">
<input type="text" id="searchBox" class="form-control" placeholder="Search tasks...">
<div class="search-bar col-md-4">
<input type="text" id="search-input" class="form-control" placeholder="Search tasks..." />
</div>

</div>
</div>

<div class="container-fluid py-4">
<!-- Kanban Board -->
<div class="row row-cols-1 row-cols-md-5 g-3">
{% set counter = 0 %}
{% 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 if task.status == status %}

<div class="kanban-card">
{% set card_id = "card-" ~ status | lower | replace(" ", "-") ~ "-" ~ counter %}
{% set counter = counter + 1 %}
<div class="d-flex align-items-start gap-2">
<a
href="{{ task.content.url }}"
target="_blank"
class="text-primary text-decoration-none fw-bold"
>
🟢 #{{ task.content.number }}
</a>
<a
class="text-dark text-decoration-none fw-bold flex-grow-1"
data-bs-toggle="collapse"
href="#{{ card_id }}"
role="button"
aria-expanded="false"
aria-controls="{{ card_id }}"
>
{{ task.title }}
</a>
<div class="col">
<div class="kanban-column">
<div class="kanban-header text-primary text-center">{{ status }}</div>

{% for task in tasks if task.status == status %}
{% set card_id = "card-" ~ status | lower | replace(" ", "-") ~ "-" ~ loop.index0 %}

<div class="kanban-card">
<div class="d-flex flex-column align-items-start gap-2">
<a
class="text-dark text-decoration-none fw-bold flex-grow-1"
data-bs-toggle="collapse"
href="#{{ card_id }}"
role="button"
aria-expanded="false"
aria-controls="{{ card_id }}"
>
🟢 {{ task.title }}<a
href="{{ task.content.url }}"
target="_blank"
class="fs-8 text-primary text-decoration-none">
(#{{ task.content.number }})</a>
</a>
</div>
<div class="collapse mt-2" id="{{ card_id }}">
<div>
<small>
<strong>📦 Repository:</strong>
<a href="{{ task.repository }}" target="_blank">
{{ task.content.repository }}
</a>
</small>
</div>
<div class="collapse mt-2" id="{{ card_id }}">
<!-- <div><small><strong>Issue #:</strong> {{ task.content.number }}</small></div> -->
<div>
<small>
<strong>📦 Repository:</strong>
<a href="{{ task.repository }}" target="_blank">
{{ task.content.repository }}
</a>
</small>
</div>
<div><small><strong>👤 Assignee:</strong> {{ task.assignees | join(', ') }}</small></div>
<div><small><strong>🏷️ Labels:</strong> {{ task.labels | join(', ') }}</small></div>
<div><small><strong>📌 Status:</strong> {{ task.status }}</small></div>
<div class="text-center">
<a href="{{ task.content.url }}" target="_blank" class="btn btn-sm btn-outline-primary mt-2">View Issue</a>
</div>
<div><small><strong>👤 Assignee:</strong> {{ task.assignees | join(', ') }}</small></div>
<div><small><strong>🏷️ Labels:</strong> {{ task.labels | join(', ') }}</small></div>
<div><small><strong>📌 Status:</strong> {{ task.status }}</small></div>
<div class="text-center">
<a href="{{ task.content.url }}" target="_blank" class="btn btn-sm btn-outline-primary mt-2">View Issue</a>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</div>




<script>
document.addEventListener("DOMContentLoaded", function () {
const searchInput = document.querySelector("#searchBox");

searchInput.addEventListener("input", function () {
const searchTerm = this.value.toLowerCase();
const cards = document.querySelectorAll(".kanban-card");

cards.forEach(card => {
const title = card.querySelector("strong").textContent.toLowerCase();
const description = card.querySelector("small").textContent.toLowerCase();

if (title.includes(searchTerm) || description.includes(searchTerm)) {
card.style.display = "block";
<script>
document.addEventListener("DOMContentLoaded", function() {
// Get the search input and all Kanban cards
const searchInput = document.getElementById('search-input');
const kanbanCards = document.querySelectorAll('.kanban-card');

// Add an event listener for the search input
searchInput.addEventListener('input', function() {
const query = searchInput.value.toLowerCase(); // Get the lowercase version of the query

// Iterate over all the cards
kanbanCards.forEach(function(card) {
// Get the card's title, issue number, and other text content to check if it matches the query
const title = card.querySelector('.d-flex .text-dark').textContent.toLowerCase();
const issueNumber = card.querySelector('.d-flex .text-primary').textContent.toLowerCase();
const repository = card.querySelector('.text-muted') ? card.querySelector('.text-muted').textContent.toLowerCase() : '';
const assignee = card.querySelector('.d-flex .assignee') ? card.querySelector('.d-flex .assignee').textContent.toLowerCase() : '';

// Check if the query matches any part of the task (title, issue number, repository, assignee)
const matches = title.includes(query) || issueNumber.includes(query) || repository.includes(query) || assignee.includes(query);

// Show or hide the card based on the search query match
if (matches) {
card.style.display = 'block'; // Show the card
} else {
card.style.display = "none";
card.style.display = 'none'; // Hide the card
}
});
});
Expand Down
Loading