Compare commits
2 commits
92f42d5bd9
...
6bfbf6ad0a
Author | SHA1 | Date | |
---|---|---|---|
|
6bfbf6ad0a | ||
|
dbfc7409c3 |
3 changed files with 109 additions and 40 deletions
24
Cargo.lock
generated
24
Cargo.lock
generated
|
@ -293,9 +293,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
|||
|
||||
[[package]]
|
||||
name = "bytecheck"
|
||||
version = "0.6.11"
|
||||
version = "0.6.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627"
|
||||
checksum = "23cdc57ce23ac53c931e88a43d06d070a6fd142f2617be5855eb75efc9beb1c2"
|
||||
dependencies = [
|
||||
"bytecheck_derive",
|
||||
"ptr_meta",
|
||||
|
@ -305,9 +305,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "bytecheck_derive"
|
||||
version = "0.6.11"
|
||||
version = "0.6.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61"
|
||||
checksum = "3db406d29fbcd95542e92559bed4d8ad92636d1ca8b3b72ede10b4bcc010e659"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1711,9 +1711,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.1"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
|
||||
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
@ -2177,9 +2177,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
|||
|
||||
[[package]]
|
||||
name = "rend"
|
||||
version = "0.4.1"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2571463863a6bd50c32f94402933f03457a3fbaf697a707c5be741e459f08fd"
|
||||
checksum = "71fe3824f5629716b1589be05dacd749f6aa084c87e00e016714a8cdfccc997c"
|
||||
dependencies = [
|
||||
"bytecheck",
|
||||
]
|
||||
|
@ -2200,9 +2200,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rkyv"
|
||||
version = "0.7.43"
|
||||
version = "0.7.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "527a97cdfef66f65998b5f3b637c26f5a5ec09cc52a3f9932313ac645f4190f5"
|
||||
checksum = "5cba464629b3394fc4dbc6f940ff8f5b4ff5c7aef40f29166fd4ad12acbc99c0"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"bytecheck",
|
||||
|
@ -2218,9 +2218,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rkyv_derive"
|
||||
version = "0.7.43"
|
||||
version = "0.7.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033"
|
||||
checksum = "a7dddfff8de25e6f62b9d64e6e432bf1c6736c57d20323e15ee10435fbda7c65"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
124
server/src/db.rs
124
server/src/db.rs
|
@ -3,7 +3,100 @@ use leptos::*;
|
|||
use serde::*;
|
||||
use sqlx::*;
|
||||
|
||||
pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> {
|
||||
// pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> {
|
||||
// let _res = query(
|
||||
// "
|
||||
// CREATE TABLE
|
||||
// blog (
|
||||
// content_type TEXT,
|
||||
// title TEXT,
|
||||
// date TEXT,
|
||||
// content TEXT
|
||||
// )
|
||||
// ",
|
||||
// )
|
||||
// .execute(pool)
|
||||
// .await?;
|
||||
//
|
||||
// // println!("{:?}", _res);
|
||||
//
|
||||
// #[derive(Deserialize)]
|
||||
// struct ArticleFrontmatter {
|
||||
// content_type: String,
|
||||
// title: String,
|
||||
// date: String,
|
||||
// }
|
||||
//
|
||||
// for file in std::fs::read_dir("./public/blog".to_string())? {
|
||||
// let fileinfo = file?;
|
||||
// let filepath = fileinfo.path();
|
||||
//
|
||||
// if let Some(filetype) = filepath.extension() {
|
||||
// if filetype == "md" {
|
||||
// let file = std::fs::read_to_string(filepath)?;
|
||||
// let html_from_md =
|
||||
// femark::process_markdown_to_html_with_frontmatter(&file.to_string(), true)
|
||||
// .expect("Problem processing markdown");
|
||||
// let content = html_from_md.content;
|
||||
// let _toc = html_from_md.toc;
|
||||
//
|
||||
// if let Some(front_raw) = html_from_md.frontmatter {
|
||||
// if let Some(front_code) = front_raw.code_block {
|
||||
// let toml: ArticleFrontmatter = toml::from_str(&front_code.source)?;
|
||||
//
|
||||
// let article = Article {
|
||||
// content_type: toml.content_type,
|
||||
// title: toml.title,
|
||||
// date: toml.date,
|
||||
// content,
|
||||
// };
|
||||
//
|
||||
// let _res = sqlx::query(
|
||||
// "
|
||||
// INSERT INTO
|
||||
// blog (content_type, title, date, content)
|
||||
// VALUES
|
||||
// ($1, $2, $3, $4)
|
||||
// ",
|
||||
// )
|
||||
// .bind(article.content_type)
|
||||
// .bind(article.title)
|
||||
// .bind(article.date)
|
||||
// .bind(article.content)
|
||||
// .execute(pool)
|
||||
// .await?;
|
||||
//
|
||||
// // println!("{:?}", _res);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Ok(())
|
||||
// }
|
||||
|
||||
pub async fn start_pool() -> Result<SqlitePool, ServerFnError> {
|
||||
println!(
|
||||
"
|
||||
⠄⠄⠄⠄⢀⡤⣖⣞⣮⢾⢽⣳⢯⢿⢷⣦⣄⠄⠄⠐⠄
|
||||
⠐⠄⠄⣴⣯⣯⢷⣻⣺⢽⣫⢾⣝⡵⡯⣾⣽⢷⣄⠄⠄
|
||||
⠄⢀⣼⢿⡽⣾⢯⣷⣻⣽⢽⣳⣳⢽⡺⡮⣫⢯⢿⣦⠄
|
||||
⠄⣼⣿⢽⡯⣿⡽⣾⡿⣞⣯⢷⢯⢯⢯⢯⡺⡪⡳⣻⠄
|
||||
⣴⣿⣿⣽⣟⣷⣟⣯⣿⡽⣞⣯⢿⡽⡽⡵⣝⢮⣫⣺⠄
|
||||
⠄⠄⠉⠉⠛⠛⠛⠛⠛⠻⠿⠿⠿⣿⣿⡿⣿⣽⣾⣾⡀
|
||||
⠐⡀⠢⠄⡀⠄⢀⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠣
|
||||
⡀⠂⠈⣪⣌⡤⢾⠿⠕⢤⣤⣨⣠⢤⠡⠄⠄⡌⠄⡐⡐
|
||||
⠐⠈⠄⠱⣻⡻⠶⢦⠶⠯⠟⢟⢯⢳⢩⡂⡆⡇⡐⡐⢌
|
||||
⢁⠐⠄⠈⣾⣓⢝⣛⡛⡗⣞⣗⢕⡕⢕⠕⡸⡀⠂⠌⡂
|
||||
⡀⠂⡁⠄⡿⣕⢷⣻⢽⢝⢞⢮⢳⠑⠅⢑⢜⠜⣬⢐⢈
|
||||
⠄⢁⣀⣴⠋⠪⠳⠹⠵⠹⠘⠈⠂⠁⡐⡸⡘⣠⡳⡣⣪
|
||||
⣽⢟⣿⡣⠄⢸⡄⠠⠠⡠⢠⢐⠨⡐⣴⣹⡨⣞⣎⢎⢺
|
||||
⠏⠟⠛⠃⠄⠘⠛⠊⠊⠘⠐⠅⠇⠻⠛⠓⠛⠛⠪⠓⠹
|
||||
db goin up"
|
||||
);
|
||||
let pool = SqlitePool::connect("sqlite::memory:").await?;
|
||||
|
||||
let _res = query(
|
||||
"
|
||||
CREATE TABLE
|
||||
|
@ -15,7 +108,7 @@ pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> {
|
|||
)
|
||||
",
|
||||
)
|
||||
.execute(pool)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
// println!("{:?}", _res);
|
||||
|
@ -63,7 +156,7 @@ pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> {
|
|||
.bind(article.title)
|
||||
.bind(article.date)
|
||||
.bind(article.content)
|
||||
.execute(pool)
|
||||
.execute(&pool)
|
||||
.await?;
|
||||
|
||||
// println!("{:?}", _res);
|
||||
|
@ -73,28 +166,5 @@ pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn start_pool() -> Result<SqlitePool, ServerFnError> {
|
||||
println!(
|
||||
"
|
||||
⠄⠄⠄⠄⢀⡤⣖⣞⣮⢾⢽⣳⢯⢿⢷⣦⣄⠄⠄⠐⠄
|
||||
⠐⠄⠄⣴⣯⣯⢷⣻⣺⢽⣫⢾⣝⡵⡯⣾⣽⢷⣄⠄⠄
|
||||
⠄⢀⣼⢿⡽⣾⢯⣷⣻⣽⢽⣳⣳⢽⡺⡮⣫⢯⢿⣦⠄
|
||||
⠄⣼⣿⢽⡯⣿⡽⣾⡿⣞⣯⢷⢯⢯⢯⢯⡺⡪⡳⣻⠄
|
||||
⣴⣿⣿⣽⣟⣷⣟⣯⣿⡽⣞⣯⢿⡽⡽⡵⣝⢮⣫⣺⠄
|
||||
⠄⠄⠉⠉⠛⠛⠛⠛⠛⠻⠿⠿⠿⣿⣿⡿⣿⣽⣾⣾⡀
|
||||
⠐⡀⠢⠄⡀⠄⢀⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⠣
|
||||
⡀⠂⠈⣪⣌⡤⢾⠿⠕⢤⣤⣨⣠⢤⠡⠄⠄⡌⠄⡐⡐
|
||||
⠐⠈⠄⠱⣻⡻⠶⢦⠶⠯⠟⢟⢯⢳⢩⡂⡆⡇⡐⡐⢌
|
||||
⢁⠐⠄⠈⣾⣓⢝⣛⡛⡗⣞⣗⢕⡕⢕⠕⡸⡀⠂⠌⡂
|
||||
⡀⠂⡁⠄⡿⣕⢷⣻⢽⢝⢞⢮⢳⠑⠅⢑⢜⠜⣬⢐⢈
|
||||
⠄⢁⣀⣴⠋⠪⠳⠹⠵⠹⠘⠈⠂⠁⡐⡸⡘⣠⡳⡣⣪
|
||||
⣽⢟⣿⡣⠄⢸⡄⠠⠠⡠⢠⢐⠨⡐⣴⣹⡨⣞⣎⢎⢺
|
||||
⠏⠟⠛⠃⠄⠘⠛⠊⠊⠘⠐⠅⠇⠻⠛⠓⠛⠛⠪⠓⠹
|
||||
db goin up"
|
||||
);
|
||||
|
||||
Ok(SqlitePool::connect("sqlite::memory:").await?)
|
||||
Ok(pool)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ async fn main() {
|
|||
let routes = generate_route_list(App);
|
||||
|
||||
let pool = start_pool().await.expect("pool error");
|
||||
let _ = db_build(&pool).await.expect("build error");
|
||||
|
||||
let app = Router::new()
|
||||
.leptos_routes_with_context(
|
||||
|
|
Loading…
Add table
Reference in a new issue