| @book.route('/books/<int:book_id>') | @book.route('/books/<int:book_id>') | ||||
| def show_book(book_id): | def show_book(book_id): | ||||
| book = get_full_resource(book_id) | book = get_full_resource(book_id) | ||||
| # render Markdown as HTML | |||||
| book.description = markdown.markdown(book.description) | |||||
| return render_template('book.html', resource=book) | return render_template('book.html', resource=book) | ||||
| # route for editing a single book based on the ID in the database | # route for editing a single book based on the ID in the database | 
| import requests | import requests | ||||
| import re | import re | ||||
| from sqlalchemy.sql import func | from sqlalchemy.sql import func | ||||
| import markdown | |||||
| # function to retrieve data about a single resource from the database | # function to retrieve data about a single resource from the database | ||||
| def get_resource(resource_id): | def get_resource(resource_id): | ||||
| resource = get_resource(resource_id) | resource = get_resource(resource_id) | ||||
| resource = append_relationships(resource) | resource = append_relationships(resource) | ||||
| if resource.type == 'book': | if resource.type == 'book': | ||||
| # render Markdown as HTML | |||||
| resource.description = markdown.markdown(resource.description) | |||||
| book_data = get_book_data(resource.isbn) | book_data = get_book_data(resource.isbn) | ||||
| if book_data: | if book_data: | ||||
| resource.__dict__.update(book_data) | resource.__dict__.update(book_data) | 
| width:1px; | width:1px; | ||||
| height:1px; | height:1px; | ||||
| overflow:hidden; | overflow:hidden; | ||||
| } | |||||
| #about { | |||||
| display: inline-block; | |||||
| width: 60%; | |||||
| } | |||||
| #colophon { | |||||
| float: right; | |||||
| width: 30%; | |||||
| } | |||||
| hr { | |||||
| clear: both; | |||||
| margin-bottom: 25%; | |||||
| visibility: hidden; | |||||
| } | } | 
| {% block content %} | {% block content %} | ||||
| <div class="cell-margin text max-w-[65ch]"> | |||||
| <div id="about" class="cell-margin text max-w-[65ch]"> | |||||
| {{ about_text|safe }} | {{ about_text|safe }} | ||||
| </div> | </div> | ||||
| <div id="colophon" class="cell-margin text"> | |||||
| {{ colophon_text | safe }} | |||||
| </div> | |||||
| {% endblock %} | {% endblock %} |