Browse Source

Create marches templates

marches
Josh Gordon 3 years ago
parent
commit
98102d1603
  1. 6
      app/items.py
  2. 29
      app/routes.py
  3. 4
      app/templates/marchWorld.html
  4. 9
      app/templates/marches.html

6
app/items.py

@ -35,3 +35,9 @@ def get_items(items_dir):
items_list.sort(key = lambda data: data[0])
return items_list
def get_worlds():
world_list = []
for fname in glob.glob("../Worlds/*"):
world_list.append(fname.split("/")[-1])
return world_list

29
app/routes.py

@ -2,7 +2,7 @@ import sys
from flask import Flask, render_template, request, redirect
from items import get_items
from items import get_items, get_worlds
from random import choice, sample
@ -24,24 +24,6 @@ def index():
return render_template('index.html',featureType=featureType,featureText=item)
"""
@app.route('/add')
def addPage():
return render_template('add.html')
@app.route('/addContent', methods=['POST'])
def addContent():
bucket = request.form['bucket']
text = request.form['entry']
title = text.partition('\n')[0].lower().replace(".","").replace("/","").replace(" ","_").strip()
if bucket in ["Items","Places","Characters","Spells"]:
f = open("../" + bucket + "/" + title + ".txt",'x')
f.write(text)
f.close()
return render_template('add.html')
else:
return "<h1>bruh</h1><p><b>Pls no.</b></p>"
"""
@app.route('/search', methods=['POST'])
def search():
@ -75,6 +57,15 @@ def search():
return render_template('index.html',featureType=featureType,featureText=item, searchResults=results)
@app.route("/marches")
def marches():
return render_template('marches.html', worlds=get_worlds())
@app.route("/marches/worlds/<world>")
def marchWorld(world):
worldDir = "../Worlds/"+world
return render_template("marchWorld.html",worldname=world)
def bucket_route(uri, dir, sing=None):
if sing is None:
sing = dir[:-1] # minus "s"

4
app/templates/marchWorld.html

@ -0,0 +1,4 @@
{% extends "base.html" %}
{% block content %}
<p>{{worldname}}</p>
{% endblock %}

9
app/templates/marches.html

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block content %}
<p> This is the index for D&amp;D Archive <strong>West Marches Mode</strong></p>
<ul>
{% for w in worlds %}
<li><a href="marches/worlds/{{w}}">{{w}}</a></li>
{% endfor %}
</ul>
{% endblock %}
Loading…
Cancel
Save