Compare commits
No commits in common. "c8c9d7c5074730622ad16f0c4a59322ff425e003" and "9bfc8477be2be3d0e37287419f7b618d79259b4f" have entirely different histories.
c8c9d7c507
...
9bfc8477be
|
@ -17,7 +17,6 @@ path = "source/main.rs"
|
||||||
askama = "0.11.1"
|
askama = "0.11.1"
|
||||||
color-eyre = "0.6.2"
|
color-eyre = "0.6.2"
|
||||||
comrak = "0.15.0"
|
comrak = "0.15.0"
|
||||||
minify-html = "0.10.7"
|
|
||||||
rsass = "0.23.4"
|
rsass = "0.23.4"
|
||||||
toml-frontmatter = "0.1.0"
|
toml-frontmatter = "0.1.0"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
/* global document window */
|
window.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", async () => {
|
|
||||||
const loop = async () => {
|
const loop = async () => {
|
||||||
const listen = await getCurrentListen();
|
const listen = await getCurrentListen();
|
||||||
if (listen === undefined) {
|
if (listen === undefined) {
|
||||||
|
@ -28,14 +26,11 @@ async function getCoverArt(listen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await window.fetch(
|
const result = await window.fetch(`https://coverartarchive.org/release/${releaseMbid}`, {
|
||||||
`https://coverartarchive.org/release/${releaseMbid}`,
|
headers: {
|
||||||
{
|
Accept: 'application/json',
|
||||||
headers: {
|
|
||||||
Accept: "application/json",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -46,15 +41,11 @@ async function getCoverArt(listen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const thumbnails = data.images[0].thumbnails;
|
const thumbnails = data.images[0].thumbnails;
|
||||||
return (
|
return thumbnails.small ?? thumbnails['250'] ?? thumbnails['500'] ?? undefined;
|
||||||
thumbnails.small ?? thumbnails["250"] ?? thumbnails["500"] ?? undefined
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCurrentListen() {
|
async function getCurrentListen() {
|
||||||
const result = await window.fetch(
|
const result = await window.fetch('https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now');
|
||||||
"https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now",
|
|
||||||
);
|
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
console.warn(result.status);
|
console.warn(result.status);
|
||||||
return;
|
return;
|
||||||
|
@ -73,16 +64,16 @@ function insertHtml(listen, image) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const existing = document.querySelector(".listenbrainz") ?? undefined;
|
const existing = document.querySelector('.listenbrainz') ?? undefined;
|
||||||
if (existing !== undefined) {
|
if (existing !== undefined) {
|
||||||
existing.remove();
|
existing.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = `${listen.track_metadata.artist_name} - ${listen.track_metadata.track_name}`;
|
const text = `${listen.track_metadata.artist_name} - ${listen.track_metadata.track_name}`;
|
||||||
const alt = image === undefined ? "ListenBrainz Logo" : `${text} Cover Art`;
|
const alt = image === undefined ? 'ListenBrainz Logo' : `${text} Cover Art`;
|
||||||
|
|
||||||
image = image ?? "https://listenbrainz.org/static/img/logo_big.svg";
|
image = image ?? 'https://listenbrainz.org/static/img/logo_big.svg';
|
||||||
image = image.startsWith("http://") ? "https" + image.slice(4) : image;
|
image = image.startsWith('http://') ? 'https' + image.slice(4) : image;
|
||||||
|
|
||||||
const listenHtml = `
|
const listenHtml = `
|
||||||
<p class="listenbrainz">
|
<p class="listenbrainz">
|
||||||
|
@ -93,7 +84,5 @@ function insertHtml(listen, image) {
|
||||||
</a>
|
</a>
|
||||||
</p>`;
|
</p>`;
|
||||||
|
|
||||||
document
|
document.querySelector('.page-header').insertAdjacentHTML('beforeend', listenHtml);
|
||||||
.querySelector(".page-header")
|
|
||||||
.insertAdjacentHTML("beforeend", listenHtml);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ use std::{
|
||||||
use color_eyre::{install, Result};
|
use color_eyre::{install, Result};
|
||||||
|
|
||||||
mod copy;
|
mod copy;
|
||||||
mod minify;
|
|
||||||
mod scss;
|
mod scss;
|
||||||
mod templates;
|
mod templates;
|
||||||
mod video;
|
mod video;
|
||||||
|
@ -30,7 +29,7 @@ fn main() -> Result<()> {
|
||||||
fn build_userstyles(build_dir: &Path) -> Result<()> {
|
fn build_userstyles(build_dir: &Path) -> Result<()> {
|
||||||
for target in userstyles::ALL_USERSTYLES {
|
for target in userstyles::ALL_USERSTYLES {
|
||||||
let style = userstyles::Userstyle::load(target)?;
|
let style = userstyles::Userstyle::load(target)?;
|
||||||
let style_name = style.metadata.name.to_lowercase().replace(' ', "-");
|
let style_name = style.metadata.name.to_lowercase().replace(" ", "-");
|
||||||
|
|
||||||
let style_dir = build_dir.join("userstyles");
|
let style_dir = build_dir.join("userstyles");
|
||||||
fs::create_dir_all(&style_dir)?;
|
fs::create_dir_all(&style_dir)?;
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
use color_eyre::Result;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Minify HTML using [`minify-html`].
|
|
||||||
*/
|
|
||||||
pub fn html(data: String) -> Result<String> {
|
|
||||||
let minify_config = minify_html::Cfg {
|
|
||||||
do_not_minify_doctype: true,
|
|
||||||
ensure_spec_compliant_unquoted_attribute_values: true,
|
|
||||||
keep_closing_tags: true,
|
|
||||||
keep_comments: false,
|
|
||||||
keep_html_and_head_opening_tags: true,
|
|
||||||
keep_spaces_between_attributes: true,
|
|
||||||
minify_css: false,
|
|
||||||
minify_js: false,
|
|
||||||
remove_bangs: false,
|
|
||||||
remove_processing_instructions: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
let minified_data = minify_html::minify(&data.into_bytes(), &minify_config);
|
|
||||||
String::from_utf8(minified_data).map_err(Into::into)
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
@use "mixins";
|
@use 'mixins';
|
||||||
|
|
||||||
.listenbrainz {
|
.listenbrainz {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@use "mixins";
|
@use 'mixins';
|
||||||
|
|
||||||
.page-footer {
|
.page-footer {
|
||||||
@include mixins.responsive-container;
|
@include mixins.responsive-container;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@use "mixins";
|
@use 'mixins';
|
||||||
|
|
||||||
.page-header {
|
.page-header {
|
||||||
--anchor-color: #000;
|
--anchor-color: #000;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@use "mixins";
|
@use 'mixins';
|
||||||
|
|
||||||
.page-main {
|
.page-main {
|
||||||
a {
|
a {
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&.driftingnebula {
|
&.driftingnebula {
|
||||||
background: url("/assets/driftingnebula 2022-03-09.jpeg");
|
background: url('/assets/driftingnebula 2022-03-09.jpeg');
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&.holllo {
|
&.holllo {
|
||||||
background: url("/assets/holllo-mark-square-pattern.png");
|
background: url('/assets/holllo-mark-square-pattern.png');
|
||||||
background-color: #1f1731;
|
background-color: #1f1731;
|
||||||
background-repeat: repeat;
|
background-repeat: repeat;
|
||||||
background-size: 48px;
|
background-size: 48px;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@use "reset";
|
@use 'reset';
|
||||||
|
|
||||||
html {
|
html {
|
||||||
font-size: 62.5%;
|
font-size: 62.5%;
|
||||||
|
@ -43,7 +43,7 @@ button {
|
||||||
margin-top: 2rem;
|
margin-top: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@use "components/page-footer";
|
@use 'components/page-footer';
|
||||||
@use "components/page-header";
|
@use 'components/page-header';
|
||||||
@use "components/page-main";
|
@use 'components/page-main';
|
||||||
@use "components/listenbrainz";
|
@use 'components/listenbrainz';
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
@use "../../node_modules/modern-normalize/modern-normalize.css";
|
@use '../../node_modules/modern-normalize/modern-normalize.css';
|
||||||
|
|
|
@ -21,7 +21,7 @@ impl Index {
|
||||||
page_title: "Bauke".to_string(),
|
page_title: "Bauke".to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
write(destination, crate::minify::html(template.render()?)?)?;
|
write(destination, template.render()?)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ Turn a timestamp with format `mm:ss` into its total seconds.
|
||||||
- `01:30` -> 90 seconds
|
- `01:30` -> 90 seconds
|
||||||
*/
|
*/
|
||||||
pub fn timestamp_to_seconds(timestamp: &str) -> askama::Result<i32> {
|
pub fn timestamp_to_seconds(timestamp: &str) -> askama::Result<i32> {
|
||||||
let mut split = timestamp.split(':');
|
let mut split = timestamp.split(":");
|
||||||
let minutes = split.next().map(str::parse::<i32>).unwrap().unwrap();
|
let minutes = split.next().map(str::parse::<i32>).unwrap().unwrap();
|
||||||
let seconds = split.next().map(str::parse::<i32>).unwrap().unwrap();
|
let seconds = split.next().map(str::parse::<i32>).unwrap().unwrap();
|
||||||
Ok(minutes * 60 + seconds)
|
Ok(minutes * 60 + seconds)
|
||||||
|
|
|
@ -68,11 +68,7 @@ pub fn write_all(public_dir: &Path) -> Result<()> {
|
||||||
speedrun: video_data.speedrun,
|
speedrun: video_data.speedrun,
|
||||||
video_id: video_data.id,
|
video_id: video_data.id,
|
||||||
};
|
};
|
||||||
|
fs::write(video_dir.join("index.html"), template.render()?)?;
|
||||||
fs::write(
|
|
||||||
video_dir.join("index.html"),
|
|
||||||
crate::minify::html(template.render()?)?,
|
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in New Issue