Complete ircquotes application with all features

- Added copy quote functionality with clipboard integration
- Implemented bulk moderation actions for admin
- Created mobile responsive design with bash.org styling
- Added API rate limiting per IP address
- Implemented dark mode toggle with flash prevention
- Enhanced error messages throughout application
- Fixed all security vulnerabilities (SQL injection, XSS, CSRF)
- Added comprehensive rate limiting on all endpoints
- Implemented secure session configuration
- Added input validation and length limits
- Created centralized configuration system with config.json
- Set up production deployment with Gunicorn
- Added security headers and production hardening
- Added password generation and config management tools
This commit is contained in:
2025-09-20 19:41:23 +01:00
parent 0b1241714d
commit f409977257
21 changed files with 1936 additions and 304 deletions

View File

@@ -6,6 +6,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Browse Quotes</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='voting.js') }}"></script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
@@ -33,8 +45,9 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a>
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>
@@ -48,12 +61,16 @@
{% for quote in quotes.items %}
<p class="quote">
<a href="/quote?id={{ quote.id }}" title="Permanent link to this quote."><b>#{{ quote.id }}</b></a>
<a href="/vote/{{ quote.id }}/upvote?page={{ quotes.page }}" class="qa">+</a>
(<font color="green">{{ quote.votes }}</font>)
<a href="/vote/{{ quote.id }}/downvote?page={{ quotes.page }}" class="qa">-</a>
<a href="/flag/{{ quote.id }}" class="qa"></a>
&nbsp;
<a href="#" onclick="return vote({{ quote.id }}, &quot;upvote&quot;, this)" class="qa" id="up-{{ quote.id }}">+</a>
<span id="votes-{{ quote.id }}"><font color="green">{{ quote.votes }}</font></span>
<a href="#" onclick="return vote({{ quote.id }}, &quot;downvote&quot;, this)" class="qa" id="down-{{ quote.id }}">-</a>
&nbsp;
<a href="#" onclick="return flag({{ quote.id }}, this)" class="qa">X</a>
&nbsp;
<a href="#" onclick="return copyQuote({{ quote.id }}, this)" class="qa" title="Copy quote to clipboard">C</a>
</p>
<p class="qt">{{ quote.text }}</p>
<p class="qt">{{ quote.text|e }}</p>
<hr>
{% endfor %}
</td>

View File

@@ -5,6 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: FAQ</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
@@ -29,8 +40,9 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a>
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>

View File

@@ -6,6 +6,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Home</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
@@ -33,8 +44,9 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a>
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>

View File

@@ -5,6 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Admin Login</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
@@ -31,8 +42,9 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a>
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>
@@ -42,6 +54,7 @@
<center>
<h2>Admin Login</h2>
<form method="POST" action="/login">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<table>
<tr>
<td>Username:</td>

View File

