1
Fork 0

Compare commits

...

3 Commits

5 changed files with 33 additions and 9 deletions

View File

@ -0,0 +1,9 @@
<h2>Mods</h2>
<ul>
{% for mod_id in mods %}
{% let (mod_link, mod_title) = mod_id|drg_mod %}
<li>
<a href="{{ mod_link }}" target="_blank">{{ mod_title }}</a>
</li>
{% endfor %}
</ul>

View File

@ -24,15 +24,7 @@
</ul> </ul>
{% if let Some(mods) = speedrun.mods %} {% if let Some(mods) = speedrun.mods %}
<h2>Mods</h2> {% include "drg-mods.html" %}
<ul>
{% for mod_id in mods %}
{% let (mod_link, mod_title) = mod_id|drg_mod %}
<li>
<a href="{{ mod_link }}" target="_blank">{{ mod_title }}</a>
</li>
{% endfor %}
</ul>
{% endif %} {% endif %}
{% if let Some(chapters) = speedrun.chapters %} {% if let Some(chapters) = speedrun.chapters %}
@ -54,6 +46,12 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if let Some(drg) = drg %}
{% if let Some(mods) = drg.mods %}
{% include "drg-mods.html" %}
{% endif %}
{% endif %}
<iframe <iframe
src="https://www.youtube-nocookie.com/embed/{{ video_id }}" src="https://www.youtube-nocookie.com/embed/{{ video_id }}"
title="Embedded YouTube video player" title="Embedded YouTube video player"

View File

@ -2,6 +2,9 @@
id = "_9xtYCGWtn4" id = "_9xtYCGWtn4"
page_title = "No HUD Hazard 5 Mining Expedition" page_title = "No HUD Hazard 5 Mining Expedition"
tags = ["Deep Rock Galactic", "No HUD"] tags = ["Deep Rock Galactic", "No HUD"]
[drg]
mods = ["brighter-objects"]
--- ---
## Description ## Description

View File

@ -7,6 +7,7 @@ Get the DRG mod link and title from a given ID.
*/ */
pub fn drg_mod(mod_id: &str) -> askama::Result<(String, &str)> { pub fn drg_mod(mod_id: &str) -> askama::Result<(String, &str)> {
let mods = std::collections::HashMap::<_, _>::from_iter([ let mods = std::collections::HashMap::<_, _>::from_iter([
("brighter-objects", "Brighter Objects"),
("drglib", "DRGLib"), ("drglib", "DRGLib"),
("simplemissiontimer", "SimpleMissionTimer"), ("simplemissiontimer", "SimpleMissionTimer"),
]); ]);

View File

@ -11,6 +11,9 @@ mod filters;
#[derive(Debug, Template)] #[derive(Debug, Template)]
#[template(path = "video.html")] #[template(path = "video.html")]
pub struct VideoTemplate { pub struct VideoTemplate {
/// Deep Rock Galactic data.
pub drg: Option<DeepRockGalacticData>,
/// The title of the page. /// The title of the page.
pub page_title: String, pub page_title: String,
@ -26,6 +29,9 @@ pub struct VideoTemplate {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct VideoData { pub struct VideoData {
/// Deep Rock Galactic data.
pub drg: Option<DeepRockGalacticData>,
/// The YouTube video ID. /// The YouTube video ID.
pub id: String, pub id: String,
@ -55,6 +61,12 @@ pub struct SpeedrunData {
pub mods: Option<Vec<String>>, pub mods: Option<Vec<String>>,
} }
#[derive(Debug, Deserialize)]
pub struct DeepRockGalacticData {
/// Deep Rock Galactic mods used in the run.
pub mods: Option<Vec<String>>,
}
pub fn write_all(public_dir: &Path) -> Result<()> { pub fn write_all(public_dir: &Path) -> Result<()> {
let video_datas = { let video_datas = {
let mut data = vec![]; let mut data = vec![];
@ -90,6 +102,7 @@ pub fn write_all(public_dir: &Path) -> Result<()> {
fs::create_dir_all(&video_dir)?; fs::create_dir_all(&video_dir)?;
let template = VideoTemplate { let template = VideoTemplate {
drg: video_data.drg,
page_title: video_data.page_title, page_title: video_data.page_title,
rendered_markdown: comrak::markdown_to_html( rendered_markdown: comrak::markdown_to_html(
&markdown, &markdown,