summary refs log tree commit diff
path: root/src/components/app.rs
diff options
context:
space:
mode:
authorAshelyn Rose <git@ashen.earth>2025-04-26 21:06:00 -0600
committerAshelyn Rose <git@ashen.earth>2025-04-26 21:06:00 -0600
commit2dacece4eedc8af2ccde3be6918371293350cc4e (patch)
tree81364da50cad615cd387f38d1abcc62102939033 /src/components/app.rs
parent619373a261ad18c51cd09bc61d116f585c8295ec (diff)
Convert to rocket and morgana no-leptos
Diffstat (limited to 'src/components/app.rs')
-rw-r--r--src/components/app.rs133
1 files changed, 0 insertions, 133 deletions
diff --git a/src/components/app.rs b/src/components/app.rs
deleted file mode 100644
index 2814562..0000000
--- a/src/components/app.rs
+++ /dev/null
@@ -1,133 +0,0 @@
-use std::collections::HashMap;
-
-use leptos::prelude::*;
-use leptos::Params;
-use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
-use leptos_router::hooks::use_params;
-use leptos_router::params::Params;
-use leptos_router::{
-    components::{ParentRoute, Route, Router, Routes},
-    path,
-};
-
-use super::editor::WikiEditor;
-use super::renderer::WikiPage;
-use crate::components::layout::Layout;
-use crate::data::{Namespace, Page, PageData, PageUuid};
-
-pub fn shell(options: LeptosOptions) -> impl IntoView {
-    view! {
-        <!DOCTYPE html>
-        <html lang="en">
-            <head>
-                <meta charset="utf-8"/>
-                <meta name="viewport" content="width=device-width, initial-scale=1"/>
-                <AutoReload options=options.clone() />
-                <HydrationScripts options islands=true/>
-                <MetaTags/>
-            </head>
-            <body>
-                <App/>
-            </body>
-        </html>
-    }
-}
-
-#[component]
-pub fn App() -> impl IntoView {
-    // Provides context that manages stylesheets, titles, meta tags, etc.
-    provide_meta_context();
-
-    view! {
-        // injects a stylesheet into the document <head>
-        // id=leptos means cargo-leptos will hot-reload this stylesheet
-        <Stylesheet id="leptos" href="/_/stormscribe.css"/>
-
-        // sets the document title
-        <Title text="Welcome to Leptos"/>
-
-        // content for this welcome page
-        <Router>
-            <Routes fallback=|| "Page not found.".into_view()>
-                <ParentRoute path=path!("/") view=Layout>
-                    <Route path=path!("/~/*path") view=PageRender/>
-                    <Route path=path!("/edit/*path") view=PageEdit/>
-                </ParentRoute>
-            </Routes>
-        </Router>
-    }
-}
-
-#[derive(Params, PartialEq)]
-struct PageParams {
-    path: Option<String>,
-}
-
-#[server]
-async fn get_namespace() -> Result<Namespace, ServerFnError> {
-    use crate::data::StormscribeData;
-
-    Ok(StormscribeData::get_namespace().await)
-}
-
-#[server]
-async fn get_pages() -> Result<HashMap<PageUuid, Page>, ServerFnError> {
-    use crate::data::StormscribeData;
-
-    Ok(StormscribeData::get_all_pages().await)
-}
-
-#[server]
-async fn lookup_page(path: String) -> Result<PageData, ServerFnError> {
-    use crate::data::StormscribeData;
-
-    Ok(StormscribeData::get_page_data(path).await)
-}
-
-// Renders a page
-#[component]
-fn PageRender() -> impl IntoView {
-    let params = use_params::<PageParams>();
-
-    let page_path = params
-        .read()
-        .as_ref()
-        .ok()
-        .map(|params| params.path.clone().unwrap_or("Unknown path".to_string()))
-        .unwrap_or("Could not read params".to_string());
-
-    let page_resource = Resource::new(
-        move || page_path.clone(),
-        |page_path| async move { lookup_page(page_path).await },
-    );
-
-    view! {
-        <Suspense
-            fallback=move || view! { <p>"Loading..."</p> }
-        >
-            {move || page_resource.get()
-                .map(|page| view! {
-                    <pre>{format!("{page:#?}")}</pre>
-                })
-            }
-        </Suspense>
-    }
-    .into_any()
-}
-
-// Renders a page
-#[component]
-fn PageEdit() -> impl IntoView {
-    let params = use_params::<PageParams>();
-
-    let page_path = params
-        .read()
-        .as_ref()
-        .ok()
-        .map(|params| params.path.clone().unwrap_or("Unknown path".to_string()))
-        .unwrap_or("Could not read params".to_string());
-
-    view! {
-        <WikiEditor url_path=page_path />
-    }
-}