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"
|
||||
color-eyre = "0.6.2"
|
||||
comrak = "0.15.0"
|
||||
minify-html = "0.10.7"
|
||||
rsass = "0.23.4"
|
||||
toml-frontmatter = "0.1.0"
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
/* global document window */
|
||||
|
||||
window.addEventListener("DOMContentLoaded", async () => {
|
||||
window.addEventListener('DOMContentLoaded', async () => {
|
||||
const loop = async () => {
|
||||
const listen = await getCurrentListen();
|
||||
if (listen === undefined) {
|
||||
|
@ -28,14 +26,11 @@ async function getCoverArt(listen) {
|
|||
return;
|
||||
}
|
||||
|
||||
const result = await window.fetch(
|
||||
`https://coverartarchive.org/release/${releaseMbid}`,
|
||||
{
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
const result = await window.fetch(`https://coverartarchive.org/release/${releaseMbid}`, {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
);
|
||||
});
|
||||
if (!result.ok) {
|
||||
return;
|
||||
}
|
||||
|
@ -46,15 +41,11 @@ async function getCoverArt(listen) {
|
|||
}
|
||||
|
||||
const thumbnails = data.images[0].thumbnails;
|
||||
return (
|
||||
thumbnails.small ?? thumbnails["250"] ?? thumbnails["500"] ?? undefined
|
||||
);
|
||||
return thumbnails.small ?? thumbnails['250'] ?? thumbnails['500'] ?? undefined;
|
||||
}
|
||||
|
||||
async function getCurrentListen() {
|
||||
const result = await window.fetch(
|
||||
"https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now",
|
||||
);
|
||||
const result = await window.fetch('https://api.listenbrainz.org/1/user/BaukeXYZ/playing-now');
|
||||
if (!result.ok) {
|
||||
console.warn(result.status);
|
||||
return;
|
||||
|
@ -73,16 +64,16 @@ function insertHtml(listen, image) {
|
|||
return;
|
||||
}
|
||||
|
||||
const existing = document.querySelector(".listenbrainz") ?? undefined;
|
||||
const existing = document.querySelector('.listenbrainz') ?? undefined;
|
||||
if (existing !== undefined) {
|
||||
existing.remove();
|
||||
}
|
||||
|
||||
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.startsWith("http://") ? "https" + image.slice(4) : image;
|
||||
image = image ?? 'https://listenbrainz.org/static/img/logo_big.svg';
|
||||
image = image.startsWith('http://') ? 'https' + image.slice(4) : image;
|
||||
|
||||
const listenHtml = `
|
||||
<p class="listenbrainz">
|
||||
|
@ -93,7 +84,5 @@ function insertHtml(listen, image) {
|
|||
</a>
|
||||
</p>`;
|
||||
|
||||
document
|
||||
.querySelector(".page-header")
|
||||
.insertAdjacentHTML("beforeend", listenHtml);
|
||||
document.querySelector('.page-header').insertAdjacentHTML('beforeend', listenHtml);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use std::{
|
|||
use color_eyre::{install, Result};
|
||||
|
||||
mod copy;
|
||||
mod minify;
|
||||
mod scss;
|
||||
mod templates;
|
||||
mod video;
|
||||
|
@ -30,7 +29,7 @@ fn main() -> Result<()> {
|
|||
fn build_userstyles(build_dir: &Path) -> Result<()> {
|
||||
for target in userstyles::ALL_USERSTYLES {
|
||||
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");
|
||||
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 {
|
||||
align-items: center;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@use "mixins";
|
||||
@use 'mixins';
|
||||
|
||||
.page-footer {
|
||||
@include mixins.responsive-container;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@use "mixins";
|
||||
@use 'mixins';
|
||||
|
||||
.page-header {
|
||||
--anchor-color: #000;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@use "mixins";
|
||||
@use 'mixins';
|
||||
|
||||
.page-main {
|
||||
a {
|
||||
|
@ -14,7 +14,7 @@
|
|||
}
|
||||
|
||||
&.driftingnebula {
|
||||
background: url("/assets/driftingnebula 2022-03-09.jpeg");
|
||||
background: url('/assets/driftingnebula 2022-03-09.jpeg');
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
|
||||
&.holllo {
|
||||
background: url("/assets/holllo-mark-square-pattern.png");
|
||||
background: url('/assets/holllo-mark-square-pattern.png');
|
||||
background-color: #1f1731;
|
||||
background-repeat: repeat;
|
||||
background-size: 48px;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@use "reset";
|
||||
@use 'reset';
|
||||
|
||||
html {
|
||||
font-size: 62.5%;
|
||||
|
@ -43,7 +43,7 @@ button {
|
|||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
@use "components/page-footer";
|
||||
@use "components/page-header";
|
||||
@use "components/page-main";
|
||||
@use "components/listenbrainz";
|
||||
@use 'components/page-footer';
|
||||
@use 'components/page-header';
|
||||
@use 'components/page-main';
|
||||
@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(),
|
||||
};
|
||||
|
||||
write(destination, crate::minify::html(template.render()?)?)?;
|
||||
write(destination, template.render()?)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ Turn a timestamp with format `mm:ss` into its total seconds.
|
|||
- `01:30` -> 90 seconds
|
||||
*/
|
||||
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 seconds = split.next().map(str::parse::<i32>).unwrap().unwrap();
|
||||
Ok(minutes * 60 + seconds)
|
||||
|
|
|
@ -68,11 +68,7 @@ pub fn write_all(public_dir: &Path) -> Result<()> {
|
|||
speedrun: video_data.speedrun,
|
||||
video_id: video_data.id,
|
||||
};
|
||||
|
||||
fs::write(
|
||||
video_dir.join("index.html"),
|
||||
crate::minify::html(template.render()?)?,
|
||||
)?;
|
||||
fs::write(video_dir.join("index.html"), template.render()?)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue