Geometer1729 4 years ago
parent
commit
fff5a5b3d4
No known key found for this signature in database GPG Key ID: FA41E6E8CED5E58A
  1. 32
      app/routes.py
  2. 31
      app/templates/index.html
  3. 25
      app/templates/items.html
  4. 34
      app/templates/spells.html

32
app/routes.py

@ -24,6 +24,38 @@ def index():
return render_template('index.html',featureType=featureType,featureText=item)
@app.route('/search', methods=['POST'])
def search():
typ = request.form['type']
query = request.form['inputText']
print(typ + ": " + query)
results = []
for direct in ["../Items/*","../Places/*","../Spells/*"]:
objects = get_items(direct)
for (name,heads,body) in objects:
if typ == "name":
if query.lower() in name.lower():
results.append((name,heads,body))
elif typ == "rarity":
if "rarity" in [h[0].lower() for h in heads]:
if query.lower() in [h[1].lower() for h in heads if h[0].lower() == "rarity"]:
results.append((name,heads,body))
elif typ == "aura":
if "aura" in [h[0].lower() for h in heads]:
if query.lower() in [h[1].lower() for h in heads if h[0].lower() == "aura"]:
results.append((name,heads,body))
elif typ == "text":
if query.lower() in body.lower():
results.append((name,heads,body))
print("Number of results: " + str(len(results)))
featureType = choice(["Item","Place","Spell"])
item = choice(get_items("../"+featureType+"s/*"))
return render_template('index.html',featureType=featureType,featureText=item, searchResults=results)
@app.route('/items')
def items():
return render_template('listing.html',title="Items",items=get_items("../Items/*"))

31
app/templates/index.html

@ -15,6 +15,37 @@
<li><a href="/spells">Spells</a></li>
</ul>
</nav>
<form action="/search" id="searchForm" method="post">
Search Type:
<select name="type">
<option value="name">Name</option>
<option value="rarity">Rarity</option>
<option value="aura">Aura</option>
<option value="text">Text</option>
</select>
<input type="text" name="inputText" placeholder="Enter your search here">
<input type="submit" value="search">
</form>
{% if searchResults is defined %}
<table>
{% for (name,heads,text) in searchResults %}
<tr>
<th class="topalign" id="{{name}}">
{{name}}
<table class="props">
{% for (key, value) in heads %}
<tr><th> {{key}} </th><td> {{value}} </td></tr>
{% endfor %}
</table>
</th>
<td class="freeform monospace"> {{text}} </td>
</tr>
{% endfor %}
</table>
{% endif %}
<section>
<h2>Featured {{featureType}}:</h2>
<table>

25
app/templates/items.html

@ -1,25 +0,0 @@
<html>
<head>
<meta charset='utf-8'>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono|IBM+Plex+Sans|IBM+Plex+Sans+Condensed" rel="stylesheet">
<title>{{ title }} - COSI D&D Archive</title>
</head>
<body class="content">
<h1><a href="/">COSI D&D Archive</a></h1>
<ul class="headlist">
{% for (name,_) in items %}
<li><a href="#{{name}}"> {{name}} </a> {% if not loop.last %} &middot; {% endif %} </li>
{% endfor %}
</ul>
<table>
{% for (name,item) in items %}
<tr>
<th class="topalign" id="{{name}}"> {{name}} </td>
<td class="freeform monospace"> {{item}} </td>
</tr>
{% endfor %}
</table>
<a class="topLink" href="#">Scroll to Top</a>
</body>
</html>

34
app/templates/spells.html

@ -1,34 +0,0 @@
<html>
<head>
<meta charset='utf-8'>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=IBM+Plex+Mono|IBM+Plex+Sans|IBM+Plex+Sans+Condensed" rel="stylesheet">
<title>{{ title }} - COSI D&D Archive</title>
</head>
<body class="content">
<h1><a href="/">COSI D&D Archive</a></h1>
<ul class="headlist">
{% for (name,_,_) in spells %}
<li><a href="#{{name}}"> {{name}} </a> {% if not loop.last %} &middot; {% endif %} </li>
{% endfor %}
</ul>
<table>
{% for (name,(kind,time,rang,comp,dura),text) in spells %}
<tr>
<th class="topalign" id="{{name}}">
{{name}}
<table class="props">
<tr><th> {{kind[0]}} </th><td> {{kind[2]}} </td></tr>
<tr><th> {{time[0]}} </th><td> {{time[2]}} </td></tr>
<tr><th> {{rang[0]}} </th><td> {{rang[2]}} </td></tr>
<tr><th> {{comp[0]}} </th><td> {{comp[2]}} </td></tr>
<tr><th> {{dura[0]}} </th><td> {{dura[2]}} </td></tr>
</table>
</th>
<td class="freeform monospace"> {{text}} </td>
</tr>
{% endfor %}
</table>
<a class="topLink" href="#">Scroll to Top</a>
</body>
</html>
Loading…
Cancel
Save