🚀 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:
@@ -368,7 +368,8 @@
|
||||
</div>
|
||||
|
||||
<div class="page-actions">
|
||||
<a href="/links/{{ page.id }}" target="_blank" class="btn">👁️ View Public Page</a>
|
||||
<a href="/stats/{{ page.id }}" class="btn">📊 View Statistics</a>
|
||||
<a href="/links/{{ page.id }}" target="_blank" class="btn btn-secondary">👁️ Preview Public Page</a>
|
||||
<a href="/" class="btn btn-secondary">🏠 Back to Dashboard</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -751,6 +751,7 @@
|
||||
<button class="btn btn-small btn-primary" onclick="downloadQRById('${qr.id}', 'png')" title="Download PNG">📥 PNG</button>
|
||||
<button class="btn btn-small btn-success" onclick="downloadQRById('${qr.id}', 'svg')" title="Download SVG">🎨 SVG</button>
|
||||
${qr.type === 'link_page' ? `<button class="btn btn-small" onclick="openLinkPage('${qr.id}')" style="background: #28a745;" title="Manage Links">📝 Manage</button>` : ''}
|
||||
${qr.type === 'link_page' ? `<button class="btn btn-small" onclick="openStatistics('${qr.id}')" style="background: #17a2b8;" title="View Statistics">📊 Stats</button>` : ''}
|
||||
<button class="btn btn-small btn-secondary" onclick="deleteQR('${qr.id}')" title="Delete QR Code">🗑️</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -801,6 +802,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function openStatistics(qrId) {
|
||||
try {
|
||||
const response = await fetch(`/api/qr_codes/${qrId}`);
|
||||
const qrData = await response.json();
|
||||
|
||||
if (qrData.page_id) {
|
||||
window.open(`/stats/${qrData.page_id}`, '_blank');
|
||||
} else {
|
||||
alert('Link page not found');
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Error opening statistics page: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Load history on page load
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
loadQRHistory();
|
||||
|
||||
319
app/templates/public_page.html
Normal file
319
app/templates/public_page.html
Normal file
@@ -0,0 +1,319 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ page.title }}</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 40px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.1em;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.links-section h2 {
|
||||
color: #333;
|
||||
margin-bottom: 25px;
|
||||
font-size: 1.8em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.link-item {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
margin-bottom: 15px;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.link-item:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.link-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.link-title {
|
||||
font-size: 1.3em;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.link-logo {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.link-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.link-description {
|
||||
color: #666;
|
||||
font-size: 0.95em;
|
||||
line-height: 1.4;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.link-url {
|
||||
color: #667eea;
|
||||
font-size: 0.9em;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.empty-state h3 {
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 15px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
font-size: 1.1em;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* Responsive design */
|
||||
@media (max-width: 768px) {
|
||||
body {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.container {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 30px 20px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.link-item {
|
||||
padding: 15px;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.link-content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.link-title {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.header h1 {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.links-section h2 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>{{ page.title }}</h1>
|
||||
<p>{{ page.description }}</p>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="links-section">
|
||||
{% if page.links %}
|
||||
<h2>📚 Available Links</h2>
|
||||
{% for link in page.links %}
|
||||
<a href="{{ link.short_url if link.short_url else link.url }}" target="_blank" class="link-item" data-url="{{ link.url }}">
|
||||
<div class="link-content">
|
||||
<div class="link-title">
|
||||
{{ link.title }}
|
||||
{% if link.short_url %}<span style="background: #2196f3; color: white; font-size: 0.7em; padding: 2px 6px; border-radius: 10px; margin-left: 8px;">SHORT</span>{% endif %}
|
||||
</div>
|
||||
{% if link.description %}
|
||||
<div class="link-description">{{ link.description }}</div>
|
||||
{% endif %}
|
||||
<div class="link-url">{{ link.short_url if link.short_url else link.url }}</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<img class="link-logo" style="display: none;" alt="Logo">
|
||||
<div class="link-icon">🔗</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<h3>No Links Yet</h3>
|
||||
<p>This page doesn't have any links yet. Check back later!</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Website logo mapping for better recognition
|
||||
function getWebsiteLogo(url) {
|
||||
try {
|
||||
const urlObj = new URL(url.startsWith('http') ? url : 'https://' + url);
|
||||
const domain = urlObj.hostname.replace('www.', '');
|
||||
|
||||
const logoMap = {
|
||||
'youtube.com': 'https://www.youtube.com/favicon.ico',
|
||||
'youtu.be': 'https://www.youtube.com/favicon.ico',
|
||||
'facebook.com': 'https://www.facebook.com/favicon.ico',
|
||||
'instagram.com': 'https://www.instagram.com/favicon.ico',
|
||||
'twitter.com': 'https://abs.twimg.com/favicons/twitter.ico',
|
||||
'x.com': 'https://abs.twimg.com/favicons/twitter.ico',
|
||||
'linkedin.com': 'https://static.licdn.com/sc/h/al2o9zrvru7aqj8e1x2rzsrca',
|
||||
'github.com': 'https://github.com/favicon.ico',
|
||||
'stackoverflow.com': 'https://stackoverflow.com/favicon.ico',
|
||||
'reddit.com': 'https://www.reddit.com/favicon.ico',
|
||||
'medium.com': 'https://medium.com/favicon.ico',
|
||||
'discord.com': 'https://discord.com/assets/f8389ca1a741a115313bede9ac02e2c0.ico',
|
||||
'twitch.tv': 'https://static.twitchcdn.net/assets/favicon-32-d6025c14e900565d6177.png',
|
||||
'spotify.com': 'https://open.spotify.com/favicon.ico',
|
||||
'apple.com': 'https://www.apple.com/favicon.ico',
|
||||
'google.com': 'https://www.google.com/favicon.ico',
|
||||
'microsoft.com': 'https://www.microsoft.com/favicon.ico',
|
||||
'amazon.com': 'https://www.amazon.com/favicon.ico',
|
||||
'netflix.com': 'https://assets.nflxext.com/ffe/siteui/common/icons/nficon2016.ico',
|
||||
'whatsapp.com': 'https://static.whatsapp.net/rsrc.php/v3/yz/r/ujTY9i_Jhs1.png'
|
||||
};
|
||||
|
||||
if (logoMap[domain]) {
|
||||
return logoMap[domain];
|
||||
}
|
||||
|
||||
// Fallback to favicon
|
||||
return `https://www.google.com/s2/favicons?domain=${domain}&sz=64`;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Set logos for links
|
||||
function setLogosForLinks() {
|
||||
document.querySelectorAll('.link-item[data-url]').forEach(linkElement => {
|
||||
const url = linkElement.getAttribute('data-url');
|
||||
const logoImg = linkElement.querySelector('.link-logo');
|
||||
const fallbackIcon = linkElement.querySelector('.link-icon');
|
||||
const logoSrc = getWebsiteLogo(url);
|
||||
|
||||
if (logoSrc && logoImg) {
|
||||
logoImg.src = logoSrc;
|
||||
logoImg.style.display = 'block';
|
||||
logoImg.alt = new URL(url.startsWith('http') ? url : 'https://' + url).hostname;
|
||||
// Hide the fallback icon when logo is shown
|
||||
logoImg.onload = function() {
|
||||
if (fallbackIcon) fallbackIcon.style.display = 'none';
|
||||
};
|
||||
logoImg.onerror = function() {
|
||||
this.style.display = 'none';
|
||||
if (fallbackIcon) fallbackIcon.style.display = 'flex';
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize logos when page loads
|
||||
document.addEventListener('DOMContentLoaded', setLogosForLinks);
|
||||
|
||||
// Add click tracking (optional)
|
||||
document.querySelectorAll('.link-item').forEach(link => {
|
||||
link.addEventListener('click', function() {
|
||||
// You could add analytics here
|
||||
console.log('Link clicked:', this.querySelector('.link-title').textContent.trim());
|
||||
});
|
||||
});
|
||||
|
||||
// Auto-refresh every 30 seconds to get latest links
|
||||
setInterval(() => {
|
||||
window.location.reload();
|
||||
}, 30000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
501
app/templates/statistics_page.html
Normal file
501
app/templates/statistics_page.html
Normal file
@@ -0,0 +1,501 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ page.title }} - Statistics</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 900px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 40px 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.1em;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.stats {
|
||||
background: rgba(255,255,255,0.1);
|
||||
margin-top: 20px;
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 30px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 0.9em;
|
||||
opacity: 0.8;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.admin-info {
|
||||
background: rgba(255,255,255,0.1);
|
||||
margin-top: 15px;
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.admin-info h3 {
|
||||
margin-bottom: 10px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.section h2 {
|
||||
color: #333;
|
||||
margin-bottom: 20px;
|
||||
font-size: 1.8em;
|
||||
border-bottom: 2px solid #667eea;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.links-section h2 {
|
||||
color: #333;
|
||||
margin-bottom: 25px;
|
||||
font-size: 1.8em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.link-item {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
margin-bottom: 15px;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.link-item:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.link-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.link-title {
|
||||
font-size: 1.3em;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.link-logo {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.link-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.link-description {
|
||||
color: #666;
|
||||
font-size: 0.95em;
|
||||
line-height: 1.4;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.link-url {
|
||||
color: #667eea;
|
||||
font-size: 0.9em;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.empty-state h3 {
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 15px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
font-size: 1.1em;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.actions {
|
||||
background: #f8f9fa;
|
||||
padding: 20px 30px;
|
||||
border-top: 1px solid #e9ecef;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 24px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
}
|
||||
|
||||
.qr-info {
|
||||
background: #e8f4fd;
|
||||
border: 1px solid #b8daff;
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.qr-info h3 {
|
||||
color: #0c5460;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.qr-info p {
|
||||
color: #0c5460;
|
||||
font-size: 0.9em;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.qr-url {
|
||||
background: white;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
font-family: monospace;
|
||||
font-size: 0.9em;
|
||||
word-break: break-all;
|
||||
border: 1px solid #b8daff;
|
||||
}
|
||||
|
||||
/* Responsive design */
|
||||
@media (max-width: 768px) {
|
||||
body {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.container {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 30px 20px;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
padding: 15px 20px;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.stats {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.link-item {
|
||||
padding: 15px;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.link-content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.link-title {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.header h1 {
|
||||
font-size: 1.8em;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.links-section h2 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>{{ page.title }} - Statistics</h1>
|
||||
<p>{{ page.description }}</p>
|
||||
|
||||
<div class="stats">
|
||||
<div class="stat-item">
|
||||
<div class="stat-number">{{ page.links|length }}</div>
|
||||
<div class="stat-label">Links</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-number">{{ page.view_count }}</div>
|
||||
<div class="stat-label">Page Views</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-number">{{ page.links|sum(attribute='click_count') or 0 }}</div>
|
||||
<div class="stat-label">Total Clicks</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-info">
|
||||
<h3>📊 Page Information</h3>
|
||||
<div class="info-row">
|
||||
<span>Page ID:</span>
|
||||
<span>{{ page.id }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span>Created:</span>
|
||||
<span>{{ page.created_at or 'N/A' }}</span>
|
||||
</div>
|
||||
<div class="info-row">
|
||||
<span>Last Updated:</span>
|
||||
<span>{{ page.updated_at or 'N/A' }}</span>
|
||||
</div>
|
||||
{% if page.short_url %}
|
||||
<div class="info-row">
|
||||
<span>Short URL:</span>
|
||||
<span>{{ page.short_url }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<div class="section">
|
||||
<div class="qr-info">
|
||||
<h3>🔗 Public QR Code URL</h3>
|
||||
<p>This is the URL that your QR code points to (public page without statistics):</p>
|
||||
<div class="qr-url">{{ request.url_root }}links/{{ page.id }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section links-section">
|
||||
{% if page.links %}
|
||||
<h2>📚 Links with Statistics</h2>
|
||||
{% for link in page.links %}
|
||||
<div class="link-item" style="cursor: default;">
|
||||
<div class="link-content">
|
||||
<div class="link-title">
|
||||
{{ link.title }}
|
||||
{% if link.short_url %}<span style="background: #2196f3; color: white; font-size: 0.7em; padding: 2px 6px; border-radius: 10px; margin-left: 8px;">SHORT</span>{% endif %}
|
||||
</div>
|
||||
{% if link.description %}
|
||||
<div class="link-description">{{ link.description }}</div>
|
||||
{% endif %}
|
||||
<div class="link-url">{{ link.short_url if link.short_url else link.url }}</div>
|
||||
<div style="margin-top: 10px; font-size: 0.85em; color: #666;">
|
||||
<strong>Clicks:</strong> {{ link.click_count or 0 }} |
|
||||
<strong>Added:</strong> {{ link.created_at or 'N/A' }}
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 10px;">
|
||||
<img class="link-logo" style="display: none;" alt="Logo">
|
||||
<div class="link-icon">📊</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="empty-state">
|
||||
<h3>No Links Yet</h3>
|
||||
<p>This page doesn't have any links yet. Add some links to see statistics here.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<a href="/edit/{{ page.id }}" class="btn btn-primary">
|
||||
✏️ Edit Page
|
||||
</a>
|
||||
<a href="/links/{{ page.id }}" class="btn btn-secondary" target="_blank">
|
||||
👁️ View Public Page
|
||||
</a>
|
||||
<a href="/" class="btn btn-secondary">
|
||||
🏠 Back to Dashboard
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Website logo mapping for better recognition
|
||||
function getWebsiteLogo(url) {
|
||||
try {
|
||||
const urlObj = new URL(url.startsWith('http') ? url : 'https://' + url);
|
||||
const domain = urlObj.hostname.replace('www.', '');
|
||||
|
||||
const logoMap = {
|
||||
'youtube.com': 'https://www.youtube.com/favicon.ico',
|
||||
'youtu.be': 'https://www.youtube.com/favicon.ico',
|
||||
'facebook.com': 'https://www.facebook.com/favicon.ico',
|
||||
'instagram.com': 'https://www.instagram.com/favicon.ico',
|
||||
'twitter.com': 'https://abs.twimg.com/favicons/twitter.ico',
|
||||
'x.com': 'https://abs.twimg.com/favicons/twitter.ico',
|
||||
'linkedin.com': 'https://static.licdn.com/sc/h/al2o9zrvru7aqj8e1x2rzsrca',
|
||||
'github.com': 'https://github.com/favicon.ico',
|
||||
'stackoverflow.com': 'https://stackoverflow.com/favicon.ico',
|
||||
'reddit.com': 'https://www.reddit.com/favicon.ico',
|
||||
'medium.com': 'https://medium.com/favicon.ico',
|
||||
'discord.com': 'https://discord.com/assets/f8389ca1a741a115313bede9ac02e2c0.ico',
|
||||
'twitch.tv': 'https://static.twitchcdn.net/assets/favicon-32-d6025c14e900565d6177.png',
|
||||
'spotify.com': 'https://open.spotify.com/favicon.ico',
|
||||
'apple.com': 'https://www.apple.com/favicon.ico',
|
||||
'google.com': 'https://www.google.com/favicon.ico',
|
||||
'microsoft.com': 'https://www.microsoft.com/favicon.ico',
|
||||
'amazon.com': 'https://www.amazon.com/favicon.ico',
|
||||
'netflix.com': 'https://assets.nflxext.com/ffe/siteui/common/icons/nficon2016.ico',
|
||||
'whatsapp.com': 'https://static.whatsapp.net/rsrc.php/v3/yz/r/ujTY9i_Jhs1.png'
|
||||
};
|
||||
|
||||
if (logoMap[domain]) {
|
||||
return logoMap[domain];
|
||||
}
|
||||
|
||||
// Fallback to favicon
|
||||
return `https://www.google.com/s2/favicons?domain=${domain}&sz=64`;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Set logos for links
|
||||
function setLogosForLinks() {
|
||||
document.querySelectorAll('[data-url]').forEach(linkElement => {
|
||||
const url = linkElement.getAttribute('data-url');
|
||||
const logoImg = linkElement.querySelector('.link-logo');
|
||||
const fallbackIcon = linkElement.querySelector('.link-icon');
|
||||
const logoSrc = getWebsiteLogo(url);
|
||||
|
||||
if (logoSrc && logoImg) {
|
||||
logoImg.src = logoSrc;
|
||||
logoImg.style.display = 'block';
|
||||
logoImg.alt = new URL(url.startsWith('http') ? url : 'https://' + url).hostname;
|
||||
// Hide the fallback icon when logo is shown
|
||||
logoImg.onload = function() {
|
||||
if (fallbackIcon) fallbackIcon.style.display = 'none';
|
||||
};
|
||||
logoImg.onerror = function() {
|
||||
this.style.display = 'none';
|
||||
if (fallbackIcon) fallbackIcon.style.display = 'flex';
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize logos when page loads
|
||||
document.addEventListener('DOMContentLoaded', setLogosForLinks);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user