made views in url_for relative to current blueprint

This commit is contained in:
iou1name 2018-06-21 09:06:23 -04:00
parent 1529c77084
commit 124adf5580
6 changed files with 11 additions and 11 deletions

View File

@ -9,12 +9,12 @@
if (document.getElementById('header').style.display == 'initial') {
document.getElementById('header').style.display = 'none';
document.getElementById('headerHidden').style.display = 'initial';
xhr.open('GET', '{{ url_for("views.set_session", hide_header="on") }}', true);
xhr.open('GET', '{{ url_for(".set_session", hide_header="on") }}', true);
}
else {
document.getElementById('header').style.display = 'initial';
document.getElementById('headerHidden').style.display = 'none';
xhr.open('GET', '{{ url_for("views.set_session", hide_header="off") }}', true);
xhr.open('GET', '{{ url_for(".set_session", hide_header="off") }}', true);
}
xhr.send();
}
@ -24,7 +24,7 @@
<body>
<ul id="header" class="header" style="{% if session.get("hide_header") == True %}display:none;{% else %}display:initial;{% endif %}">
<li><a onclick="toggleHeader();" href="javascript:void(0);">^</a></li>
<li><a href="{{ url_for('views.index') }}">Home</a></li>
<li><a href="{{ url_for('.index') }}">Home</a></li>
{% block header %}{% endblock %}
</ul>
<ul id="headerHidden" class="header" style="{% if session.get("hide_header") == True %}display:initial;{% else %}display:none;{% endif %}">

View File

@ -2,7 +2,7 @@
{% block title %}Start a new quest{% endblock %}
{% block content %}
<h1>New Quest</h1>
<form method="post" action="{{ url_for('views.create_quest') }}">
<form method="post" action="{{ url_for('.create_quest') }}">
<input type="text" placeholder="Quest Title" name="quest_title" maxlength="300" required/><br/>
<textarea id="create_textarea" name="quest_body"></textarea>
<input type="submit" name="submit" value="Submit"/>

View File

@ -2,7 +2,7 @@
{% block title %}Login{% endblock %}
{% block content %}
<h1>Login</h1>
<form method="post" action="{{ url_for('views.login') }}">
<form method="post" action="{{ url_for('.login') }}">
<input type="text" placeholder="Username" name="user" maxlength="20" required/><br />
<input type="password" placeholder="Password" name="pass" maxlength="1024" required/><br />
<input type="submit" value="Log in" name="submit"/>

View File

@ -60,7 +60,7 @@
{% endblock %}
{% block header %}
{% if session.get("user_id") == owner_id %}
<li><a href="{{ url_for('views.edit_quest') }}">Edit Quest</a></li>
<li><a href="{{ url_for('.edit_quest') }}">Edit Quest</a></li>
{% endif %}
{% endblock %}
{% block content %}

View File

@ -13,7 +13,7 @@
<li>Must be between 8 and 1024 characters</li>
</ul>
</div>
<form method="post" action="{{ url_for('views.signup') }}">
<form method="post" action="{{ url_for('.signup') }}">
<input type="text" placeholder="Username" name="user" maxlength="20" required/><br />
<input type="password" placeholder="Password" name="pass" maxlength="1024" required/><br />
<input type="password" placeholder="Verify password" name="pass_verify" maxlength="1024" required/><br />

View File

@ -72,7 +72,7 @@ def quest(quest_title):
@views.route("/create_quest", methods=["GET", "POST"])
@login_required("views.login")
@login_required(".login")
def create_quest():
"""
Starts a new quest.
@ -92,7 +92,7 @@ def create_quest():
quest_id = db.insert_quest(canon_title, ident_title, owner_id)
db.insert_quest_post(quest_id, quest_body, timestamp)
return redirect(url_for('views.quest', quest_title=ident_title))
return redirect(url_for('.quest', quest_title=ident_title))
@views.route("/edit_quest")
@ -129,7 +129,7 @@ def login():
if db.verify_password(username, password):
session["username"] = username
return redirect(url_for("views.index"))
return redirect(url_for(".index"))
else:
abort(401)
@ -165,7 +165,7 @@ def signup():
"passwords_dont_match"
res = db.add_user(username, password)
return redirect(url_for("views.index"))
return redirect(url_for(".index"))
@views.route("/")