Refactored and redesigned dashboards to show button to show sharable image.

This commit is contained in:
2025-07-25 23:12:31 +02:00
parent 38e42efdef
commit f940470de3
3 changed files with 32 additions and 7 deletions

View File

@@ -37,7 +37,6 @@ def inject_subreddits():
def overall_dashboard():
"""Handler for the main, overall dashboard."""
view_type = request.args.get('view', 'daily')
is_image_mode = request.args.get('image') == 'true'
if view_type == 'weekly':
@@ -57,19 +56,19 @@ def overall_dashboard():
tickers=tickers,
view_type=view_type,
subreddit_name=None,
is_image_mode=is_image_mode
is_image_mode=is_image_mode,
base_url="/"
)
@app.route("/subreddit/<name>")
def subreddit_dashboard(name):
"""Handler for per-subreddit dashboards."""
view_type = request.args.get('view', 'daily')
is_image_mode = request.args.get('image') == 'true'
if view_type == 'weekly':
today = datetime.now(timezone.utc)
target_date = today - timedelta(days=7) # Default to last week
target_date = today - timedelta(days=7)
tickers, start, end = get_weekly_summary_for_subreddit(name, target_date)
date_string = f"{start.strftime('%b %d')} - {end.strftime('%b %d, %Y')}"
subtitle = f"r/{name} - Top 10 Weekly"
@@ -86,7 +85,8 @@ def subreddit_dashboard(name):
tickers=tickers,
view_type=view_type,
subreddit_name=name,
is_image_mode=is_image_mode
is_image_mode=is_image_mode,
base_url=f"/subreddit/{name}"
)
@app.route("/deep-dive/<symbol>")

View File

@@ -67,6 +67,18 @@
}
.image-container { width: 750px; background: linear-gradient(145deg, #2d3748, #1a202c); color: #ffffff; border-radius: 16px; padding: 2.5rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5); text-align: center; }
header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; }
.header-action {
display: flex;
align-items: center;
gap: 1rem;
}
.header-action .icon-link svg {
color: #a0aec0;
transition: color 0.2s;
}
.header-action .icon-link:hover svg {
color: #ffffff;
}
.title-block { text-align: left; }
.title-block h1 { font-size: 2.5rem; font-weight: 800; margin: 0; line-height: 1; }
.title-block h2 { font-size: 1.25rem; font-weight: 600; margin: 0.5rem 0 0; color: #a0aec0; }

View File

@@ -9,7 +9,20 @@
<h1>Reddit Ticker Mentions</h1>
<h2>{{ subtitle }}</h2>
</div>
<div class="header-action">
<div class="date">{{ date_string }}</div>
<!-- Only show the icon if we are NOT already in image mode -->
{% if not is_image_mode %}
<a href="{{ base_url }}?view={{ view_type }}&image=true" class="icon-link" title="View as Shareable Image">
<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"></path>
<circle cx="12" cy="13" r="4"></circle>
</svg>
</a>
{% endif %}
</div>
</header>
<table>
<thead>