// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::fmt; use std::io; use std::path::PathBuf; use externalfiles::ExternalHtml; #[derive(Clone)] pub struct Layout { pub logo: String, pub favicon: String, pub external_html: ExternalHtml, pub krate: String, } pub struct Page<'a> { pub title: &'a str, pub css_class: &'a str, pub root_path: &'a str, pub description: &'a str, pub keywords: &'a str, pub resource_suffix: &'a str, } pub fn render( dst: &mut io::Write, layout: &Layout, page: &Page, sidebar: &S, t: &T, css_file_extension: bool, themes: &[PathBuf]) -> io::Result<()> { write!(dst, "\ \ \ \ \ \ \ \ {title}\ \ \ {themes}\ \ \ \ {css_extension}\ {favicon}\ {in_header}\ \ \ \ {before_content}\ \
\ \
\
\ \ \
{content}
\
\
\ \ {after_content}\ \ \ \ \ \ ", css_extension = if css_file_extension { format!("", root_path = page.root_path, suffix=page.resource_suffix) } else { "".to_owned() }, content = *t, root_path = page.root_path, css_class = page.css_class, logo = if layout.logo.is_empty() { "".to_string() } else { format!("\ logo", page.root_path, layout.krate, layout.logo) }, title = page.title, description = page.description, keywords = page.keywords, favicon = if layout.favicon.is_empty() { "".to_string() } else { format!(r#""#, layout.favicon) }, in_header = layout.external_html.in_header, before_content = layout.external_html.before_content, after_content = layout.external_html.after_content, sidebar = *sidebar, krate = layout.krate, themes = themes.iter() .filter_map(|t| t.file_stem()) .filter_map(|t| t.to_str()) .map(|t| format!(r#""#, page.root_path, t, page.resource_suffix)) .collect::(), suffix=page.resource_suffix, ) } pub fn redirect(dst: &mut io::Write, url: &str) -> io::Result<()> { // "##, url = url, ) }