Skip to content

feat: dynamically assign user name and filtered teams #71

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 3 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The following dependencies are required to run the program:

## 💻 Setup
- Authentication through `gh auth login`
- Set the `GITHUB_TOKEN` environment variable: `export GITHUB_TOKEN=$(gh auth token)`
- Set the `GITHUB_UNAME` environment variable: `export GITHUB_UNAME=$(gh auth status | grep "(GITHUB_TOKEN)" | cut -d " " -f9)`
- Set the appropriate token permissions: `gh auth refresh --scopes read:project`
- Run `make install` inside the repo directory to configure the appropriate versions of dependencies.

Expand Down
16 changes: 12 additions & 4 deletions src/static_site_generator.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
from jinja2 import Environment, FileSystemLoader
import logging
import logging
import os


class StaticSiteGenerator():

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

def generate_site(self, data=None, output_file='./_site/index.html'):
def generate_site(self, data:list=None, teams:list[str]=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 []

# Set the github user name
self.github_uname = os.getenv("GITHUB_UNAME") if os.getenv("GITHUB_UNAME") else "Not logged in"
self.GENERATOR_DATA["github_user"] = self.github_uname

# Set the team(s)
self.GENERATOR_DATA["team"] = ' '.join(teams) if teams is not None else ""

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

Expand Down
2 changes: 1 addition & 1 deletion version2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def main():
with open(output_file, 'r') as f:
data = json.load(f)

ss_gen.generate_site(data=data)
ss_gen.generate_site(data=data, teams=filters["include_teams"])

if __name__ == "__main__":
main()