Added sitebuilder model + Alert implementation

This commit is contained in:
Keanu D?lle 2020-02-02 22:07:35 +01:00
parent 04fc9067eb
commit b93ac94280
5 changed files with 88 additions and 0 deletions

View File

@ -1,3 +1,4 @@
extern crate config; extern crate config;
pub mod settings; pub mod settings;
pub mod sitebuilder;

View File

@ -0,0 +1,30 @@
use crate::helper::sitebuilder::model::{Alert, AlertType, SidebarEntry};
trait ToHtml {
fn into_html(&self) -> String;
}
impl ToHtml for AlertType {
fn into_html(&self) -> String {
match self {
AlertType::Danger => "alert-danger".to_string(),
AlertType::Primary => "alert-primary".to_string(),
AlertType::Secondary => "alert-secondary".to_string(),
AlertType::Success => "alert-success".to_string(),
AlertType::Warning => "alert-warning".to_string(),
AlertType::Info => "alert-info".to_string(),
AlertType::Light => "alert-light".to_string(),
AlertType::Dark => "alert-dark".to_string(),
}
}
}
impl ToHtml for Alert {
fn into_html(&self) -> String {
format!(
"<div class=\"alert {}\" role=\"alert\">{}</div>",
self.alert_type.into_html(),
self.message
)
}
}

View File

@ -0,0 +1,3 @@
pub mod model;
pub mod view;
pub mod controller;

View File

@ -0,0 +1,54 @@
pub struct Builder {
sidebar: Sidebar,
navigation: Navigation,
content_panel: ContentPanel,
site_title: String,
}
pub struct SidebarEntry {
active: bool,
title: String,
icon: String,
}
pub struct Sidebar {
entries: Vec<SidebarEntry>,
}
pub struct Navigation {
entries: Vec<NavigationEntry>,
}
pub struct NavigationEntry {
active: bool,
title: String,
link: String,
}
pub struct ContentPanel {
sections: Vec<Section>,
alerts: Vec<Alert>,
}
pub struct Section {
title: String,
content: String,
}
pub enum AlertType {
//According to bootstrap alert types
Primary,
Secondary,
Success,
Danger,
Warning,
Info,
Light,
Dark,
}
pub struct Alert {
pub alert_type: AlertType,
//dismissible: bool,
pub message: String,
}

View File