diff --git a/examples/.base/.gitignore b/examples/.base/.gitignore index 9405098b45..6df95ee360 100644 --- a/examples/.base/.gitignore +++ b/examples/.base/.gitignore @@ -1 +1,3 @@ -.perseus/ +dist/ +target_engine/ +target_wasm/ diff --git a/examples/.base/Cargo.toml b/examples/.base/Cargo.toml index b43d3537c3..599cc7218f 100644 --- a/examples/.base/Cargo.toml +++ b/examples/.base/Cargo.toml @@ -1,12 +1,35 @@ [package] name = "perseus-example-base" -version = "0.3.2" +version = "0.4.0-beta.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] perseus = { path = "../../../packages/perseus", features = [ "hydrate" ] } -sycamore = "0.7" +sycamore = "=0.8.0-beta.7" serde = { version = "1", features = ["derive"] } serde_json = "1" + +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +fantoccini = "0.17" + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +tokio = { version = "1", features = [ "macros", "rt", "rt-multi-thread" ] } +# This is an internal convenience crate that exposes all integrations through features for testing +perseus-integration = { path = "../../../packages/perseus-integration", default-features = false } + +[target.'cfg(target_arch = "wasm32")'.dependencies] +wasm-bindgen = "0.2" + +[lib] +name = "lib" +path = "src/lib.rs" +crate-type = [ "cdylib", "rlib" ] + +[[bin]] +name = "perseus-example-base" +path = "src/lib.rs" + +[package.metadata.wasm-pack.profile.release] +wasm-opt = [ "-Oz" ] diff --git a/examples/.base/README.md b/examples/.base/README.md index 6e97fb83a3..2315942944 100644 --- a/examples/.base/README.md +++ b/examples/.base/README.md @@ -2,6 +2,8 @@ This isn't an example per se, rather it's a template for future examples. If you want to create a new example, you should copy this directory and modify it to suit your needs, its purpsoe is just to create a universal minimal boilerplate from which examples can work. -After copying this, you'll need to change this README to describe your example, and you'll need to change the name of your example in `Cargo.toml` to `perseus-example-` (right now, it's `perseus-example-base`, leabving it as this will cause a compilation error). +After copying this, you'll need to change this README to describe your example, and you'll need to change the name of your example in `Cargo.toml` to `perseus-example-` (right now, it's `perseus-example-base`, leaving it as this will cause a compilation error). + +*Note: by default, all examples are compatible with all integrations, and will be tested with them all. If your example is only compatible with a single integration, you shouldn't use `perseus-integration`, but the specific integration crate instead, and make sure to add an empty `.integration_locked` file to the root of the example. See `examples/core/custom_server/` for more details.* If you need some help with creating your example, feel free to pop over to our [Discord channel](https://discord.com/invite/GNqWYWNTdp)! diff --git a/examples/.base/index.html b/examples/.base/index.html deleted file mode 100644 index edc8a66246..0000000000 --- a/examples/.base/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - -
- - diff --git a/examples/.base/src/error_pages.rs b/examples/.base/src/error_pages.rs index d472912966..1bd77f5561 100644 --- a/examples/.base/src/error_pages.rs +++ b/examples/.base/src/error_pages.rs @@ -2,13 +2,13 @@ use perseus::{ErrorPages, Html}; use sycamore::view; pub fn get_error_pages() -> ErrorPages { - let mut error_pages = ErrorPages::new(|url, status, err, _| { - view! { + let mut error_pages = ErrorPages::new(|cx, url, status, err, _| { + view! { cx, p { (format!("An error with HTTP code {} occurred at '{}': '{}'.", status, url, err)) } } }); - error_pages.add_page(404, |_, _, _, _| { - view! { + error_pages.add_page(404, |cx, _, _, _, _| { + view! { cx, p { "Page not found." } } }); diff --git a/examples/.base/src/lib.rs b/examples/.base/src/lib.rs index 7522e8240a..9a777e008a 100644 --- a/examples/.base/src/lib.rs +++ b/examples/.base/src/lib.rs @@ -3,7 +3,7 @@ mod templates; use perseus::{Html, PerseusApp}; -#[perseus::main] +#[perseus::main(perseus_integration::dflt_server)] pub fn main() -> PerseusApp { PerseusApp::new() .template(crate::templates::index::get_template) diff --git a/examples/.base/src/templates/index.rs b/examples/.base/src/templates/index.rs index 220269e531..74bd0c8a9e 100644 --- a/examples/.base/src/templates/index.rs +++ b/examples/.base/src/templates/index.rs @@ -1,16 +1,16 @@ -use perseus::{Html, Template}; -use sycamore::prelude::{view, SsrNode, View}; +use perseus::Template; +use sycamore::prelude::{view, Html, Scope, SsrNode, View}; #[perseus::template_rx] -pub fn index_page() -> View { - view! { +pub fn index_page(cx: Scope) -> View { + view! { cx, p { "Hello World!" } } } #[perseus::head] -pub fn head() -> View { - view! { +pub fn head(cx: Scope) -> View { + view! { cx, title { "Index Page" } } }