readd btns

🐛 fixed some blog stuff
This commit is contained in:
lia
2025-08-21 02:19:36 +00:00
parent bfd8c187c6
commit f1c471839f
14 changed files with 297 additions and 745 deletions

View File

@@ -1,144 +1,74 @@
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Author {
pub seed: u8,
pub id: u8,
pub image_url: String,
pub name: String,
pub keywords: Vec<String>,
pub image_url: String,
pub about: String
pub about: String,
}
impl BlogEntry for Author {
fn from_entry(entry: &mut Entry) -> Self {
return match entry.seed {
match entry.id {
0 => Self {
seed: entry.seed,
name: "iouring".to_string(),
id: entry.id,
image_url: "profile.avif".to_string(),
about: "sup".to_string(),
keywords: vec![
"meow".to_string(),
"mrrp".to_string(),
"mew".to_string()
]
},
_ => Self {
seed: u8::MAX,
name: "not found".to_string(),
image_url: "".to_string(),
about: "".to_string(),
keywords: vec![]
}
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PostMeta {
pub seed: u8,
pub title: String,
pub author: Author,
pub keywords: Vec<String>,
pub image_url: String,
}
impl BlogEntry for PostMeta {
fn from_entry(entry: &mut Entry) -> Self {
return match entry.seed {
0 => Self {
seed: entry.seed,
title: "awawa title".to_string(),
author: Author::from_entry(entry),
name: "iouring".to_string(),
keywords: vec!["meow".to_string(), "mrrp".to_string(), "mew".to_string()],
image_url: "testimage.jpg".to_string()
about: "sup".to_string(),
},
_ => Self {
seed: entry.seed,
title: "not found".to_string(),
author: Author::from_entry(entry),
id: u8::MAX,
image_url: "".to_string(),
name: "not found".to_string(),
keywords: vec![],
image_url: "".to_string()
}
about: "".to_string(),
},
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Post {
pub meta: PostMeta,
pub content: Vec<PostPart>,
pub id: u8,
pub author: Author,
pub title: String,
pub content: Vec<String>,
}
impl BlogEntry for Post {
fn from_entry(entry: &mut Entry) -> Self {
return Self {
meta: PostMeta::from_entry(entry),
content: vec![PostPart::from_entry(entry)]
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum PostPart {
Section(Section),
Quote(Quote),
}
impl BlogEntry for PostPart {
fn from_entry(entry: &mut Entry) -> Self {
// TODO: ... | add proper logic
return Self::Section(Section::from_entry(entry))
// return Self::Quote(Quote::from_entry(entry))
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Section {
pub title: String,
pub paragraphs: Vec<String>,
pub image_url: String,
}
impl BlogEntry for Section {
fn from_entry(entry: &mut Entry) -> Self {
return match entry.seed {
return match entry.id {
0 => Self {
title: "awawa title".to_string(),
image_url: "".to_string(),
paragraphs: vec![
"meow 1".to_string(),
"mrrp 2".to_string(),
"mew 3".to_string()
]
id: 0,
author: Author::from_id(0),
title: "meow".parse().unwrap(),
content: vec!["<h1>meow</h1>", "mrrp", "meow"]
.iter()
.map(|s| s.to_string())
.collect(),
},
_ => Self {
title: "not found".to_string(),
image_url: "".to_string(),
paragraphs: vec![]
id: u8::MAX,
author: Author::from_id(u8::MAX),
title: "not found".parse().unwrap(),
content: vec![],
},
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Quote {
pub author: Author,
pub content: String,
}
impl BlogEntry for Quote {
fn from_entry(entry: &mut Entry) -> Self {
return Self { author: Author::from_seed(entry.seed), content: "awawa content".to_string() }
};
}
}
pub struct Entry {
pub seed: u8
pub id: u8,
}
impl Entry {
pub fn from_seed(seed: u8) -> Self {
Self { seed }
pub fn from_id(seed: u8) -> Self {
Self { id: seed }
}
}
pub trait BlogEntry: Sized {
fn from_entry(entry: &mut Entry) -> Self;
fn from_seed(seed: u8) -> Self {
Self::from_entry(&mut Entry::from_seed(seed))
fn from_id(id: u8) -> Self {
Self::from_entry(&mut Entry::from_id(id))
}
}