🚀 Major improvements: Fix short URLs, separate public/admin views, and enhance UX

 Fixed Critical Issues:
- Fixed dynamic QR code short URL redirect functionality
- Resolved data consistency issues with multiple LinkPageManager instances
- Fixed worker concurrency problems in Gunicorn configuration

🎨 UI/UX Enhancements:
- Separated public page from admin statistics view
- Created clean public_page.html for QR code users (no admin info)
- Added comprehensive statistics_page.html for admin analytics
- Enhanced dashboard with separate 'Manage' and 'Stats' buttons
- Improved navigation flow throughout the application

🔧 Technical Improvements:
- Added URLShortener instance reloading for data consistency
- Reduced Gunicorn workers to 1 to prevent file conflicts
- Increased timeout to 60s for better performance
- Enhanced debug logging for troubleshooting
- Added proper error handling and 404 responses

📁 New Files:
- app/templates/public_page.html - Clean public interface
- app/templates/statistics_page.html - Admin analytics dashboard

�� Modified Files:
- app/routes/main.py - Added /stats route, improved short URL handling
- app/templates/edit_links.html - Added Statistics button
- app/templates/index.html - Added Stats button for QR codes
- app/utils/link_manager.py - Enhanced data reloading
- app/utils/url_shortener.py - Added debug logging
- gunicorn.conf.py - Optimized worker configuration

This update provides a professional separation between public content and admin functionality while ensuring reliable short URL operation.
This commit is contained in:
2025-07-18 09:21:36 -04:00
parent 1ae080df37
commit 53f5c513d4
11 changed files with 920 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ Main routes for QR Code Manager
from flask import Blueprint, render_template, redirect, abort
from app.utils.auth import login_required
from app.utils.link_manager import LinkPageManager
from app.utils.url_shortener import URLShortener
bp = Blueprint('main', __name__)
@@ -19,14 +20,24 @@ def index():
@bp.route('/links/<page_id>')
def view_link_page(page_id):
"""Display the public link page"""
"""Display the public link page (for QR codes)"""
if not link_manager.page_exists(page_id):
return "Page not found", 404
link_manager.increment_view_count(page_id)
page_data = link_manager.get_page(page_id)
return render_template('link_page.html', page=page_data)
return render_template('public_page.html', page=page_data)
@bp.route('/stats/<page_id>')
@login_required
def view_page_statistics(page_id):
"""Display the statistics page for admins"""
if not link_manager.page_exists(page_id):
return "Page not found", 404
page_data = link_manager.get_page(page_id)
return render_template('statistics_page.html', page=page_data)
@bp.route('/edit/<page_id>')
@login_required
@@ -48,6 +59,8 @@ def health_check():
@bp.route('/s/<short_code>')
def redirect_short_url(short_code):
"""Redirect short URL to original URL"""
# Force reload of data to ensure we have the latest short URLs
link_manager.url_shortener = URLShortener()
original_url = link_manager.resolve_short_url(short_code)
if original_url:
return redirect(original_url)