Skip to content

Commit

Permalink
fix: use search page as start page
Browse files Browse the repository at this point in the history
  • Loading branch information
pdmnyberg committed May 27, 2024
1 parent 4e4d464 commit e47b15e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
37 changes: 24 additions & 13 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,20 @@
Compress(app)


def get_page(page_id: str):
page_path = f'pages/{page_id}.md'
with open(page_path, "r") as f:
page_data = frontmatter.load(f)
html = markdown.markdown(
page_data.content,
extensions=[TocExtension(baselevel=1)]
)
return (html, page_data)


@app.route('/')
def root():
return redirect("page/home")
return redirect("search")


def parse_gene_ids(gene_id=None, gene_list=None):
Expand Down Expand Up @@ -71,9 +82,13 @@ def form():
except SearchError as e:
error = str(e)
status_code = 404

(html, page_data) = get_page("search")

return render_template(
'form.html',
title=page_data.get('title', 'Search'),
content=html,
gene_ids=gene_ids,
output=None if output is None else json.dumps(output),
error=error,
Expand All @@ -95,19 +110,15 @@ def form():

@app.route('/page/<page_id>', methods=['GET'])
def page(page_id):
page_path = f'pages/{page_id}.md'
try:
with open(page_path, "r") as f:
page_data = frontmatter.load(f)
html = markdown.markdown(
page_data.content,
extensions=[TocExtension(baselevel=1)]
)
return render_template(
'page.html',
content=html,
title=page_data.metadata.get('title', "Default title")
)
(html, page_data) = get_page(page_id)
print(page_data)
return render_template(
'page.html',
content=html,
title=page_data.metadata.get('title', page_id)
)

except FileNotFoundError:
return render_template('404.html', url=f'page/{page_id}'), 404

Expand Down
4 changes: 2 additions & 2 deletions pages/home.md → pages/search.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: Home
title: Search
---

## Knockout design database
## Search

This site provides a database of knockout designs targeting the entire Plasmodium berghei protein encoding genome using the PbHiT CRISPR system as described in Jonsdottir et al. DOI: <https://doi.org/10.1101/2024.04.20.590404> Synthetic fragments are ranked by guide RNA scoring.

Expand Down
1 change: 0 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</div>
</div>
<nav class="navbar navbar-expand-lg navbar-light px-3" style="background-color: #f0f0f0">
<a class="navbar-brand" href="/">Home</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
Expand Down
6 changes: 4 additions & 2 deletions templates/form.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{% extends "base.html" %}
{% block title %}Search form{% endblock %}
{% block title %}Vector oligo search: {{ title }}{% endblock %}
{% block content %}
<div class="container-fluid page-content px-lg-5 my-3">
<h2>Search</h2>
{% autoescape false %}
{{ content }}
{% endautoescape %}
<form
action="/search"
method="POST">
Expand Down

0 comments on commit e47b15e

Please sign in to comment.