use crate::phighlighter::lecture_str_to_html;
pub fn lecture_book_theme_header(title: &String) -> String {
let html_title: String = lecture_str_to_html(title);
let body = String::from(format!(r#"<!DOCTYPE html>
<html class="js sidebar-visible navy" lang="fr">
<head>
<meta charset="UTF-8">
<title>{}</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta name="description" content="{}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="rgba(0, 0, 0, 0)">
<link rel="stylesheet" href="book/variables.css">
<link rel="stylesheet" href="book/dark.css" />
<link rel="stylesheet" href="book/environment.css" />
<link rel="stylesheet" href="book/general.css">
<link rel="stylesheet" href="book/chrome.css">
<link rel="stylesheet" href="book/highlight.css" disabled="">
<link rel="stylesheet" href="book/tomorrow-night.css">
<link rel="stylesheet" href="book/ayu-highlight.css" disabled="">
<!-- Fonts -->
<link rel="stylesheet" href="book/font-awesome.css">
<link rel="stylesheet" href="book/fonts.css">
<script src="book/phoenix_clipboard.js"></script>
</head>
"#, html_title, html_title));
return body;
}
pub fn lecture_book_theme_body_begin() -> String {
let body = String::from(r#" <body>
<div id="MathJax_Message" style="display: none;"></div>
<!-- Provide site root to javascript -->
<script type="text/javascript">
var path_to_root = "./";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script type="text/javascript">
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script type="text/javascript">
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
</script>
<!-- Hide / unhide sidebar before it is displayed -->
<script type="text/javascript">
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
"#);
return body;
}
pub fn lecture_book_theme_body_top_menu(project_url: &String, author_email: &String, current_branch: &String, current_source_file: &String, current_source_line: usize, master_project_url: &String) -> String{
let mut body = String::from(format!(r#"
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar" style="top: 0px;">
<div class="left-buttons">
<button id="sidebar-toggle" class="icon-button book-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar" aria-expanded="true">
<i class="fa book-toggle-sidebar-icon"></i>
</button>
<button id="theme-toggle" class="icon-button book-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa book-theme-icon"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
</ul>
<a href="{}" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa book-gitlab-icon"></i>
</a>
<a href="mailto: {}" title="Send email to authors" aria-label="Send mail">
<i id="git-repository-button" class="fa book-mail-icon"></i>
</a>
<a href="{}/-/edit/{}/{}#L{}" title="Suggest an edit" aria-label="Suggest an edit">
<i id="git-edit-button" class="fa book-edit-icon"></i>
</a>
<a href="{}" title="Master project" aria-label="Master projec">
<i id="master-project-button" class="fa book-home-icon"></i>
</a>
</div>
"#, project_url, author_email, project_url, current_branch, current_source_file, current_source_line, master_project_url));
body += &String::from(r#" <h1 class="menu-title"></h1>
<div class="right-buttons">
<a href="https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/static-site-generator/RustyPhoenixLecture/" title="RustyPhoenixLecture" aria-label="RustyPhoenixLecture compiler">
<i id="git-repository-button" class="fa book-gitlab-icon"></i>
</a>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script type="text/javascript">
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
"#);
return body;
}
pub fn lecture_book_theme_body_end(prev_page: &String, next_page: &String) -> String {
let mut body = String::from(r#"
</main>
"#);
if !prev_page.is_empty() || !next_page.is_empty() {
body += &String::from(r#" <nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
"#);
if !prev_page.is_empty() {
body += &String::from(format!(r#"<a rel="prev" href="{}" class="mobile-nav-chapters previous" title="Previous page" aria-label="Previous page" aria-keyshortcuts="Left">
<i class="book-prev-icon"></i>
</a>
"#, prev_page));
}
if !next_page.is_empty() {
body += &String::from(format!(r#"<a rel="next" href="{}" class="mobile-nav-chapters next" title="Next page" aria-label="Next page" aria-keyshortcuts="Right">
<i class="book-next-icon"></i>
</a>
"#, next_page));
}
body += &String::from(r#"<div style="clear: both"></div>
</nav>
"#);
}
body += &String::from(r#" </div>
</div>
"#);
if !prev_page.is_empty() || !next_page.is_empty() {
body += &String::from(r#" <nav class="nav-wide-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
"#);
if !prev_page.is_empty() {
body += &String::from(format!(r#"<a rel="prev" href="{}" class="nav-chapters previous" title="Previous page" aria-label="Previous page" aria-keyshortcuts="Left">
<i class="book-prev-icon"></i>
</a>
"#, prev_page));
}
if !next_page.is_empty() {
body += &String::from(format!(r#"<a rel="next" href="{}" class="nav-chapters next" title="Next page" aria-label="Next page" aria-keyshortcuts="Right">
<i class="book-next-icon"></i>
</a>
"#, next_page));
}
body += &String::from(r#" </nav>
"#);
}
body += &String::from(r#" </div>
<script type="text/javascript">
window.playground_copyable = true;
</script>
<script src="book/clipboard.js" type="text/javascript" charset="utf-8"></script>
<script src="book/highlight.js" type="text/javascript" charset="utf-8"></script>
<script src="book/book.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>"#);
return body;
}