Search page improvements
This commit is contained in:
parent
2b75aac67c
commit
1e81fe18bb
3 changed files with 27 additions and 14 deletions
|
@ -23,6 +23,7 @@ template_env = jinja2.Environment(
|
|||
error_template = template_env.get_template("error.html")
|
||||
|
||||
template_env.globals["convert_times"] = utils.convert_times
|
||||
template_env.globals["isSelected"] = utils.isSelected
|
||||
template_env.globals["generate_thumbnail_url"] = utils.generate_thumbnail_url
|
||||
template_env.globals["__version__"] = __version__
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title></title>
|
||||
<title>IWM Browser - {{ QueryValues["q"] }}</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="/static/index.css">
|
||||
<link rel="stylesheet" href="/static/main.css">
|
||||
|
@ -32,26 +33,30 @@
|
|||
</div>
|
||||
<details>
|
||||
<summary>More options</summary>
|
||||
{% macro option(name, value, key) -%}
|
||||
<option value={{ value }} {{ isSelected(value, QueryValues[key]) }}>{{ name }}</option>
|
||||
{%- endmacro %}
|
||||
<div class="sortType">
|
||||
<label for="sort">Sort type</label>
|
||||
<select id="sort" name="sort">
|
||||
<option value="average_rating">Rating</option>
|
||||
<option value="created_at">Upload date</option>
|
||||
<option value="average_difficulty">Difficulty</option>
|
||||
<option value="play_count">Plays</option>
|
||||
{{ option("Rating", "average_rating", "sort") }}
|
||||
{{ option("Upload date", "created_at", "sort") }}
|
||||
{{ option("Difficulty", "average_difficulty", "sort") }}
|
||||
{{ option("Plays", "play_count", "sort") }}
|
||||
</select>
|
||||
<select id="dir" name="dir">
|
||||
<option value="desc">Descending</option>
|
||||
<option value="asc">Ascending</option>
|
||||
{{ option("Descending", "desc", "dir") }}
|
||||
{{ option("Ascending", "asc", "dir") }}
|
||||
</select>
|
||||
</div>
|
||||
<div class="upload_date">
|
||||
<label for="date">Upload date</label>
|
||||
<select id="date" name="date">
|
||||
<option value="-1">All time</option>
|
||||
<option value="720">Past 30 days</option>
|
||||
<option value="168">Past 7 days</option>
|
||||
<option value="24">Past day</option>
|
||||
{{ option("All time", -1, "date") }}
|
||||
{{ option("Past 30 days", 720, "date") }}
|
||||
{{ option("Past 7 days", 168, "date") }}
|
||||
{{ option("Past day", 24, "date") }}
|
||||
{{ option("Past hour", 1, "date") }}
|
||||
</select>
|
||||
</div>
|
||||
</details>
|
||||
|
@ -61,15 +66,15 @@
|
|||
<div class="searchResults">
|
||||
{% for map in searchResults %}
|
||||
<div class="searchResultCard">
|
||||
<div class="thumbnail"><img src="{{ generate_thumbnail_url(map['ID'], THUMB_URL) }}"></div>
|
||||
<div class="thumbnail"><img aria-hidden="true" src="{{ generate_thumbnail_url(map['ID'], THUMB_URL) }}"></div>
|
||||
<div class="details">
|
||||
<div class="basic">
|
||||
<div class="levelTitle"><a href="/level/{{ map['ID'] }}">{{ map['Name'] }}</a></div>
|
||||
<div class="levelDifficulty"><span>Difficulty: {{ '▲' * map['AverageUserDifficulty']|int }}</span></div>
|
||||
<div class="levelDifficulty"><span aria-label="Difficulty: {{ map['AverageUserDifficulty']|int }}">Difficulty: {{ '▲' * map['AverageUserDifficulty']|int }}</span></div>
|
||||
<div class="creatorName">by <a href="/user/{{ map['CreatorId'] }}"><b>{{ map['CreatorName'] }}</b></a></div>
|
||||
<div class="levelRating">{{ map['NumThumbsUp'] }} 👍 {{ map['NumThumbsDown'] }} 👎</div>
|
||||
{% if map['Description'] != ''%}<div class="levelDescription">{{ map['Description'] }}</div>{% endif %}
|
||||
<div class="levelCode">Code: <input type="text" onclick="copy(this)" readonly=1 value="{{ map['MapCode'] }}" /></div>
|
||||
<div class="levelCode"><label for="levelCode-input-{{ map['ID'] }}">Code:</label> <input id="levelCode-input-{{ map['ID'] }}" type="text" onclick="copy(this)" readonly=1 value="{{ map['MapCode'] }}" /></div>
|
||||
</div>
|
||||
<div class="times">
|
||||
<div class="FirstClear">First Clear: <b>{{ map['FirstClearUsername'] }}</b></div>
|
||||
|
|
|
@ -27,6 +27,13 @@ def config_value(key: str, default_value=None):
|
|||
return default_value
|
||||
|
||||
|
||||
def isSelected(selection, value):
|
||||
"""Returns 'selected' if values are equal.
|
||||
Intended for selection boxes"""
|
||||
print(f"DBG: {selection} {value},")
|
||||
return 'selected="true"' if selection == value else ''
|
||||
|
||||
|
||||
# Specify default imgproxy instance.
|
||||
global_imgproxy_url = None
|
||||
global_imgproxy_params = None
|
||||
|
|
Loading…
Reference in a new issue