struct file cleanups
This commit is contained in:
parent
6d0dcb987f
commit
7fed8e907a
2
src/blog/mod.rs
Normal file
2
src/blog/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod structs;
|
||||
pub use structs::{BlogConfig};
|
6
src/blog/structs.rs
Normal file
6
src/blog/structs.rs
Normal file
@ -0,0 +1,6 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub struct BlogConfig {
|
||||
source: String,
|
||||
}
|
@ -1,56 +1,12 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
pub mod structs;
|
||||
pub use structs::{LinksConfig, RustyLinks, MetaData};
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde_yaml::{self};
|
||||
use minijinja::Environment;
|
||||
use std::path::PathBuf;
|
||||
use crate::file_utils::{write_file, copy_recursively};
|
||||
|
||||
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub struct LinksConfig {
|
||||
pub source: String,
|
||||
pub template: String,
|
||||
pub static_dir: String,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct RustyLinks {
|
||||
config: Config,
|
||||
links: Vec<Links>,
|
||||
pub metadata: Option<MetaData>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct MetaData {
|
||||
pub last_updated: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Config {
|
||||
title: String,
|
||||
name: String,
|
||||
description: String,
|
||||
avatar: String,
|
||||
background: String,
|
||||
background_opacity: f64,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Links {
|
||||
title: String,
|
||||
links: Vec<Link>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Link {
|
||||
text: String,
|
||||
icon: String,
|
||||
href: Option<String>,
|
||||
copy: Option<String>,
|
||||
rels: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
fn load_links(config: &LinksConfig) -> RustyLinks {
|
||||
let links_yaml = std::fs::File::open(&config.source).expect(&format!("Could not find {}", config.source));
|
||||
|
||||
|
45
src/links/structs.rs
Normal file
45
src/links/structs.rs
Normal file
@ -0,0 +1,45 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Links {
|
||||
title: String,
|
||||
links: Vec<Link>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Link {
|
||||
text: String,
|
||||
icon: String,
|
||||
href: Option<String>,
|
||||
copy: Option<String>,
|
||||
rels: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub struct LinksConfig {
|
||||
pub source: String,
|
||||
pub template: String,
|
||||
pub static_dir: String,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct RustyLinks {
|
||||
config: Config,
|
||||
links: Vec<Links>,
|
||||
pub metadata: Option<MetaData>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct MetaData {
|
||||
pub last_updated: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Config {
|
||||
title: String,
|
||||
name: String,
|
||||
description: String,
|
||||
avatar: String,
|
||||
background: String,
|
||||
background_opacity: f64,
|
||||
}
|
@ -1,16 +1,13 @@
|
||||
mod links;
|
||||
mod file_utils;
|
||||
mod blog;
|
||||
|
||||
use crate::links::{LinksConfig, create_links};
|
||||
use crate::blog::{BlogConfig};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
pub struct BlogConfig {
|
||||
source: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||
pub struct Config {
|
||||
output_dir: String,
|
||||
|
Loading…
Reference in New Issue
Block a user