Added search.html which was missing.
This commit is contained in:
12
app.py
12
app.py
@@ -182,6 +182,18 @@ def modapp():
|
|||||||
pending_quotes = Quote.query.filter_by(status=0).all()
|
pending_quotes = Quote.query.filter_by(status=0).all()
|
||||||
return render_template('modapp.html', pending_quotes=pending_quotes)
|
return render_template('modapp.html', pending_quotes=pending_quotes)
|
||||||
|
|
||||||
|
@app.route('/search', methods=['GET'])
|
||||||
|
def search():
|
||||||
|
query = request.args.get('q', '').strip() # Get the search query and trim whitespace
|
||||||
|
quotes = []
|
||||||
|
|
||||||
|
if query:
|
||||||
|
# Perform the search only if the query is provided
|
||||||
|
quotes = Quote.query.filter(Quote.text.like(f'%{query}%'), Quote.status == 1).all()
|
||||||
|
|
||||||
|
# Render the search page with the results (or empty if no query)
|
||||||
|
return render_template('search.html', quotes=quotes, query=query)
|
||||||
|
|
||||||
# Route for browsing approved quotes
|
# Route for browsing approved quotes
|
||||||
@app.route('/browse', methods=['GET'])
|
@app.route('/browse', methods=['GET'])
|
||||||
def browse():
|
def browse():
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
<a href="/submit">Submit</a> /
|
<a href="/submit">Submit</a> /
|
||||||
<a href="/browse">Browse</a> /
|
<a href="/browse">Browse</a> /
|
||||||
<a href="/modapp">ModApp</a> /
|
<a href="/modapp">ModApp</a> /
|
||||||
|
<!-- This link will now load search.html -->
|
||||||
<a href="/search">Search</a>
|
<a href="/search">Search</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
98
templates/search.html
Normal file
98
templates/search.html
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>ircquotes: Search</title>
|
||||||
|
<link rel="stylesheet" href="/static/css/styles.css">
|
||||||
|
</head>
|
||||||
|
<body bgcolor="#ffffff" text="#000000" link="#c08000" vlink="#c08000" alink="#c08000">
|
||||||
|
|
||||||
|
<!-- Top Navigation Bar -->
|
||||||
|
<center>
|
||||||
|
<table cellpadding="2" cellspacing="0" width="80%" border="0">
|
||||||
|
<tr>
|
||||||
|
<td bgcolor="#c08000" align="left">
|
||||||
|
<font size="+1"><b><i>ircquotes</i></b></font>
|
||||||
|
</td>
|
||||||
|
<td bgcolor="#c08000" align="right">
|
||||||
|
<font face="arial" size="+1"><b>Search 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>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<!-- Search Form -->
|
||||||
|
<center>
|
||||||
|
<h2>Search for Quotes</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>
|
||||||
|
|
||||||
|
<!-- Show Search Results only if there is a search query -->
|
||||||
|
{% 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>
|
||||||
|
(<font color="green">{{ quote.votes }}</font>)
|
||||||
|
<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 %}
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<!-- 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> /
|
||||||
|
<a href="/browse">Browse</a> /
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="footertext" align="left"> </td>
|
||||||
|
<td class="footertext" align="right">{{ approved_count }} quotes approved</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<font size="-1">© ircquotes 2024, All Rights Reserved.</font>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user