From 4e24495b159df0dbc4f503843c08ccd452af616a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cel=20=F0=9F=8C=B8?= Date: Tue, 30 May 2023 21:48:26 +0100 Subject: [PATCH] WIP: blog --- Cargo.lock | 35 ++++++++++++++++++++------ Cargo.toml | 1 + db/blossom.sqlite | Bin 0 -> 4096 bytes db/blossom.sqlite-shm | Bin 0 -> 32768 bytes db/blossom.sqlite-wal | Bin 0 -> 86552 bytes migrations/20230218162011_blossom.sql | 14 ++++++++--- src/main.rs | 5 ++-- src/posts/mod.rs | 33 ++++++++++++++++++++++++ src/posts/note.rs | 1 + static/style.css | 5 ++-- 10 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 db/blossom.sqlite create mode 100644 db/blossom.sqlite-shm create mode 100644 db/blossom.sqlite-wal diff --git a/Cargo.lock b/Cargo.lock index 8c72e2f..07a19f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,8 +284,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ "iana-time-zone", + "js-sys", "num-integer", "num-traits", + "time 0.1.45", + "wasm-bindgen", "winapi 0.3.9", ] @@ -345,7 +348,7 @@ dependencies = [ "rand", "sha2", "subtle", - "time", + "time 0.3.19", "version_check", ] @@ -859,7 +862,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -1348,7 +1351,7 @@ dependencies = [ "static_assertions", "tap-reader", "thiserror", - "time", + "time 0.3.19", "tokio", "tokio-util", "url", @@ -1366,7 +1369,7 @@ dependencies = [ "serde", "static_assertions", "thiserror", - "time", + "time 0.3.19", ] [[package]] @@ -1442,7 +1445,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.45.0", ] @@ -2140,7 +2143,7 @@ dependencies = [ "serde_json", "state", "tempfile", - "time", + "time 0.3.19", "tokio", "tokio-stream", "tokio-util", @@ -2222,7 +2225,7 @@ dependencies = [ "smallvec", "stable-pattern", "state", - "time", + "time 0.3.19", "tokio", "uncased", ] @@ -2432,6 +2435,7 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" name = "site" version = "0.1.0" dependencies = [ + "chrono", "listenbrainz", "mastodon-async", "reqwest", @@ -2748,6 +2752,17 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", +] + [[package]] name = "time" version = "0.3.19" @@ -3174,6 +3189,12 @@ dependencies = [ "try-lock", ] +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 417dd4a..37d5e82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,4 @@ tokio = { version = "1", features = ["full"] } serde = { version = "1.0", features = ["derive"] } rocket_dyn_templates = { version = "0.1.0-rc.2", features = ["tera"] } listenbrainz = "0.7" +chrono = "0.4.23" diff --git a/db/blossom.sqlite b/db/blossom.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..3d1e885c117696bd5e798b7c2570aa90f2e7f3e6 GIT binary patch literal 4096 zcmWFz^vNtqRY=P(%1ta$FlG>7U}9o$P*7lCU|@t|N&q8+UbGP}$OHjOj2Q)^U=)mk YQ7{Td!6+C7qhJ(_f>AIEMgb)N0AlV2o&W#< literal 0 HcmV?d00001 diff --git a/db/blossom.sqlite-shm b/db/blossom.sqlite-shm new file mode 100644 index 0000000000000000000000000000000000000000..a276541e1e332ec13f826832be7745e04aab8906 GIT binary patch literal 32768 zcmeI*J4!=g6ot{9_H+6kD;kus3o-0;vQ$;jC3% zE|;JCPvG0*_lwL8lF@OJgCygdlc$HvtLu;N+xwTZ=dZiZ$>Zty+w1s`-_Oskb0-TH z-VUnfU^Kz1vB&$i*lB_4$NV1t^E6H|}og}+S_L7W}?9cvvehvTt0000000000 z000000095pVA`30j)pnvcx{-LhN?*f9aUQkda9}%^i(}X=&4Gg&{H*Zp{J@xLr>LB rhn{LN0D7ve4Ctv=VxXtmM}nSe84P-=O+4tSmMo#C!=Bd$0N@ut1u-d8 literal 0 HcmV?d00001 diff --git a/db/blossom.sqlite-wal b/db/blossom.sqlite-wal new file mode 100644 index 0000000000000000000000000000000000000000..9b36685744f3f819e76a1c9e26c6a8fe0782208d GIT binary patch literal 86552 zcmeI*Z)_W99l-Ik-Pp17=hC2XD_zHR1sZEfiIa7#EgDNUuZxx@ZR+%2R;;UiNsjtY za(8YMsZ*DRY_> z?tc=JB>Ae#AA2tG(%~=9oZq`=$gp*FB5!6jTkVtDB)?y}TU8}V@=KBwa86bvj$c!= zy%N8)WxTgV{IZkl_a^#x?Jn=6-W$KKe{3kB z-ZM5j8Xrz1%exd0w+gA0ZdvNU$jDHHu{JfOr;b{MtU53>GEh^e&+4gyXjRfS zvbx)Rw{el^m;6CxZ?{h}a%p|mn#mZpp419<-q}vpc1AK*TOvN!Hj>^%-1XXD|Jb2LM7-n$0000009frj&k>yd z%!MxwKlbboR(Ot}y{c103gL#IBUl@J-g%Co<#Ox3=2x3fHhs{%FY?=_mm^K#6OFHj zcWTU8ahS{7x|Pi8X+x`exz@AJu&Sc8#88wZjkIdy zY<*HU#kQI&WHMc3~#S4~emN>}0 zfafTuu+v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Y7?h{q~-xn;!i7g-eIeUOD;cyPh(Bc<8`0jSua3y|ww9 zw>~^<{%QXcf8O@$nT2&NN` W`jPDx000000B}RXfrfA~$?!kLxVH%a literal 0 HcmV?d00001 diff --git a/migrations/20230218162011_blossom.sql b/migrations/20230218162011_blossom.sql index 188bbf8..c8ed09d 100644 --- a/migrations/20230218162011_blossom.sql +++ b/migrations/20230218162011_blossom.sql @@ -33,10 +33,18 @@ create table articles ( foreign key (post_id) references posts(id) ); +create table text_formats ( + name varchar(16) not null primary key +); + +insert into text_formats (name) values ('plaintext'), ('markdown'), ('html'); + create table notes ( post_id integer not null, - content text, - foreign key (post_id) references posts(id) + text_format varchar(16) not null default ('plaintext'); + text_content text, + foreign key (post_id) references posts(id), + foreign key (text_format) references text_formats(name) ); create table media_types ( @@ -58,4 +66,4 @@ create table notes_media ( foreign key (note_id) references notes(note_id), foreign key (media_id) references media(id), primary key (note_id, media_id) -); \ No newline at end of file +); diff --git a/src/main.rs b/src/main.rs index 8ad4bf4..833a7ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,11 +3,12 @@ use rocket::fs::{relative, FileServer}; use rocket::http::Status; use rocket::State; use rocket::{Build, Request, Rocket}; -use rocket_db_pools::sqlx::{self, database}; -use rocket_db_pools::{Connection, Database}; +use rocket_db_pools::sqlx; +use rocket_db_pools::Database; use rocket_dyn_templates::{context, Template}; use std::borrow::Cow; +mod posts; mod scrobbles; mod skweets; diff --git a/src/posts/mod.rs b/src/posts/mod.rs index e69de29..b0c3749 100644 --- a/src/posts/mod.rs +++ b/src/posts/mod.rs @@ -0,0 +1,33 @@ +use chrono::{DateTime, Utc}; +use std::path::Path; + +enum PostType { + Article, + Note, +} + +enum TextFormat { + Markdown, + Plaintext, + Html, +} + +pub struct Post { + id: i64, + created_at: DateTime, + updated_at: Option>, + post_type: PostType, + media: Option>>, + content: Option, + tags: Vec, +} + +pub trait Content { + fn render(&self) -> String; +} + +// impl Post { +// // renders as internal html (must sanitize) +// fn new(type: PostType, ) -> Post { +// } +// } diff --git a/src/posts/note.rs b/src/posts/note.rs index e69de29..95655d4 100644 --- a/src/posts/note.rs +++ b/src/posts/note.rs @@ -0,0 +1 @@ +struct note diff --git a/static/style.css b/static/style.css index 934041a..035c404 100644 --- a/static/style.css +++ b/static/style.css @@ -51,7 +51,8 @@ a.active { color: #311f20; } -img, video { +img, +video { max-width: 100%; border: 4px solid #311f20; } @@ -388,4 +389,4 @@ iframe { -webkit-transform: scaleX(-1); transform: scaleX(-1); z-index: 4; -} +} \ No newline at end of file