@@ -5,6 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Admin Panel</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
@@ -29,6 +40,7 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">Modapp</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>
@@ -45,48 +57,130 @@
<option value="pending" {% if filter_status == 'pending' %}selected{% endif %}>Pending</option>
<option value="approved" {% if filter_status == 'approved' %}selected{% endif %}>Approved</option>
<option value="rejected" {% if filter_status == 'rejected' %}selected{% endif %}>Rejected</option>
<option value="flagged" {% if filter_status == 'flagged' %}selected{% endif %}>Flagged</option>
</select>
<input type="submit" value="Apply Filter">
</form>
{% if quotes.items %}
<!-- Bulk Actions Form -->
<form id="bulk-action-form" method="POST" action="/modapp/bulk">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<div style="margin: 10px 0; padding: 10px; background-color: #f0f0f0; border: 1px solid #ccc;">
<b>Bulk Actions:</b>
<input type="checkbox" id="select-all" onchange="toggleAllCheckboxes(this)"> <label for="select-all">Select All</label>
&nbsp;&nbsp;
<button type="submit" name="action" value="approve" class="qa" onclick="return confirmBulkAction('approve')">Bulk Approve</button>
<button type="submit" name="action" value="reject" class="qa" onclick="return confirmBulkAction('reject')">Bulk Reject</button>
<button type="submit" name="action" value="delete" class="qa" onclick="return confirmBulkAction('delete')">Bulk Delete</button>
<button type="submit" name="action" value="clear_flags" class="qa" onclick="return confirmBulkAction('clear flags')">Clear All Flags</button>
</div>
<!-- Table for Quotes -->
<div class="modapp-table-container">
<table border="1" cellpadding="5" cellspacing="0" width="100%">
<tr>
<th>Select</th>
<th>Quote ID</th>
<th>Quote</th>
<th>Status</th>
<th>Submitted At</th>
<th>IP Address</th>
<th>User Agent</th>
<th>Flags</th>
<th class="mobile-hide">Submitted At</th>
<th class="mobile-hide">IP Address</th>
<th class="mobile-hide">User Agent</th>
<th>Actions</th>
</tr>
<!-- Loop through quotes -->
{% for quote in quotes.items %}
<tr style="background-color:
{% if quote.status == 1 %} #d4edda {% elif quote.status == 2 %} #f8d7da {% else %} #fff {% endif %}">
{% if quote.flag_count > 5 %} #ffcccc {% elif quote.flag_count > 2 %} #ffe6cc {% elif quote.status == 1 %} #d4edda {% elif quote.status == 2 %} #f8d7da {% else %} #fff {% endif %}">
<td><input type="checkbox" name="quote_ids" value="{{ quote.id }}" class="quote-checkbox"></td>
<td>#{{ quote.id }}</td>
<td>{{ quote.text }}</td>
<td>{{ quote.text|e }}</td>
<td>
{% if quote.status == 0 %}
Pending
{% elif quote.status == 1 %}
Approved
{% if filter_status == 'flagged' %}
<!-- Prominent status display for flagged quotes -->
{% if quote.status == 0 %}
<span style="background-color: #fff3cd; padding: 2px 6px; border-radius: 3px; font-weight: bold;">⚠️ PENDING + FLAGGED</span>
{% elif quote.status == 1 %}
<span style="background-color: #d4edda; padding: 2px 6px; border-radius: 3px; font-weight: bold;">✅ APPROVED + FLAGGED</span>
{% else %}
<span style="background-color: #f8d7da; padding: 2px 6px; border-radius: 3px; font-weight: bold;">❌ REJECTED + FLAGGED</span>
{% endif %}
{% else %}
Rejected
<!-- Normal status display -->
{% if quote.status == 0 %}
Pending
{% elif quote.status == 1 %}
Approved
{% else %}
Rejected
{% endif %}
{% endif %}
</td>
<td>{{ quote.submitted_at.strftime('%Y-%m-%d %H:%M:%S') if quote.submitted_at else 'N/A' }}</td>
<td>{{ quote.ip_address }}</td>
<td>{{ quote.user_agent }}</td>
<td>
<a href="/approve/{{ quote.id }}">Approve</a> |
<a href="/reject/{{ quote.id }}">Reject</a> |
<a href="/delete/{{ quote.id }}">Delete</a>
{% if quote.flag_count > 0 %}
<span style="color: red; font-weight: bold;">{{ quote.flag_count }}</span>
{% else %}
0
{% endif %}
</td>
<td class="mobile-hide">{{ quote.submitted_at.strftime('%Y-%m-%d %H:%M:%S') if quote.submitted_at else 'N/A' }}</td>
<td class="mobile-hide">{{ quote.ip_address|e }}</td>
<td class="mobile-hide">{{ quote.user_agent|e|truncate(50) }}</td>
<td>
{% if filter_status == 'flagged' %}
<!-- Special actions for flagged quotes -->
{% if quote.status == 1 %}
<!-- Already approved but flagged -->
<a href="/clear_flags/{{ quote.id }}" style="color: blue;">Clear Flags</a> |
<a href="/reject/{{ quote.id }}" style="color: orange;">Reject</a> |
<a href="/delete/{{ quote.id }}" style="color: red;">Delete</a>
{% elif quote.status == 0 %}
<!-- Pending and flagged -->
<a href="/approve/{{ quote.id }}" style="color: green;">Approve</a> |
<a href="/clear_flags/{{ quote.id }}" style="color: blue;">Clear Flags</a> |
<a href="/reject/{{ quote.id }}" style="color: orange;">Reject</a> |
<a href="/delete/{{ quote.id }}" style="color: red;">Delete</a>
{% else %}
<!-- Rejected and flagged -->
<a href="/clear_flags/{{ quote.id }}" style="color: blue;">Clear Flags</a> |
<a href="/delete/{{ quote.id }}" style="color: red;">Delete</a>
{% endif %}
{% else %}
<!-- Standard actions for non-flagged quotes -->
<a href="/approve/{{ quote.id }}">Approve</a> |
<a href="/reject/{{ quote.id }}">Reject</a> |
<a href="/delete/{{ quote.id }}">Delete</a>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</form>
<!-- Bulk Actions JavaScript -->
<script>
function toggleAllCheckboxes(selectAllCheckbox) {
const checkboxes = document.querySelectorAll('.quote-checkbox');
checkboxes.forEach(checkbox => {
checkbox.checked = selectAllCheckbox.checked;
});
}
function confirmBulkAction(action) {
const selectedCheckboxes = document.querySelectorAll('.quote-checkbox:checked');
if (selectedCheckboxes.length === 0) {
alert('Please select at least one quote.');
return false;
}
const count = selectedCheckboxes.length;
const message = `Are you sure you want to ${action} ${count} selected quote(s)?`;
return confirm(message);
}
</script>
<!-- Pagination Links -->
<div id="pagination">
@@ -118,7 +212,8 @@
<tr>
<td class="footertext" align="left">&nbsp;</td>
<td class="footertext" align="right">
{{ approved_count }} quotes approved; {{ pending_count }} quotes pending; {{ rejected_count }} quotes rejected
{{ approved_count }} quotes approved; {{ pending_count }} quotes pending; {{ rejected_count }} quotes rejected;
<span style="color: red; font-weight: bold;">{{ flagged_count }} quotes flagged</span>
</td>
</tr>
</table>

