diff --git a/templates/book.html b/templates/book.html
index 28fe906..6bf9212 100644
--- a/templates/book.html
+++ b/templates/book.html
@@ -1,8 +1,8 @@
{{book["title"]}}
-{% if book["image"] is not equalto "" %}
- cover:
+{% if book["cover"] is not equalto "" %}
+
{% endif %}
{% for datum in (book|dictsort) %}
- {{datum[0]}}: {{ datum[1] }}
+ {{names[datum[0]]}}: {{ datum[1] }}
{% endfor %}
diff --git a/templates/main.html b/templates/main.html
index 603d037..1cd73a6 100644
--- a/templates/main.html
+++ b/templates/main.html
@@ -9,7 +9,7 @@
{% for book in books %}
- |
+ |
{% for datum in attributes %}
{{ book[datum] }} |
{% endfor %}
diff --git a/test.py b/test.py
index 4d9161f..39defb8 100644
--- a/test.py
+++ b/test.py
@@ -7,9 +7,11 @@ app = Flask(__name__)
data = []
attributes= ["title",
- "authors",
+ "author",
"isbn"]
+names = {}
+
def updateData():
out = []
@@ -18,9 +20,14 @@ def updateData():
collection = tree.getroot()[0]
ns = "{http://periapsis.org/tellico/}"
+ for field in collection.find(ns + "fields"):
+ print(field.attrib)
+ if "title" in field.attrib:
+ names[field.attrib["name"]] = field.attrib["title"]
+
for book in collection.iter(ns + "entry"):
bookout = {}
- bookout["image"] = book.find(ns + "cover").text if book.find(ns + "cover") != None else ""
+ bookout["cover"] = book.find(ns + "cover").text if book.find(ns + "cover") != None else ""
bookout["id"] = int(book.find(ns + "id").text)
bookout["title"] = book.find(ns + "title").text if (book.find(ns + "title") != None) else ""
bookout["isbn"] = book.find(ns + "isbn").text if (book.find(ns + "isbn") != None) else ""
@@ -28,7 +35,7 @@ def updateData():
if book.find(ns + "authors") != None:
for a in book.find(ns + "authors"):
authors.append(a.text)
- bookout["authors"] = "; ".join(authors)
+ bookout["author"] = "; ".join(authors)
out.append(bookout.copy())
return out.copy()
@@ -42,7 +49,7 @@ def main():
def book(id):
data = updateData();
book = next((item for item in data if item["id"] == id), {})
- return render_template("book.html", book = book)
+ return render_template("book.html", book = book, names = names)
if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0')