From f5dc6c9d85516e6aef24fd2d92af47d6e5303bb7 Mon Sep 17 00:00:00 2001 From: Igor Olszewski Date: Tue, 26 May 2026 15:28:33 +0200 Subject: [PATCH] feat: implement report sharing functionality and clean up sitemap configuration --- app.py | 2 +- nginx/nginx.conf | 8 -------- static/app.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index 130f774..fa47baf 100644 --- a/app.py +++ b/app.py @@ -5,7 +5,7 @@ import json import time import datetime -from flask import Flask, render_template, request, jsonify, send_from_directory +from flask import Flask, render_template, request, jsonify, send_from_directory, redirect, url_for from urllib.parse import urlparse import requests from dotenv import load_dotenv diff --git a/nginx/nginx.conf b/nginx/nginx.conf index f152569..c0bce30 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -49,14 +49,6 @@ server { include /etc/nginx/security_headers.inc; } - location = /sitemap.xml { - alias /opt/infrascan/static/sitemap.xml; - # Cache sitemap for 24 hours - add_header Cache-Control "public, max-age=86400" always; - add_header Content-Type "application/xml; charset=utf-8" always; - include /etc/nginx/security_headers.inc; - } - location = /robots.txt { alias /opt/infrascan/static/robots.txt; # Cache robots.txt for 24 hours diff --git a/static/app.js b/static/app.js index cfce403..cbd6477 100644 --- a/static/app.js +++ b/static/app.js @@ -119,6 +119,36 @@ function initApp() { if (uuidMatch) { currentScanId = uuidMatch[1]; } + + // Register hosted-report button listeners (must happen before early return) + if (newScanBtn) { + newScanBtn.addEventListener('click', () => { + window.location.href = '/'; + }); + } + + if (shareBtn) { + shareBtn.addEventListener('click', () => { + if (!currentScanId) return; + let cleanRepo = 'report'; + if (currentMetadata && currentMetadata.repository_name) { + cleanRepo = currentMetadata.repository_name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'report'; + } + const shareUrl = `${window.location.origin}/report/${cleanRepo}-${currentScanId}`; + if (shareUrlInput) shareUrlInput.value = shareUrl; + if (shareLinkContainer) shareLinkContainer.classList.remove('hidden'); + shareBtn.textContent = 'Results Shared'; + }); + } + + if (copyShareBtn) { + copyShareBtn.addEventListener('click', () => { + if (shareUrlInput) shareUrlInput.select(); + document.execCommand('copy'); + copyShareBtn.textContent = 'Copied!'; + setTimeout(() => { copyShareBtn.textContent = 'Copy'; }, 2000); + }); + } } // Ensure container is correctly styled for full-width report