Try to use only "absolute" links to avoid trailing-slash bugs

This commit is contained in:
Bat 2018-07-26 19:00:23 +02:00
parent 999e91290a
commit b42030e831
6 changed files with 13 additions and 14 deletions

View File

@ -259,8 +259,7 @@ impl Blog {
pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value { pub fn to_json(&self, conn: &PgConnection) -> serde_json::Value {
let mut json = serde_json::to_value(self).unwrap(); let mut json = serde_json::to_value(self).unwrap();
let formatted = serde_json::Value::String(format!("/~/{}",self.get_fqn(conn))); json["fqn"] = json!(self.get_fqn(conn));
json["fqn"] = formatted;
json json
} }
} }

View File

@ -41,7 +41,7 @@ fn details_response(blog: String, slug: String, conn: DbConn, user: Option<User>
Template::render("posts/details", json!({ Template::render("posts/details", json!({
"author": post.get_authors(&*conn)[0].to_json(&*conn), "author": post.get_authors(&*conn)[0].to_json(&*conn),
"post": post, "article": post.to_json(&*conn),
"blog": blog, "blog": blog,
"comments": &comments.into_iter().filter_map(|c| if c.in_response_to_id.is_none() { "comments": &comments.into_iter().filter_map(|c| if c.in_response_to_id.is_none() {
Some(c.to_json(&*conn, &comms)) Some(c.to_json(&*conn, &comms))

View File

@ -28,7 +28,7 @@
<p>{{ "No posts to see here yet." | _ }}</p> <p>{{ "No posts to see here yet." | _ }}</p>
{% endif %} {% endif %}
{% if is_author %} {% if is_author %}
<a href="new" class="button inline-block">{{ "New article" | _ }}</a> <a href="/~/{{ blog.fqn }}/new/" class="button inline-block">{{ "New article" | _ }}</a>
{% endif %} {% endif %}
<div class="cards"> <div class="cards">
{% for article in posts %} {% for article in posts %}

View File

@ -13,7 +13,7 @@
link_4="</a>") link_4="</a>")
}} }}
⋅ {{ article.date | date(format="%B %e") }} ⋅ {{ article.date | date(format="%B %e") }}
⋅ <a href="{{ article.blog.fqn }}">{{ article.blog.title }}</a> ⋅ <a href="/~/{{ article.blog.fqn }}/">{{ article.blog.title }}</a>
</p> </p>
</div> </div>
{% endmacro post_card %} {% endmacro post_card %}

View File

@ -2,15 +2,15 @@
{% import "macros" as macros %} {% import "macros" as macros %}
{% block title %} {% block title %}
{{ post.title }} {{ article.post.title }}
{% endblock title %} {% endblock title %}
{% block header %} {% block header %}
<a href="../">{{ blog.title }}</a> <a href="/~/{{ blog.fqn }}">{{ blog.title }}</a>
{% endblock header %} {% endblock header %}
{% block content %} {% block content %}
<h1 class="article">{{ post.title }}</h1> <h1 class="article">{{ article.post.title }}</h1>
<p class="article-info"> <p class="article-info">
<span class="author">{{ "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" | _( <span class="author">{{ "Written by {{ link_1 }}{{ url }}{{ link_2 }}{{ name | escape }}{{ link_3 }}" | _(
link_1='<a href="/@/', link_1='<a href="/@/',
@ -24,15 +24,15 @@
<span class="date">{{ date | date(format="%B %e, %Y") }}</span> <span class="date">{{ date | date(format="%B %e, %Y") }}</span>
</p> </p>
<article> <article>
{{ post.content | safe }} {{ article.post.content | safe }}
</article> </article>
<div class="article-meta"> <div class="article-meta">
<p>{{ "This article is under the {{ license }} license." | _(license=post.license) }}</p> <p>{{ "This article is under the {{ license }} license." | _(license=article.post.license) }}</p>
{% if account %} {% if account %}
<div class="actions"> <div class="actions">
<form class="likes" action="like" method="POST"> <form class="likes" action="{{ article.url }}like" method="POST">
<p aria-label="{{ "{{ count }} likes" | _n(singular="One like", count=n_likes) }}" title="{{ "{{ count }} likes" | _n(singular="One like", count=n_likes) }}">{{ n_likes }}</p> <p aria-label="{{ "{{ count }} likes" | _n(singular="One like", count=n_likes) }}" title="{{ "{{ count }} likes" | _n(singular="One like", count=n_likes) }}">{{ n_likes }}</p>
{% if has_liked %} {% if has_liked %}
@ -41,7 +41,7 @@
<button type="submit"><i class="fa fa-heart"></i>{{ "Add yours" | _ }}</button> <button type="submit"><i class="fa fa-heart"></i>{{ "Add yours" | _ }}</button>
{% endif %} {% endif %}
</form> </form>
<form class="reshares" action="reshare" method="POST"> <form class="reshares" action="{{ article.url }}reshare" method="POST">
<p aria-label="{{ "{{ count }} reshares" | _n(singular="One reshare", count=n_reshares) }}" title="{{ "{{ count }} reshares" | _n(singular="One reshare", count=n_reshares) }}">{{ n_reshares }}</p> <p aria-label="{{ "{{ count }} reshares" | _n(singular="One reshare", count=n_reshares) }}" title="{{ "{{ count }} reshares" | _n(singular="One reshare", count=n_reshares) }}">{{ n_reshares }}</p>
{% if has_reshared %} {% if has_reshared %}
@ -59,7 +59,7 @@
<h2>{{ "Comments" | _ }}</h2> <h2>{{ "Comments" | _ }}</h2>
{% if account %} {% if account %}
<form method="post" action="/~/{{ blog.actor_id }}/{{ post.slug }}/comment"> <form method="post" action="{{ article.url }}comment">
<label for="content">{{ "Your comment" | _ }}</label> <label for="content">{{ "Your comment" | _ }}</label>
{% if previous %} {% if previous %}
<input type="hidden" name="responding_to" value="{{ previous.id }}"/> <input type="hidden" name="responding_to" value="{{ previous.id }}"/>

View File

@ -32,5 +32,5 @@
</div> </div>
<div> <div>
<a href="followers/">{{ "{{ count }} followers" | _n(singular="One follower", count=n_followers) }}</a> <a href="/@/{{ user.fqn }}/followers/">{{ "{{ count }} followers" | _n(singular="One follower", count=n_followers) }}</a>
</div> </div>