diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index faa378c3..ef774421 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -14,10 +14,11 @@ use models::users::User; use utils; #[get("/~/", rank = 2)] -fn details(name: String, conn: DbConn) -> Template { +fn details(name: String, conn: DbConn, user: Option) -> Template { let blog = Blog::find_by_actor_id(&*conn, name).unwrap(); Template::render("blogs/details", json!({ - "blog": blog + "blog": blog, + "account": user })) } @@ -28,8 +29,10 @@ fn activity_details(name: String, conn: DbConn) -> ActivityPub { } #[get("/blogs/new")] -fn new(_user: User) -> Template { - Template::render("blogs/new", HashMap::::new()) +fn new(user: User) -> Template { + Template::render("blogs/new", json!({ + "account": user + })) } #[derive(FromForm)] diff --git a/src/routes/comments.rs b/src/routes/comments.rs index abb42566..8a7a8d15 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -10,10 +10,11 @@ use models::posts::Post; use models::users::User; #[get("/~/<_blog>//comment")] -fn new(_blog: String, slug: String, _user: User, conn: DbConn) -> Template { +fn new(_blog: String, slug: String, user: User, conn: DbConn) -> Template { let post = Post::find_by_slug(&*conn, slug).unwrap(); Template::render("comments/new", json!({ "post": post, + "account": user })) } diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 6e823726..ca4f1d4f 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -5,14 +5,16 @@ use std::collections::HashMap; use BASE_URL; use db_conn::DbConn; +use models::users::User; use models::instance::*; #[get("/")] -fn index(conn: DbConn) -> Template { +fn index(conn: DbConn, user: Option) -> Template { match Instance::get_local(&*conn) { Some(inst) => { Template::render("instance/index", json!({ - "instance": inst + "instance": inst, + "account": user })) } None => { @@ -25,7 +27,7 @@ fn index(conn: DbConn) -> Template { #[get("/configure")] fn configure() -> Template { - Template::render("instance/configure", HashMap::::new()) + Template::render("instance/configure", json!({})) } #[derive(FromForm)] diff --git a/src/routes/posts.rs b/src/routes/posts.rs index e88cc3e3..ddd8224c 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -18,7 +18,7 @@ use models::users::User; use utils; #[get("/~//", rank = 4)] -fn details(blog: String, slug: String, conn: DbConn) -> Template { +fn details(blog: String, slug: String, conn: DbConn, user: Option) -> Template { let blog = Blog::find_by_actor_id(&*conn, blog).unwrap(); let post = Post::find_by_slug(&*conn, slug).unwrap(); let comments = Comment::for_post(&*conn, post.id); @@ -32,7 +32,8 @@ fn details(blog: String, slug: String, conn: DbConn) -> Template { "author": c.get_author(&*conn) }) }).collect::>(), - "n_likes": post.get_likes(&*conn).len() + "n_likes": post.get_likes(&*conn).len(), + "account": user })) } @@ -52,8 +53,10 @@ fn new_auth(_blog: String) -> Redirect { } #[get("/~/<_blog>/new", rank = 1)] -fn new(_blog: String, _user: User) -> Template { - Template::render("posts/new", HashMap::::new()) +fn new(_blog: String, user: User) -> Template { + Template::render("posts/new", json!({ + "account": user + })) } #[derive(FromForm)] diff --git a/src/routes/session.rs b/src/routes/session.rs index a4aefb45..2adf7336 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -9,8 +9,10 @@ use db_conn::DbConn; use models::users::{User, AUTH_COOKIE}; #[get("/login")] -fn new() -> Template { - Template::render("session/login", HashMap::::new()) +fn new(user: Option) -> Template { + Template::render("session/login", json!({ + "account": user + })) } #[derive(FromForm)] diff --git a/src/routes/user.rs b/src/routes/user.rs index 49cdab9e..16061dc1 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -19,10 +19,11 @@ fn me(user: User) -> Redirect { } #[get("/@/", rank = 2)] -fn details(name: String, conn: DbConn) -> Template { +fn details(name: String, conn: DbConn, account: Option) -> Template { let user = User::find_by_fqn(&*conn, name).unwrap(); Template::render("users/details", json!({ - "user": serde_json::to_value(user).unwrap() + "user": serde_json::to_value(user).unwrap(), + "account": account })) } @@ -44,8 +45,10 @@ fn activity_details(name: String, conn: DbConn) -> ActivityPub { } #[get("/users/new")] -fn new() -> Template { - Template::render("users/new", HashMap::::new()) +fn new(user: Option) -> Template { + Template::render("users/new", json!({ + "account": user + })) } #[derive(FromForm)] diff --git a/static/main.css b/static/main.css index c8260b3e..10494bef 100644 --- a/static/main.css +++ b/static/main.css @@ -1,4 +1,91 @@ -html { +html, body { margin: 0px; padding: 0px; + font-family: 'Lato'; + line-height: 1.5em; +} + +h1, h2, h3, h4, h5, h6 { + font-weight: 200; +} + +a, a:visited { + color: #7a28cb; + text-decoration: none; +} + +header { + padding: 20px 10%; + display: flex; + align-content: center; + justify-content: space-between; +} + +header nav a { + margin: 0px 20px; +} + +main > * { + padding: 20px 20%; +} + +main article { + font-family: 'Utopia'; +} + +.inline { + display: flex; + align-items: center; +} + +.button, input[type="submit"] { + background: white; + color: #7a28cb; + border: 1px solid #7a28cb; + border-radius: 3px; + padding: 5px 10px; + margin: 0px 20px; +} + +input[type="submit"] { + margin: 10px 0px; +} + +.article-meta { + background: #F9F9F9; +} + +.comment { + background: white; + border: 1px solid #7a28cb; + border-radius: 3px; + padding: 20px; + margin: 10px 0px; +} + +.comment a { + margin-top: 10px; + display: block; +} + +.inline-block { + display: inline-block; + margin: 0px; +} + +label { + display: block; +} + +input { + border: none; + border-bottom: 1px solid #DADADA; + display: block; + margin: 10px 0px; +} + +textarea { + width: 100%; + min-height: 200px; + resize: vertical; } diff --git a/templates/base.tera b/templates/base.tera index 833f078f..766c76bd 100644 --- a/templates/base.tera +++ b/templates/base.tera @@ -6,7 +6,26 @@ - {% block content %} - {% endblock content %} +
+ + +
+
+ {% block content %} + {% endblock content %} +
diff --git a/templates/posts/details.tera b/templates/posts/details.tera index 959c04cf..412e5a70 100644 --- a/templates/posts/details.tera +++ b/templates/posts/details.tera @@ -4,28 +4,34 @@ {{ post.title }} {% endblock title %} +{% block header %} + {{ blog.title }} +{% endblock header %} + {% block content %}

{{ post.title }}

-

Published in {{ blog.title }}

-
-

+

{{ post.content | safe }} -

-

License: {{ post.license }}

-
+
-

- {{ n_likes }} like{{ n_likes | pluralize }} -

- Add yours +