Skip to content

Commit

Permalink
Dojo: Support static file page
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson authored Apr 26, 2024
1 parent 1aec771 commit ee9f8fc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dojo_plugin/pages/dojo.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,19 @@ def view_module(dojo, module):


def view_page(dojo, page):
if (dojo.path / f"{page}.md").is_file():
if (dojo.path / page).is_file():
path = (dojo.path / page).resolve()
return send_file(path)

elif (dojo.path / f"{page}.md").is_file():
content = render_markdown((dojo.path / f"{page}.md").read_text())
return render_template("markdown.html", dojo=dojo, content=content)

elif (dojo.path / page).is_dir():
user = get_current_user()
if user and (dojo.path / page / f"{user.id}").is_file():
path = (dojo.path / page / f"{user.id}").resolve()
return send_file(path, as_attachment=True)
return send_file(path)
elif user and (dojo.path / page / f"{user.id}.md").is_file():
content = render_markdown((dojo.path / page / f"{user.id}.md").read_text())
return render_template("markdown.html", dojo=dojo, content=content)
Expand Down

0 comments on commit ee9f8fc

Please sign in to comment.