rename some parts
This commit is contained in:
parent
bad7d1462f
commit
1c702242d6
13
src/main.rs
13
src/main.rs
@ -1,12 +1,14 @@
|
|||||||
use std::{fs,io};
|
mod links;
|
||||||
|
|
||||||
|
use links::{RustyLinks, MetaData};
|
||||||
|
|
||||||
|
use std::{fs, io};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde_yaml::{self};
|
use serde_yaml::{self};
|
||||||
use minijinja::{Environment};
|
use minijinja::{Environment};
|
||||||
|
|
||||||
mod links;
|
|
||||||
use links::{RustyLinks,MetaData};
|
|
||||||
|
|
||||||
pub fn copy_recursively(source: impl AsRef<Path>, destination: impl AsRef<Path>) -> io::Result<()> {
|
pub fn copy_recursively(source: impl AsRef<Path>, destination: impl AsRef<Path>) -> io::Result<()> {
|
||||||
// Credit: https://nick.groenen.me/notes/recursively-copy-files-in-rust/
|
// Credit: https://nick.groenen.me/notes/recursively-copy-files-in-rust/
|
||||||
@ -30,8 +32,8 @@ fn load_links(file_name: &str) -> RustyLinks {
|
|||||||
let mut rusty_links: RustyLinks = serde_yaml::from_reader(links_yaml).expect("Could not read values");
|
let mut rusty_links: RustyLinks = serde_yaml::from_reader(links_yaml).expect("Could not read values");
|
||||||
|
|
||||||
// Set last updated time to now.
|
// Set last updated time to now.
|
||||||
let now : DateTime<Utc> = Utc::now();
|
let now: DateTime<Utc> = Utc::now();
|
||||||
let metadata : MetaData = MetaData { last_updated: now.to_rfc2822()};
|
let metadata: MetaData = MetaData { last_updated: now.to_rfc2822() };
|
||||||
rusty_links.metadata = Some(metadata);
|
rusty_links.metadata = Some(metadata);
|
||||||
|
|
||||||
rusty_links
|
rusty_links
|
||||||
@ -40,7 +42,6 @@ fn load_links(file_name: &str) -> RustyLinks {
|
|||||||
fn render_links(rusty_links: RustyLinks) -> String {
|
fn render_links(rusty_links: RustyLinks) -> String {
|
||||||
let main = std::fs::read_to_string("templates/links/links.html").expect("Could not find links.html");
|
let main = std::fs::read_to_string("templates/links/links.html").expect("Could not find links.html");
|
||||||
|
|
||||||
|
|
||||||
let mut env = Environment::new();
|
let mut env = Environment::new();
|
||||||
env.add_template("main", &*main).unwrap();
|
env.add_template("main", &*main).unwrap();
|
||||||
let tmpl = env.get_template("main").unwrap();
|
let tmpl = env.get_template("main").unwrap();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE htmstylel>
|
||||||
<html lang="en-US">
|
<html lang="en-US">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{config.title}}</title>
|
<title>{{config.title}}</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="links.css">
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
background:
|
background:
|
||||||
|
Loading…
Reference in New Issue
Block a user