[#2] Database integration complete.
Posts and Authors can now be inserted and retrieved from the database created. It was decided to use a SQLite database for it high read spead and ease of use/maintenance. A build feature was created to seperate how the library is being used. If you are making the database and storing posts, then use the publisher flag. If you are just reading from a database then do not use the publisher flag. This was also set to change the tale contents from a PathBuf to the String of HTML blog data without having to create a whole new data object. An example and a test were made. Test coverage needs to be increased however.
This commit is contained in:
39
src/tale.rs
39
src/tale.rs
@ -1,18 +1,27 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
|
||||
|
||||
|
||||
/// A type alias representing the path to a Markdown file.
|
||||
/// This type is used to point to the location of the content of a `Tale`.
|
||||
#[cfg(feature = "publisher")]
|
||||
pub type Markdown = std::path::PathBuf;
|
||||
|
||||
|
||||
/// Represents a post or story in the application.
|
||||
/// A type alias representing the HTML content of the tale.
|
||||
#[cfg(not(feature = "publisher"))]
|
||||
pub type Markdown = String;
|
||||
|
||||
|
||||
|
||||
/// Metadata describing a tale.
|
||||
///
|
||||
/// A `Tale` contains metadata about the post such as its title, author,
|
||||
/// and tags, along with a path to its Markdown content.
|
||||
/// This includes details such as the title, author, summary, and
|
||||
/// associated tags.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Tale
|
||||
pub struct FrontMatter
|
||||
{
|
||||
/// The title of the tale.
|
||||
pub title: String,
|
||||
@ -26,15 +35,23 @@ pub struct Tale
|
||||
/// A short summary or description of the tale.
|
||||
pub summary: String,
|
||||
|
||||
/// A list of tags associated with the tale for categorization and searching.
|
||||
/// A list of tags associated with the tale for categorization and
|
||||
/// searching.
|
||||
pub tags: Vec<String>,
|
||||
|
||||
/// The Date and Time that must elapse before this tale can be told.
|
||||
pub publish_date: NaiveDateTime
|
||||
}
|
||||
|
||||
|
||||
/// Represents a post or story in the application.
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Tale
|
||||
{
|
||||
/// Metadata of the post.
|
||||
#[serde(flatten)]
|
||||
pub front_matter: FrontMatter,
|
||||
|
||||
/// The file path to the Markdown content of the tale.
|
||||
pub content: Markdown
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Tale
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user