#![feature(proc_macro_hygiene, decl_macro)] pub mod admin; pub mod controllers; pub mod misc; pub mod models; mod schema; #[macro_use] extern crate rocket; #[macro_use] extern crate diesel; extern crate comrak; extern crate dotenv; extern crate rocket_contrib; extern crate tera; use comrak::{markdown_to_html, ComrakOptions}; use controllers::posts; use dotenv::dotenv; use misc::get_context; use rocket::response::content; use rocket::response::NamedFile; use rocket::Request; use rocket_contrib::serve::StaticFiles; use rocket_contrib::templates::Template; use std::path::Path; use std::vec::Vec; #[get("/?")] fn index(page: Option) -> Template { let page: u64 = page.unwrap_or(1); let mut context = get_context(); let (posts, n_posts) = posts::get_posts(Some(page)); let total_pages = (n_posts as f64 / posts::MAX_POSTS_PER_PAGE as f64).ceil() as i64; context.insert("posts", &posts); context.insert("total_pages", &total_pages); context.insert("actual_page", &page); Template::render("index", context) } #[get("/feed.xml")] fn rss_feed() -> content::Xml