Browse Source

add book_showcase to home page

joel
Simon Bowie 1 year ago
parent
commit
6ebb89b783
2 changed files with 10 additions and 1 deletions
  1. +3
    -1
      web/app/main.py
  2. +7
    -0
      web/app/resources.py

+ 3
- 1
web/app/main.py View File

from flask import Blueprint, render_template from flask import Blueprint, render_template
from flask_login import login_required, current_user from flask_login import login_required, current_user
from .models import Resource from .models import Resource
from .resources import *
from sqlalchemy.sql import func from sqlalchemy.sql import func
import markdown import markdown


with open('content/home.md', 'r') as f: with open('content/home.md', 'r') as f:
text = f.read() text = f.read()
text = markdown.markdown(text) text = markdown.markdown(text)
return render_template('index.html', text=text, tools=tools)
book_showcase = get_book('69')
return render_template('index.html', text=text, tools=tools, book=book_showcase)


# route for profile page # route for profile page
@main.route('/profile') @main.route('/profile')

+ 7
- 0
web/app/resources.py View File

except: except:
pass pass


# function to get full metadata for a book and combine into one object
def get_book(resource_id):
book = get_resource(resource_id)
book_data = get_book_data(book.isbn)
book.__dict__.update(book_data)
return book

# function to replace embedded URL strings with href links # function to replace embedded URL strings with href links
def replace_urls(input): def replace_urls(input):
# Compile a regular expression to match URLs. # Compile a regular expression to match URLs.

Loading…
Cancel
Save