navbar current decorator
This commit is contained in:
@ -48,7 +48,7 @@ def explore():
|
||||
next_url = url_for('explore', page=posts.next_num) if posts.has_next else None
|
||||
prev_url = url_for('explore', page=posts.prev_num) if posts.has_prev else None
|
||||
|
||||
return render_template('index.html', title='Explore', posts=posts.items, next_url=next_url, prev_url=prev_url)
|
||||
return render_template('explore.html', title='Explore', posts=posts.items, next_url=next_url, prev_url=prev_url)
|
||||
|
||||
@app.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
|
@ -11,12 +11,12 @@
|
||||
<body>
|
||||
<header>
|
||||
<nav>
|
||||
<a href="{{ url_for('index') }}">home</a>
|
||||
<a href="{{ url_for('explore') }}">explore</a>
|
||||
<a {% block indexcurrent %}{% endblock %} href="{{ url_for('index') }}">home</a>
|
||||
<a {% block explorecurrent %}{% endblock %} href="{{ url_for('explore') }}">explore</a>
|
||||
{% if current_user.is_anonymous %}
|
||||
<a href="{{ url_for('login') }}">login</a>
|
||||
<a {% block logincurrent %}{% endblock %} href="{{ url_for('login') }}">login</a>
|
||||
{% else %}
|
||||
<a href="{{ url_for('user', username=current_user.username) }}">profile</a>
|
||||
<a {% block profilecurrent %}{% endblock %} href="{{ url_for('user', username=current_user.username) }}">profile</a>
|
||||
<a href="{{ url_for('logout') }}">logout</a>
|
||||
{% endif %}
|
||||
|
||||
|
29
backend/app/templates/explore.html
Normal file
29
backend/app/templates/explore.html
Normal file
@ -0,0 +1,29 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block explorecurrent %}class="current"{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Hello, {{ current_user.username }}!</h1>
|
||||
{% if form %}
|
||||
<form action="" method="post">
|
||||
{{ form.hidden_tag() }}
|
||||
<p>
|
||||
{{ form.post.label }}
|
||||
{{ form.post(cols=32, rows=4) }}
|
||||
{% for error in form.post.errors %}
|
||||
<span style="color: red;">[{{ error }}]</span>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>{{ form.submit() }}</p>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% for post in posts %}
|
||||
{% include '_post.html' %}
|
||||
{% endfor %}
|
||||
{% if prev_url %}<a href="{{ prev_url }}">Newer Posts</a>{% endif %}
|
||||
{% if next_url %}<a href="{{ next_url }}">Older Posts</a>{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block indexcurrent %}class="current"{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Hello, {{ current_user.username }}!</h1>
|
||||
{% if form %}
|
||||
|
@ -1,5 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block logincurrent %}class="current"{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Sign In</h1>
|
||||
<form action="" method="post" novalidate>
|
||||
|
@ -1,5 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block profilecurrent %}class="current"{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<table>
|
||||
<tr valign="top">
|
||||
|
Reference in New Issue
Block a user