Add actual templates for everything
This commit is contained in:
+5
-2
@@ -14,8 +14,11 @@ use models::users::User;
|
||||
use utils;
|
||||
|
||||
#[get("/~/<name>", rank = 2)]
|
||||
fn details(name: String) -> String {
|
||||
format!("Welcome on ~{}", name)
|
||||
fn details(name: String, conn: DbConn) -> Template {
|
||||
let blog = Blog::find_by_actor_id(&*conn, name).unwrap();
|
||||
Template::render("blogs/details", json!({
|
||||
"blog": blog
|
||||
}))
|
||||
}
|
||||
|
||||
#[get("/~/<name>", format = "application/activity+json", rank = 1)]
|
||||
|
||||
@@ -8,13 +8,17 @@ use db_conn::DbConn;
|
||||
use models::instance::*;
|
||||
|
||||
#[get("/")]
|
||||
fn index(conn: DbConn) -> String {
|
||||
fn index(conn: DbConn) -> Template {
|
||||
match Instance::get_local(&*conn) {
|
||||
Some(inst) => {
|
||||
format!("Welcome on {}", inst.name)
|
||||
Template::render("instance/index", json!({
|
||||
"instance": inst
|
||||
}))
|
||||
}
|
||||
None => {
|
||||
String::from("Not initialized")
|
||||
Template::render("errors/500", json!({
|
||||
"error_message": "You need to configure your instance before using it."
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -16,10 +16,13 @@ use models::users::User;
|
||||
use utils;
|
||||
|
||||
#[get("/~/<blog>/<slug>", rank = 4)]
|
||||
fn details(blog: String, slug: String, conn: DbConn) -> String {
|
||||
fn details(blog: String, slug: String, conn: DbConn) -> Template {
|
||||
let blog = Blog::find_by_actor_id(&*conn, blog).unwrap();
|
||||
let post = Post::find_by_slug(&*conn, slug).unwrap();
|
||||
format!("{} in {}", post.title, blog.title)
|
||||
Template::render("posts/details", json!({
|
||||
"post": post,
|
||||
"blog": blog
|
||||
}))
|
||||
}
|
||||
|
||||
#[get("/~/<_blog>/<slug>", rank = 3, format = "application/activity+json")]
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ use models::instance::Instance;
|
||||
use models::users::*;
|
||||
|
||||
#[get("/me")]
|
||||
fn me(user: User) -> String {
|
||||
format!("Logged in as {}", user.username.to_string())
|
||||
fn me(user: User) -> Redirect {
|
||||
Redirect::to(format!("/@/{}", user.username).as_ref())
|
||||
}
|
||||
|
||||
#[get("/@/<name>", rank = 2)]
|
||||
|
||||
Reference in New Issue
Block a user