View File

@@ -6,6 +6,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Quote #{{ quote.id }}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='voting.js') }}"></script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
@@ -33,8 +45,9 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a>
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>
@@ -47,13 +60,17 @@
<td valign="top">
<p class="quote">
<a href="/quote?id={{ quote.id }}" title="Permanent link to this quote."><b>#{{ quote.id }}</b></a>
<a href="/vote/{{ quote.id }}/upvote" class="qa">+</a>
(<font color="green">{{ quote.votes }}</font>)
<a href="/vote/{{ quote.id }}/downvote" class="qa">-</a>
<a href="/flag/{{ quote.id }}" class="qa">[X]</a>
&nbsp;
<a href="#" onclick="return vote({{ quote.id }}, 'upvote', this)" class="qa" id="up-{{ quote.id }}">+</a>
<span id="votes-{{ quote.id }}"><font color="green">{{ quote.votes }}</font></span>
<a href="#" onclick="return vote({{ quote.id }}, 'downvote', this)" class="qa" id="down-{{ quote.id }}">-</a>
&nbsp;
<a href="#" onclick="return flag({{ quote.id }}, this)" class="qa">X</a>
&nbsp;
<a href="#" onclick="return copyQuote({{ quote.id }}, this)" class="qa" title="Copy quote to clipboard">C</a>
</p>
<p class="qt">{{ quote.text }}</p>
<p class="qt">{{ quote.text|e }}</p>
</td>
<td valign="top"></td>
</tr>

View File

