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 0000000..3d1e885 Binary files /dev/null and b/db/blossom.sqlite differ diff --git a/db/blossom.sqlite-shm b/db/blossom.sqlite-shm new file mode 100644 index 0000000..a276541 Binary files /dev/null and b/db/blossom.sqlite-shm differ diff --git a/db/blossom.sqlite-wal b/db/blossom.sqlite-wal new file mode 100644 index 0000000..9b36685 Binary files /dev/null and b/db/blossom.sqlite-wal differ 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