diff --git a/flabk/src/servek/html.rs b/flabk/src/servek/html.rs
index bd51e21..9fd1a0a 100644
--- a/flabk/src/servek/html.rs
+++ b/flabk/src/servek/html.rs
@@ -38,9 +38,25 @@ impl Server {
)
.route("/@/:username", routing::get(Self::profile))
.route("/static/*file", routing::get(Self::static_handler))
+ .route("/!", routing::get(Self::timeline))
.fallback(routing::get(Self::handler_404))
}
+ fn get_auth(&self, cookies: Cookies) -> Result {
+ match cookies.get(AUTH_COOKIE_NAME) {
+ Some(cookie) => self
+ .auth
+ .get_claims(cookie.value().to_owned())
+ .map_err(|e| {
+ if e.expired() {
+ cookies.remove(Cookie::new(AUTH_COOKIE_NAME, ""));
+ }
+ e.into()
+ }),
+ None => Err(ServerError::NotLoggedIn),
+ }
+ }
+
fn from_cookies(&self, cookies: Cookies) -> Result>, ServerError> {
const LOGGED_OUT: Result>, ServerError> = Ok(WithNav {
obj: None,
@@ -201,6 +217,18 @@ impl Server {
))
}
+ async fn timeline(
+ cookies: Cookies,
+ Extension(srv): Extension,
+ ) -> Result {
+ let claims = srv.get_auth(cookies)?;
+
+ Ok((
+ StatusCode::OK,
+ response::Html(srv.hb.render("timeline", &())?),
+ ))
+ }
+
async fn create_user(
Extension(srv): Extension,
Form(body): Form,
diff --git a/flabk/src/servek/servek.rs b/flabk/src/servek/servek.rs
index 0afe514..fa01ac7 100644
--- a/flabk/src/servek/servek.rs
+++ b/flabk/src/servek/servek.rs
@@ -43,6 +43,11 @@ impl Server {
.expect("index");
hb.register_template_string("err404", include_str!("../../templates/html/404.html"))
.expect("err404");
+ hb.register_template_string(
+ "timeline",
+ include_str!("../../templates/html/loggedin/timeline.html"),
+ )
+ .expect("timeline");
hb.register_partial(
"LoggedOut",
include_str!("../../templates/html/nav-loggedout.html"),
@@ -79,6 +84,7 @@ impl Server {
pub(super) enum ServerError {
Internal(String),
NotFound,
+ NotLoggedIn,
BadRequest(String),
}
@@ -126,6 +132,7 @@ impl IntoResponse for ServerError {
)
.into_response(),
ServerError::BadRequest(err) => (StatusCode::BAD_REQUEST, err).into_response(),
+ ServerError::NotLoggedIn => (StatusCode::UNAUTHORIZED, "unauthorized").into_response(),
}
}
}
diff --git a/flabk/src/svc/auth.rs b/flabk/src/svc/auth.rs
index 3cc4f51..05dcb33 100644
--- a/flabk/src/svc/auth.rs
+++ b/flabk/src/svc/auth.rs
@@ -103,8 +103,8 @@ pub enum AuthError {
}
impl AuthError {
- pub fn expired(self) -> bool {
- self == Self::Expired
+ pub fn expired(&self) -> bool {
+ *self == Self::Expired
}
}
diff --git a/flabk/static/style/main.css b/flabk/static/style/main.css
index ad961f7..a7ca153 100644
--- a/flabk/static/style/main.css
+++ b/flabk/static/style/main.css
@@ -72,7 +72,7 @@ a {
font-weight: bold;
}
-.avatar {
+.profile-avatar {
width: 128px;
height: 128px;
border: 3px solid rebeccapurple;
@@ -152,10 +152,21 @@ nav ul li {
}
nav>ul>li>a {
- /* color: #aaa; */
- /* background-color:#FF0; */
display: block;
line-height: 2em;
padding: 0.5em 0.5em;
text-decoration: none;
}
+
+.avatar {
+ width: 42px;
+ height: 42px;
+}
+
+button {
+ background-color: rgba(102, 51, 153, 0.75);
+ color: rgb(204, 179, 230);
+ border-color: rgba(102, 51, 153, 0.25);
+ border-style: initial;
+ font-size: large;
+}
diff --git a/flabk/static/style/timeline.css b/flabk/static/style/timeline.css
new file mode 100644
index 0000000..fd52ffc
--- /dev/null
+++ b/flabk/static/style/timeline.css
@@ -0,0 +1,69 @@
+#postbox {
+ /* border: 3px solid rebeccapurple; */
+ /* padding: 5px; */
+ margin: 0 0 30px 0;
+ height: fit-content;
+ display: flex;
+ /* text-align: left; */
+}
+
+#timeline {
+ margin: 0;
+ padding: 0;
+}
+
+#timeline li {
+ display: grid;
+ list-style-type: none;
+ width: 85vw;
+}
+
+#post-content {
+ color: rgb(204, 179, 230);
+ background-color: rebeccapurple;
+ border-width: 0px;
+ height: 60px;
+ width: 85vw;
+}
+
+.note {
+ display: flex;
+}
+
+.content {
+ display: inline-flex;
+ flex-direction: column;
+}
+
+div>p {
+ font-size: small;
+ margin-left: 2px;
+ margin-right: 2px;
+}
+
+.display-name {
+ font-weight: bold;
+}
+
+.username {
+ color: rgba(102, 51, 153, 0.5);
+}
+
+.user-info {
+ display: inline-flex;
+ margin-top: 0px;
+}
+
+#timeline-box {
+ color: rgb(204, 179, 230);
+ display: flex;
+ flex-direction: column;
+}
+
+.note:nth-child(even) {
+ background: rgba(102, 51, 153, 0.25);
+}
+
+.note:nth-child(odd) {
+ background: rgba(102, 51, 153, 0.125);
+}
diff --git a/flabk/templates/html/loggedin/timeline.html b/flabk/templates/html/loggedin/timeline.html
new file mode 100644
index 0000000..5316276
--- /dev/null
+++ b/flabk/templates/html/loggedin/timeline.html
@@ -0,0 +1,53 @@
+
+
+
+
+ timeline - flabk
+
+
+
+
+
+
+ {{> LoggedIn }}
+
+
+
+
+
+
+
+
+
+
+
Big Duck
+
@emilis@flab.k
+
+
this is gay :puffrage:
+
+
+
+
+
+
+
Big Duck
+
@emilis@flab.k
+
+
im posting agen
+
+
+
+
+
+
+
Big Duck
+
@emilis@flab.k
+
+
just landed in piss
+
+
+
+
+
+
+
diff --git a/flabk/templates/html/profile.html b/flabk/templates/html/profile.html
index 4d73154..f04c727 100644
--- a/flabk/templates/html/profile.html
+++ b/flabk/templates/html/profile.html
@@ -12,7 +12,7 @@