[#5] Tavern components added to database.

This commit is contained in:
2025-08-29 22:50:19 -04:00
parent 89fa545ba6
commit a57b2db1ff
2 changed files with 24 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "tavern"
version = "0.2.2"
version = "0.2.3"
edition = "2024"
description = "A blogging system that will allow you to write your blog in Markdown and then display it in HTML using Dioxus."
repository = "/CyberMages/tavern"

View File

@ -12,6 +12,8 @@ use crate::tale::Tale;
#[cfg(feature = "publisher")]
use crate::converter::Converter;
#[cfg(feature = "publisher")]
use crate::tavern::Tavern;
#[cfg(not(feature = "publisher"))]
use crate::tale::Lore;
@ -135,7 +137,7 @@ impl Database
/// Inserts a single tale into the database.
#[cfg(feature = "publisher")]
pub async fn insert_tale(&self, tale: &Tale)
-> Result<(), Box<dyn std::error::Error>>
-> Result<()>
{
// Convert the tales content from Markdown to HTML.
let markdown_content = std::fs::read_to_string(&tale.story)?;
@ -218,7 +220,7 @@ impl Database
/// Inserts the site-wide settings like title and description.
#[cfg(feature = "publisher")]
pub async fn insert_tavern(&self, title: &str, description: &str)
pub async fn insert_tavern_settings(&self, title: &str, description: &str)
-> Result<()>
{
// Start a transaction.
@ -242,6 +244,25 @@ impl Database
Ok(())
}
/// Inserts a Tavern into the database.
#[cfg(feature = "publisher")]
pub async fn insert_tavern(&self, tavern: &Tavern) -> Result<()>
{
self.insert_tavern_settings(&tavern.title, &tavern.description).await?;
for tale in &tavern.tales
{
self.insert_tale(tale).await?;
}
for author in &tavern.authors
{
self.insert_adventurer(author).await?;
}
Ok(())
}
#[cfg(not(feature = "publisher"))]
pub async fn get_tales_summary(&self, categories: &[String])
-> Result<Vec<Lore>>