Skip to content
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

New Optional Variables #9

Merged
merged 3 commits into from
Jan 22, 2025
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: 1 addition & 6 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: ProjectHUD CI

on:
push:
branches:
- "*"
tags:
- "*"
on: push

env:
REGISTRY: ghcr.io
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.db
__pycache__
.env
node_modules/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ services:
GITHUB_TOKEN: YOUR_TOKEN
GITHUB_REPOS: YOUR,REPOS
USERNAME_MAP: username:realname,
REFRESH_DURATION: 25 # Optional
API_REFRESH_DURATION: 200 # Optional
```

## Example setup with openbox autostart
Expand Down
5 changes: 4 additions & 1 deletion app/routes/index.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os
from flask import Blueprint, render_template

index_bp = Blueprint("main", __name__)


@index_bp.route("/")
def index():
return render_template("index.html")
return render_template(
"index.html", refresh_duration=int(os.getenv("REFRESH_DURATION", 25))
)
2 changes: 1 addition & 1 deletion app/routes/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_screen():
</style>
</head>
<body>
<h1>Please Wait! Version {os.getenv('GIT_COMMIT', 'Unknown')}</h1>
<h1>ProjectHUD Starting! Version {os.getenv('GIT_COMMIT', 'Unknown')}</h1>
</body>
</html>
"""
Expand Down
13 changes: 9 additions & 4 deletions app/services/github_service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import time
import threading

from datetime import datetime

from github import Github
Expand Down Expand Up @@ -33,7 +35,7 @@ def fetch_data(self):
print("Updated github data.")
self.last_updated = datetime.now()

time.sleep(120)
time.sleep(int(os.getenv("API_REFRESH_DURATION", 200)))

def get_mapped_username(self, username):
return self.username_mapping.get(username, username)
Expand All @@ -54,9 +56,12 @@ def update_general_data(self):
"name": milestone.title,
"progress": (
(
milestone.closed_issues
/ (milestone.closed_issues + milestone.open_issues)
* 100
round(
milestone.closed_issues
/ (milestone.closed_issues + milestone.open_issues)
* 100,
2,
)
)
if (milestone.closed_issues + milestone.open_issues) > 0
else 0
Expand Down
7 changes: 2 additions & 5 deletions app/static/scripts/autorefresh.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
document.addEventListener('DOMContentLoaded', () => {
// Configurable refresh duration (in seconds)
const REFRESH_DURATION = 25;

// HTML items
const iframe = document.getElementById("board-iframe");
const refreshIndicator = document.getElementById('refresh-indicator');

let screens = [];
let currentScreenIndex = 0;
let initialVersion = null;
let countdown = REFRESH_DURATION;
let countdown = REFRESH_DURATION; // Use the dynamic variable

async function fetchScreens() {
try {
Expand Down Expand Up @@ -42,7 +39,7 @@ document.addEventListener('DOMContentLoaded', () => {
function updateCountdown() {
refreshIndicator.innerText = `Changing in ${countdown}s`;
if (countdown <= 0) {
countdown = REFRESH_DURATION;
countdown = REFRESH_DURATION; // Reset countdown
fetchScreens(); // Fetch screens and check for updates
cycleScreens(); // Cycle to the next screen
} else {
Expand Down
4 changes: 4 additions & 0 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project HUD</title>
<link rel="stylesheet" href="/static/styles/base.css">

<script>
const REFRESH_DURATION = {{ refresh_duration }};
</script>
<script src="/static/scripts/autorefresh.js" defer></script>
</head>

Expand Down
Loading