1
0
Fork 0
forked from alemi/upub
upub/web/src/main.rs

58 lines
1.6 KiB
Rust
Raw Normal View History

use leptos::*;
use leptos_router::*;
use leptos_use::{use_cookie, utils::FromToStringCodec};
use upub_web::{
Actor, LoginBox, PostBox, Timeline
};
fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
let (cookie, set_cookie) = use_cookie::<String, FromToStringCodec>("token");
mount_to_body(
move || view! {
<nav class="w-100">
<p>
2024-04-15 18:22:16 +02:00
<code><a class="upub-title" href="/web" >μpub</a></code>
<small class="ml-1 mr-1" ><a class="clean" href="/web" >micro social network, federated</a></small>
/* TODO kinda jank with the float but whatever, will do for now */
<small style="float: right" ><a href="https://git.alemi.dev/upub.git" >src</a></small>
</p>
</nav>
<hr />
<div class="container">
<div class="two-col">
<div class="col-side">
<LoginBox
tx=set_cookie
rx=cookie
/>
<PostBox token=cookie />
</div>
<div class="col-main">
2024-04-15 17:53:54 +02:00
<Router // TODO maybe set base="/web" ?
fallback=move || view! {
<div class="center">
<h3>nothing to see here!</h3>
<p><a href="/web"><button type="button">back to root</button></a></p>
</div>
}.into_view()
>
<main>
<Routes>
2024-04-15 17:12:06 +02:00
<Route path="/" view=move || view! { <Redirect path="/web" /> } />
<Route path="/web" view=move || view! { <Timeline token=cookie /> } />
<Route path="/web/users/:id" view=Actor />
// <Route path="/object/:id" view=Object />
</Routes>
</main>
</Router>
</div>
</div>
</div>
}
);
}