2024-04-14 06:45:51 +02:00
|
|
|
use leptos::*;
|
2024-04-15 01:56:33 +02:00
|
|
|
use leptos_router::*;
|
2024-04-14 06:45:51 +02:00
|
|
|
|
|
|
|
use leptos_use::{use_cookie, utils::FromToStringCodec};
|
|
|
|
use upub_web::{
|
2024-04-15 03:38:16 +02:00
|
|
|
Actor, LoginBox, PostBox, Timeline
|
2024-04-14 06:45:51 +02:00
|
|
|
};
|
|
|
|
|
2024-04-15 05:00:23 +02:00
|
|
|
|
2024-04-14 06:45:51 +02:00
|
|
|
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>
|
2024-04-15 05:00:23 +02:00
|
|
|
<small class="ml-1 mr-1" ><a class="clean" href="/web" >micro social network, federated</a></small>
|
2024-04-14 06:45:51 +02:00
|
|
|
/* 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()
|
|
|
|
>
|
2024-04-15 01:56:33 +02:00
|
|
|
<main>
|
|
|
|
<Routes>
|
2024-04-15 17:12:06 +02:00
|
|
|
<Route path="/" view=move || view! { <Redirect path="/web" /> } />
|
2024-04-15 05:00:23 +02:00
|
|
|
<Route path="/web" view=move || view! { <Timeline token=cookie /> } />
|
|
|
|
<Route path="/web/users/:id" view=Actor />
|
2024-04-15 01:56:33 +02:00
|
|
|
// <Route path="/object/:id" view=Object />
|
|
|
|
</Routes>
|
|
|
|
</main>
|
|
|
|
</Router>
|
2024-04-14 06:45:51 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|