@@ -6,6 +6,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Random Quote</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='voting.js') }}"></script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
@@ -30,8 +42,9 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a>
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>
@@ -43,12 +56,16 @@
<td valign="top">
<p class="quote">
<a href="/quote?id={{ quote.id }}" title="Permanent link to this quote."><b>#{{ quote.id }}</b></a>
<a href="/vote/{{ quote.id }}/upvote" class="qa">+</a>
(<font color="green">{{ quote.votes }}</font>)
<a href="/vote/{{ quote.id }}/downvote" class="qa">-</a>
<a href="/flag/{{ quote.id }}" class="qa">[X]</a>
&nbsp;
<a href="#" onclick="return vote({{ quote.id }}, 'upvote', this)" class="qa" id="up-{{ quote.id }}">+</a>
<span id="votes-{{ quote.id }}"><font color="green">{{ quote.votes }}</font></span>
<a href="#" onclick="return vote({{ quote.id }}, 'downvote', this)" class="qa" id="down-{{ quote.id }}">-</a>
&nbsp;
<a href="#" onclick="return flag({{ quote.id }}, this)" class="qa">X</a>
&nbsp;
<a href="#" onclick="return copyQuote({{ quote.id }}, this)" class="qa" title="Copy quote to clipboard">C</a>
</p>
<p class="qt">{{ quote.text }}</p>
<p class="qt">{{ quote.text|e }}</p>
</td>
</tr>
</table>
@@ -77,6 +94,7 @@
&#169; ircquotes 2024, All Rights Reserved.
</font>
</center>
</body>
</html>

View File

