mirror of
https://github.com/senju1337/senju.git
synced 2025-12-24 07:39:29 +00:00
fix: use dictionary to store the views and pass them to the jinja templates for easier access
Refs: OPS-11
This commit is contained in:
parent
e134182974
commit
322d0684a1
3 changed files with 14 additions and 9 deletions
|
|
@ -2,15 +2,20 @@ from flask import Flask, render_template
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
urls = {
|
||||||
|
"home": "index_view",
|
||||||
|
"haiku":"haiku_view"
|
||||||
|
}
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index_view():
|
||||||
return render_template("index.jinja", title="Senju", active_page="home")
|
return render_template("index.jinja", title="Senju", urls=urls)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/haiku")
|
@app.route("/haiku")
|
||||||
def haiku_page():
|
def haiku_view():
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"haiku.jinja",
|
"haiku.jinja",
|
||||||
title="Haiku of the Day",
|
title="Haiku of the Day",
|
||||||
active_page="haiku")
|
urls = urls)
|
||||||
|
|
|
||||||
|
|
@ -25,16 +25,16 @@
|
||||||
<div class="hidden md:block">
|
<div class="hidden md:block">
|
||||||
<div class="ml-10 flex items-baseline space-x-4">
|
<div class="ml-10 flex items-baseline space-x-4">
|
||||||
<!-- Current: "bg-gray-900 text-white", Default: "text-gray-300 hover:bg-gray-700 hover:text-white" -->
|
<!-- Current: "bg-gray-900 text-white", Default: "text-gray-300 hover:bg-gray-700 hover:text-white" -->
|
||||||
<a href="{{ url_for('index') }}"
|
<a href="{{ url_for(urls['home']) }}"
|
||||||
class="rounded-md px-3 py-2 text-sm font-medium
|
class="rounded-md px-3 py-2 text-sm font-medium
|
||||||
{% if request.endpoint == 'index' %} bg-gray-900 text-white {% else %} text-gray-300 hover:bg-gray-700 hover:text-white {% endif %}"
|
{% if request.endpoint == urls['home'] %} bg-gray-900 text-white {% else %} text-gray-300 hover:bg-gray-700 hover:text-white {% endif %}"
|
||||||
>
|
>
|
||||||
Start
|
Start
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="{{ url_for('haiku_page') }}"
|
<a href="{{ url_for(urls['haiku']) }}"
|
||||||
class="rounded-md px-3 py-2 text-sm font-medium
|
class="rounded-md px-3 py-2 text-sm font-medium
|
||||||
{% if request.endpoint == 'haiku_page' %} bg-gray-900 text-white {% else %} text-gray-300 hover:bg-gray-700 hover:text-white {% endif %}"
|
{% if request.endpoint == urls['haiku'] %} bg-gray-900 text-white {% else %} text-gray-300 hover:bg-gray-700 hover:text-white {% endif %}"
|
||||||
>
|
>
|
||||||
Haiku
|
Haiku
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
Splash! Silence again.
|
Splash! Silence again.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<a href="{{ url_for('index') }}" class=" inline-block bg-violet-600 hover:bg-violet-700 text-white font-bold py-2 px-4 rounded-lg">
|
<a href="{{ url_for(urls['home']) }}" class=" inline-block bg-violet-600 hover:bg-violet-700 text-white font-bold py-2 px-4 rounded-lg">
|
||||||
Back to Home
|
Back to Home
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue