From 07a3aff21e3ce519f3df2823fec819ec349c170a Mon Sep 17 00:00:00 2001 From: Admin9705 <9705@duck.com> Date: Sun, 15 Jun 2025 12:37:23 -0400 Subject: [PATCH] Update avatar URLs in manifest and workflow files; enhance direct reset button functionality on settings page --- .github/workflows/update-manifest.yml | 18 ++-- frontend/static/js/direct-reset.js | 16 +++- .../templates/components/home_section.html | 83 ++++++++++++------- manifest.json | 16 ++-- src/primary/web_server.py | 10 +-- 5 files changed, 86 insertions(+), 57 deletions(-) diff --git a/.github/workflows/update-manifest.yml b/.github/workflows/update-manifest.yml index 7ce74b59..3b0867a3 100644 --- a/.github/workflows/update-manifest.yml +++ b/.github/workflows/update-manifest.yml @@ -71,9 +71,9 @@ jobs: "category": "featured" }, { - "login": "simplytoast1", - "name": "simplytoast1", - "avatarUrl": "https://avatars.githubusercontent.com/u/simplytoast1?v=4", + "login": "simplytoast1", + "name": "simplytoast1", + "avatarUrl": "https://avatars.githubusercontent.com/u/4954230?v=4", "url": "https://github.com/simplytoast1", "tier": "Tier II - Sponsor", "monthlyAmount": 20, @@ -81,9 +81,9 @@ jobs: "category": "active" }, { - "login": "TheOnlyLite", - "name": "TheOnlyLite", - "avatarUrl": "https://avatars.githubusercontent.com/u/TheOnlyLite?v=4", + "login": "TheOnlyLite", + "name": "TheOnlyLite", + "avatarUrl": "https://avatars.githubusercontent.com/u/1551675?v=4", "url": "https://github.com/TheOnlyLite", "tier": "Tier II - Sponsor", "monthlyAmount": 20, @@ -91,9 +91,9 @@ jobs: "category": "active" }, { - "login": "tcconnally", - "name": "tcconnally", - "avatarUrl": "https://avatars.githubusercontent.com/u/tcconnally?v=4", + "login": "tcconnally", + "name": "tcconnally", + "avatarUrl": "https://avatars.githubusercontent.com/u/51974392?v=4", "url": "https://github.com/tcconnally", "tier": "Tier I - Sponsor", "monthlyAmount": 10, diff --git a/frontend/static/js/direct-reset.js b/frontend/static/js/direct-reset.js index d512d5bb..9f2c1193 100644 --- a/frontend/static/js/direct-reset.js +++ b/frontend/static/js/direct-reset.js @@ -6,14 +6,24 @@ window.justCompletedStatefulReset = false; // Keep track of the current stateful hours value to detect real changes window.lastStatefulHoursValue = null; -// Run this code as soon as this script is loaded +// Run this code as soon as this script is loaded, but only on settings page (function() { + // Exit early if not on settings page + function isOnSettingsPage() { + return window.location.hash === '#settings' || window.location.pathname.includes('/settings'); + } + + // Don't run any of this code unless we're on the settings page + if (!isOnSettingsPage()) { + return; + } + function insertDirectResetButton() { // Look for the stateful header row const headerRow = document.querySelector('.stateful-header-row'); if (!headerRow) { - // If we can't find it, try again soon + // If we can't find it, try again soon (we're already on settings page) console.log('Stateful header not found, will try again in 1 second'); setTimeout(insertDirectResetButton, 1000); return; @@ -114,7 +124,7 @@ window.lastStatefulHoursValue = null; // And again when everything is fully loaded window.addEventListener('load', insertDirectResetButton); - // Also check periodically to make sure the button exists + // Also check periodically to make sure the button exists (we're already on settings page) setInterval(function() { const headerRow = document.querySelector('.stateful-header-row'); if (headerRow && !document.getElementById('emergency_reset_btn')) { diff --git a/frontend/templates/components/home_section.html b/frontend/templates/components/home_section.html index 5a7d5cb9..9d002efc 100644 --- a/frontend/templates/components/home_section.html +++ b/frontend/templates/components/home_section.html @@ -1962,7 +1962,6 @@ document.addEventListener('DOMContentLoaded', function() { document.querySelector('.dashboard-grid').style.opacity = '1'; }, 25); const sponsorContainer = document.getElementById('rotating-sponsor-content'); - console.log('sponsorContainer:', sponsorContainer); let sponsors = []; let weightedSponsorPool = []; let currentSponsorIndex = 0; @@ -1988,8 +1987,6 @@ document.addEventListener('DOMContentLoaded', function() { // Apply transition styles for smooth sponsor changes const avatarContainer = document.getElementById('sponsor-avatar-container'); const descContainer = document.getElementById('rotating-sponsor-content'); - console.log('avatarContainer:', avatarContainer); - console.log('descContainer:', descContainer); // Add transition effects but keep them faster avatarContainer.style.transition = 'opacity 0.15s ease'; @@ -2079,19 +2076,36 @@ document.addEventListener('DOMContentLoaded', function() { // Helper function to update sponsor content function updateSponsorContent(sponsor, avatarContainer, descContainer) { - // Update avatar with enhanced styling - avatarContainer.innerHTML = ` - - ${sponsor.name}'s avatar - - `; + // Create elements without href to prevent prefetching, add click handlers instead + const avatarDiv = document.createElement('div'); + avatarDiv.style.cssText = 'width: 100%; height: 100%; cursor: pointer; border-radius: 50%;'; + avatarDiv.title = `Visit ${sponsor.name}'s GitHub profile`; + avatarDiv.onclick = function(e) { + e.preventDefault(); + window.open(sponsor.url || '#', '_blank', 'noopener,noreferrer'); + }; - // Update name in the description area - descContainer.innerHTML = ` - - ${sponsor.name} - - `; + const avatarImg = document.createElement('img'); + avatarImg.src = sponsor.avatarUrl; + avatarImg.alt = `${sponsor.name}'s avatar`; + avatarImg.style.cssText = 'width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;'; + + avatarDiv.appendChild(avatarImg); + avatarContainer.innerHTML = ''; + avatarContainer.appendChild(avatarDiv); + + // Create name element without href to prevent prefetching + const nameDiv = document.createElement('div'); + nameDiv.textContent = sponsor.name; + nameDiv.style.cssText = 'cursor: pointer; color: inherit;'; + nameDiv.title = `Visit ${sponsor.name}'s GitHub profile`; + nameDiv.onclick = function(e) { + e.preventDefault(); + window.open(sponsor.url || '#', '_blank', 'noopener,noreferrer'); + }; + + descContainer.innerHTML = ''; + descContainer.appendChild(nameDiv); // Add sponsor-icon class avatarContainer.classList.add('sponsor-icon'); @@ -2121,19 +2135,29 @@ document.addEventListener('DOMContentLoaded', function() { // Style the container directly and apply the styling immediately document.getElementById('sponsor-widget-container').style.visibility = 'visible'; - // Create a solid orange-red circle with gold border exactly like image #2 - avatarContainer.innerHTML = ` - - `; + // Create a solid orange-red circle with gold border exactly like image #2 (no href to prevent prefetching) + const placeholderDiv = document.createElement('div'); + placeholderDiv.style.cssText = 'width: 100%; height: 100%; border-radius: 50%; background-color: #FF6347; border: 3px solid #ffb700; box-sizing: border-box; cursor: pointer;'; + placeholderDiv.title = `Support ${placeholderSponsor.name}`; + placeholderDiv.onclick = function(e) { + e.preventDefault(); + window.open(placeholderSponsor.url, '_blank', 'noopener,noreferrer'); + }; - descContainer.innerHTML = ` - - ${placeholderSponsor.name} - - `; + avatarContainer.innerHTML = ''; + avatarContainer.appendChild(placeholderDiv); + + const placeholderNameDiv = document.createElement('div'); + placeholderNameDiv.textContent = placeholderSponsor.name; + placeholderNameDiv.style.cssText = 'cursor: pointer; color: inherit;'; + placeholderNameDiv.title = 'Support us'; + placeholderNameDiv.onclick = function(e) { + e.preventDefault(); + window.open(placeholderSponsor.url, '_blank', 'noopener,noreferrer'); + }; + + descContainer.innerHTML = ''; + descContainer.appendChild(placeholderNameDiv); // Add sponsor-icon class and show immediately avatarContainer.classList.add('sponsor-icon'); @@ -2144,16 +2168,12 @@ document.addEventListener('DOMContentLoaded', function() { } // Show placeholder immediately - console.log('About to display placeholder sponsor'); displayPlaceholderSponsor(); - console.log('Placeholder sponsor displayed'); // Fetch sponsors from the API async function fetchSponsors() { - console.log('fetchSponsors function called'); try { // Fetch in the background without waiting for visual updates - console.log('About to call HuntarrUtils.fetchWithTimeout'); const response = await HuntarrUtils.fetchWithTimeout('/api/github_sponsors'); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); @@ -2187,7 +2207,6 @@ document.addEventListener('DOMContentLoaded', function() { } // Initialize sponsors on page load - console.log('About to fetch sponsors'); fetchSponsors(); }); diff --git a/manifest.json b/manifest.json index 1d3e9b1c..c9b38a3a 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ { "login": "simplytoast1", "name": "simplytoast1", - "avatarUrl": "https://avatars.githubusercontent.com/u/simplytoast1?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/4954230?v=4", "url": "https://github.com/simplytoast1", "tier": "Tier II - Sponsor", "monthlyAmount": 20, @@ -25,7 +25,7 @@ { "login": "TheOnlyLite", "name": "TheOnlyLite", - "avatarUrl": "https://avatars.githubusercontent.com/u/TheOnlyLite?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/1551675?v=4", "url": "https://github.com/TheOnlyLite", "tier": "Tier II - Sponsor", "monthlyAmount": 20, @@ -35,7 +35,7 @@ { "login": "tcconnally", "name": "tcconnally", - "avatarUrl": "https://avatars.githubusercontent.com/u/tcconnally?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/51974392?v=4", "url": "https://github.com/tcconnally", "tier": "Tier I - Sponsor", "monthlyAmount": 10, @@ -45,7 +45,7 @@ { "login": "feinhorn", "name": "feinhorn", - "avatarUrl": "https://avatars.githubusercontent.com/u/feinhorn?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/53579799?v=4", "url": "https://github.com/feinhorn", "tier": "Supporter", "monthlyAmount": 5, @@ -55,7 +55,7 @@ { "login": "jimmyza-cpu", "name": "jimmyza-cpu", - "avatarUrl": "https://avatars.githubusercontent.com/u/jimmyza-cpu?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/211182673?v=4", "url": "https://github.com/jimmyza-cpu", "tier": "Supporter", "monthlyAmount": 5, @@ -65,7 +65,7 @@ { "login": "pozd5995", "name": "pozd5995", - "avatarUrl": "https://avatars.githubusercontent.com/u/pozd5995?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/210923654?v=4", "url": "https://github.com/pozd5995", "tier": "Supporter", "monthlyAmount": 5, @@ -75,7 +75,7 @@ { "login": "NumNuts101", "name": "NumNuts101", - "avatarUrl": "https://avatars.githubusercontent.com/u/NumNuts101?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/84128224?v=4", "url": "https://github.com/NumNuts101", "tier": "Supporter", "monthlyAmount": 5, @@ -85,7 +85,7 @@ { "login": "xtamtamx", "name": "xtamtamx", - "avatarUrl": "https://avatars.githubusercontent.com/u/xtamtamx?v=4", + "avatarUrl": "https://avatars.githubusercontent.com/u/30088598?v=4", "url": "https://github.com/xtamtamx", "tier": "Supporter", "monthlyAmount": 5, diff --git a/src/primary/web_server.py b/src/primary/web_server.py index 58fa571c..81988f22 100644 --- a/src/primary/web_server.py +++ b/src/primary/web_server.py @@ -1186,24 +1186,24 @@ def get_github_sponsors(): 'monthlyAmount': sponsor.get('monthly_amount', 0) }) - current_app.logger.info(f"Returning {len(formatted_sponsors)} sponsors from database") + current_app.logger.debug(f"Returning {len(formatted_sponsors)} sponsors from database") return jsonify(formatted_sponsors) # If no sponsors in database, try to populate from manifest - current_app.logger.info("No sponsors in database, attempting to populate from manifest") + current_app.logger.debug("No sponsors in database, attempting to populate from manifest") # Try to use local manifest.json first, then fallback to GitHub local_manifest_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'manifest.json') manifest_data = None if os.path.exists(local_manifest_path): - current_app.logger.info(f"Using local manifest.json from {local_manifest_path}") + current_app.logger.debug(f"Using local manifest.json from {local_manifest_path}") with open(local_manifest_path, 'r') as f: manifest_data = json.load(f) else: # Fallback to GitHub raw content manifest_url = "https://raw.githubusercontent.com/plexguide/Huntarr.io/main/manifest.json" - current_app.logger.info(f"Local manifest not found, fetching from {manifest_url}") + current_app.logger.debug(f"Local manifest not found, fetching from {manifest_url}") response = requests.get(manifest_url, timeout=10) response.raise_for_status() manifest_data = response.json() @@ -1213,7 +1213,7 @@ def get_github_sponsors(): if sponsors_list: # Save sponsors to database db.save_sponsors(sponsors_list) - current_app.logger.info(f"Populated database with {len(sponsors_list)} sponsors from manifest") + current_app.logger.debug(f"Populated database with {len(sponsors_list)} sponsors from manifest") # Return the sponsors (recursively call this function to get formatted data) return get_github_sponsors()