Skip to content

Commit f1af1ea

Browse files
committed
wip
1 parent d6e56c8 commit f1af1ea

20 files changed

Lines changed: 1052 additions & 0 deletions

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ jobs = 8
44
# Use sccache for distributed caching (only if available)
55
# rustc-wrapper = "sccache" # Commented out to avoid CI failures when sccache is not available
66
# Additional optimization flags
7+
[target.'cfg(not(target_arch = "wasm32"))']
78
rustflags = ["-C", "target-cpu=native"]
89

910
[profile.dev]

ladmin/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8+
Cargo.lock
9+
10+
# These are backup files generated by rustfmt
11+
**/*.rs.bk
12+
13+
# MSVC Windows builds of rustc generate these, which store debugging information
14+
*.pdb

ladmin/Cargo.toml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
[package]
2+
name = "ladmin"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
crate-type = ["cdylib", "rlib"]
8+
9+
[dependencies]
10+
leptos = { version = "0.8.0" }
11+
leptos_router = { version = "0.8.0" }
12+
axum = { version = "0.8.0", optional = true }
13+
console_error_panic_hook = { version = "0.1", optional = true }
14+
leptos_axum = { version = "0.8.0", optional = true }
15+
leptos_meta = { version = "0.8.0" }
16+
tokio = { version = "1", features = ["rt-multi-thread"], optional = true }
17+
wasm-bindgen = { version = "0.2.108", optional = true }
18+
tonic = {version = "0.14.2", default-features = false, features = ["codegen"], optional = true}
19+
tonic-prost = "0.14.2"
20+
prost = "0.14"
21+
tonic-web-wasm-client = { version = "0.8", optional = true, default-features = false }
22+
23+
[build-dependencies]
24+
tonic-prost-build = { version = "0.14.2" }
25+
26+
[features]
27+
hydrate = [
28+
"leptos/hydrate",
29+
"dep:console_error_panic_hook",
30+
"dep:wasm-bindgen",
31+
"dep:tonic",
32+
"dep:tonic-web-wasm-client",
33+
]
34+
ssr = [
35+
"dep:axum",
36+
"dep:tokio",
37+
"dep:leptos_axum",
38+
"leptos/ssr",
39+
"leptos_meta/ssr",
40+
"leptos_router/ssr",
41+
"dep:tonic",
42+
"dep:tonic-web-wasm-client",
43+
]
44+
45+
# Defines a size-optimized profile for the WASM bundle in release mode
46+
[profile.wasm-release]
47+
inherits = "release"
48+
opt-level = 'z'
49+
lto = true
50+
codegen-units = 1
51+
panic = "abort"
52+
53+
[package.metadata.leptos]
54+
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
55+
output-name = "ladmin"
56+
57+
# 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.
58+
site-root = "target/site"
59+
60+
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
61+
# Defaults to pkg
62+
site-pkg-dir = "pkg"
63+
64+
# [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
65+
style-file = "style/main.scss"
66+
# Assets source dir. All files found here will be copied and synchronized to site-root.
67+
# The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir.
68+
#
69+
# Optional. Env: LEPTOS_ASSETS_DIR.
70+
assets-dir = "public"
71+
72+
# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
73+
site-addr = "127.0.0.1:3000"
74+
75+
# The port to use for automatic reload monitoring
76+
reload-port = 3001
77+
78+
# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
79+
# [Windows] for non-WSL use "npx.cmd playwright test"
80+
# This binary name can be checked in Powershell with Get-Command npx
81+
end2end-cmd = "npx playwright test"
82+
end2end-dir = "end2end"
83+
84+
# The browserlist query used for optimizing the CSS.
85+
browserquery = "defaults"
86+
87+
# The environment Leptos will run in, usually either "DEV" or "PROD"
88+
env = "DEV"
89+
90+
# The features to use when compiling the bin target
91+
#
92+
# Optional. Can be over-ridden with the command line parameter --bin-features
93+
bin-features = ["ssr"]
94+
95+
# If the --no-default-features flag should be used when compiling the bin target
96+
#
97+
# Optional. Defaults to false.
98+
bin-default-features = false
99+
100+
# The features to use when compiling the lib target
101+
#
102+
# Optional. Can be over-ridden with the command line parameter --lib-features
103+
lib-features = ["hydrate"]
104+
105+
# If the --no-default-features flag should be used when compiling the lib target
106+
#
107+
# Optional. Defaults to false.
108+
lib-default-features = false
109+
110+
# The profile to use for the lib target when compiling for release
111+
#
112+
# Optional. Defaults to "release".
113+
lib-profile-release = "wasm-release"

ladmin/LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org>

ladmin/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<picture>
2+
<source srcset="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_Solid_White.svg" media="(prefers-color-scheme: dark)">
3+
<img src="https://raw.githubusercontent.com/leptos-rs/leptos/main/docs/logos/Leptos_logo_RGB.svg" alt="Leptos Logo">
4+
</picture>
5+
6+
# Leptos Axum Starter Template
7+
8+
This is a template for use with the [Leptos](https://github.com/leptos-rs/leptos) web framework and the [cargo-leptos](https://github.com/akesson/cargo-leptos) tool using [Axum](https://github.com/tokio-rs/axum).
9+
10+
## Creating your template repo
11+
12+
If you don't have `cargo-leptos` installed you can install it with
13+
14+
```bash
15+
cargo install cargo-leptos --locked
16+
```
17+
18+
Then run
19+
```bash
20+
cargo leptos new --git https://github.com/leptos-rs/start-axum
21+
```
22+
23+
to generate a new project template.
24+
25+
```bash
26+
cd ladmin
27+
```
28+
29+
to go to your newly created project.
30+
Feel free to explore the project structure, but the best place to start with your application code is in `src/app.rs`.
31+
Additionally, Cargo.toml may need updating as new versions of the dependencies are released, especially if things are not working after a `cargo update`.
32+
33+
## Running your project
34+
35+
```bash
36+
cargo leptos watch
37+
```
38+
39+
## Installing Additional Tools
40+
41+
By default, `cargo-leptos` uses `nightly` Rust, `cargo-generate`, and `sass`. If you run into any trouble, you may need to install one or more of these tools.
42+
43+
1. `rustup toolchain install nightly --allow-downgrade` - make sure you have Rust nightly
44+
2. `rustup target add wasm32-unknown-unknown` - add the ability to compile Rust to WebAssembly
45+
3. `cargo install cargo-generate` - install `cargo-generate` binary (should be installed automatically in future)
46+
4. `npm install -g sass` - install `dart-sass` (should be optional in future
47+
5. Run `npm install` in end2end subdirectory before test
48+
49+
## Compiling for Release
50+
```bash
51+
cargo leptos build --release
52+
```
53+
54+
Will generate your server binary in target/release and your site package in target/site
55+
56+
## Testing Your Project
57+
```bash
58+
cargo leptos end-to-end
59+
```
60+
61+
```bash
62+
cargo leptos end-to-end --release
63+
```
64+
65+
Cargo-leptos uses Playwright as the end-to-end test tool.
66+
Tests are located in end2end/tests directory.
67+
68+
## Executing a Server on a Remote Machine Without the Toolchain
69+
After running a `cargo leptos build --release` the minimum files needed are:
70+
71+
1. The server binary located in `target/server/release`
72+
2. The `site` directory and all files within located in `target/site`
73+
74+
Copy these files to your remote server. The directory structure should be:
75+
```text
76+
ladmin
77+
site/
78+
```
79+
Set the following environment variables (updating for your project as needed):
80+
```sh
81+
export LEPTOS_OUTPUT_NAME="ladmin"
82+
export LEPTOS_SITE_ROOT="site"
83+
export LEPTOS_SITE_PKG_DIR="pkg"
84+
export LEPTOS_SITE_ADDR="127.0.0.1:3000"
85+
export LEPTOS_RELOAD_PORT="3001"
86+
```
87+
Finally, run the server binary.
88+
89+
## Licensing
90+
91+
This template itself is released under the Unlicense. You should replace the LICENSE for your own application with an appropriate license if you plan to release it publicly.

ladmin/build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Build script for generating protobuf code from .proto files.
2+
3+
4+
fn main() -> Result<(), Box<dyn std::error::Error>> {
5+
let proto_root = "../proto";
6+
let proto_files = &[
7+
"misc.proto"
8+
];
9+
let proto_out_dir = "src/proto";
10+
11+
if true {
12+
println!("cargo:warning=Compiling protobuf files...");
13+
tonic_prost_build::configure()
14+
.out_dir(proto_out_dir)
15+
.build_server(false)
16+
.build_transport(false)
17+
.compile_protos(proto_files, &[proto_root])?;
18+
} else {
19+
println!("cargo:warning=Using cached protobuf files");
20+
}
21+
22+
Ok(())
23+
}

ladmin/end2end/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
playwright-report
3+
test-results

0 commit comments

Comments
 (0)