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 6 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
4 changes: 3 additions & 1 deletion current-implemented-CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Currently Implemented


- `include-team` - Include a team to the query
- `output-file` - Define the filename and location of the output file
- `output-file` - Define the filename and location of the output file
- `temp-dir` - The temporary directory to write JSON response files

- `include-team` - Include a team to the query


Expand Down
50 changes: 28 additions & 22 deletions src/static_site_generator.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
from jinja2 import Environment, FileSystemLoader
import logging

# Example data
GENERATOR_DATA = {
'title': 'Version Two',
'github_user': 'octocat',
'team': 'Platform Engineering',
'tasks': []
}

def generate_site(data=None, output_file='./_site/index.html'):
env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template('kaban_board.html')
class StaticSiteGenerator():

GENERATOR_DATA["tasks"] = data if data is not None else []
def __init__(self):
self.GENERATOR_DATA = {
'title': 'Version Two',
'github_user': 'octocat',
'team': 'Platform Engineering',
'tasks': []
}

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

# Add statuses to the data dictionary
data_with_statuses = {**GENERATOR_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)
def generate_site(self, data=None, output_file='./_site/index.html'):
logging.info("Generating Static Site")
env = Environment(loader=FileSystemLoader('templates'))
template = env.get_template('kaban_board.html')

self.GENERATOR_DATA["tasks"] = data if data is not None else []

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

# Add statuses to the data dictionary
data_with_statuses = {**self.GENERATOR_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)

logging.info("Static Site Generated @ ./_site/index.html")
19 changes: 19 additions & 0 deletions src/version2config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ def init_parser(self):
help="Include all issues and PRs for the provided user [Required Parameter]"
)

parser.add_argument(
"--include-team",
dest="include_team",
action="append",
type=str,
help="Include provided teams in the output"
)

parser.add_argument(
"--exclude-team",
dest="exclude_team",
action="append",
type=str,
help="Exclude provided teams in the output"
)

parser.add_argument(
"--include-repository",
dest="include_repository",
Expand Down Expand Up @@ -148,6 +164,7 @@ def init_parser(self):
self.temp_dir = parsed_args.temp_dir
self.include_team = parsed_args.include_team
self.include_user = parsed_args.include_user
self.include_team = parsed_args.include_team
self.include_repository = parsed_args.include_repository
self.include_organization = parsed_args.include_organization
self.include_organization_repository = parsed_args.include_organization_repository
Expand All @@ -158,6 +175,7 @@ def init_parser(self):
self.exclude_organization = parsed_args.exclude_organization
self.exclude_organization_repository = parsed_args.exclude_organization_repository
self.exclude_label = parsed_args.exclude_label
self.exclude_team = parsed_args.exclude_team
self.publish_board = parsed_args.publish_board

def init_logger(self):
Expand All @@ -182,4 +200,5 @@ def display_config(self):
logging.info(f"Exclude Organization: {self.exclude_organization}")
logging.info(f"Exclude Organization/Repository: {self.exclude_organization_repository}")
logging.info(f"Exclude Label: {self.exclude_label}")
logging.info(f"Exclude Team: {self.exclude_team}")
logging.info(f"Publish Board: {self.publish_board}")
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
9 changes: 6 additions & 3 deletions version2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from src.version2config import VersionTwoConfig
from src.version2query import Version2Query
from src.static_site_generator import generate_site
from src.static_site_generator import StaticSiteGenerator
from pathlib import Path
import json
import logging

def main():
config:VersionTwoConfig = VersionTwoConfig()
Expand All @@ -12,18 +13,20 @@ def main():
teams:list[str] = config.include_team

query:VersionTwoQuery = Version2Query(temp_dir=temp_dir, output_file=output_file)
ss_gen = StaticSiteGenerator()

# Generate output_file or die
logging.info("Querying GitHub API...")
if not query.process(teams):
print("Failed to process query.")
logging.error("Failed to process query.")
return

# Get json object
data = None
with open(output_file, 'r') as f:
data = json.load(f)

generate_site(data=data)
ss_gen.generate_site(data=data)

if __name__ == "__main__":
main()