Compare commits
No commits in common. "8d9cfa8ad02f2b44224f9e183b096d596b8f1d5c" and "4e40f961fa872dd5b4f1745d6d5ac49e0ce496f6" have entirely different histories.
8d9cfa8ad0
...
4e40f961fa
|
@ -1,4 +1,3 @@
|
|||
.direnv/
|
||||
.netlify/
|
||||
node_modules/
|
||||
public/
|
||||
|
|
13
Cargo.toml
13
Cargo.toml
|
@ -14,10 +14,10 @@ name = "bauke-xyz"
|
|||
path = "source/main.rs"
|
||||
|
||||
[dependencies]
|
||||
askama = "0.12.1"
|
||||
askama = "0.11.1"
|
||||
color-eyre = "0.6.2"
|
||||
comrak = "0.20.0"
|
||||
minify-html = "0.15.0"
|
||||
comrak = "0.15.0"
|
||||
minify-html = "0.10.7"
|
||||
rsass = "0.23.4"
|
||||
toml-frontmatter = "0.1.0"
|
||||
|
||||
|
@ -28,10 +28,3 @@ version = "1.0.152"
|
|||
[dependencies.userstyles]
|
||||
git = "https://git.bauke.xyz/Bauke/userstyles"
|
||||
rev = "8aa9ad3"
|
||||
|
||||
[lints.clippy]
|
||||
missing_docs_in_private_items = "warn"
|
||||
|
||||
[lints.rust]
|
||||
missing_docs = "warn"
|
||||
unsafe_code = "forbid"
|
||||
|
|
|
@ -1,41 +1,40 @@
|
|||
# Build the website.
|
||||
[tasks.fmt]
|
||||
command = "cargo"
|
||||
args = ["fmt", "${@}"]
|
||||
|
||||
[tasks.check]
|
||||
command = "cargo"
|
||||
args = ["check", "${@}"]
|
||||
|
||||
[tasks.clippy]
|
||||
command = "cargo"
|
||||
args = ["clippy", "${@}"]
|
||||
|
||||
[tasks.test]
|
||||
command = "cargo"
|
||||
args = ["test", "${@}"]
|
||||
|
||||
[tasks.doc]
|
||||
command = "cargo"
|
||||
args = ["doc", "${@}"]
|
||||
|
||||
[tasks.build]
|
||||
clear = true
|
||||
command = "cargo"
|
||||
args = ["run", "--release"]
|
||||
args = ["build", "${@}"]
|
||||
|
||||
# Remove build directories.
|
||||
[tasks.clean]
|
||||
clear = true
|
||||
command = "pnpm"
|
||||
args = ["trash", "public"]
|
||||
[tasks.complete-check]
|
||||
dependencies = ["fmt", "check", "clippy", "test", "doc", "build"]
|
||||
|
||||
# Deploy the website to Netlify.
|
||||
[tasks.deploy-netlify]
|
||||
clear = true
|
||||
command = "pnpm"
|
||||
dependencies = ["clean", "lint", "build"]
|
||||
args = ["netlify", "deploy", "-p", "-d", "public/", "-s", "bauke.xyz"]
|
||||
|
||||
# Run all other linting tasks.
|
||||
[tasks.lint]
|
||||
clear = true
|
||||
dependencies = ["lint-clippy", "lint-js", "lint-scss"]
|
||||
|
||||
# Run Clippy.
|
||||
[tasks.lint-clippy]
|
||||
clear = true
|
||||
[tasks.code-coverage]
|
||||
workspace = false
|
||||
install_crate = "cargo-tarpaulin"
|
||||
command = "cargo"
|
||||
args = ["clippy"]
|
||||
|
||||
# Run XO.
|
||||
[tasks.lint-js]
|
||||
clear = true
|
||||
command = "pnpm"
|
||||
args = ["xo"]
|
||||
|
||||
# Run Stylelint.
|
||||
[tasks.lint-scss]
|
||||
clear = true
|
||||
command = "pnpm"
|
||||
args = ["stylelint", "source/**/*.scss"]
|
||||
args = [
|
||||
"tarpaulin",
|
||||
"--exclude-files=target/*",
|
||||
"--out=html",
|
||||
"--output-dir=coverage",
|
||||
"--skip-clean",
|
||||
"--target-dir=target/tarpaulin",
|
||||
"--workspace"
|
||||
]
|
||||
|
|
|
@ -4,7 +4,12 @@
|
|||
|
||||
## Development
|
||||
|
||||
With [Nix flakes](https://nixos.wiki/wiki/Flakes) and [direnv](https://direnv.net/) installed and enabled, all the required dependencies are automatically loaded from [`shell.nix`](./shell.nix). Then [cargo-make](https://sagiegurari.github.io/cargo-make/) can be used to build, deploy and lint the code. The available tasks are all described in the [`Makefile.toml`](Makefile.toml) configuration.
|
||||
Requires working installations of [Rust and Cargo](https://www.rust-lang.org/learn/get-started), [NodeJS](https://nodejs.org) and [pnpm](https://pnpm.io).
|
||||
|
||||
* Install the dependencies with `pnpm install`.
|
||||
* Build the website with `cargo run`.
|
||||
* Deploy to Netlify with `pnpm run deploy`.
|
||||
* Test the code with `pnpm test`.
|
||||
|
||||
## License
|
||||
|
||||
|
|
59
flake.lock
59
flake.lock
|
@ -1,59 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705309234,
|
||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1705242415,
|
||||
"narHash": "sha256-a8DRYrNrzTudvO7XHUPNJD89Wbf1ZZT0VbwCsPnHWaE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ea780f3de2d169f982564128804841500e85e373",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
13
flake.nix
13
flake.nix
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShells.default = import ./shell.nix { inherit pkgs; };
|
||||
}
|
||||
);
|
||||
}
|
20
package.json
20
package.json
|
@ -1,16 +1,20 @@
|
|||
{
|
||||
"private": "true",
|
||||
"scripts": {
|
||||
"deploy": "cargo run --release -q && pnpm deploy:netlify",
|
||||
"deploy:netlify": "netlify deploy --prod --dir 'public/' -s bauke.xyz",
|
||||
"test": "xo && stylelint 'source/**/*.scss'"
|
||||
},
|
||||
"dependencies": {
|
||||
"modern-normalize": "^2.0.0"
|
||||
"modern-normalize": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@bauke/eslint-config": "^0.1.5",
|
||||
"@bauke/prettier-config": "^0.1.5",
|
||||
"@bauke/stylelint-config": "^0.1.5",
|
||||
"netlify-cli": "^17.13.2",
|
||||
"stylelint": "^16.1.0",
|
||||
"trash-cli": "^5.0.0",
|
||||
"xo": "^0.56.0"
|
||||
"@bauke/eslint-config": "^0.1.2",
|
||||
"@bauke/prettier-config": "^0.1.2",
|
||||
"@bauke/stylelint-config": "^0.1.2",
|
||||
"netlify-cli": "^12.5.0",
|
||||
"stylelint": "^14.16.1",
|
||||
"xo": "^0.53.1"
|
||||
},
|
||||
"prettier": "@bauke/prettier-config",
|
||||
"stylelint": {
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
mkShell rec {
|
||||
packages = [ cargo-make nodejs nodePackages.pnpm ];
|
||||
}
|
|
@ -1,14 +1,10 @@
|
|||
//! The logic for files that need be directly copied over.
|
||||
|
||||
use std::{fs, path::Path, process::Command};
|
||||
|
||||
use color_eyre::Result;
|
||||
|
||||
/// Struct to contain functionality for copying.
|
||||
pub struct Copy;
|
||||
|
||||
impl Copy {
|
||||
/// Copy all the files to their respective destinations.
|
||||
pub fn write(
|
||||
build_dir: &Path,
|
||||
public_dir: &Path,
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
//! # Bauke 🦖 XYZ
|
||||
//!
|
||||
//! > **Bauke's website.**
|
||||
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
|
@ -31,7 +27,6 @@ fn main() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Write the userstyle files to the right place in the build directory.
|
||||
fn build_userstyles(build_dir: &Path) -> Result<()> {
|
||||
for target in userstyles::ALL_USERSTYLES {
|
||||
let style = userstyles::Userstyle::load(target)?;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//! Code for minifying.
|
||||
|
||||
use color_eyre::Result;
|
||||
|
||||
/// Minify HTML using [`minify-html`].
|
||||
/**
|
||||
Minify HTML using [`minify-html`].
|
||||
*/
|
||||
pub fn html(data: String) -> Result<String> {
|
||||
let minify_config = minify_html::Cfg {
|
||||
do_not_minify_doctype: true,
|
||||
|
@ -10,13 +10,9 @@ pub fn html(data: String) -> Result<String> {
|
|||
keep_closing_tags: true,
|
||||
keep_comments: false,
|
||||
keep_html_and_head_opening_tags: true,
|
||||
keep_input_type_text_attr: true,
|
||||
keep_spaces_between_attributes: true,
|
||||
keep_ssi_comments: false,
|
||||
minify_css: false,
|
||||
minify_js: false,
|
||||
preserve_brace_template_syntax: false,
|
||||
preserve_chevron_percent_template_syntax: false,
|
||||
remove_bangs: false,
|
||||
remove_processing_instructions: false,
|
||||
};
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
# Other redirects
|
||||
/driftingnebula https://driftingnebula.com
|
||||
/git https://git.bauke.xyz
|
||||
/gitea https://git.bauke.xyz
|
||||
/github https://github.com/Bauke
|
||||
/gitlab https://gitlab.com/Bauke
|
||||
/glimesh https://glimesh.tv/Bauke
|
||||
/holllo https://holllo.org
|
||||
/tildes https://tildes.net/user/Bauke
|
||||
/twitch https://twitch.tv/Bauke
|
||||
/youtube https://www.youtube.com/@baukexyz
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
//! Logic for building and writing the SCSS.
|
||||
|
||||
use std::{
|
||||
fs::{create_dir_all, write},
|
||||
path::Path,
|
||||
|
@ -11,11 +9,9 @@ use rsass::{
|
|||
output::{Format, Style},
|
||||
};
|
||||
|
||||
/// Struct to contain functionality for building the SCSS.
|
||||
pub struct Scss;
|
||||
|
||||
impl Scss {
|
||||
/// Build the SCSS and write the CSS to their respective places.
|
||||
pub fn write(public_dir: &Path, source_dir: &Path) -> Result<()> {
|
||||
let css_dir = public_dir.join("css");
|
||||
create_dir_all(&css_dir)?;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
//! The main [`askama`] templates.
|
||||
|
||||
use std::{
|
||||
fs::{create_dir_all, write},
|
||||
path::Path,
|
||||
|
@ -8,16 +6,13 @@ use std::{
|
|||
use askama::Template;
|
||||
use color_eyre::Result;
|
||||
|
||||
/// The template for the home page.
|
||||
#[derive(Debug, Template)]
|
||||
#[template(path = "index.html")]
|
||||
pub struct Index {
|
||||
/// The text for the `<title>` element.
|
||||
pub page_title: String,
|
||||
}
|
||||
|
||||
impl Index {
|
||||
/// Build, minify and write the template.
|
||||
pub fn write(public_dir: &Path) -> Result<()> {
|
||||
let destination = public_dir.join("index.html");
|
||||
create_dir_all(destination.parent().unwrap())?;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
//! Custom filters for [`askama`] templates.
|
||||
/*!
|
||||
Filters for Askama templates.
|
||||
*/
|
||||
|
||||
/// Get the DRG mod link and title from a given ID.
|
||||
/**
|
||||
Get the DRG mod link and title from a given ID.
|
||||
*/
|
||||
pub fn drg_mod(mod_id: &str) -> askama::Result<(String, &str)> {
|
||||
let mods = std::collections::HashMap::<_, _>::from_iter([
|
||||
("brighter-objects", "Brighter Objects"),
|
||||
|
@ -12,13 +16,15 @@ pub fn drg_mod(mod_id: &str) -> askama::Result<(String, &str)> {
|
|||
Ok((format!("https://drg.mod.io/{mod_id}"), mod_title))
|
||||
}
|
||||
|
||||
/// Turn a timestamp with format `mm:ss` into its total seconds.
|
||||
///
|
||||
/// ## Examples
|
||||
///
|
||||
/// - `00:30` -> 30 seconds
|
||||
/// - `01:00` -> 60 seconds
|
||||
/// - `01:30` -> 90 seconds
|
||||
/**
|
||||
Turn a timestamp with format `mm:ss` into its total seconds.
|
||||
|
||||
## Examples
|
||||
|
||||
- `00:30` -> 30 seconds
|
||||
- `01:00` -> 60 seconds
|
||||
- `01:30` -> 90 seconds
|
||||
*/
|
||||
pub fn timestamp_to_seconds(timestamp: &str) -> askama::Result<i32> {
|
||||
let mut split = timestamp.split(':');
|
||||
let minutes = split.next().map(str::parse::<i32>).unwrap().unwrap();
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
//! Templates, data structures and logic for the video pages.
|
||||
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use {
|
||||
|
@ -10,7 +8,6 @@ use {
|
|||
|
||||
mod filters;
|
||||
|
||||
/// The template for videos.
|
||||
#[derive(Debug, Template)]
|
||||
#[template(path = "video.html")]
|
||||
pub struct VideoTemplate {
|
||||
|
@ -30,7 +27,6 @@ pub struct VideoTemplate {
|
|||
pub video_id: String,
|
||||
}
|
||||
|
||||
/// The frontmatter data for a video.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct VideoData {
|
||||
/// Deep Rock Galactic data.
|
||||
|
@ -50,7 +46,6 @@ pub struct VideoData {
|
|||
pub tags: Vec<String>,
|
||||
}
|
||||
|
||||
/// Data for speedrun videos.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct SpeedrunData {
|
||||
/// Video chapters as with timestamps and chapter titles.
|
||||
|
@ -66,14 +61,12 @@ pub struct SpeedrunData {
|
|||
pub mods: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
/// Additional data for Deep Rock Galactic videos.
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct DeepRockGalacticData {
|
||||
/// Deep Rock Galactic mods used in the run.
|
||||
pub mods: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
/// Compile and write all the found videos to their respective locations.
|
||||
pub fn write_all(public_dir: &Path) -> Result<()> {
|
||||
let video_datas = {
|
||||
let mut data = vec![];
|
||||
|
|
Loading…
Reference in New Issue