init
This commit is contained in:
commit
4299ea3d9a
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/.direnv/
|
||||||
|
/target/
|
||||||
|
|
||||||
|
/dist/
|
||||||
|
|
||||||
|
# node e2e test tools and outputs
|
||||||
|
node_modules/
|
||||||
|
test-results/
|
||||||
|
end2end/playwright-report/
|
||||||
|
playwright/.cache/
|
10
.helix/languages.toml
Normal file
10
.helix/languages.toml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[[language]]
|
||||||
|
name = "rust"
|
||||||
|
language-servers = ["rust-analyzer", "tailwindcss-ls"]
|
||||||
|
|
||||||
|
[language-server.rust-analyzer.config]
|
||||||
|
procMacro = { ignored = { leptos_macro = ["server"] } }
|
||||||
|
cargo = { features = ["ssr", "hydrate"] }
|
||||||
|
|
||||||
|
[language-server.tailwindcss-ls]
|
||||||
|
config = { userLanguages = { rust = "html", "*.rs" = "html" } }
|
2864
Cargo.lock
generated
Normal file
2864
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
105
Cargo.toml
Normal file
105
Cargo.toml
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
[package]
|
||||||
|
name = "ascend"
|
||||||
|
version = "0.0.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
axum = { version = "0.7", optional = true }
|
||||||
|
console_error_panic_hook = "0.1"
|
||||||
|
leptos = { version = "=0.7.0" }
|
||||||
|
leptos_axum = { version = "0.7", optional = true }
|
||||||
|
leptos_meta = { version = "0.7" }
|
||||||
|
# leptos_router = { version = "0.7.0" }
|
||||||
|
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
|
||||||
|
tower = { version = "0.4", optional = true }
|
||||||
|
tower-http = { version = "0.5", features = ["fs"], optional = true }
|
||||||
|
wasm-bindgen = "=0.2.99"
|
||||||
|
tracing = { version = "0.1", optional = true }
|
||||||
|
http = "1"
|
||||||
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
|
derive_more = { version = "1", features = ["display", "error", "from"] }
|
||||||
|
clap = { version = "4.5.7", features = ["derive"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
hydrate = ["leptos/hydrate"]
|
||||||
|
ssr = [
|
||||||
|
"dep:axum",
|
||||||
|
"dep:tokio",
|
||||||
|
"dep:tower",
|
||||||
|
"dep:tower-http",
|
||||||
|
"dep:leptos_axum",
|
||||||
|
"leptos/ssr",
|
||||||
|
"leptos_meta/ssr",
|
||||||
|
# "leptos_router/ssr",
|
||||||
|
"dep:tracing",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Defines a size-optimized profile for the WASM bundle in release mode
|
||||||
|
[profile.wasm-release]
|
||||||
|
inherits = "release"
|
||||||
|
opt-level = 'z'
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
panic = "abort"
|
||||||
|
|
||||||
|
[package.metadata.leptos]
|
||||||
|
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
|
||||||
|
output-name = "ascend"
|
||||||
|
|
||||||
|
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
|
||||||
|
site-root = "target/site"
|
||||||
|
|
||||||
|
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
|
||||||
|
# Defaults to pkg
|
||||||
|
site-pkg-dir = "pkg"
|
||||||
|
|
||||||
|
tailwind-input-file = "style/tailwind.css"
|
||||||
|
|
||||||
|
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
|
||||||
|
style-file = "style/main.scss"
|
||||||
|
# Assets source dir. All files found here will be copied and synchronized to site-root.
|
||||||
|
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
|
||||||
|
#
|
||||||
|
# Optional. Env: LEPTOS_ASSETS_DIR.
|
||||||
|
assets-dir = "public"
|
||||||
|
|
||||||
|
# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
|
||||||
|
site-addr = "127.0.0.1:3000"
|
||||||
|
|
||||||
|
# The port to use for automatic reload monitoring
|
||||||
|
reload-port = 3001
|
||||||
|
|
||||||
|
# The browserlist query used for optimizing the CSS.
|
||||||
|
browserquery = "defaults"
|
||||||
|
|
||||||
|
# The environment Leptos will run in, usually either "DEV" or "PROD"
|
||||||
|
env = "DEV"
|
||||||
|
|
||||||
|
# The features to use when compiling the bin target
|
||||||
|
#
|
||||||
|
# Optional. Can be over-ridden with the command line parameter --bin-features
|
||||||
|
bin-features = ["ssr"]
|
||||||
|
|
||||||
|
# If the --no-default-features flag should be used when compiling the bin target
|
||||||
|
#
|
||||||
|
# Optional. Defaults to false.
|
||||||
|
bin-default-features = false
|
||||||
|
|
||||||
|
# The features to use when compiling the lib target
|
||||||
|
#
|
||||||
|
# Optional. Can be over-ridden with the command line parameter --lib-features
|
||||||
|
lib-features = ["hydrate"]
|
||||||
|
|
||||||
|
# If the --no-default-features flag should be used when compiling the lib target
|
||||||
|
#
|
||||||
|
# Optional. Defaults to false.
|
||||||
|
lib-default-features = false
|
||||||
|
|
||||||
|
# The profile to use for the lib target when compiling for release
|
||||||
|
#
|
||||||
|
# Optional. Defaults to "release".
|
||||||
|
lib-profile-release = "wasm-release"
|
72
flake.lock
generated
Normal file
72
flake.lock
generated
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"basecamp": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-overlay": [
|
||||||
|
"rust-overlay"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729251766,
|
||||||
|
"narHash": "sha256-/tOGBbFKgIii6L0VZdJ2MFdhzTt0BtEsAFbWITXeIxA=",
|
||||||
|
"owner": "plul",
|
||||||
|
"repo": "basecamp",
|
||||||
|
"rev": "aae7006aec576140aadf3fdea4ed7eae904dda14",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "plul",
|
||||||
|
"repo": "basecamp",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1736420959,
|
||||||
|
"narHash": "sha256-dMGNa5UwdtowEqQac+Dr0d2tFO/60ckVgdhZU9q2E2o=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "32af3611f6f05655ca166a0b1f47b57c762b5192",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"basecamp": "basecamp",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1736649126,
|
||||||
|
"narHash": "sha256-XCw5sv/ePsroqiF3lJM6Y2X9EhPdHeE47gr3Q8b0UQw=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "162ab0edc2936508470199b2e8e6c444a2535019",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
37
flake.nix
Normal file
37
flake.nix
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
basecamp.url = "github:plul/basecamp";
|
||||||
|
basecamp.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
basecamp.inputs.rust-overlay.follows = "rust-overlay";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{ basecamp, nixpkgs, ... }:
|
||||||
|
{
|
||||||
|
devShells."x86_64-linux".default =
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||||
|
in
|
||||||
|
basecamp.mkShell pkgs {
|
||||||
|
rust.enable = true;
|
||||||
|
rust.toolchain.targets = [ "wasm32-unknown-unknown" ];
|
||||||
|
# rust.toolchain.channel = "nightly";
|
||||||
|
|
||||||
|
packages = [
|
||||||
|
pkgs.cargo-leptos
|
||||||
|
pkgs.leptosfmt
|
||||||
|
pkgs.dart-sass
|
||||||
|
pkgs.tailwindcss
|
||||||
|
pkgs.tailwindcss-language-server
|
||||||
|
|
||||||
|
# For optimizing wasm release builds
|
||||||
|
pkgs.binaryen
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
24
justfile
Normal file
24
justfile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
_default:
|
||||||
|
@just --unsorted --list
|
||||||
|
|
||||||
|
check:
|
||||||
|
bc-check
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
bc-fmt
|
||||||
|
fd --extension=rs --exec-batch leptosfmt
|
||||||
|
|
||||||
|
serve:
|
||||||
|
RUST_LOG=debug RUST_BACKTRACE=1 cargo leptos watch -- serve
|
||||||
|
|
||||||
|
build-release:
|
||||||
|
rm -rf dist
|
||||||
|
mkdir dist
|
||||||
|
cargo leptos build --release -vv
|
||||||
|
cp target/release/ascend dist/
|
||||||
|
cp -r target/site dist/
|
||||||
|
|
||||||
|
run-release:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cd dist
|
||||||
|
LEPTOS_SITE_ROOT="site" LEPTOS_SITE_ADDR="127.0.0.1:1337" ./ascend serve
|
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
6
rustfmt.toml
Normal file
6
rustfmt.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
version = "Two"
|
||||||
|
unstable_features = true
|
||||||
|
imports_granularity = "Item"
|
||||||
|
group_imports = "One"
|
||||||
|
use_field_init_shorthand = true
|
||||||
|
max_width = 150
|
51
src/app.rs
Normal file
51
src/app.rs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
use leptos::logging;
|
||||||
|
use leptos::prelude::*;
|
||||||
|
|
||||||
|
pub fn shell(options: LeptosOptions) -> impl IntoView {
|
||||||
|
use leptos_meta::MetaTags;
|
||||||
|
|
||||||
|
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 />
|
||||||
|
<MetaTags />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<App />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[leptos::component]
|
||||||
|
pub fn App() -> impl leptos::IntoView {
|
||||||
|
use leptos_meta::Stylesheet;
|
||||||
|
use leptos_meta::Title;
|
||||||
|
|
||||||
|
// Provides context that manages stylesheets, titles, meta tags, etc.
|
||||||
|
leptos_meta::provide_meta_context();
|
||||||
|
|
||||||
|
leptos::view! {
|
||||||
|
<Stylesheet id="leptos" href="/pkg/ascend.css" />
|
||||||
|
|
||||||
|
// sets the document title
|
||||||
|
<Title text="Ascend" />
|
||||||
|
|
||||||
|
<Ascend />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[leptos::component]
|
||||||
|
fn Ascend() -> impl leptos::IntoView {
|
||||||
|
logging::log!("Rendering root component");
|
||||||
|
|
||||||
|
leptos::view! {
|
||||||
|
<div>
|
||||||
|
{ "hello world" }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
16
src/lib.rs
Normal file
16
src/lib.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
pub mod app;
|
||||||
|
pub mod pages {}
|
||||||
|
|
||||||
|
#[cfg(feature = "hydrate")]
|
||||||
|
#[wasm_bindgen::prelude::wasm_bindgen]
|
||||||
|
pub fn hydrate() {
|
||||||
|
use crate::app::*;
|
||||||
|
console_error_panic_hook::set_once();
|
||||||
|
leptos::mount::hydrate_body(App);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ssr")]
|
||||||
|
pub mod server {
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct AppState {}
|
||||||
|
}
|
73
src/main.rs
Normal file
73
src/main.rs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#[cfg(feature = "ssr")]
|
||||||
|
mod cli {
|
||||||
|
#[derive(clap::Parser)]
|
||||||
|
#[command(version, about, long_about = None)]
|
||||||
|
pub struct Cli {
|
||||||
|
#[command(subcommand)]
|
||||||
|
pub command: Command,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(clap::Subcommand, Default)]
|
||||||
|
pub enum Command {
|
||||||
|
#[default]
|
||||||
|
Serve,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "ssr")]
|
||||||
|
#[tokio::main]
|
||||||
|
async fn main() {
|
||||||
|
use ascend::app::App;
|
||||||
|
use ascend::app::shell;
|
||||||
|
use ascend::server::AppState;
|
||||||
|
use axum::Router;
|
||||||
|
use clap::Parser as _;
|
||||||
|
use leptos::logging;
|
||||||
|
use leptos::prelude::*;
|
||||||
|
use leptos_axum::LeptosRoutes;
|
||||||
|
use leptos_axum::generate_route_list;
|
||||||
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
|
tracing_subscriber::fmt()
|
||||||
|
.without_time()
|
||||||
|
.with_env_filter(EnvFilter::from_default_env())
|
||||||
|
.pretty()
|
||||||
|
.init();
|
||||||
|
|
||||||
|
let cli = cli::Cli::parse();
|
||||||
|
match cli.command {
|
||||||
|
cli::Command::Serve => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setting get_configuration(None) means we'll be using cargo-leptos's env values
|
||||||
|
// For deployment these variables are:
|
||||||
|
// <https://github.com/leptos-rs/start-axum#executing-a-server-on-a-remote-machine-without-the-toolchain>
|
||||||
|
// Alternately a file can be specified such as Some("Cargo.toml")
|
||||||
|
// The file would need to be included with the executable when moved to deployment
|
||||||
|
let conf = get_configuration(None).unwrap();
|
||||||
|
let leptos_options = conf.leptos_options;
|
||||||
|
let addr = leptos_options.site_addr;
|
||||||
|
let routes = generate_route_list(App);
|
||||||
|
|
||||||
|
let app_state = AppState {};
|
||||||
|
|
||||||
|
// build our application with a route
|
||||||
|
let app = Router::new()
|
||||||
|
.leptos_routes_with_context(&leptos_options, routes, move || provide_context(app_state.clone()), {
|
||||||
|
let leptos_options = leptos_options.clone();
|
||||||
|
move || shell(leptos_options.clone())
|
||||||
|
})
|
||||||
|
.fallback(leptos_axum::file_and_error_handler(shell))
|
||||||
|
.with_state(leptos_options);
|
||||||
|
|
||||||
|
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
||||||
|
logging::log!("listening on http://{addr}");
|
||||||
|
axum::serve(listener, app.into_make_service()).await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "ssr"))]
|
||||||
|
pub fn main() {
|
||||||
|
// no client-side main function
|
||||||
|
// unless we want this to work with e.g., Trunk for a purely client-side app
|
||||||
|
// see lib.rs for hydration function instead
|
||||||
|
}
|
1
style/main.scss
Normal file
1
style/main.scss
Normal file
@ -0,0 +1 @@
|
|||||||
|
body { }
|
3
style/tailwind.css
Normal file
3
style/tailwind.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@tailwind base;
|
||||||
|
@tailwind components;
|
||||||
|
@tailwind utilities;
|
12
tailwind.config.js
Normal file
12
tailwind.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
module.exports = {
|
||||||
|
content: {
|
||||||
|
relative: true,
|
||||||
|
files: ["*.html", "./src/**/*.rs"],
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
extend: {},
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user