Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # @name: main.py
  2. # @creation_date: 2021-10-20
  3. # @license: The MIT License <https://opensource.org/licenses/MIT>
  4. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  5. # @purpose: Main route for index and other pages
  6. # @acknowledgements:
  7. # https://www.digitalocean.com/community/tutorials/how-to-add-authentication-to-your-app-with-flask-login
  8. from flask import Blueprint, render_template
  9. from flask_login import login_required, current_user
  10. from .models import Resource
  11. from .resources import *
  12. from .relationships import *
  13. from sqlalchemy.sql import func
  14. import markdown
  15. main = Blueprint('main', __name__)
  16. # route for index page
  17. @main.route('/')
  18. def index():
  19. view = request.args.get('view')
  20. # curated list of resources to display on homepage
  21. tool_ids = ['4','10', '34', '27']
  22. practice_ids = ['53', '59', '65', '56']
  23. book_ids = ['94', '72', '105', '67']
  24. # concatenate lists of resources
  25. resource_ids = tool_ids + practice_ids + book_ids
  26. # get data for curated resources
  27. curated = get_curated_resources(resource_ids)
  28. # render Markdown as HTML
  29. for resource in curated:
  30. resource.description = markdown.markdown(resource.description)
  31. with open('content/home.md', 'r') as f:
  32. text = f.read()
  33. text = markdown.markdown(text)
  34. return render_template('index.html', text=text, resources=curated, view=view)
  35. # route for profile page
  36. @main.route('/profile')
  37. @login_required
  38. def profile():
  39. return render_template('profile.html', name=current_user.name)
  40. # route for test page
  41. @main.route('/test')
  42. def test():
  43. return render_template('test.html')
  44. # route for about page
  45. @main.route('/about')
  46. def about():
  47. # get last updated date
  48. last_updated = get_last_date()
  49. with open('content/about.md', 'r') as f:
  50. main_text = f.read()
  51. main_text = markdown.markdown(main_text)
  52. with open('content/colophon.md', 'r') as f:
  53. sidebar_text = f.read()
  54. sidebar_text = markdown.markdown(sidebar_text)
  55. return render_template('about.html', main_text=main_text, sidebar_text=sidebar_text, last_updated=last_updated)
  56. # route for events page
  57. @main.route('/practice_seminars')
  58. @main.route('/expub_seminars')
  59. def events():
  60. with open('content/seminar.md', 'r') as f:
  61. main_text = f.read()
  62. main_text = markdown.markdown(main_text)
  63. with open('content/seminar_details.md', 'r') as f:
  64. sidebar_text = f.read()
  65. sidebar_text = markdown.markdown(sidebar_text)
  66. return render_template('about.html', main_text=main_text, sidebar_text=sidebar_text)