@@ -5,28 +5,113 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Search & Read</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='voting.js') }}"></script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
<!-- Header -->
<!-- Top Navigation Bar -->
<center>
<table cellpadding="2" cellspacing="0" width="80%" class="header">
<table cellpadding="2" cellspacing="0" width="80%" border="0">
<tr>
<td class="header-left">
<b><i>ircquotes</i></b>
<td bgcolor="#c08000" align="left">
<font size="+1"><b><i>ircquotes</i></b></font>
</td>
<td class="header-right">
<b>Search & Read Quotes</b>
<td bgcolor="#c08000" align="right">
<font face="arial" size="+1"><b>Search & Read Quotes</b></font>
</td>
</tr>
</table>
<!-- Navigation Links -->
<table cellpadding="2" cellspacing="0" width="80%" border="0">
<tr>
<td class="footertext" align="left" bgcolor="#f0f0f0"></td>
<td align="right" bgcolor="#f0f0f0" class="toplinks" colspan="2">
<a href="/">Home</a> /
<a href="/random">Random</a> /
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>
</center>
<!-- Navigation Bar -->
<!-- Search Forms -->
<center>
<table cellpadding="2" cellspacing="0" width="80%" class="nav-bar">
<table cellpadding="0" cellspacing="3" width="80%">
<tr>
<td align="right" class="toplinks" colspan="2">
<td class="bodytext" width="100%" valign="top">
<!-- Search for Quotes -->
<p><b>Search for Quotes by Keyword</b></p>
<form action="/search" method="GET">
<input type="text" name="q" value="{{ query or '' }}" placeholder="Enter search term" required>
<input type="submit" value="Search">
</form>
<br>
<!-- Read Quote by Number -->
<p><b>Read a Quote by Number</b></p>
<form action="/quote" method="GET">
<input type="number" name="id" placeholder="Enter quote number" required>
<input type="submit" value="Read">
</form>
<hr>
</td>
</tr>
</table>
</center>
<!-- Search Results -->
{% if query %}
<center>
<table cellpadding="0" cellspacing="3" width="80%">
<tr>
<td class="bodytext" width="100%" valign="top">
<p><b>Search Results for "{{ query }}"</b></p>
{% if quotes %}
{% for quote in quotes %}
<p class="quote">
<a href="/quote?id={{ quote.id }}" title="Permanent link to this quote."><b>#{{ quote.id }}</b></a>
&nbsp;
<a href="#" onclick="return vote({{ quote.id }}, &quot;upvote&quot;, this)" class="qa" id="up-{{ quote.id }}">+</a>
<span id="votes-{{ quote.id }}"><font color="green">{{ quote.votes }}</font></span>
<a href="#" onclick="return vote({{ quote.id }}, &quot;downvote&quot;, this)" class="qa" id="down-{{ quote.id }}">-</a>
&nbsp;
<a href="#" onclick="return flag({{ quote.id }}, this)" class="qa">X</a>
&nbsp;
<a href="#" onclick="return copyQuote({{ quote.id }}, this)" class="qa" title="Copy quote to clipboard">C</a>
</p>
<p class="qt">{{ quote.text|e }}</p>
<hr>
{% endfor %}
{% else %}
<p>No quotes found for "{{ query }}".</p>
{% endif %}
</td>
</tr>
</table>
</center>
{% endif %}
<!-- Footer -->
<center>
<table border="0" cellpadding="2" cellspacing="0" width="80%" bgcolor="#c08000">
<tr>
<td bgcolor="#f0f0f0" class="toplinks" colspan="2">
<a href="/">Home</a> /
<a href="/random">Random</a> /
<a href="/submit">Submit</a> /
@@ -36,67 +121,16 @@
<a href="/faq">FAQ</a>
</td>
</tr>
</table>
</center>
<!-- Content Section -->
<center>
<div class="content-box">
<!-- Search for Quotes -->
<h2>Search for Quotes by Keyword</h2>
<form action="/search" method="GET">
<input type="text" name="q" class="text" placeholder="Enter search term" required>
<input type="submit" value="Search" class="button">
</form>
<!-- Read Quote by Number -->
<h2>Read a Quote by Number</h2>
<form action="/read" method="GET">
<input type="number" name="id" class="text" placeholder="Enter quote number" required>
<input type="submit" value="Read" class="button">
</form>
</div>
<!-- Results Section -->
<div class="results-box">
{% if query %}
<h3>Search Results for "{{ query }}"</h3>
{% if quotes %}
<table cellpadding="0" cellspacing="3" width="80%">
<tr>
<td class="bodytext" width="100%" valign="top">
{% for quote in quotes %}
<p class="quote">
<a href="/quote?id={{ quote.id }}" title="Permanent link to this quote.">
<b>#{{ quote.id }}</b>
</a>
<a href="/vote/{{ quote.id }}/upvote" class="qa">+</a>
(<span class="votes">{{ quote.votes }}</span>)
<a href="/vote/{{ quote.id }}/downvote" class="qa">-</a>
</p>
<p class="qt">{{ quote.text }}</p>
<hr>
{% endfor %}
</td>
</tr>
</table>
{% else %}
<h4>No quotes found for "{{ query }}".</h4>
{% endif %}
{% endif %}
</div>
</center>
<!-- Footer -->
<center>
<table border="0" cellpadding="2" cellspacing="0" width="80%" class="footer">
<tr>
<td class="footertext" align="right">{{ approved_count }} quotes approved; {{ pending_count }} quotes pending</td>
<td class="footertext" align="left">&nbsp;</td>
<td class="footertext" align="right">{{ approved_count }} quotes approved</td>
</tr>
</table>
<div class="copyright">
<font size="-1">
<a href="#">Hosted by YourHostingProvider</a><br>
&#169; ircquotes 2024, All Rights Reserved.
</div>
</font>
</center>
</body>

View File

@@ -5,6 +5,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ircquotes: Add a Quote</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
<script>
// Prevent flash of white content by applying theme immediately
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && prefersDark)) {
document.documentElement.className = 'dark-theme';
}
})();
</script>
<script src="{{ url_for('static', filename='theme.js') }}"></script>
</head>
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000" onload="document.add.newquote.focus();">
<center>
@@ -32,14 +43,16 @@
<a href="/submit">Submit</a> /
<a href="/browse">Browse</a> /
<a href="/modapp">ModApp</a> /
<a href="/search">Search</a>
<a href="/search">Search</a> /
<a href="/faq">FAQ</a>
<button id="theme-toggle" onclick="toggleDarkMode()" title="Toggle dark/light mode">🌙</button>
</td>
</tr>
</table>
<!-- Add a Quote Form -->
<form action="/submit" name="add" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<table cellpadding="2" cellspacing="0" width="60%">
<tr>
<td><textarea cols="100%" rows="10" name="quote" class="text"></textarea></td>