initial commit
commit
aab7616ebf
|
@ -0,0 +1,67 @@
|
|||
# Project specific
|
||||
|
||||
/pub
|
||||
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/rust,nova,macos,sass
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,nova,macos,sass
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### macOS Patch ###
|
||||
# iCloud generated files
|
||||
*.icloud
|
||||
|
||||
### nova ###
|
||||
.nova/*
|
||||
|
||||
### Rust ###
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
### Sass ###
|
||||
.sass-cache/
|
||||
*.css.map
|
||||
*.sass.map
|
||||
*.scss.map
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/rust,nova,macos,sass
|
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "lf-builder"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
authors = [ "Alina Marquardt" ]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.24"
|
|
@ -0,0 +1,13 @@
|
|||
# lastfuture.de static page generator
|
||||
|
||||
Static page generator for lastfuture.de, written in Rust
|
||||
|
||||
## Features
|
||||
- generates static HTML pages in Rust
|
||||
|
||||
## Planned features
|
||||
- Templating using Mustache
|
||||
- SCSS preprocessing
|
||||
- TypeScript preprocessing
|
||||
- Minification
|
||||
- Deploy script
|
|
@ -0,0 +1,46 @@
|
|||
use std::fs::File;
|
||||
use std::io::{Write, BufReader, BufRead, Error};
|
||||
use chrono;
|
||||
use std::time::Instant;
|
||||
|
||||
const PUBLISH_PATH: &str = "./pub/";
|
||||
const TEMPLATE_PATH: &str = "./src/templates/";
|
||||
|
||||
fn render_html(file: &str, template: &str, data: Vec<i32>) -> Result<(), Error> {
|
||||
let output_path = &format!("{}{}", PUBLISH_PATH, file);
|
||||
let template_path = &format!("{}{}", TEMPLATE_PATH, template);
|
||||
|
||||
let now = Instant::now();
|
||||
// TODO: Templating with template and data
|
||||
let html_string = "<h1>Hello!</h1>";
|
||||
let elapsed = now.elapsed();
|
||||
|
||||
let mut output_file = File::create(output_path)?;
|
||||
write!(output_file,
|
||||
"{}\n
|
||||
<!--\n
|
||||
{}\n
|
||||
{}\n
|
||||
generated in {:.2?}\n
|
||||
-->",
|
||||
html_string,
|
||||
template,
|
||||
chrono::offset::Local::now(),
|
||||
elapsed
|
||||
)?;
|
||||
|
||||
let input = File::open(output_path)?;
|
||||
let buffered = BufReader::new(input);
|
||||
|
||||
for line in buffered.lines() {
|
||||
println!("{}", line?);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
||||
render_html("index.html", "index.tmpl", vec![1, 2, 3]);
|
||||
|
||||
}
|
Loading…
Reference in New Issue