feat(*.liquid): apply prettier to liquid templates

- offer to create tag when none is found while adding a link from cli
- fix tag display in search
This commit is contained in:
Cory Dransfeldt 2025-06-16 14:40:54 -07:00
parent 49e21d574e
commit efe701f939
No known key found for this signature in database
112 changed files with 1319 additions and 1134 deletions

View file

@ -14,5 +14,7 @@ vendor/
# env
.env
# php
*.php
# liquid with non-standard syntax
**/*.php.liquid
**/feeds/*.liquid
**/meta/*.liquid

View file

@ -3,12 +3,13 @@
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf",
"proseWrap": "preserve",
"embeddedLanguageFormatting": "auto"
"embeddedLanguageFormatting": "auto",
"singleQuote": false,
"plugins": ["@shopify/prettier-plugin-liquid"]
}

View file

@ -1,42 +1,42 @@
#!/usr/bin/env node
import { program } from 'commander';
import chalk from 'chalk';
import figlet from 'figlet';
import { loadConfig } from '../lib/config.js';
import { handleExitError } from '../lib/handlers.js';
import { runRootScript } from '../lib/runScript.js';
import { runJobsMenu } from '../lib/jobs.js';
import { runTasksMenu } from '../lib/tasks/index.js';
import { program } from "commander";
import chalk from "chalk";
import figlet from "figlet";
import { loadConfig } from "../lib/config.js";
import { handleExitError } from "../lib/handlers.js";
import { runRootScript } from "../lib/runScript.js";
import { runJobsMenu } from "../lib/jobs.js";
import { runTasksMenu } from "../lib/tasks/index.js";
process.on('unhandledRejection', (err) => handleExitError(err, 'Unhandled rejection'));
process.on('uncaughtException', (err) => handleExitError(err, 'Uncaught exception'));
process.on("unhandledRejection", (err) => handleExitError(err, "Unhandled rejection"));
process.on("uncaughtException", (err) => handleExitError(err, "Uncaught exception"));
program
.name('coryd')
.description('🪄 Handle tasks, run commands or jobs, download things and have fun.')
.version('3.2.5');
.name("coryd")
.description("🪄 Handle tasks, run commands or jobs, download things and have fun.")
.version("3.2.5");
program
.command('init')
.description('Initialize CLI and populate required config.')
.command("init")
.description("Initialize CLI and populate required config.")
.action(async () => {
const { initConfig } = await import('../lib/config.js');
const { initConfig } = await import("../lib/config.js");
await initConfig();
});
program.command('run [script]').description('Run site scripts and commands.').action(runRootScript);
program.command('tasks').description('Handle repeated tasks.').action(runTasksMenu);
program.command('jobs').description('Trigger jobs and scripts.').action(runJobsMenu);
program.command("run [script]").description("Run site scripts and commands.").action(runRootScript);
program.command("tasks").description("Handle repeated tasks.").action(runTasksMenu);
program.command("jobs").description("Trigger jobs and scripts.").action(runJobsMenu);
program
.command('download')
.description('Download, name and store image assets.')
.command("download")
.description("Download, name and store image assets.")
.action(async () => {
const { downloadAsset } = await import('../lib/download.js');
const { downloadAsset } = await import("../lib/download.js");
await downloadAsset();
});
if (process.argv.length <= 2) {
const ascii = figlet.textSync('coryd.dev', { horizontalLayout: 'default' });
console.log(chalk.hex('#3364ff')(ascii));
const ascii = figlet.textSync("coryd.dev", { horizontalLayout: "default" });
console.log(chalk.hex("#3364ff")(ascii));
console.log();
program.outputHelp();
process.exit(0);

View file

@ -1,22 +1,22 @@
import fs from 'fs-extra';
import path from 'path';
import inquirer from 'inquirer';
import { fileURLToPath } from 'url';
import dotenv from 'dotenv';
import fs from "fs-extra";
import path from "path";
import inquirer from "inquirer";
import { fileURLToPath } from "url";
import dotenv from "dotenv";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(__dirname, '..');
const CACHE_DIR = path.join(rootDir, '.cache');
const CONFIG_PATH = path.join(CACHE_DIR, 'config.json');
const rootDir = path.resolve(__dirname, "..");
const CACHE_DIR = path.join(rootDir, ".cache");
const CONFIG_PATH = path.join(CACHE_DIR, "config.json");
export const MEDIA_TYPES = [
{ key: 'movie', label: 'movie', folder: 'movies' },
{ key: 'show', label: 'tv show', folder: 'shows' }
{ key: "movie", label: "movie", folder: "movies" },
{ key: "show", label: "tv show", folder: "shows" }
];
const ASSET_TYPES = ['poster', 'backdrop'];
const ASSET_TYPES = ["poster", "backdrop"];
dotenv.config({ path: path.resolve(__dirname, '..', '..', '.env') });
dotenv.config({ path: path.resolve(__dirname, "..", "..", ".env") });
export const initConfig = async () => {
const existingConfig = (await fs.pathExists(CONFIG_PATH)) ? await fs.readJson(CONFIG_PATH) : {};
@ -25,8 +25,8 @@ export const initConfig = async () => {
if (config.storageDir) {
const { updateStorage } = await inquirer.prompt([
{
type: 'confirm',
name: 'updateStorage',
type: "confirm",
name: "updateStorage",
message: `Storage directory is already set to "${config.storageDir}". Do you want to update it?`,
default: false
}
@ -35,8 +35,8 @@ export const initConfig = async () => {
if (updateStorage) {
const { storageDir } = await inquirer.prompt([
{
name: 'storageDir',
message: 'Where is your storage root directory?',
name: "storageDir",
message: "Where is your storage root directory?",
validate: fs.pathExists
}
]);
@ -46,8 +46,8 @@ export const initConfig = async () => {
} else {
const { storageDir } = await inquirer.prompt([
{
name: 'storageDir',
message: 'Where is your storage root directory?',
name: "storageDir",
message: "Where is your storage root directory?",
validate: fs.pathExists
}
]);
@ -57,9 +57,9 @@ export const initConfig = async () => {
const { customize } = await inquirer.prompt([
{
type: 'confirm',
name: 'customize',
message: 'Do you want to customize default media paths?',
type: "confirm",
name: "customize",
message: "Do you want to customize default media paths?",
default: false
}
]);
@ -70,14 +70,14 @@ export const initConfig = async () => {
config.mediaPaths[key] = {};
for (const assetType of ASSET_TYPES) {
const assetFolder = assetType === 'poster' ? '' : `/${assetType}s`;
const defaultPath = `Media assets/${folder}${assetFolder}`.replace(/\/$/, '');
const assetFolder = assetType === "poster" ? "" : `/${assetType}s`;
const defaultPath = `Media assets/${folder}${assetFolder}`.replace(/\/$/, "");
let subpath = defaultPath;
if (customize) {
const response = await inquirer.prompt([
{
name: 'subpath',
name: "subpath",
message: `Subpath for ${label}/${assetType} (relative to storage root):`,
default: defaultPath
}
@ -94,43 +94,43 @@ export const initConfig = async () => {
? (
await inquirer.prompt([
{
name: 'artistPath',
message: 'Subpath for artist images (relative to storage root):',
default: 'Media assets/artists'
name: "artistPath",
message: "Subpath for artist images (relative to storage root):",
default: "Media assets/artists"
}
])
).artistPath
: 'Media assets/artists';
: "Media assets/artists";
config.albumPath = customize
? (
await inquirer.prompt([
{
name: 'albumPath',
message: 'Subpath for album images (relative to storage root):',
default: 'Media assets/albums'
name: "albumPath",
message: "Subpath for album images (relative to storage root):",
default: "Media assets/albums"
}
])
).albumPath
: 'Media assets/albums';
: "Media assets/albums";
config.bookPath = customize
? (
await inquirer.prompt([
{
name: 'bookPath',
message: 'Subpath for book images (relative to storage root):',
default: 'Media assets/books'
name: "bookPath",
message: "Subpath for book images (relative to storage root):",
default: "Media assets/books"
}
])
).bookPath
: 'Media assets/books';
: "Media assets/books";
if (config.directus?.apiUrl) {
const { updateApiUrl } = await inquirer.prompt([
{
type: 'confirm',
name: 'updateApiUrl',
type: "confirm",
name: "updateApiUrl",
message: `Directus API URL is already set to "${config.directus.apiUrl}". Do you want to update it?`,
default: false
}
@ -139,9 +139,9 @@ export const initConfig = async () => {
if (updateApiUrl) {
const { apiUrl } = await inquirer.prompt([
{
name: 'apiUrl',
message: 'Enter your Directus instance URL:',
validate: (input) => input.startsWith('http') || 'Must be a valid URL'
name: "apiUrl",
message: "Enter your Directus instance URL:",
validate: (input) => input.startsWith("http") || "Must be a valid URL"
}
]);
@ -150,9 +150,9 @@ export const initConfig = async () => {
} else {
const { apiUrl } = await inquirer.prompt([
{
name: 'apiUrl',
message: 'Enter your Directus URL:',
validate: (input) => input.startsWith('http') || 'Must be a valid URL'
name: "apiUrl",
message: "Enter your Directus URL:",
validate: (input) => input.startsWith("http") || "Must be a valid URL"
}
]);
@ -171,7 +171,7 @@ export const initConfig = async () => {
export const loadConfig = async () => {
if (!(await fs.pathExists(CONFIG_PATH))) {
console.error('❌ Config not found. Run \`coryd init\` first.');
console.error("❌ Config not found. Run \`coryd init\` first.");
process.exit(1);
}
@ -183,15 +183,15 @@ const fetchGlobals = async () => {
const POSTGREST_API_KEY = process.env.POSTGREST_API_KEY;
if (!POSTGREST_URL || !POSTGREST_API_KEY) {
console.warn('⚠️ Missing POSTGREST_URL or POSTGREST_API_KEY in env, skipping globals fetch.');
console.warn("⚠️ Missing POSTGREST_URL or POSTGREST_API_KEY in env, skipping globals fetch.");
return {};
}
try {
const res = await fetch(`${POSTGREST_URL}/optimized_globals?select=*`, {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
});
@ -201,7 +201,7 @@ const fetchGlobals = async () => {
const data = await res.json();
return data[0] || {};
} catch (err) {
console.error('❌ Error fetching globals:', err.message);
console.error("❌ Error fetching globals:", err.message);
return {};
}
};

View file

@ -1,11 +1,11 @@
import path from 'path';
import { fileURLToPath } from 'url';
import dotenv from 'dotenv';
import { createDirectus, staticToken, rest } from '@directus/sdk';
import path from "path";
import { fileURLToPath } from "url";
import dotenv from "dotenv";
import { createDirectus, staticToken, rest } from "@directus/sdk";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
dotenv.config({ path: path.resolve(__dirname, '..', '..', '..', '.env') });
dotenv.config({ path: path.resolve(__dirname, "..", "..", "..", ".env") });
let directus;
let API_URL;
@ -15,13 +15,13 @@ export const initDirectusClient = (config) => {
const token = process.env.DIRECTUS_API_TOKEN;
if (!API_URL || !token) throw new Error('Missing Directus API URL or token.');
if (!API_URL || !token) throw new Error("Missing Directus API URL or token.");
directus = createDirectus(API_URL).with(staticToken(process.env.DIRECTUS_API_TOKEN)).with(rest());
};
export const getDirectusClient = () => {
if (!directus) throw new Error('Directus client not initialized.');
if (!directus) throw new Error("Directus client not initialized.");
return directus;
};
@ -31,7 +31,7 @@ const request = async (method, endpoint, body = null) => {
const res = await fetch(`${API_URL}/items/${endpoint}`, {
method,
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${API_TOKEN}`
},
body: body ? JSON.stringify(body) : null
@ -46,13 +46,13 @@ const request = async (method, endpoint, body = null) => {
return await res.json();
};
export const searchItems = async (collection, query = '', filters = {}) => {
export const searchItems = async (collection, query = "", filters = {}) => {
const API_TOKEN = process.env.DIRECTUS_API_TOKEN;
const params = new URLSearchParams();
if (query) params.append('search', query);
if (query) params.append("search", query);
params.append('limit', '50');
params.append("limit", "50");
for (const [field, value] of Object.entries(filters)) {
params.append(`filter[${field}][_eq]`, value);
@ -60,9 +60,9 @@ export const searchItems = async (collection, query = '', filters = {}) => {
try {
const res = await fetch(`${API_URL}/items/${collection}?${params.toString()}`, {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${API_TOKEN}`
}
});
@ -77,6 +77,6 @@ export const searchItems = async (collection, query = '', filters = {}) => {
};
export const updateItem = async (collection, id, values) =>
await request('PATCH', `${collection}/${id}`, values);
await request("PATCH", `${collection}/${id}`, values);
export const createItem = async (collection, values) => await request('POST', collection, values);
export const createItem = async (collection, values) => await request("POST", collection, values);

View file

@ -1,12 +1,12 @@
import inquirer from 'inquirer';
import { searchItems } from '../directus/client.js';
import inquirer from "inquirer";
import { searchItems } from "../directus/client.js";
export const promptForMultipleRelations = async (collection, label = collection) => {
const selectedIds = new Set();
while (true) {
const { query } = await inquirer.prompt({
name: 'query',
name: "query",
message: `🔍 Search ${label} (or leave blank to finish):`
});
const trimmed = query.trim();
@ -22,8 +22,8 @@ export const promptForMultipleRelations = async (collection, label = collection)
}
const { selected } = await inquirer.prompt({
type: 'checkbox',
name: 'selected',
type: "checkbox",
name: "selected",
message: `✔ Select ${label} to add:`,
choices: results.map((item) => ({
name: item.name || item.title || item.id,
@ -34,8 +34,8 @@ export const promptForMultipleRelations = async (collection, label = collection)
selected.forEach((id) => selectedIds.add(id));
const { again } = await inquirer.prompt({
type: 'confirm',
name: 'again',
type: "confirm",
name: "again",
message: `Search and add more ${label}?`,
default: false
});

View file

@ -1,10 +1,10 @@
import fs from 'fs-extra';
import path from 'path';
import https from 'https';
import inquirer from 'inquirer';
import { fileURLToPath } from 'url';
import { loadConfig, MEDIA_TYPES } from './config.js';
import { sanitizeMediaString } from './sanitize.js';
import fs from "fs-extra";
import path from "path";
import https from "https";
import inquirer from "inquirer";
import { fileURLToPath } from "url";
import { loadConfig, MEDIA_TYPES } from "./config.js";
import { sanitizeMediaString } from "./sanitize.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const downloadImage = (url, dest) =>
@ -17,19 +17,19 @@ const downloadImage = (url, dest) =>
return reject(new Error(`Failed to download. Status: ${response.statusCode}`));
response.pipe(file);
file.on('finish', () => file.close(resolve));
file.on("finish", () => file.close(resolve));
})
.on('error', reject);
.on("error", reject);
});
const isValidTMDBUrl = (val) =>
/^https:\/\/image\.tmdb\.org\/t\/p\//.test(val) || '❌ Must be a valid TMDB image url';
/^https:\/\/image\.tmdb\.org\/t\/p\//.test(val) || "❌ Must be a valid TMDB image url";
const overwriteImageDownloadPrompt = async (url, finalPath, fileName) => {
await fs.ensureDir(path.dirname(finalPath));
if (await fs.pathExists(finalPath)) {
const { overwrite } = await inquirer.prompt({
type: 'confirm',
name: 'overwrite',
type: "confirm",
name: "overwrite",
message: `${fileName} already exists. Overwrite?`,
default: false
});
@ -49,29 +49,29 @@ const overwriteImageDownloadPrompt = async (url, finalPath, fileName) => {
export const downloadWatchingImages = async () => {
const config = await loadConfig();
const { mediaType } = await inquirer.prompt({
type: 'list',
name: 'mediaType',
message: 'Movie or a tv show?',
type: "list",
name: "mediaType",
message: "Movie or a tv show?",
choices: MEDIA_TYPES.map(({ key, label }) => ({
name: label,
value: key
}))
});
const { tmdbId } = await inquirer.prompt({
name: 'tmdbId',
message: 'Enter the TMDB ID:'
name: "tmdbId",
message: "Enter the TMDB ID:"
});
if (!tmdbId) {
console.warn('⚠️ TMDB ID is required.');
console.warn("⚠️ TMDB ID is required.");
return;
}
const { posterUrl, backdropUrl } = await inquirer.prompt([
{
name: 'posterUrl',
message: 'Enter the poster url:',
name: "posterUrl",
message: "Enter the poster url:",
validate: (val) => {
if (!val) return true;
@ -79,8 +79,8 @@ export const downloadWatchingImages = async () => {
}
},
{
name: 'backdropUrl',
message: 'Enter the backdrop url:',
name: "backdropUrl",
message: "Enter the backdrop url:",
validate: (val) => {
if (!val) return true;
@ -89,14 +89,14 @@ export const downloadWatchingImages = async () => {
}
]);
const types = [
{ type: 'poster', url: posterUrl },
{ type: 'backdrop', url: backdropUrl }
{ type: "poster", url: posterUrl },
{ type: "backdrop", url: backdropUrl }
];
for (const { type, url } of types) {
if (!url) continue;
const ext = path.extname(new URL(url).pathname) || '.jpg';
const ext = path.extname(new URL(url).pathname) || ".jpg";
const fileName = `${type}-${tmdbId}${ext}`;
const targetSubPath = config.mediaPaths[mediaType][type];
@ -116,34 +116,34 @@ export const downloadWatchingImages = async () => {
export const downloadArtistImage = async () => {
const config = await loadConfig();
const { artistName } = await inquirer.prompt({
name: 'artistName',
message: 'Enter the artist name:'
name: "artistName",
message: "Enter the artist name:"
});
if (!artistName) {
console.warn('⚠️ Artist name is required.');
console.warn("⚠️ Artist name is required.");
return;
}
const { imageUrl } = await inquirer.prompt({
name: 'imageUrl',
message: 'Enter the artist image url:',
name: "imageUrl",
message: "Enter the artist image url:",
validate: (val) => {
try {
new URL(val);
return true;
} catch {
return '❌ Must be a valid url.';
return "❌ Must be a valid url.";
}
}
});
const sanitizedName = sanitizeMediaString(artistName);
const ext = path.extname(new URL(imageUrl).pathname) || '.jpg';
const ext = path.extname(new URL(imageUrl).pathname) || ".jpg";
const fileName = `${sanitizedName}${ext}`;
const targetDir = path.join(config.storageDir, 'artists');
const targetDir = path.join(config.storageDir, "artists");
const finalPath = path.join(targetDir, fileName);
await overwriteImageDownloadPrompt(imageUrl, finalPath, fileName);
@ -153,44 +153,44 @@ export const downloadAlbumImage = async () => {
const config = await loadConfig();
const { artistName } = await inquirer.prompt({
name: 'artistName',
message: 'Enter the artist name:'
name: "artistName",
message: "Enter the artist name:"
});
if (!artistName) {
console.warn('⚠️ Artist name is required.');
console.warn("⚠️ Artist name is required.");
return;
}
const { albumName } = await inquirer.prompt({
name: 'albumName',
message: 'Enter the album name:'
name: "albumName",
message: "Enter the album name:"
});
if (!albumName) {
console.warn('⚠️ Album name is required.');
console.warn("⚠️ Album name is required.");
return;
}
const { imageUrl } = await inquirer.prompt({
name: 'imageUrl',
message: 'Enter the album image url:',
name: "imageUrl",
message: "Enter the album image url:",
validate: (val) => {
try {
new URL(val);
return true;
} catch {
return '❌ Must be a valid url.';
return "❌ Must be a valid url.";
}
}
});
const artistSlug = sanitizeMediaString(artistName);
const albumSlug = sanitizeMediaString(albumName);
const ext = path.extname(new URL(imageUrl).pathname) || '.jpg';
const ext = path.extname(new URL(imageUrl).pathname) || ".jpg";
const fileName = `${artistSlug}-${albumSlug}${ext}`;
const targetDir = path.join(config.storageDir, config.albumPath);
const finalPath = path.join(targetDir, fileName);
@ -201,37 +201,37 @@ export const downloadAlbumImage = async () => {
export const downloadBookImage = async () => {
const config = await loadConfig();
const { isbn } = await inquirer.prompt({
name: 'isbn',
message: 'Enter the ISBN (no spaces):',
name: "isbn",
message: "Enter the ISBN (no spaces):",
validate: (val) =>
/^[a-zA-Z0-9-]+$/.test(val) || 'ISBN must contain only letters, numbers, or hyphens'
/^[a-zA-Z0-9-]+$/.test(val) || "ISBN must contain only letters, numbers, or hyphens"
});
const { bookTitle } = await inquirer.prompt({
name: 'bookTitle',
message: 'Enter the book title:'
name: "bookTitle",
message: "Enter the book title:"
});
if (!bookTitle) {
console.warn('⚠️ Book title is required.');
console.warn("⚠️ Book title is required.");
return;
}
const { imageUrl } = await inquirer.prompt({
name: 'imageUrl',
message: 'Enter the book cover image URL:',
name: "imageUrl",
message: "Enter the book cover image URL:",
validate: (val) => {
try {
new URL(val);
return true;
} catch {
return 'Must be a valid URL';
return "Must be a valid URL";
}
}
});
const titleSlug = sanitizeMediaString(bookTitle);
const ext = path.extname(new URL(imageUrl).pathname) || '.jpg';
const ext = path.extname(new URL(imageUrl).pathname) || ".jpg";
const fileName = `${isbn}-${titleSlug}${ext}`;
const targetDir = path.join(config.storageDir, config.bookPath);
const finalPath = path.join(targetDir, fileName);
@ -241,17 +241,17 @@ export const downloadBookImage = async () => {
export const downloadAsset = async () => {
const { type } = await inquirer.prompt({
type: 'list',
name: 'type',
message: 'What type of asset are you downloading?',
choices: ['movie/tv show', 'artist', 'album', 'book']
type: "list",
name: "type",
message: "What type of asset are you downloading?",
choices: ["movie/tv show", "artist", "album", "book"]
});
if (type === 'artist') {
if (type === "artist") {
await downloadArtistImage();
} else if (type === 'album') {
} else if (type === "album") {
await downloadAlbumImage();
} else if (type === 'book') {
} else if (type === "book") {
await downloadBookImage();
} else {
await downloadWatchingImages();

View file

@ -1,11 +1,11 @@
export const handleExitError = (err, type = 'Unhandled error') => {
export const handleExitError = (err, type = "Unhandled error") => {
const isExit =
err?.name === 'ExitPromptError' ||
err?.code === 'ERR_CANCELED' ||
err?.message?.includes('SIGINT');
err?.name === "ExitPromptError" ||
err?.code === "ERR_CANCELED" ||
err?.message?.includes("SIGINT");
if (isExit) {
console.log('\n👋 Exiting. Cya!\n');
console.log("\n👋 Exiting. Cya!\n");
process.exit(0);
}

View file

@ -1,110 +1,110 @@
import inquirer from 'inquirer';
import path from 'path';
import { fileURLToPath } from 'url';
import dotenv from 'dotenv';
import { loadConfig } from './config.js';
import inquirer from "inquirer";
import path from "path";
import { fileURLToPath } from "url";
import dotenv from "dotenv";
import { loadConfig } from "./config.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
dotenv.config({ path: path.resolve(__dirname, '..', '..', '.env') });
dotenv.config({ path: path.resolve(__dirname, "..", "..", ".env") });
export const runJobsMenu = async () => {
const config = await loadConfig();
const JOBS = [
{
name: '🛠 Rebuild site',
type: 'curl',
urlEnvVar: 'SITE_REBUILD_WEBHOOK',
tokenEnvVar: 'DIRECTUS_API_TOKEN',
method: 'GET'
name: "🛠 Rebuild site",
type: "curl",
urlEnvVar: "SITE_REBUILD_WEBHOOK",
tokenEnvVar: "DIRECTUS_API_TOKEN",
method: "GET"
},
{
name: '💿 Scrobble listens from Navidrome',
type: 'curl',
name: "💿 Scrobble listens from Navidrome",
type: "curl",
apiUrl: `${config.url}/api/scrobble.php`,
tokenEnvVar: 'NAVIDROME_SCROBBLE_TOKEN',
method: 'POST'
tokenEnvVar: "NAVIDROME_SCROBBLE_TOKEN",
method: "POST"
},
{
name: '🎧 Update total plays',
type: 'curl',
urlEnvVar: 'TOTAL_PLAYS_WEBHOOK',
tokenEnvVar: 'DIRECTUS_API_TOKEN',
method: 'GET'
name: "🎧 Update total plays",
type: "curl",
urlEnvVar: "TOTAL_PLAYS_WEBHOOK",
tokenEnvVar: "DIRECTUS_API_TOKEN",
method: "GET"
},
{
name: '🐘 Send posts to Mastodon',
type: 'curl',
name: "🐘 Send posts to Mastodon",
type: "curl",
apiUrl: `${config.url}/api/mastodon.php`,
tokenEnvVar: 'MASTODON_SYNDICATION_TOKEN',
method: 'POST'
tokenEnvVar: "MASTODON_SYNDICATION_TOKEN",
method: "POST"
},
{
name: '🎤 Import artist from Navidrome',
type: 'curl',
name: "🎤 Import artist from Navidrome",
type: "curl",
apiUrl: `${config.url}/api/artist-import.php`,
tokenEnvVar: 'ARTIST_IMPORT_TOKEN',
method: 'POST',
tokenEnvVar: "ARTIST_IMPORT_TOKEN",
method: "POST",
paramsPrompt: [
{
type: 'input',
name: 'artistId',
message: 'Enter the Navidrome artist ID:',
validate: (input) => (input ? true : 'Artist ID is required')
type: "input",
name: "artistId",
message: "Enter the Navidrome artist ID:",
validate: (input) => (input ? true : "Artist ID is required")
}
]
},
{
name: '📖 Import book',
type: 'curl',
name: "📖 Import book",
type: "curl",
apiUrl: `${config.url}/api/book-import.php`,
tokenEnvVar: 'BOOK_IMPORT_TOKEN',
method: 'POST',
tokenEnvVar: "BOOK_IMPORT_TOKEN",
method: "POST",
paramsPrompt: [
{
type: 'input',
name: 'isbn',
type: "input",
name: "isbn",
message: "Enter the book's ISBN:",
validate: (input) => (input ? true : 'ISBN is required')
validate: (input) => (input ? true : "ISBN is required")
}
]
},
{
name: '📽 Import a movie or tv show',
type: 'curl',
name: "📽 Import a movie or tv show",
type: "curl",
apiUrl: `${config.url}/api/watching-import.php`,
tokenEnvVar: 'WATCHING_IMPORT_TOKEN',
method: 'POST',
tokenEnvVar: "WATCHING_IMPORT_TOKEN",
method: "POST",
tokenIncludeInParams: true,
paramsPrompt: [
{
type: 'input',
name: 'tmdb_id',
message: 'Enter the TMDB ID:',
validate: (input) => (/^\d+$/.test(input) ? true : 'Please enter a valid TMDB ID')
type: "input",
name: "tmdb_id",
message: "Enter the TMDB ID:",
validate: (input) => (/^\d+$/.test(input) ? true : "Please enter a valid TMDB ID")
},
{
type: 'list',
name: 'media_type',
message: 'Is this a movie or tv show?',
choices: ['movie', 'tv']
type: "list",
name: "media_type",
message: "Is this a movie or tv show?",
choices: ["movie", "tv"]
}
]
},
{
name: '📺 Import upcoming TV seasons',
type: 'curl',
name: "📺 Import upcoming TV seasons",
type: "curl",
apiUrl: `${config.url}/api/seasons-import.php`,
tokenEnvVar: 'SEASONS_IMPORT_TOKEN',
method: 'POST'
tokenEnvVar: "SEASONS_IMPORT_TOKEN",
method: "POST"
}
];
const { selectedJob } = await inquirer.prompt([
{
type: 'list',
name: 'selectedJob',
message: 'Select a job to run:',
type: "list",
name: "selectedJob",
message: "Select a job to run:",
choices: JOBS.map((job, index) => ({
name: job.name,
value: index
@ -114,7 +114,7 @@ export const runJobsMenu = async () => {
const job = JOBS[selectedJob];
if (job.type === 'curl') {
if (job.type === "curl") {
let params = null;
if (job.paramsPrompt) {
@ -132,9 +132,9 @@ export const runJobsMenu = async () => {
const runCurl = async ({
urlEnvVar,
apiUrl = '',
apiUrl = "",
tokenEnvVar,
method = 'POST',
method = "POST",
name,
params = null
}) => {
@ -151,7 +151,7 @@ const runCurl = async ({
const res = await fetch(url, {
method,
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
...(token && { Authorization: `Bearer ${token}` })
},
...(params && { body: JSON.stringify(params) })

View file

@ -1,13 +1,13 @@
import fs from 'fs-extra';
import path from 'path';
import inquirer from 'inquirer';
import { execSync } from 'child_process';
import { fileURLToPath } from 'url';
import fs from "fs-extra";
import path from "path";
import inquirer from "inquirer";
import { execSync } from "child_process";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootDir = path.resolve(__dirname, '..', '..');
const packageJsonPath = path.join(rootDir, 'package.json');
const rootDir = path.resolve(__dirname, "..", "..");
const packageJsonPath = path.join(rootDir, "package.json");
export const runRootScript = async (scriptArg) => {
const pkg = await fs.readJson(packageJsonPath);
@ -17,9 +17,9 @@ export const runRootScript = async (scriptArg) => {
if (!script) {
const { selected } = await inquirer.prompt([
{
type: 'list',
name: 'selected',
message: 'Select a script to run:',
type: "list",
name: "selected",
message: "Select a script to run:",
choices: Object.keys(scripts)
}
]);
@ -34,7 +34,7 @@ export const runRootScript = async (scriptArg) => {
try {
execSync(`npm run ${script}`, {
stdio: 'inherit',
stdio: "inherit",
cwd: rootDir
});
} catch (err) {

View file

@ -1,11 +1,11 @@
import { transliterate } from 'transliteration';
import { transliterate } from "transliteration";
export const sanitizeMediaString = (input) => {
const ascii = transliterate(input);
const cleaned = ascii.replace(/[^a-zA-Z0-9\s-]/g, '');
const slugified = cleaned.replace(/[\s-]+/g, '-').toLowerCase();
const cleaned = ascii.replace(/[^a-zA-Z0-9\s-]/g, "");
const slugified = cleaned.replace(/[\s-]+/g, "-").toLowerCase();
return slugified.replace(/^-+|-+$/g, '');
return slugified.replace(/^-+|-+$/g, "");
};
export const removeUrlProtocol = (url) => (url ? url.replace(/^https?:\/\//, '') : '');
export const removeUrlProtocol = (url) => (url ? url.replace(/^https?:\/\//, "") : "");

View file

@ -1,38 +1,38 @@
import inquirer from 'inquirer';
import { loadConfig } from '../config.js';
import { initDirectusClient, searchItems, createItem } from '../directus/client.js';
import inquirer from "inquirer";
import { loadConfig } from "../config.js";
import { initDirectusClient, searchItems, createItem } from "../directus/client.js";
export const addBlockedRobot = async () => {
const config = await loadConfig();
initDirectusClient(config);
const robots = await searchItems('robots', '/');
let rootRobot = robots.find((r) => r.path === '/');
const robots = await searchItems("robots", "/");
let rootRobot = robots.find((r) => r.path === "/");
if (!rootRobot) {
console.log(' No robots entry for `/` found. Creating one...');
console.log(" No robots entry for `/` found. Creating one...");
const newRobot = await createItem('robots', { path: '/' });
const newRobot = await createItem("robots", { path: "/" });
rootRobot = newRobot.data || newRobot;
console.log('✅ Created robots rule for `/`');
console.log("✅ Created robots rule for `/`");
}
const { userAgent } = await inquirer.prompt({
name: 'userAgent',
message: '🤖 Enter the user-agent string to block:',
validate: (input) => !!input || 'User-agent cannot be empty'
name: "userAgent",
message: "🤖 Enter the user-agent string to block:",
validate: (input) => !!input || "User-agent cannot be empty"
});
const createdAgent = await createItem('user_agents', {
const createdAgent = await createItem("user_agents", {
user_agent: userAgent
});
const agentId = createdAgent.data?.id || createdAgent.id;
await createItem('robots_user_agents', {
await createItem("robots_user_agents", {
robots_id: rootRobot.id,
user_agents_id: agentId
});

View file

@ -1,12 +1,12 @@
import inquirer from 'inquirer';
import { loadConfig } from '../config.js';
import inquirer from "inquirer";
import { loadConfig } from "../config.js";
import {
initDirectusClient,
getDirectusClient,
searchItems,
createItem,
updateItem
} from '../directus/client.js';
} from "../directus/client.js";
export const addEpisodeToShow = async () => {
const config = await loadConfig();
@ -15,21 +15,21 @@ export const addEpisodeToShow = async () => {
const directus = getDirectusClient();
const showResults = await inquirer.prompt({
name: 'query',
message: 'Search for a show:'
name: "query",
message: "Search for a show:"
});
const matches = await searchItems('shows', showResults.query);
const matches = await searchItems("shows", showResults.query);
if (!matches.length) {
console.warn('⚠️ No matching shows found.');
console.warn("⚠️ No matching shows found.");
return;
}
const { showId } = await inquirer.prompt({
type: 'list',
name: 'showId',
message: 'Select a show:',
type: "list",
name: "showId",
message: "Select a show:",
choices: matches.map((s) => ({
name: s.title || s.name || s.id,
value: s.id
@ -37,23 +37,23 @@ export const addEpisodeToShow = async () => {
});
const { season_number, episode_number, plays } = await inquirer.prompt([
{
name: 'season_number',
message: 'Season number:',
name: "season_number",
message: "Season number:",
validate: (val) => !isNaN(val)
},
{
name: 'episode_number',
message: 'Episode number:',
name: "episode_number",
message: "Episode number:",
validate: (val) => !isNaN(val)
},
{
name: 'plays',
message: 'Play count:',
name: "plays",
message: "Play count:",
default: 0,
validate: (val) => !isNaN(val)
}
]);
const existing = await searchItems('episodes', `${season_number} ${episode_number}`);
const existing = await searchItems("episodes", `${season_number} ${episode_number}`);
const match = existing.find(
(e) =>
Number(e.season_number) === Number(season_number) &&
@ -63,21 +63,21 @@ export const addEpisodeToShow = async () => {
if (match) {
const { update } = await inquirer.prompt({
type: 'confirm',
name: 'update',
type: "confirm",
name: "update",
message: `Episode exists. Update play count from ${match.plays ?? 0} to ${plays}?`,
default: true
});
if (update) {
await updateItem('episodes', match.id, { plays });
await updateItem("episodes", match.id, { plays });
console.log(`✅ Updated episode: S${season_number}E${episode_number}`);
} else {
console.warn('⚠️ Skipped update.');
console.warn("⚠️ Skipped update.");
}
} else {
await createItem('episodes', {
await createItem("episodes", {
season_number: Number(season_number),
episode_number: Number(episode_number),
plays: Number(plays),

View file

@ -1,7 +1,7 @@
import inquirer from 'inquirer';
import { loadConfig } from '../config.js';
import { initDirectusClient, searchItems, createItem } from '../directus/client.js';
import { removeUrlProtocol } from '../sanitize.js';
import inquirer from "inquirer";
import { loadConfig } from "../config.js";
import { initDirectusClient, searchItems, createItem } from "../directus/client.js";
import { removeUrlProtocol } from "../sanitize.js";
export const addLinkToShare = async () => {
const config = await loadConfig();
@ -10,34 +10,34 @@ export const addLinkToShare = async () => {
const { title, link, description, authorQuery } = await inquirer.prompt([
{
name: 'title',
message: '📝 Title for the link:',
validate: (input) => !!input || 'Title is required'
name: "title",
message: "📝 Title for the link:",
validate: (input) => !!input || "Title is required"
},
{
name: 'link',
message: '🔗 URL to share:',
validate: (input) => input.startsWith('http') || 'Must be a valid URL'
name: "link",
message: "🔗 URL to share:",
validate: (input) => input.startsWith("http") || "Must be a valid URL"
},
{
name: 'description',
message: '🗒 Description (optional):',
default: ''
name: "description",
message: "🗒 Description (optional):",
default: ""
},
{
name: 'authorQuery',
message: '👤 Search for an author:'
name: "authorQuery",
message: "👤 Search for an author:"
}
]);
const authorMatches = await searchItems('authors', authorQuery);
const authorMatches = await searchItems("authors", authorQuery);
let author;
if (!authorMatches.length) {
const { shouldCreate } = await inquirer.prompt({
type: 'confirm',
name: 'shouldCreate',
message: '❌ No authors found. Do you want to create a new one?',
type: "confirm",
name: "shouldCreate",
message: "❌ No authors found. Do you want to create a new one?",
default: true
});
@ -45,19 +45,19 @@ export const addLinkToShare = async () => {
const { name, url, mastodon, rss, json, newsletter, blogroll } = await inquirer.prompt([
{
name: 'name',
message: '👤 Author name:',
validate: (input) => !!input || 'Name is required'
name: "name",
message: "👤 Author name:",
validate: (input) => !!input || "Name is required"
},
{ name: 'url', message: '🔗 URL (optional):', default: '' },
{ name: 'mastodon', message: '🐘 Mastodon handle (optional):', default: '' },
{ name: 'rss', message: '📡 RSS feed (optional):', default: '' },
{ name: 'json', message: '🧾 JSON feed (optional):', default: '' },
{ name: 'newsletter', message: '📰 Newsletter URL (optional):', default: '' },
{ type: 'confirm', name: 'blogroll', message: '📌 Add to blogroll?', default: false }
{ name: "url", message: "🔗 URL (optional):", default: "" },
{ name: "mastodon", message: "🐘 Mastodon handle (optional):", default: "" },
{ name: "rss", message: "📡 RSS feed (optional):", default: "" },
{ name: "json", message: "🧾 JSON feed (optional):", default: "" },
{ name: "newsletter", message: "📰 Newsletter URL (optional):", default: "" },
{ type: "confirm", name: "blogroll", message: "📌 Add to blogroll?", default: false }
]);
const created = await createItem('authors', {
const created = await createItem("authors", {
name,
url,
mastodon,
@ -70,9 +70,9 @@ export const addLinkToShare = async () => {
author = created.data?.id || created.id;
} else {
const response = await inquirer.prompt({
type: 'list',
name: 'author',
message: 'Select an author:',
type: "list",
name: "author",
message: "Select an author:",
choices: authorMatches.map((a) => {
const cleanUrl = removeUrlProtocol(a.url);
const display = cleanUrl ? `${a.name} (${cleanUrl})` : a.name;
@ -91,41 +91,64 @@ export const addLinkToShare = async () => {
while (true) {
const { query } = await inquirer.prompt({
name: 'query',
message: '🏷 Search for tags (or leave blank to finish):'
name: "query",
message: "🏷 Search for tags (or leave blank to finish):"
});
const trimmedQuery = query.trim();
if (!trimmedQuery) break;
const tags = await searchItems('tags', trimmedQuery);
const tags = await searchItems("tags", trimmedQuery);
if (!tags.length) {
console.warn(`⚠️ No tags found matching "${trimmedQuery}"`);
const { shouldCreateTag } = await inquirer.prompt({
type: "confirm",
name: "shouldCreateTag",
message: `Do you want to create a new tag named "${trimmedQuery}"?`,
default: true
});
if (shouldCreateTag) {
const createdTag = await createItem("tags", { name: trimmedQuery });
const newTagId = createdTag.data?.id || createdTag.id;
tagIds.push(newTagId);
}
const { again } = await inquirer.prompt({
type: "confirm",
name: "again",
message: "Search and select more tags?",
default: false
});
if (!again) break;
continue;
}
const { selected } = await inquirer.prompt({
type: 'checkbox',
name: 'selected',
message: '✔ Select tags to add:',
type: "checkbox",
name: "selected",
message: "✔ Select tags to add:",
choices: tags.map((tag) => ({ name: tag.name, value: tag.id }))
});
tagIds.push(...selected);
const { again } = await inquirer.prompt({
type: 'confirm',
name: 'again',
message: 'Search and select more tags?',
type: "confirm",
name: "again",
message: "Search and select more tags?",
default: false
});
if (!again) break;
}
await createItem('links', {
await createItem("links", {
title,
link,
description,
@ -134,5 +157,5 @@ export const addLinkToShare = async () => {
date: new Date().toISOString()
});
console.log('✅ Link created successfully.');
console.log("✅ Link created successfully.");
};

View file

@ -1,16 +1,16 @@
import inquirer from 'inquirer';
import { loadConfig } from '../config.js';
import { initDirectusClient, createItem, searchItems } from '../directus/client.js';
import { promptForMultipleRelations } from '../directus/relationHelpers.js';
import inquirer from "inquirer";
import { loadConfig } from "../config.js";
import { initDirectusClient, createItem, searchItems } from "../directus/client.js";
import { promptForMultipleRelations } from "../directus/relationHelpers.js";
const ASSOCIATED_MEDIA_TYPES = ['artists', 'books', 'movies', 'shows', 'genres'];
const ASSOCIATED_MEDIA_TYPES = ["artists", "books", "movies", "shows", "genres"];
const BLOCK_COLLECTIONS = [
'youtube_player',
'github_banner',
'npm_banner',
'rss_banner',
'calendar_banner',
'forgejo_banner'
"youtube_player",
"github_banner",
"npm_banner",
"rss_banner",
"calendar_banner",
"forgejo_banner"
];
export const addPost = async () => {
@ -20,24 +20,24 @@ export const addPost = async () => {
const { title, description, content, featured } = await inquirer.prompt([
{
name: 'title',
message: '📝 Title:',
validate: (input) => !!input || 'Title is required'
name: "title",
message: "📝 Title:",
validate: (input) => !!input || "Title is required"
},
{
name: 'description',
message: '🗒 Description:',
default: ''
name: "description",
message: "🗒 Description:",
default: ""
},
{
name: 'content',
message: '📄 Content:',
default: ''
name: "content",
message: "📄 Content:",
default: ""
},
{
type: 'confirm',
name: 'featured',
message: '⭐ Featured?',
type: "confirm",
name: "featured",
message: "⭐ Featured?",
default: false
}
]);
@ -46,14 +46,14 @@ export const addPost = async () => {
while (true) {
const { query } = await inquirer.prompt({
name: 'query',
message: '🏷 Search for tags (or leave blank to finish):'
name: "query",
message: "🏷 Search for tags (or leave blank to finish):"
});
const trimmedQuery = query.trim();
if (!trimmedQuery) break;
const tags = await searchItems('tags', trimmedQuery);
const tags = await searchItems("tags", trimmedQuery);
if (!tags.length) {
console.warn(`⚠️ No tags found matching "${trimmedQuery}"`);
@ -62,18 +62,18 @@ export const addPost = async () => {
}
const { selected } = await inquirer.prompt({
type: 'checkbox',
name: 'selected',
message: '✔ Select tags to add:',
type: "checkbox",
name: "selected",
message: "✔ Select tags to add:",
choices: tags.map((tag) => ({ name: tag.name, value: tag.id }))
});
tagIds.push(...selected);
const { again } = await inquirer.prompt({
type: 'confirm',
name: 'again',
message: 'Search and select more tags?',
type: "confirm",
name: "again",
message: "Search and select more tags?",
default: false
});
@ -82,25 +82,25 @@ export const addPost = async () => {
const selectedBlocks = [];
const { includeBlocks } = await inquirer.prompt({
type: 'confirm',
name: 'includeBlocks',
message: ' Add blocks?',
type: "confirm",
name: "includeBlocks",
message: " Add blocks?",
default: false
});
if (includeBlocks) {
while (true) {
const { collection } = await inquirer.prompt({
type: 'list',
name: 'collection',
message: '🧱 Choose a block collection (or Cancel to finish):',
choices: [...BLOCK_COLLECTIONS, new inquirer.Separator(), 'Cancel']
type: "list",
name: "collection",
message: "🧱 Choose a block collection (or Cancel to finish):",
choices: [...BLOCK_COLLECTIONS, new inquirer.Separator(), "Cancel"]
});
if (collection === 'Cancel') break;
if (collection === "Cancel") break;
const { query } = await inquirer.prompt({
name: 'query',
name: "query",
message: `🔍 Search ${collection}:`
});
const results = await searchItems(collection, query);
@ -112,8 +112,8 @@ export const addPost = async () => {
}
const { itemId } = await inquirer.prompt({
type: 'list',
name: 'itemId',
type: "list",
name: "itemId",
message: `Select an item from ${collection}:`,
choices: results.map((item) => ({
name: item.title || item.name || item.id,
@ -124,9 +124,9 @@ export const addPost = async () => {
selectedBlocks.push({ collection, item: itemId });
const { again } = await inquirer.prompt({
type: 'confirm',
name: 'again',
message: ' Add another block?',
type: "confirm",
name: "again",
message: " Add another block?",
default: false
});
@ -136,16 +136,16 @@ export const addPost = async () => {
const associatedMediaPayload = {};
const { includeMedia } = await inquirer.prompt({
type: 'confirm',
name: 'includeMedia',
message: ' Add associated media?',
type: "confirm",
name: "includeMedia",
message: " Add associated media?",
default: false
});
if (includeMedia) {
for (const mediaType of ASSOCIATED_MEDIA_TYPES) {
const { query } = await inquirer.prompt({
name: 'query',
name: "query",
message: `🔎 Search for ${mediaType} to associate (or leave blank to skip):`
});
@ -160,8 +160,8 @@ export const addPost = async () => {
}
const { selected } = await inquirer.prompt({
type: 'checkbox',
name: 'selected',
type: "checkbox",
name: "selected",
message: `✔ Select ${mediaType} to associate:`,
choices: matches.map((m) => ({
name: m.name_string || m.title || m.name || m.label || m.id,
@ -176,7 +176,7 @@ export const addPost = async () => {
}
}
const media = await promptForMultipleRelations('media', 'Associated media');
const media = await promptForMultipleRelations("media", "Associated media");
const payload = {
title,
description,
@ -188,7 +188,7 @@ export const addPost = async () => {
...associatedMediaPayload
};
await createItem('posts', payload);
await createItem("posts", payload);
console.log('✅ Post created successfully.');
console.log("✅ Post created successfully.");
};

View file

@ -1,24 +1,24 @@
import inquirer from 'inquirer';
import { addPost } from './addPost.js';
import { addLinkToShare } from './addLinkToShare.js';
import { addEpisodeToShow } from './addEpisodeToShow.js';
import { updateReadingProgress } from './updateReadingProgress.js';
import { addBlockedRobot } from './addBlockedRobot.js';
import inquirer from "inquirer";
import { addPost } from "./addPost.js";
import { addLinkToShare } from "./addLinkToShare.js";
import { addEpisodeToShow } from "./addEpisodeToShow.js";
import { updateReadingProgress } from "./updateReadingProgress.js";
import { addBlockedRobot } from "./addBlockedRobot.js";
const TASKS = [
{ name: '📄 Add post', handler: addPost },
{ name: '🔗 Add link to share', handler: addLinkToShare },
{ name: ' Add episode to show', handler: addEpisodeToShow },
{ name: '📚 Update reading progress', handler: updateReadingProgress },
{ name: '🤖 Block robot', handler: addBlockedRobot }
{ name: "📄 Add post", handler: addPost },
{ name: "🔗 Add link to share", handler: addLinkToShare },
{ name: " Add episode to show", handler: addEpisodeToShow },
{ name: "📚 Update reading progress", handler: updateReadingProgress },
{ name: "🤖 Block robot", handler: addBlockedRobot }
];
export const runTasksMenu = async () => {
const { task } = await inquirer.prompt([
{
type: 'list',
name: 'task',
message: 'Select a task to perform:',
type: "list",
name: "task",
message: "Select a task to perform:",
choices: TASKS.map((t) => ({ name: t.name, value: t.handler }))
}
]);

View file

@ -1,13 +1,13 @@
import inquirer from 'inquirer';
import { loadConfig } from '../config.js';
import { initDirectusClient, searchItems, updateItem } from '../directus/client.js';
import inquirer from "inquirer";
import { loadConfig } from "../config.js";
import { initDirectusClient, searchItems, updateItem } from "../directus/client.js";
export const updateReadingProgress = async () => {
const config = await loadConfig();
initDirectusClient(config);
const readingBooks = await searchItems('books', '', { read_status: 'started' });
const readingBooks = await searchItems("books", "", { read_status: "started" });
if (!readingBooks.length) {
console.log('📖 No books currently marked as "started".');
@ -16,9 +16,9 @@ export const updateReadingProgress = async () => {
}
const { bookId } = await inquirer.prompt({
type: 'list',
name: 'bookId',
message: '📚 Select a book to update progress:',
type: "list",
name: "bookId",
message: "📚 Select a book to update progress:",
choices: readingBooks.map((book) => {
const title = book.title || book.name || `Book #${book.id}`;
const progress = book.progress ?? 0;
@ -30,16 +30,16 @@ export const updateReadingProgress = async () => {
})
});
const { progress } = await inquirer.prompt({
name: 'progress',
message: '📕 New progress percentage (0100):',
name: "progress",
message: "📕 New progress percentage (0100):",
validate: (input) => {
const num = Number(input);
return (!isNaN(num) && num >= 0 && num <= 100) || 'Enter a number from 0 to 100';
return (!isNaN(num) && num >= 0 && num <= 100) || "Enter a number from 0 to 100";
}
});
await updateItem('books', bookId, { progress: Number(progress) });
await updateItem("books", bookId, { progress: Number(progress) });
console.log(`✅ Updated book progress to ${progress}%`);
};

4
cli/package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "coryd",
"version": "3.2.6",
"version": "3.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd",
"version": "3.2.6",
"version": "3.3.0",
"dependencies": {
"@directus/sdk": "^19.1.0",
"chalk": "^5.4.1",

View file

@ -1,6 +1,6 @@
{
"name": "coryd",
"version": "3.2.6",
"version": "3.3.0",
"description": "The CLI for my site to handle tasks, run commands or jobs and download things.",
"type": "module",
"bin": {

View file

@ -1,4 +1,4 @@
import ics from 'ics';
import ics from "ics";
export const albumReleasesCalendar = (collection) => {
const collectionData = collection.getAll()[0];
@ -8,7 +8,7 @@ export const albumReleasesCalendar = (collection) => {
globals: { url }
} = data;
if (!all || all.length === 0) return '';
if (!all || all.length === 0) return "";
const events = all
.map((album) => {
@ -16,15 +16,15 @@ export const albumReleasesCalendar = (collection) => {
if (isNaN(date.getTime())) return null;
const albumUrl = album.url?.includes('http') ? album.url : `${url}${album.url}`;
const artistUrl = album.artist.url?.includes('http')
const albumUrl = album.url?.includes("http") ? album.url : `${url}${album.url}`;
const artistUrl = album.artist.url?.includes("http")
? album.artust.url
: `${url}${album.artist.url}`;
return {
start: [date.getFullYear(), date.getMonth() + 1, date.getDate()],
startInputType: 'local',
startOutputType: 'local',
startInputType: "local",
startOutputType: "local",
title: `Release: ${album.artist.name} - ${album.title}`,
description: `Check out this new album release: ${albumUrl}. Read more about ${album.artist.name} at ${artistUrl}`,
url: albumUrl,
@ -34,12 +34,12 @@ export const albumReleasesCalendar = (collection) => {
.filter((event) => event !== null);
const { error, value } = ics.createEvents(events, {
calName: 'Album releases calendar • coryd.dev'
calName: "Album releases calendar • coryd.dev"
});
if (error) {
console.error('Error creating events: ', error);
return '';
console.error("Error creating events: ", error);
return "";
}
return value;

View file

@ -1,9 +1,9 @@
import fs from 'fs';
import path from 'path';
import { minify } from 'terser';
import fs from "fs";
import path from "path";
import { minify } from "terser";
export const minifyJsComponents = async () => {
const scriptsDir = 'dist/assets/scripts';
const scriptsDir = "dist/assets/scripts";
const minifyJsFilesInDir = async (dir) => {
const files = fs.readdirSync(dir);
@ -13,8 +13,8 @@ export const minifyJsComponents = async () => {
if (stat.isDirectory()) {
await minifyJsFilesInDir(filePath);
} else if (fileName.endsWith('.js')) {
const fileContent = fs.readFileSync(filePath, 'utf8');
} else if (fileName.endsWith(".js")) {
const fileContent = fs.readFileSync(filePath, "utf8");
const minified = await minify(fileContent);
if (minified.error) {

View file

@ -1,4 +1,4 @@
import * as cheerio from 'cheerio';
import * as cheerio from "cheerio";
export default {
convertRelativeLinks: (htmlContent, domain) => {
@ -6,32 +6,32 @@ export default {
const $ = cheerio.load(htmlContent);
$('a[href]').each((_, link) => {
$("a[href]").each((_, link) => {
const $link = $(link);
let href = $link.attr('href');
let href = $link.attr("href");
if (href.startsWith('#')) {
$link.replaceWith($('<span>').text($link.text()));
} else if (!href.startsWith('http://') && !href.startsWith('https://')) {
const normalizedDomain = domain.replace(/\/$/, '');
const normalizedHref = href.replace(/^\/+/, '');
$link.attr('href', `${normalizedDomain}/${normalizedHref}`);
if (href.startsWith("#")) {
$link.replaceWith($("<span>").text($link.text()));
} else if (!href.startsWith("http://") && !href.startsWith("https://")) {
const normalizedDomain = domain.replace(/\/$/, "");
const normalizedHref = href.replace(/^\/+/, "");
$link.attr("href", `${normalizedDomain}/${normalizedHref}`);
}
});
return $.html();
},
generatePermalink: (url, baseUrl) => {
if (url?.includes('http') || !baseUrl) return url;
if (url?.includes("http") || !baseUrl) return url;
return `${baseUrl}${url}`;
},
getRemoteFileSize: async (url) => {
try {
const response = await fetch(url, { method: 'HEAD' });
const response = await fetch(url, { method: "HEAD" });
if (!response.ok) return 0;
const contentLength = response.headers.get('content-length');
const contentLength = response.headers.get("content-length");
if (!contentLength) return 0;

View file

@ -1,22 +1,22 @@
import truncateHtml from 'truncate-html';
import truncateHtml from "truncate-html";
export default {
encodeAmp: (string) => {
if (!string) return;
const pattern = /&(?!(?:[a-zA-Z]+|#[0-9]+|#x[0-9a-fA-F]+);)/g;
const replacement = '&amp;';
const replacement = "&amp;";
return string.replace(pattern, replacement);
},
replaceQuotes: (string) => {
if (!string) return '';
return string.replace(/"/g, '&quot;');
if (!string) return "";
return string.replace(/"/g, "&quot;").replace(/'/g, "&#39;");
},
htmlTruncate: (content, limit = 50) =>
truncateHtml(content, limit, {
byWords: true,
ellipsis: '...'
ellipsis: "..."
}),
shuffleArray: (array) => {
const shuffled = [...array];
@ -32,12 +32,12 @@ export default {
},
mergeArray: (a, b) => (Array.isArray(a) && Array.isArray(b) ? [...new Set([...a, ...b])] : []),
pluralize: (count, string, trailing) => {
const countStr = String(count).replace(/,/g, '');
const countStr = String(count).replace(/,/g, "");
if (parseInt(countStr, 10) === 1) return string;
return `${string}s${trailing ? `${trailing}` : ''}`;
return `${string}s${trailing ? `${trailing}` : ""}`;
},
jsonEscape: (string) => JSON.stringify(string),
regexEscape: (string) => string.replace(/[.*+?^${}()[]\\]/g, '\\$&')
regexEscape: (string) => string.replace(/[.*+?^${}()[]\\]/g, "\\$&")
};

View file

@ -1,8 +1,8 @@
import feeds from './feeds.js';
import general from './general.js';
import media from './media.js';
import metadata from './metadata.js';
import navigation from './navigation.js';
import feeds from "./feeds.js";
import general from "./general.js";
import media from "./media.js";
import metadata from "./metadata.js";
import navigation from "./navigation.js";
export default {
...feeds,

View file

@ -7,12 +7,12 @@ export default {
.map(
(year, index) =>
`<a href="/reading/years/${year.value}">${year.value}</a>${
index < years.length - 1 ? ' • ' : ''
index < years.length - 1 ? " • " : ""
}`
)
.join(''),
.join(""),
mediaLinks: (data, type, count = 10) => {
if (!data || !type) return '';
if (!data || !type) return "";
const dataSlice = data.slice(0, count);
@ -20,21 +20,21 @@ export default {
const buildLink = (item) => {
switch (type) {
case 'genre':
case "genre":
return `<a href="${item.genre_url}">${item.genre_name}</a>`;
case 'artist':
case "artist":
return `<a href="${item.url}">${item.name}</a>`;
case 'book':
case "book":
return `<a href="${item.url}">${item.title}</a>`;
default:
return '';
return "";
}
};
if (dataSlice.length === 1) return buildLink(dataSlice[0]);
const links = dataSlice.map(buildLink);
const allButLast = links.slice(0, -1).join(', ');
const allButLast = links.slice(0, -1).join(", ");
const last = links[links.length - 1];
return `${allButLast} and ${last}`;

View file

@ -1,8 +1,8 @@
export default {
getMetadata: (data = {}, globals = {}, page = {}, title = '', description = '', schema = '') => {
getMetadata: (data = {}, globals = {}, page = {}, title = "", description = "", schema = "") => {
const metadata = data?.metadata;
const baseUrl = globals.url || '';
const ogPath = '/og/w800';
const baseUrl = globals.url || "";
const ogPath = "/og/w800";
const image =
metadata?.open_graph_image || globals.metadata?.open_graph_image || globals.avatar;
const rawTitle = title || page.title || metadata?.title || globals.site_name;
@ -10,7 +10,7 @@ export default {
rawTitle === globals.site_name ? globals.site_name : `${rawTitle}${globals.site_name}`;
const resolvedDescription =
description || metadata?.description || page.description || globals.site_description;
const url = metadata?.url || (page.url ? `${baseUrl}${page.url}` : '#');
const url = metadata?.url || (page.url ? `${baseUrl}${page.url}` : "#");
return {
title: resolvedTitle,

View file

@ -1,11 +1,11 @@
const normalizeUrl = (url) =>
url.replace(/index\.php$|index\.html$/i, '').replace(/\.php$|\.html$/i, '') || '/';
url.replace(/index\.php$|index\.html$/i, "").replace(/\.php$|\.html$/i, "") || "/";
export default {
isLinkActive: (category, page) => {
const normalized = normalizeUrl(page);
return (
normalized.includes(category) && normalized.split('/').filter((a) => a !== '').length <= 1
normalized.includes(category) && normalized.split("/").filter((a) => a !== "").length <= 1
);
},
normalizeUrl

View file

@ -1,18 +1,18 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import postcss from 'postcss';
import postcssImport from 'postcss-import';
import postcssImportExtGlob from 'postcss-import-ext-glob';
import cssnano from 'cssnano';
import fs from "node:fs/promises";
import path from "node:path";
import postcss from "postcss";
import postcssImport from "postcss-import";
import postcssImportExtGlob from "postcss-import-ext-glob";
import cssnano from "cssnano";
export const cssConfig = (eleventyConfig) => {
eleventyConfig.addTemplateFormats('css');
eleventyConfig.addExtension('css', {
outputFileExtension: 'css',
eleventyConfig.addTemplateFormats("css");
eleventyConfig.addExtension("css", {
outputFileExtension: "css",
compile: async (inputContent, inputPath) => {
const outputPath = 'dist/assets/css/index.css';
const outputPath = "dist/assets/css/index.css";
if (inputPath.endsWith('index.css')) {
if (inputPath.endsWith("index.css")) {
return async () => {
let result = await postcss([postcssImportExtGlob, postcssImport, cssnano]).process(
inputContent,

View file

@ -1,8 +1,8 @@
import htmlmin from 'html-minifier-terser';
import htmlmin from "html-minifier-terser";
export const htmlConfig = (eleventyConfig) => {
eleventyConfig.addTransform('html-minify', (content, path) => {
if (path && path.endsWith('.html')) {
eleventyConfig.addTransform("html-minify", (content, path) => {
if (path && path.endsWith(".html")) {
return htmlmin.minify(content, {
collapseBooleanAttributes: true,
collapseWhitespace: true,

View file

@ -1,5 +1,5 @@
import { cssConfig } from './css-config.js';
import { htmlConfig } from './html-config.js';
import { markdownLib } from './markdown.js';
import { cssConfig } from "./css-config.js";
import { htmlConfig } from "./html-config.js";
import { markdownLib } from "./markdown.js";
export default { cssConfig, htmlConfig, markdownLib };

View file

@ -1,8 +1,8 @@
import markdownIt from 'markdown-it';
import markdownItAnchor from 'markdown-it-anchor';
import markdownItFootnote from 'markdown-it-footnote';
import markdownItLinkAttributes from 'markdown-it-link-attributes';
import markdownItPrism from 'markdown-it-prism';
import markdownIt from "markdown-it";
import markdownItAnchor from "markdown-it-anchor";
import markdownItFootnote from "markdown-it-footnote";
import markdownItLinkAttributes from "markdown-it-link-attributes";
import markdownItPrism from "markdown-it-prism";
export const markdownLib = markdownIt({ html: true, linkify: true })
.use(markdownItAnchor, {
@ -17,7 +17,7 @@ export const markdownLib = markdownIt({ html: true, linkify: true })
return href.match(/^https?:\/\//);
},
attrs: {
rel: 'noopener'
rel: "noopener"
}
}
])

View file

@ -1,13 +1,13 @@
import { createRequire } from 'module';
import 'dotenv/config';
import filters from './config/filters/index.js';
import tablerIcons from '@cdransf/eleventy-plugin-tabler-icons';
import { minifyJsComponents } from './config/events/minify-js.js';
import { albumReleasesCalendar } from './config/collections/index.js';
import plugins from './config/plugins/index.js';
import { createRequire } from "module";
import "dotenv/config";
import filters from "./config/filters/index.js";
import tablerIcons from "@cdransf/eleventy-plugin-tabler-icons";
import { minifyJsComponents } from "./config/events/minify-js.js";
import { albumReleasesCalendar } from "./config/collections/index.js";
import plugins from "./config/plugins/index.js";
const require = createRequire(import.meta.url);
const appVersion = require('./package.json').version;
const appVersion = require("./package.json").version;
export default async function (eleventyConfig) {
eleventyConfig.addPlugin(tablerIcons);
@ -18,22 +18,22 @@ export default async function (eleventyConfig) {
eleventyConfig.configureErrorReporting({ allowMissingExtensions: true });
eleventyConfig.setLiquidOptions({ jsTruthy: true });
eleventyConfig.watchIgnores.add('queries/**');
eleventyConfig.watchIgnores.add("queries/**");
eleventyConfig.addPassthroughCopy('src/assets');
eleventyConfig.addPassthroughCopy('api');
eleventyConfig.addPassthroughCopy('bootstrap.php');
eleventyConfig.addPassthroughCopy("src/assets");
eleventyConfig.addPassthroughCopy("api");
eleventyConfig.addPassthroughCopy("bootstrap.php");
eleventyConfig.addPassthroughCopy({
'node_modules/minisearch/dist/umd/index.js': 'assets/scripts/components/minisearch.js',
'node_modules/youtube-video-element/dist/youtube-video-element.js':
'assets/scripts/components/youtube-video-element.js'
"node_modules/minisearch/dist/umd/index.js": "assets/scripts/components/minisearch.js",
"node_modules/youtube-video-element/dist/youtube-video-element.js":
"assets/scripts/components/youtube-video-element.js"
});
eleventyConfig.addCollection('albumReleasesCalendar', albumReleasesCalendar);
eleventyConfig.addCollection("albumReleasesCalendar", albumReleasesCalendar);
eleventyConfig.setLibrary('md', plugins.markdownLib);
eleventyConfig.setLibrary("md", plugins.markdownLib);
eleventyConfig.addLiquidFilter('markdown', (content) => {
eleventyConfig.addLiquidFilter("markdown", (content) => {
if (!content) return;
return plugins.markdownLib.render(content);
});
@ -42,17 +42,17 @@ export default async function (eleventyConfig) {
eleventyConfig.addLiquidFilter(filterName, filters[filterName]);
});
eleventyConfig.addShortcode('appVersion', () => appVersion);
eleventyConfig.addShortcode("appVersion", () => appVersion);
eleventyConfig.on('afterBuild', minifyJsComponents);
eleventyConfig.on("afterBuild", minifyJsComponents);
return {
dir: {
input: 'src',
includes: 'includes',
layouts: 'layouts',
data: 'data',
output: 'dist'
input: "src",
includes: "includes",
layouts: "layouts",
data: "data",
output: "dist"
}
};
}

86
package-lock.json generated
View file

@ -16,6 +16,7 @@
"@11ty/eleventy": "3.1.1",
"@11ty/eleventy-fetch": "5.1.0",
"@cdransf/eleventy-plugin-tabler-icons": "^2.13.1",
"@shopify/prettier-plugin-liquid": "1.9.3",
"cheerio": "1.1.0",
"concurrently": "9.1.2",
"cssnano": "^7.0.7",
@ -235,9 +236,9 @@
}
},
"node_modules/@11ty/recursive-copy": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@11ty/recursive-copy/-/recursive-copy-4.0.1.tgz",
"integrity": "sha512-Zsg1xgfdVTMKNPj9o4FZeYa73dFZRX856CL4LsmqPMvDr0TuIK4cH9CVWJyf0OkNmM8GmlibGX18fF0B75Rn1w==",
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@11ty/recursive-copy/-/recursive-copy-4.0.2.tgz",
"integrity": "sha512-174nFXxL/6KcYbLYpra+q3nDbfKxLxRTNVY1atq2M1pYYiPfHse++3IFNl8mjPFsd7y2qQjxLORzIjHMjL3NDQ==",
"dev": true,
"license": "ISC",
"dependencies": {
@ -466,6 +467,31 @@
"node": ">=14.0.0"
}
},
"node_modules/@shopify/liquid-html-parser": {
"version": "2.8.2",
"resolved": "https://registry.npmjs.org/@shopify/liquid-html-parser/-/liquid-html-parser-2.8.2.tgz",
"integrity": "sha512-g8DRcz4wUj4Ttxm+rK1qPuvIV2/ZqlyGRcVytVMbUkrr/+eVL2yQI/jRGDMeOamkRqB3InuoOjF7nARH+o9UYQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"line-column": "^1.0.2",
"ohm-js": "^16.3.0"
}
},
"node_modules/@shopify/prettier-plugin-liquid": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/@shopify/prettier-plugin-liquid/-/prettier-plugin-liquid-1.9.3.tgz",
"integrity": "sha512-XRRnwfONrzjW8AY/l39szH9OgCCg5Xx61QxxdrC3BT2RAqo229jomjhCEszGIUJ5YZYq1ewdyBwbvUVTUSTcTg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@shopify/liquid-html-parser": "^2.8.2",
"html-styles": "^1.0.0"
},
"peerDependencies": {
"prettier": "^2.0.0 || ^3.0.0"
}
},
"node_modules/@sindresorhus/slugify": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@sindresorhus/slugify/-/slugify-2.2.1.tgz",
@ -1655,9 +1681,9 @@
"license": "MIT"
},
"node_modules/electron-to-chromium": {
"version": "1.5.167",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.167.tgz",
"integrity": "sha512-LxcRvnYO5ez2bMOFpbuuVuAI5QNeY1ncVytE/KXaL6ZNfzX1yPlAO0nSOyIHx2fVAuUprMqPs/TdVhUFZy7SIQ==",
"version": "1.5.168",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.168.tgz",
"integrity": "sha512-RUNQmFLNIWVW6+z32EJQ5+qx8ci6RGvdtDC0Ls+F89wz6I2AthpXF0w0DIrn2jpLX0/PU9ZCo+Qp7bg/EckJmA==",
"dev": true,
"license": "ISC"
},
@ -2150,6 +2176,13 @@
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/html-styles": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/html-styles/-/html-styles-1.0.0.tgz",
"integrity": "sha512-cDl5dcj73oI4Hy0DSUNh54CAwslNLJRCCoO+RNkVo+sBrjA/0+7E/xzvj3zH/GxbbBLGJhE0hBe1eg+0FINC6w==",
"dev": true,
"license": "MIT"
},
"node_modules/htmlparser2": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-10.0.0.tgz",
@ -2405,6 +2438,13 @@
"node": ">=0.12.0"
}
},
"node_modules/isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"dev": true,
"license": "MIT"
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -2422,6 +2462,19 @@
"node": ">=6.0"
}
},
"node_modules/isobject": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
"integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==",
"dev": true,
"license": "MIT",
"dependencies": {
"isarray": "1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/jackspeak": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz",
@ -2538,6 +2591,17 @@
"url": "https://github.com/sponsors/antonk52"
}
},
"node_modules/line-column": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/line-column/-/line-column-1.0.2.tgz",
"integrity": "sha512-Ktrjk5noGYlHsVnYWh62FLVs4hTb8A3e+vucNZMgPeAOITdshMSgv4cCZQeRDjm7+goqmo6+liZwTXo+U3sVww==",
"dev": true,
"license": "MIT",
"dependencies": {
"isarray": "^1.0.0",
"isobject": "^2.0.0"
}
},
"node_modules/linkify-it": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
@ -3769,6 +3833,16 @@
"node": ">= 6"
}
},
"node_modules/ohm-js": {
"version": "16.6.0",
"resolved": "https://registry.npmjs.org/ohm-js/-/ohm-js-16.6.0.tgz",
"integrity": "sha512-X9P4koSGa7swgVQ0gt71UCYtkAQGOjciJPJAz74kDxWt8nXbH5HrDOQG6qBDH7SR40ktNv4x61BwpTDE9q4lRA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.12.1"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "10.6.7",
"version": "10.7.0",
"description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module",
"engines": {
@ -13,7 +13,7 @@
"php": "export $(grep -v '^#' .env | xargs) && php -d error_reporting=E_ALL^E_DEPRECATED -S localhost:8080 -t dist",
"build": "eleventy",
"clean": "rimraf dist .cache",
"format": "npx prettier --write '**/*.{js,json,css,md}' && composer format:php && npm run format:sql",
"format": "npx prettier --write '**/*.{js,json,css,md,liquid}' && composer format:php && npm run format:sql",
"format:sql": "find queries -name '*.sql' -print0 | xargs -0 -n 1 sql-formatter --language postgresql --fix",
"lint:md": "markdownlint '**/*.md'",
"update": "composer update && npm upgrade && npm --prefix cli upgrade && ncu && ncu --cwd cli",
@ -22,7 +22,7 @@
"prepare": "husky"
},
"lint-staged": {
"*.{js,json,css,md}": "prettier --write",
"*.{js,json,css,md,liquid}": "prettier --write",
"*.php": "composer format:php",
"*.md": "markdownlint"
},
@ -45,6 +45,7 @@
"@11ty/eleventy": "3.1.1",
"@11ty/eleventy-fetch": "5.1.0",
"@cdransf/eleventy-plugin-tabler-icons": "^2.13.1",
"@shopify/prettier-plugin-liquid": "1.9.3",
"cheerio": "1.1.0",
"concurrently": "9.1.2",
"cssnano": "^7.0.7",

View file

@ -1,31 +1,31 @@
class SelectPagination extends HTMLElement {
static register(tagName = 'select-pagination') {
if ('customElements' in window) customElements.define(tagName, this);
static register(tagName = "select-pagination") {
if ("customElements" in window) customElements.define(tagName, this);
}
static get observedAttributes() {
return ['data-base-index'];
return ["data-base-index"];
}
get baseIndex() {
return parseInt(this.getAttribute('data-base-index') || '0', 10);
return parseInt(this.getAttribute("data-base-index") || "0", 10);
}
connectedCallback() {
if (this.shadowRoot) return;
this.attachShadow({ mode: 'open' }).appendChild(document.createElement('slot'));
this.attachShadow({ mode: "open" }).appendChild(document.createElement("slot"));
const uriSegments = window.location.pathname.split('/').filter(Boolean);
const uriSegments = window.location.pathname.split("/").filter(Boolean);
let pageNumber = this.extractPageNumber(uriSegments);
if (pageNumber === null) pageNumber = this.baseIndex;
this.control = this.querySelector('select');
this.control = this.querySelector("select");
this.control.value = pageNumber.toString();
this.control.addEventListener('change', (event) => {
this.control.addEventListener("change", (event) => {
pageNumber = parseInt(event.target.value);
const updatedUrlSegments = this.updateUrlSegments(uriSegments, pageNumber);
window.location.href = `${window.location.origin}/${updatedUrlSegments.join('/')}`;
window.location.href = `${window.location.origin}/${updatedUrlSegments.join("/")}`;
});
}

View file

@ -1,66 +1,66 @@
window.addEventListener('load', () => {
window.addEventListener("load", () => {
// service worker
if ('serviceWorker' in navigator) navigator.serviceWorker.register('/assets/scripts/sw.js');
if ("serviceWorker" in navigator) navigator.serviceWorker.register("/assets/scripts/sw.js");
// dialog controls
(() => {
const dialogButtons = document.querySelectorAll('.dialog-open');
const dialogButtons = document.querySelectorAll(".dialog-open");
if (!dialogButtons.length) return;
dialogButtons.forEach((button) => {
const dialogId = button.getAttribute('data-dialog-trigger');
const dialogId = button.getAttribute("data-dialog-trigger");
const dialog = document.getElementById(`dialog-${dialogId}`);
if (!dialog) return;
const closeButton = dialog.querySelector('.dialog-close');
const closeButton = dialog.querySelector(".dialog-close");
button.addEventListener('click', async () => {
button.addEventListener("click", async () => {
const isDynamic = dialog.dataset.dynamic;
const isLoaded = dialog.dataset.loaded;
if (isDynamic && !isLoaded) {
const markdownFields = dialog.dataset.markdown || '';
const markdownFields = dialog.dataset.markdown || "";
try {
const res = await fetch(
`/api/query.php?data=${isDynamic}&id=${dialogId}&markdown=${encodeURIComponent(markdownFields)}`
);
const [data] = await res.json();
const firstField = markdownFields.split(',')[0]?.trim();
const html = data?.[`${firstField}_html`] || '<p>No notes available.</p>';
const firstField = markdownFields.split(",")[0]?.trim();
const html = data?.[`${firstField}_html`] || "<p>No notes available.</p>";
dialog.querySelectorAll('.dialog-dynamic').forEach((el) => el.remove());
dialog.querySelectorAll(".dialog-dynamic").forEach((el) => el.remove());
const container = document.createElement('div');
const container = document.createElement("div");
container.classList.add('dialog-dynamic');
container.classList.add("dialog-dynamic");
container.innerHTML = html;
dialog.appendChild(container);
dialog.dataset.loaded = 'true';
dialog.dataset.loaded = "true";
} catch (err) {
dialog.querySelectorAll('.dialog-dynamic').forEach((el) => el.remove());
dialog.querySelectorAll(".dialog-dynamic").forEach((el) => el.remove());
const errorNode = document.createElement('div');
const errorNode = document.createElement("div");
errorNode.classList.add('dialog-dynamic');
errorNode.textContent = 'Failed to load content.';
errorNode.classList.add("dialog-dynamic");
errorNode.textContent = "Failed to load content.";
dialog.appendChild(errorNode);
console.warn('Dialog content load error:', err);
console.warn("Dialog content load error:", err);
}
}
dialog.showModal();
dialog.classList.remove('closing');
dialog.classList.remove("closing");
});
if (closeButton) {
closeButton.addEventListener('click', () => {
dialog.classList.add('closing');
closeButton.addEventListener("click", () => {
dialog.classList.add("closing");
setTimeout(() => dialog.close(), 200);
});
}
dialog.addEventListener('click', (event) => {
dialog.addEventListener("click", (event) => {
const rect = dialog.getBoundingClientRect();
const outsideClick =
event.clientX < rect.left ||
@ -69,14 +69,14 @@ window.addEventListener('load', () => {
event.clientY > rect.bottom;
if (outsideClick) {
dialog.classList.add('closing');
dialog.classList.add("closing");
setTimeout(() => dialog.close(), 200);
}
});
dialog.addEventListener('cancel', (event) => {
dialog.addEventListener("cancel", (event) => {
event.preventDefault();
dialog.classList.add('closing');
dialog.classList.add("closing");
setTimeout(() => dialog.close(), 200);
});
});
@ -84,23 +84,23 @@ window.addEventListener('load', () => {
// text toggle for media pages
(() => {
const button = document.querySelector('[data-toggle-button]');
const content = document.querySelector('[data-toggle-content]');
const text = document.querySelectorAll('[data-toggle-content] p');
const button = document.querySelector("[data-toggle-button]");
const content = document.querySelector("[data-toggle-content]");
const text = document.querySelectorAll("[data-toggle-content] p");
const minHeight = 500; // this needs to match the height set on [data-toggle-content].text-toggle-hidden in text-toggle.css
const interiorHeight = Array.from(text).reduce((acc, node) => acc + node.scrollHeight, 0);
if (!button || !content || !text.length) return;
if (interiorHeight < minHeight) {
content.classList.remove('text-toggle-hidden');
button.style.display = 'none';
content.classList.remove("text-toggle-hidden");
button.style.display = "none";
return;
}
button.addEventListener('click', () => {
const isHidden = content.classList.toggle('text-toggle-hidden');
button.textContent = isHidden ? 'Show more' : 'Show less';
button.addEventListener("click", () => {
const isHidden = content.classList.toggle("text-toggle-hidden");
button.textContent = isHidden ? "Show more" : "Show less";
});
})();
});

View file

@ -1,16 +1,16 @@
const cacheName = 'coryd.dev-static-assets';
const cacheName = "coryd.dev-static-assets";
const staticAssets = [
'/assets/styles/index.css',
'/assets/styles/noscript.css',
'/assets/fonts/sg.woff2',
'/assets/fonts/dm.woff2',
'/assets/fonts/dmi.woff2',
'/assets/fonts/ml.woff2',
'/assets/scripts/index.js',
'/assets/scripts/components/select-pagination.js'
"/assets/styles/index.css",
"/assets/styles/noscript.css",
"/assets/fonts/sg.woff2",
"/assets/fonts/dm.woff2",
"/assets/fonts/dmi.woff2",
"/assets/fonts/ml.woff2",
"/assets/scripts/index.js",
"/assets/scripts/components/select-pagination.js"
];
self.addEventListener('install', (event) => {
self.addEventListener("install", (event) => {
event.waitUntil(
caches
.open(cacheName)
@ -19,7 +19,7 @@ self.addEventListener('install', (event) => {
);
});
self.addEventListener('activate', (event) => {
self.addEventListener("activate", (event) => {
event.waitUntil(
(async () => {
const keys = await caches.keys();
@ -32,11 +32,11 @@ self.addEventListener('activate', (event) => {
);
});
self.addEventListener('fetch', (event) => {
self.addEventListener("fetch", (event) => {
const request = event.request;
if (request.method !== 'GET') return;
if (request.headers.get('Accept').includes('text/html')) {
if (request.method !== "GET") return;
if (request.headers.get("Accept").includes("text/html")) {
event.respondWith(
(async () => {
try {

View file

@ -1,46 +1,46 @@
@font-face {
font-family: 'Space Grotesk';
src: url('/assets/fonts/sg.woff2') format('woff2');
font-family: "Space Grotesk";
src: url("/assets/fonts/sg.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'DM Sans';
src: url('/assets/fonts/dm-regular.woff2') format('woff2');
font-family: "DM Sans";
src: url("/assets/fonts/dm-regular.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'DM Sans';
src: url('/assets/fonts/dm-bold.woff2') format('woff2');
font-family: "DM Sans";
src: url("/assets/fonts/dm-bold.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'DM Sans';
src: url('/assets/fonts/dm-regular-italic.woff2') format('woff2');
font-family: "DM Sans";
src: url("/assets/fonts/dm-regular-italic.woff2") format("woff2");
font-weight: 400;
font-style: italic;
font-display: optional;
}
@font-face {
font-family: 'DM Sans';
src: url('/assets/fonts/dm-bold-italic.woff2') format('woff2');
font-family: "DM Sans";
src: url("/assets/fonts/dm-bold-italic.woff2") format("woff2");
font-weight: 700;
font-style: italic;
font-display: optional;
}
@font-face {
font-family: 'MonoLisa';
src: url('/assets/fonts/ml.woff2') format('woff2');
font-family: "MonoLisa";
src: url("/assets/fonts/ml.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;

View file

@ -443,7 +443,7 @@ td {
text-overflow: ellipsis;
&::after {
content: '';
content: "";
position: absolute;
inset-block-start: 0;
inset-inline-end: 0;

View file

@ -6,7 +6,7 @@
box-sizing: border-box;
}
:where([hidden]:not([hidden='until-found'])) {
:where([hidden]:not([hidden="until-found"])) {
display: none !important;
}
@ -49,7 +49,7 @@
resize: block;
}
:where(button, label, select, summary, [role='button'], [role='option']) {
:where(button, label, select, summary, [role="button"], [role="option"]) {
cursor: pointer;
}

View file

@ -71,10 +71,10 @@
--border-gray: 1px solid var(--gray-light);
/* fonts */
--font-body: 'DM Sans', Helvetica Neue, Helvetica, Arial, system-ui, sans-serif;
--font-heading: 'Space Grotesk', 'Arial Black', 'Arial Bold', Gadget, sans-serif;
--font-body: "DM Sans", Helvetica Neue, Helvetica, Arial, system-ui, sans-serif;
--font-heading: "Space Grotesk", "Arial Black", "Arial Bold", Gadget, sans-serif;
--font-code:
'MonoLisa', SFMono-Regular, Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
"MonoLisa", SFMono-Regular, Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace;
/* text */
--font-size-xs: 0.7rem;

View file

@ -1,4 +1,4 @@
@import url('./text-toggle.css');
@import url("./text-toggle.css");
button:not([data-dialog-button]),
.button {

View file

@ -7,12 +7,12 @@ input {
accent-color: var(--section-color, var(--accent-color));
}
input:not([type='button']):not([type='submit']):not([type='reset']):not([type='checkbox']),
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]),
textarea {
width: var(--sizing-full);
}
input:not([type='button']):not([type='submit']):not([type='reset']):not([type='checkbox']),
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]),
textarea,
select {
color: var(--text-color);
@ -23,7 +23,7 @@ select {
}
form,
input:not([type='button']):not([type='submit']):not([type='reset']):not([type='checkbox']),
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]),
textarea {
margin-bottom: var(--spacing-base);
}
@ -50,7 +50,7 @@ label svg {
cursor: pointer;
}
detail label:has(input[type='checkbox']) {
detail label:has(input[type="checkbox"]) {
display: inline-flex;
gap: var(--spacing-xs);
}

View file

@ -11,7 +11,7 @@
&::after {
position: absolute;
z-index: 1;
content: '';
content: "";
box-shadow: var(--box-shadow-text-toggle);
width: var(--sizing-full);
height: calc(var(--sizing-full) * 0.2);

View file

@ -1,36 +1,36 @@
@layer reset, defaults, base, page, components, plugins;
/* style resets */
@import url('./base/reset.css') layer(reset);
@import url("./base/reset.css") layer(reset);
/* core defaults */
@import url('./base/fonts.css') layer(defaults);
@import url('./base/vars.css') layer(defaults);
@import url("./base/fonts.css") layer(defaults);
@import url("./base/vars.css") layer(defaults);
/* base styles */
@import url('./base/index.css') layer(base);
@import url("./base/index.css") layer(base);
/* page styles */
@import url('./pages/contact.css') layer(page);
@import url('./pages/links.css') layer(page);
@import url('./pages/media.css') layer(page);
@import url('./pages/music.css') layer(page);
@import url('./pages/reading.css') layer(page);
@import url('./pages/watching.css') layer(page);
@import url('./pages/webrings.css') layer(page);
@import url("./pages/contact.css") layer(page);
@import url("./pages/links.css") layer(page);
@import url("./pages/media.css") layer(page);
@import url("./pages/music.css") layer(page);
@import url("./pages/reading.css") layer(page);
@import url("./pages/watching.css") layer(page);
@import url("./pages/webrings.css") layer(page);
/* plugins */
@import url('./plugins/prism.css') layer(plugins);
@import url("./plugins/prism.css") layer(plugins);
/* component styles */
@import url('./components/banners.css') layer(components);
@import url('./components/buttons.css') layer(components);
@import url('./components/forms.css') layer(components);
@import url('./components/header.css') layer(components);
@import url('./components/media-grid.css') layer(components);
@import url('./components/nav.css') layer(components);
@import url('./components/dialog.css') layer(components);
@import url('./components/music-chart.css') layer(components);
@import url('./components/paginator.css') layer(components);
@import url('./components/progress-bar.css') layer(components);
@import url('./components/youtube-player.css') layer(components);
@import url("./components/banners.css") layer(components);
@import url("./components/buttons.css") layer(components);
@import url("./components/forms.css") layer(components);
@import url("./components/header.css") layer(components);
@import url("./components/media-grid.css") layer(components);
@import url("./components/nav.css") layer(components);
@import url("./components/dialog.css") layer(components);
@import url("./components/music-chart.css") layer(components);
@import url("./components/paginator.css") layer(components);
@import url("./components/progress-bar.css") layer(components);
@import url("./components/youtube-player.css") layer(components);

View file

@ -1,23 +1,23 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAlbumReleases = async () => {
try {
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_album_releases`, {
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
const pacificNow = new Date().toLocaleString('en-US', {
timeZone: 'America/Los_Angeles'
const pacificNow = new Date().toLocaleString("en-US", {
timeZone: "America/Los_Angeles"
});
const pacificDate = new Date(pacificNow);
pacificDate.setHours(0, 0, 0, 0);
@ -29,11 +29,11 @@ const fetchAlbumReleases = async () => {
return {
...album,
description: album.artist?.description || 'No description',
date: releaseDate.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
description: album.artist?.description || "No description",
date: releaseDate.toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric"
})
};
})
@ -45,7 +45,7 @@ const fetchAlbumReleases = async () => {
return { all, upcoming };
} catch (error) {
console.error('Error fetching and processing album releases:', error);
console.error("Error fetching and processing album releases:", error);
return { all: [], upcoming: [] };
}
};

View file

@ -1,16 +1,16 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
export default async function fetchAllActivity() {
try {
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_all_activity`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -18,7 +18,7 @@ export default async function fetchAllActivity() {
return data?.[0] || [];
} catch (error) {
console.error('Error fetching activity:', error);
console.error("Error fetching activity:", error);
return [];
}
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchBlogroll = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_blogroll`, {
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching and processing the blogroll:', error);
console.error("Error fetching and processing the blogroll:", error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllBooks = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_books?order=date_finished.desc`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching books:', error);
console.error("Error fetching books:", error);
return [];
}
};
@ -42,7 +42,7 @@ export default async function () {
const booksForCurrentYear =
sortedByYear
.find((yearGroup) => yearGroup.value === currentYear)
?.data.filter((book) => book.status === 'finished') || [];
?.data.filter((book) => book.status === "finished") || [];
return {
all: books,

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllConcerts = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_concerts`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching concerts:', error);
console.error("Error fetching concerts:", error);
return [];
}
};
@ -32,7 +32,7 @@ export default async function () {
const concerts = await fetchAllConcerts();
return processConcerts(concerts);
} catch (error) {
console.error('Error fetching and processing concerts data:', error);
console.error("Error fetching and processing concerts data:", error);
return [];
}
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchFeeds = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_feeds?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching feed metadata:', error);
console.error("Error fetching feed metadata:", error);
return [];
}
};
@ -24,12 +24,12 @@ const fetchFeeds = async () => {
const fetchFeedData = async (feedKey) => {
try {
return await EleventyFetch(`${POSTGREST_URL}/rpc/get_feed_data`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
},
body: JSON.stringify({ feed_key: feedKey })

View file

@ -1,16 +1,16 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchGlobals = async () => {
try {
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_globals?select=*`, {
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -18,7 +18,7 @@ const fetchGlobals = async () => {
return data[0];
} catch (error) {
console.error('Error fetching globals:', error);
console.error("Error fetching globals:", error);
return {};
}
};

View file

@ -1,15 +1,15 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
export default async function () {
const res = await EleventyFetch(`${POSTGREST_URL}/optimized_all_tags?order=tag.asc`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -18,7 +18,7 @@ export default async function () {
const groupedMap = new Map();
for (const tag of tags) {
const letter = /^[a-zA-Z]/.test(tag.tag) ? tag.tag[0].toUpperCase() : '#';
const letter = /^[a-zA-Z]/.test(tag.tag) ? tag.tag[0].toUpperCase() : "#";
if (!groupedMap.has(letter)) groupedMap.set(letter, []);

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchHeaders = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_headers?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching header data:', error);
console.error("Error fetching header data:", error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllLinks = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_links?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching links:', error);
console.error("Error fetching links:", error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllMovies = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_movies?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching movies:', error);
console.error("Error fetching movies:", error);
return [];
}
};
@ -48,7 +48,7 @@ export default async function () {
feed: movies.filter((movie) => movie.feed)
};
} catch (error) {
console.error('Error fetching and processing movies data:', error);
console.error("Error fetching and processing movies data:", error);
return {
movies: [],
watchHistory: [],

View file

@ -1,16 +1,16 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchDataFromView = async (viewName) => {
try {
return await EleventyFetch(`${POSTGREST_URL}/${viewName}?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -34,15 +34,15 @@ export default async function fetchMusicData() {
monthAlbums,
monthGenres
] = await Promise.all([
fetchDataFromView('recent_tracks'),
fetchDataFromView('week_tracks'),
fetchDataFromView('week_artists'),
fetchDataFromView('week_albums'),
fetchDataFromView('week_genres'),
fetchDataFromView('month_tracks'),
fetchDataFromView('month_artists'),
fetchDataFromView('month_albums'),
fetchDataFromView('month_genres')
fetchDataFromView("recent_tracks"),
fetchDataFromView("week_tracks"),
fetchDataFromView("week_artists"),
fetchDataFromView("week_albums"),
fetchDataFromView("week_genres"),
fetchDataFromView("month_tracks"),
fetchDataFromView("month_artists"),
fetchDataFromView("month_albums"),
fetchDataFromView("month_genres")
]);
return {
@ -52,7 +52,7 @@ export default async function fetchMusicData() {
artists: weekArtists,
albums: weekAlbums,
genres: weekGenres,
totalTracks: weekTracks.reduce((acc, track) => acc + track.plays, 0).toLocaleString('en-US')
totalTracks: weekTracks.reduce((acc, track) => acc + track.plays, 0).toLocaleString("en-US")
},
month: {
tracks: monthTracks,
@ -61,11 +61,11 @@ export default async function fetchMusicData() {
genres: monthGenres,
totalTracks: monthTracks
.reduce((acc, track) => acc + track.plays, 0)
.toLocaleString('en-US')
.toLocaleString("en-US")
}
};
} catch (error) {
console.error('Error fetching and processing music data:', error);
console.error("Error fetching and processing music data:", error);
return {
recent: [],
week: {
@ -73,14 +73,14 @@ export default async function fetchMusicData() {
artists: [],
albums: [],
genres: [],
totalTracks: '0'
totalTracks: "0"
},
month: {
tracks: [],
artists: [],
albums: [],
genres: [],
totalTracks: '0'
totalTracks: "0"
}
};
}

View file

@ -1,16 +1,16 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllNavigation = async () => {
try {
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_navigation?select=*`, {
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -40,7 +40,7 @@ const fetchAllNavigation = async () => {
return nav;
} catch (error) {
console.error('Error fetching navigation data:', error);
console.error("Error fetching navigation data:", error);
return {};
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllPages = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_pages?select=*`, {
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching pages:', error);
console.error("Error fetching pages:", error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllPosts = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_posts?select=*&order=date.desc`, {
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching posts:', error);
console.error("Error fetching posts:", error);
return [];
}
};

View file

@ -1,16 +1,16 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
export default async function () {
try {
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_recent_activity`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -20,7 +20,7 @@ export default async function () {
return feeds.filter((item) => item !== null);
} catch (error) {
console.error('Error fetching recent activity:', error);
console.error("Error fetching recent activity:", error);
return [];
}
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchRedirects = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_redirects?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching redirect data:', error);
console.error("Error fetching redirect data:", error);
return [];
}
};

View file

@ -1,30 +1,30 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllRobots = async () => {
try {
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_robots?select=path,user_agents`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
const sortedData = data.sort((a, b) => {
const aHasWildcard = a.user_agents.includes('*') ? 0 : 1;
const bHasWildcard = b.user_agents.includes('*') ? 0 : 1;
const aHasWildcard = a.user_agents.includes("*") ? 0 : 1;
const bHasWildcard = b.user_agents.includes("*") ? 0 : 1;
return aHasWildcard - bHasWildcard || a.path.localeCompare(b.path);
});
return sortedData;
} catch (error) {
console.error('Error fetching robot data:', error);
console.error("Error fetching robot data:", error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchSitemap = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_sitemap?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching sitemap entries:', error);
console.error("Error fetching sitemap entries:", error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchStats = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_stats?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching stats data:', error);
console.error("Error fetching stats data:", error);
return [];
}
};

View file

@ -1,4 +1,4 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
@ -7,12 +7,12 @@ const fetchTopAlbums = async () => {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_albums?select=table&order=total_plays_raw.desc&limit=8`,
{
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -21,7 +21,7 @@ const fetchTopAlbums = async () => {
return data;
} catch (error) {
console.error('Error fetching top albums:', error);
console.error("Error fetching top albums:", error);
return {};
}
};

View file

@ -1,4 +1,4 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
@ -7,12 +7,12 @@ const fetchTopArtists = async () => {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_artists?select=table&order=total_plays_raw.desc&limit=8`,
{
duration: '1d',
type: 'json',
duration: "1d",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
@ -21,7 +21,7 @@ const fetchTopArtists = async () => {
return data;
} catch (error) {
console.error('Error fetching top artists:', error);
console.error("Error fetching top artists:", error);
return {};
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchTopTags = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/rpc/get_top_tag_groups`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'POST',
method: "POST",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching top tag entries:', error);
console.error("Error fetching top tag entries:", error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllShows = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_shows?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching shows:', error);
console.error("Error fetching shows:", error);
return [];
}
};
@ -46,7 +46,7 @@ export default async function () {
.sort((a, b) => a.title.localeCompare(b.title))
};
} catch (error) {
console.error('Error fetching and processing shows data:', error);
console.error("Error fetching and processing shows data:", error);
return {
shows: [],

View file

@ -1,22 +1,22 @@
import EleventyFetch from '@11ty/eleventy-fetch';
import EleventyFetch from "@11ty/eleventy-fetch";
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchUpcomingShows = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_scheduled_shows?select=*`, {
duration: '1h',
type: 'json',
duration: "1h",
type: "json",
fetchOptions: {
method: 'GET',
method: "GET",
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error('Error fetching upcoming shows:', error);
console.error("Error fetching upcoming shows:", error);
return [];
}
};

View file

@ -10,6 +10,6 @@
?>
{% render "static/blocks/banners/rss.liquid",
url:"/feeds",
text:"Subscribe to my posts, movies, books, links or activity feed(s)"
url: "/feeds",
text: "Subscribe to my posts, movies, books, links or activity feed(s)"
%}

View file

@ -1,29 +1,41 @@
{% assign media = artists | concat:books | concat:genres | concat:movies | concat:posts | concat:shows %}
{% assign media = artists
| concat: books
| concat: genres
| concat: movies
| concat: posts
| concat: shows
%}
{% if media.size > 0 %}
<div class="associated-media">
{% assign sections =
"artists:headphones:music:Related artist(s):true," | append:
"books:books:books:Related book(s):true," | append:
"genres:headphones:music:Related genre(s):false," | append:
"movies:movie:movies:Related movie(s):true," | append:
"posts:article:article:Related post(s):false," | append:
"shows:device-tv-old:tv:Related show(s):true"
| split:"," %}
{% assign sections = 'artists:headphones:music:Related artist(s):true,'
| append: 'books:books:books:Related book(s):true,'
| append: 'genres:headphones:music:Related genre(s):false,'
| append: 'movies:movie:movies:Related movie(s):true,'
| append: 'posts:article:article:Related post(s):false,'
| append: 'shows:device-tv-old:tv:Related show(s):true'
| split: ','
%}
{% for section in sections %}
{% assign parts = section | split:":" %}
{% assign parts = section | split: ':' %}
{% assign key = parts[0] %}
{% assign icon = parts[1] %}
{% assign css_class = parts[2] %}
{% assign label = parts[3] %}
{% assign hasGrid = parts[4] == "true" %}
{% assign items = nil %}
{% assign items = null %}
{% case key %}
{% when "artists" %} {% assign items = artists %}
{% when "books" %} {% assign items = books %}
{% when "genres" %} {% assign items = genres %}
{% when "movies" %} {% assign items = movies %}
{% when "posts" %} {% assign items = posts %}
{% when "shows" %} {% assign items = shows %}
{% when 'artists' %}
{% assign items = artists %}
{% when 'books' %}
{% assign items = books %}
{% when 'genres' %}
{% assign items = genres %}
{% when 'movies' %}
{% assign items = movies %}
{% when 'posts' %}
{% assign items = posts %}
{% when 'shows' %}
{% assign items = shows %}
{% endcase %}
{% if items and items.size > 0 %}
<h3 id="{{ key }}" class="{{ css_class }}">
@ -31,27 +43,25 @@
{{ label }}
</h3>
{% if hasGrid %}
{% assign shape = "square" %}
{% if key == "books" or key == "movies" or key == "shows" %}
{% assign shape = "vertical" %}
{% assign shape = 'square' %}
{% if key == 'books' or key == 'movies' or key == 'shows' %}
{% assign shape = 'vertical' %}
{% endif %}
{% render "static/media/grid.liquid",
data:items,
shape:shape
%}
{% render 'static/media/grid.liquid', data: items, shape: shape %}
{% else %}
<ul>
{% for item in items %}
<li class="{{ css_class }}">
<a href="{{ item.url }}">{{ item.title | default:item.name }}</a>
{% if key == "artists" and item.total_plays > 0 %}
({{ item.total_plays }} {{ item.total_plays | pluralize:"play" }})
{% elsif key == "books" %}
<a href="{{ item.url }}">{{ item.title | default: item.name }}</a>
{% if key == 'artists' and item.total_plays > 0 %}
({{ item.total_plays }}
{{ item.total_plays | pluralize: 'play' }})
{% elsif key == 'books' %}
by {{ item.author }}
{% elsif key == "movies" or key == "shows" %}
{% elsif key == 'movies' or key == 'shows' %}
({{ item.year }})
{% elsif key == "posts" %}
({{ item.date | date:"%B %e, %Y" }})
{% elsif key == 'posts' %}
({{ item.date | date: '%B %e, %Y' }})
{% endif %}
</li>
{% endfor %}

View file

@ -1,3 +1,6 @@
<div class="banner calendar">
<p>{% tablericon "calendar" %} <a href="{{ url }}">{{ text }}</a>.</p>
<p>
{% tablericon "calendar" %}
<a href="{{ url }}">{{ text }}</a>.
</p>
</div>

View file

@ -1,3 +1,7 @@
<div class="banner forgejo">
<p>{% tablericon "git-merge" %} Take a look at <a href="{{ url }}">the repository for this project</a> on my <a href="https://forgejo.org">Forgejo</a> instance.</p>
<p>
{% tablericon "git-merge" %} Take a look at
<a href="{{ url }}">the repository for this project</a> on my
<a href="https://forgejo.org">Forgejo</a> instance.
</p>
</div>

View file

@ -1,3 +1,7 @@
<div class="banner github">
<p>{% tablericon "brand-github" %} Take a look at <a href="{{ url }}">the GitHub repository for this project</a>. (Give it a star if you feel like it.)</p>
<p>
{% tablericon "brand-github" %} Take a look at
<a href="{{ url }}">the GitHub repository for this project</a>. (Give it a star if you feel like
it.)
</p>
</div>

View file

@ -1,3 +1,7 @@
<div class="banner npm">
<p>{% tablericon "brand-npm" %} <a href="{{ url }}">You can take a look at this package on NPM</a> or install it by running <code>{{ command }}</code>.</p>
<p>
{% tablericon "brand-npm" %}
<a href="{{ url }}">You can take a look at this package on NPM</a> or install it by running
<code>{{ command }}</code>.
</p>
</div>

View file

@ -1,5 +1,8 @@
{%- if isOldPost -%}
<div class="banner old-post">
<p>{% tablericon "clock-x" %} This post is over 3 years old. I've probably changed my mind since it was written and it <em>could</em> be out of date.</p>
<p>
{% tablericon "clock-x" %} This post is over 3 years old. I've probably changed my mind since
it was written and it <em>could</em> be out of date.
</p>
</div>
{%- endif -%}

View file

@ -1,3 +1,6 @@
<div class="banner rss">
<p>{% tablericon "rss" %} <a href="{{ url }}">{{ text }}</a>.</p>
<p>
{% tablericon "rss" %}
<a href="{{ url }}">{{ text }}</a>.
</p>
</div>

View file

@ -1,3 +1,6 @@
<div class="banner warning">
<p>{% tablericon "alert-triangle" %} {{ text }}</p>
<p>
{% tablericon "alert-triangle" %}
{{ text }}
</p>
</div>

View file

@ -5,19 +5,29 @@
{{ label }}
{%- endif -%}
{%- endcapture -%}
{% assign dialogId = id | default:"dialog-controls" %}
<button class="dialog-open client-side" aria-label="{{ label }}" data-dialog-trigger="{{ dialogId }}" data-dialog-button>
{% assign dialogId = id | default: 'dialog-controls' %}
<button
class="dialog-open client-side"
aria-label="{{ label }}"
data-dialog-trigger="{{ dialogId }}"
data-dialog-button
>
{{ labelContent }}
</button>
<dialog
id="dialog-{{ dialogId }}"
class="client-side"
{% if dynamic %}data-dynamic="{{ dynamic }}"{% endif %}
{% if markdown %}data-markdown="{{ markdown }}"{% endif %}>
{% if dynamic %}
data-dynamic="{{ dynamic }}"
{% endif %}
{% if markdown %}
data-markdown="{{ markdown }}"
{% endif %}
>
<button class="dialog-close" aria-label="Close dialog" data-dialog-button>
{% tablericon "circle-x" %}
</button>
{%- unless dynamic -%}
{{ content }}
{{ content }}
{%- endunless -%}
</dialog>

View file

@ -4,9 +4,11 @@
{{ image }}?class=bannermd&type=webp 512w,
{{ image }}?class=bannerbase&type=webp 1024w
"
sizes="(max-width: 450px) 256px,
sizes="
(max-width: 450px) 256px,
(max-width: 850px) 512px,
1024px"
1024px
"
src="{{ image }}?class=bannersm&type=webp"
alt="{{ alt | replaceQuotes }}"
class="image-banner"

View file

@ -1,41 +1,22 @@
{%- for block in blocks -%}
{%- case block.type -%}
{%- when "calendar_banner" -%}
{% render "static/blocks/banners/calendar.liquid",
url:block.url,
text:block.text
%}
{%- when "divider" -%}
{%- when 'calendar_banner' -%}
{% render 'static/blocks/banners/calendar.liquid', url: block.url, text: block.text %}
{%- when 'divider' -%}
{{ block.markup | markdown }}
{%- when "forgejo_banner" -%}
{% render "static/blocks/banners/forgejo.liquid",
url:block.url
%}
{%- when "github_banner" -%}
{% render "static/blocks/banners/github.liquid",
url:block.url
%}
{%- when "hero" -%}
{% render "static/blocks/hero.liquid",
globals:globals,
image:block.image,
alt:block.alt
%}
{%- when "markdown" -%}
{%- when 'forgejo_banner' -%}
{% render 'static/blocks/banners/forgejo.liquid', url: block.url %}
{%- when 'github_banner' -%}
{% render 'static/blocks/banners/github.liquid', url: block.url %}
{%- when 'hero' -%}
{% render 'static/blocks/hero.liquid', globals: globals, image: block.image, alt: block.alt %}
{%- when 'markdown' -%}
{{ block.text | markdown }}
{%- when "npm_banner" -%}
{% render "static/blocks/banners/npm.liquid",
url:block.url,
command:block.command
%}
{%- when "rss_banner" -%}
{% render "static/blocks/banners/rss.liquid",
url:block.url,
text:block.text
%}
{%- when "youtube_player" -%}
{% render "static/blocks/youtube-player.liquid",
url:block.url
%}
{%- when 'npm_banner' -%}
{% render 'static/blocks/banners/npm.liquid', url: block.url, command: block.command %}
{%- when 'rss_banner' -%}
{% render 'static/blocks/banners/rss.liquid', url: block.url, text: block.text %}
{%- when 'youtube_player' -%}
{% render 'static/blocks/youtube-player.liquid', url: block.url %}
{%- endcase -%}
{%- endfor -%}

View file

@ -1 +1,8 @@
{% if tags %}<p class="tags tags-small">{%- for tag in tags %} {% assign tagLowercase = tag | downcase -%}<a href="/tags/{{ tagLowercase | url_encode }}">#{{ tagLowercase }}</a>{%- endfor -%}</p>{% endif %}
{% if tags %}
<p class="tags tags-small">
{%- for tag in tags %}
{% assign tagLowercase = tag | downcase -%}
<a href="/tags/{{ tagLowercase | url_encode }}">#{{ tagLowercase }}</a>
{%- endfor -%}
</p>
{% endif %}

View file

@ -1 +1,7 @@
<p><mark>{{ label }}</mark>{%- for tag in tags %} {% assign tagLowercase = tag.tag | downcase -%}<a href="/tags/{{ tagLowercase | url_encode }}">#{{ tagLowercase }}</a>{%- endfor -%}</p>
<p>
<mark>{{ label }}</mark>
{%- for tag in tags %}
{% assign tagLowercase = tag.tag | downcase -%}
<a href="/tags/{{ tagLowercase | url_encode }}">#{{ tagLowercase }}</a>
{%- endfor -%}
</p>

View file

@ -1,2 +1,6 @@
<script type="module" src="/assets/scripts/components/youtube-video-element.js?v={% appVersion %}" defer></script>
<script
type="module"
src="/assets/scripts/components/youtube-video-element.js?v={% appVersion %}"
defer
></script>
<youtube-video controls src="{{ url }}"></youtube-video>

View file

@ -1,7 +1,5 @@
<article class="intro">
{{ intro }}
{% render "dynamic/media/now-playing.php.liquid",
section:"music"
%}
<hr />
{% render 'dynamic/media/now-playing.php.liquid', section: 'music' %}
<hr>
</article>

View file

@ -1,56 +1,54 @@
{%- for item in items -%}
<article class="{{ item.type }}">
<aside>
{%- if item.featured -%}
{% tablericon "star" %}
{%- endif -%}
<time datetime="{{ item.content_date }}">
{{ item.content_date | date:"%B %e, %Y" }}
</time>
• {{ item.label }}
{%- if item.notes -%}
{% assign notes = item.notes | markdown %}
{% render "static/blocks/dialog.liquid",
icon:"info-circle",
label:"View info about this concert"
dynamic:"optimized_concerts",
markdown:"concert_notes",
id:item.id
%}
{%- endif -%}
</aside>
<h3>
{%- if item.type == "concerts" -%}
{%- capture artistName -%}
<article class="{{ item.type }}">
<aside>
{%- if item.featured -%}
{% tablericon "star" %}
{%- endif -%}
<time datetime="{{ item.content_date }}">
{{ item.content_date | date: '%B %e, %Y' }}
</time>
• {{ item.label }}
{%- if item.notes -%}
{% assign notes = item.notes | markdown %}
{% render 'static/blocks/dialog.liquid',
icon: 'info-circle',
label: 'View info about this concert',
dynamic: 'optimized_concerts',
markdown: 'concert_notes',
id: item.id
%}
{%- endif -%}
</aside>
<h3>
{%- if item.type == 'concerts' -%}
{%- capture artistName -%}
{%- if item.artist_url -%}
<a href="{{ item.artist_url }}">{{ item.title | split: ' at ' | first }}</a>
{%- else -%}
{{ item.title | split: ' at ' | first }}
{%- endif -%}
{%- endcapture -%}
{%- capture venue -%}
{%- capture venue -%}
{%- if item.venue_lat and item.venue_lon -%}
<a href="https://www.openstreetmap.org/?mlat={{ item.venue_lat }}&mlon={{ item.venue_lon }}#map=18/{{ item.venue_lat }}/{{ item.venue_lon }}">{{ item.venue_name }}</a>
{%- else -%}
{{ item.venue_name }}
{%- endif -%}
{%- endcapture -%}
{{ artistName }}
{% if venue %} at {{ venue }}{% endif %}
{%- else -%}
<a href="{{ item.url | prepend: globals.url }}">{{ item.title }}</a>
{%- if item.type == "link" and item.author -%}
<span> via </span>
{%- if item.author.url -%}
<a href="{{ item.author.url }}">{{ item.author.name }}</a>
{%- else -%}
{{ item.author.name }}
{{ artistName }}
{% if venue %} at {{ venue }}{% endif %}
{%- else -%}
<a href="{{ item.url | prepend: globals.url }}">{{ item.title }}</a>
{%- if item.type == 'link' and item.author -%}
<span> via </span>
{%- if item.author.url -%}
<a href="{{ item.author.url }}">{{ item.author.name }}</a>
{%- else -%}
{{ item.author.name }}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
</h3>
{% render "static/blocks/tags.liquid",
tags:item.tags
%}
</article>
</h3>
{% render 'static/blocks/tags.liquid', tags: item.tags %}
</article>
{%- endfor -%}

View file

@ -1,13 +1,9 @@
<footer>
{% render "static/nav/menu.liquid",
page:page,
nav:nav.footer_icons
class:"social"
%}
{% render "static/nav/menu.liquid",
page:page,
nav:nav.footer_text
class:"sub-pages"
separator:true
{% render 'static/nav/menu.liquid', page: page, nav: nav.footer_icons, class: 'social' %}
{% render 'static/nav/menu.liquid',
page: page,
nav: nav.footer_text,
class: 'sub-pages',
separator: true
%}
</footer>

View file

@ -15,20 +15,12 @@
{%- endcapture -%}
<section class="main-title">
<h1>
{%- if normalizedUrl == "/" -%}
{%- if normalizedUrl == '/' -%}
{{ headerContent }}
{%- else -%}
<a href="/" tabindex="0">{{ headerContent }}</a>
{%- endif -%}
</h1>
{% render "static/nav/menu.liquid",
page:page,
nav:nav.primary_icons
class:"icons"
%}
{% render 'static/nav/menu.liquid', page: page, nav: nav.primary_icons, class: 'icons' %}
</section>
{% render "static/nav/menu.liquid",
page:page,
nav:nav.primary
class:"primary"
%}
{% render 'static/nav/menu.liquid', page: page, nav: nav.primary, class: 'primary' %}

View file

@ -1,26 +1,26 @@
<div class="media-grid {{ shape | default: square }}">
{%- assign loadingStrategy = loading | default:"lazy" -%}
{%- for item in data limit:count -%}
{%- assign loadingStrategy = loading | default: 'lazy' -%}
{%- for item in data limit: count -%}
{%- assign alt = item.grid.alt | replaceQuotes -%}
{%- assign imageUrl = item.grid.image -%}
<a class="{{ item.type }}" href="{{ item.grid.url }}" title="{{ alt }}">
<div class="media-grid-item">
{%- if item.grid.title or item.grid.subtext -%}
<mark class="meta-text{{ item.type }}">
{% if item.grid.title %}
<div class="header">{{ item.grid.title }}</div>
{% endif %}
{% if item.grid.subtext %}
<div class="subheader">{{ item.grid.subtext }}</div>
{% endif %}
</mark>
<mark class="meta-text{{ item.type }}">
{% if item.grid.title %}
<div class="header">{{ item.grid.title }}</div>
{% endif %}
{% if item.grid.subtext %}
<div class="subheader">{{ item.grid.subtext }}</div>
{% endif %}
</mark>
{%- endif -%}
{%- assign imageClass = "square" -%}
{%- assign imageClass = 'square' -%}
{%- assign width = 150 -%}
{%- assign height = 150 -%}
{%- case shape -%}
{%- when "vertical" -%}
{%- assign imageClass = "vertical" -%}
{%- when 'vertical' -%}
{%- assign imageClass = 'vertical' -%}
{%- assign width = 120 -%}
{%- assign height = 184 -%}
{%- endcase -%}
@ -41,6 +41,4 @@
</a>
{%- endfor -%}
</div>
{% render "static/nav/paginator.liquid",
pagination:pagination
%}
{% render 'static/nav/paginator.liquid', pagination: pagination %}

View file

@ -1,13 +1,14 @@
<div class="chart-item">
<div class="chart-item-info">
<a class="title" href="{{ item.chart.url }}">{{ item.chart.title }}</a>
{%- assign playsLabel = item.chart.plays | pluralize:"play" -%}
{%- assign playsLabel = item.chart.plays | pluralize: 'play' -%}
<span class="subheader">{{ item.chart.artist }}</span>
<span class="subheader">{{ item.chart.plays }} {{ playsLabel }}</span>
<span class="subheader">
{{- item.chart.plays }}
{{ playsLabel -}}
</span>
</div>
<div class="chart-item-progress">
{% render "static/media/progress-bar.liquid",
percentage:item.chart.percentage
%}
{% render 'static/media/progress-bar.liquid', percentage: item.chart.percentage %}
</div>
</div>

View file

@ -1,24 +1,18 @@
<div class="music-chart">
<ol type="1">
{%- if count -%}
{%- for item in data limit:count -%}
{%- for item in data limit: count -%}
<li value="{{ item.chart.rank }}">
{% render "static/media/music/charts/item.liquid",
item:item
%}
{% render 'static/media/music/charts/item.liquid', item: item %}
</li>
{%- endfor -%}
{%- else -%}
{%- for item in pagination.items -%}
<li value="{{ item.chart.rank }}">
{% render "static/media/music/charts/item.liquid",
item:item
%}
{% render 'static/media/music/charts/item.liquid', item: item %}
</li>
{%- endfor -%}
{%- endif -%}
</ol>
</div>
{% render "static/nav/paginator.liquid",
pagination:pagination
%}
{% render 'static/nav/paginator.liquid', pagination: pagination %}

View file

@ -6,16 +6,18 @@
<th>Year</th>
</tr>
{% for album in topAlbums %}
<tr>
<td>
<div>
<img src="{{ album.table.image }}?class=w100" alt="{{ album.table.alt }}" width="50">
{{ album.table.title }}
</div>
</td>
<td><a href="{{ album.table.url }}">{{ album.table.artist }}</a></td>
<td>{{ album.table.plays }}</td>
<td>{{ album.table.year }}</td>
</tr>
<tr>
<td>
<div>
<img src="{{ album.table.image }}?class=w100" alt="{{ album.table.alt }}" width="50">
{{ album.table.title }}
</div>
</td>
<td>
<a href="{{ album.table.url }}">{{ album.table.artist }}</a>
</td>
<td>{{ album.table.plays }}</td>
<td>{{ album.table.year }}</td>
</tr>
{% endfor %}
</table>

View file

@ -5,15 +5,18 @@
<th>Plays</th>
</tr>
{% for artist in topArtists %}
<tr>
<td>
<div>
<img src="{{ artist.table.image }}?class=w100" alt="{{ artist.table.alt }}" width="50">
<a href="{{ artist.table.url }}">{{ artist.table.title }}</a>
</div>
</td>
<td>{{ artist.table.emoji }} <a href="{{ artist.table.genre_url }}">{{ artist.table.genre }}</a></td>
<td>{{ artist.table.plays }}</td>
</tr>
<tr>
<td>
<div>
<img src="{{ artist.table.image }}?class=w100" alt="{{ artist.table.alt }}" width="50">
<a href="{{ artist.table.url }}">{{ artist.table.title }}</a>
</div>
</td>
<td>
{{ artist.table.emoji }}
<a href="{{ artist.table.genre_url }}">{{ artist.table.genre }}</a>
</td>
<td>{{ artist.table.plays }}</td>
</tr>
{% endfor %}
</table>

View file

@ -1,3 +1,3 @@
{%- if percentage -%}
<progress value="{{ percentage }}" max="100">{{ percentage }}%</progress>
<progress value="{{ percentage }}" max="100">{{ percentage }}%</progress>
{%- endif -%}

View file

@ -9,10 +9,10 @@
({{ movie.year }})
</div>
</mark>
{% render "static/blocks/hero.liquid",
globals:globals,
image:movie.backdrop,
alt:movie.title
{% render 'static/blocks/hero.liquid',
globals: globals,
image: movie.backdrop,
alt: movie.title
%}
</div>
</a>

View file

@ -1,15 +1,41 @@
<meta name="amazonbot" content="noarchive">
<meta name="bingbot" content="noarchive">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="light dark" />
<meta name="theme-color" content="{{ globals.theme_color }}" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<meta name="theme-color" content="{{ globals.theme_color }}">
<meta name="msapplication-TileColor" content="{{ globals.theme_color }}">
<meta name="fediverse:creator" content="{{ globals.mastodon }}" />
<meta name="generator" content="{{ eleventy.generator }}" />
<link href="{{ globals.url }}/og/w50/{% appVersion %}{{ globals.metadata.open_graph_image_transparent }}" rel="icon" sizes="any" />
<link href="{{ globals.url }}/og/w800/{% appVersion %}{{ globals.metadata.open_graph_image }}" rel="apple-touch-icon" />
<link rel="alternate" href="{{ globals.url }}/feeds/posts.xml" title="Posts • {{ globals.site_name }}" />
<link rel="alternate" href="{{ globals.url }}/feeds/links.xml" title="Links • {{ globals.site_name }}" type="application/rss+xml" />
<link rel="alternate" href="{{ globals.url }}/feeds/movies.xml" title="Movies • {{ globals.site_name }}" type="application/rss+xml" />
<link rel="alternate" href="{{ globals.url }}/feeds/books.xml" title="Books • {{ globals.site_name }}" type="application/rss+xml" />
<meta name="fediverse:creator" content="{{ globals.mastodon }}">
<meta name="generator" content="{{ eleventy.generator }}">
<link
href="{{ globals.url }}/og/w50/{% appVersion %}{{ globals.metadata.open_graph_image_transparent }}"
rel="icon"
sizes="any"
>
<link
href="{{ globals.url }}/og/w800/{% appVersion %}{{ globals.metadata.open_graph_image }}"
rel="apple-touch-icon"
>
<link
rel="alternate"
href="{{ globals.url }}/feeds/posts.xml"
title="Posts • {{ globals.site_name }}"
>
<link
rel="alternate"
href="{{ globals.url }}/feeds/links.xml"
title="Links • {{ globals.site_name }}"
type="application/rss+xml"
>
<link
rel="alternate"
href="{{ globals.url }}/feeds/movies.xml"
title="Movies • {{ globals.site_name }}"
type="application/rss+xml"
>
<link
rel="alternate"
href="{{ globals.url }}/feeds/books.xml"
title="Books • {{ globals.site_name }}"
type="application/rss+xml"
>
<link rel="blogroll" type="text/xml" href="/blogroll.opml">

View file

@ -1,8 +1,8 @@
{%- capture appVersionString -%}{% appVersion %}{%- endcapture -%}
{%- assign source = page -%}
{%- case schema -%}
{%- when 'artist', 'genre', 'book', 'movie', 'show', 'tags' -%}
{% render "dynamic/fetchers/{{ schema }}.php.liquid" %}
{%- when 'artist', 'genre', 'book', 'movie', 'show', 'tags' -%}
{% render 'dynamic/fetchers/{{ schema }}.php.liquid' %}
{%- when 'blog' -%}
{%- assign source = post -%}
{%- when 'music-index', 'music-week-artists' -%}
@ -18,7 +18,11 @@
{%- when 'books' -%}
{%- assign source = books.all | filterBooksByStatus: 'started' | reverse | first -%}
{%- when 'reading-year' -%}
{%- assign title = 'Books • ' | append: year.value | append: ' • ' | append: globals.site_name -%}
{%- assign title = 'Books • '
| append: year.value
| append: ' • '
| append: globals.site_name
-%}
{%- assign description = "Here's what I read in " | append: year.value | append: '.' -%}
{%- assign bookYear = year.data | filterBooksByStatus: 'finished' | shuffleArray | first -%}
{%- assign source = bookYear -%}
@ -35,29 +39,29 @@
{%- endcase %}
{%- assign meta = source | getMetadata: globals, page, title, description, schema -%}
{%- assign fullUrl = meta.url -%}
{%- assign oembedUrl = globals.url | append: "/oembed" | append: page.url -%}
{%- assign oembedUrl = globals.url | append: '/oembed' | append: page.url -%}
{%- if type == 'dynamic' -%}
{% render "dynamic/metadata/index.php.liquid"
{% render 'dynamic/metadata/index.php.liquid',
fullUrl: fullUrl,
oembedUrl: oembedUrl,
pageTitle: meta.title,
pageDescription: meta.description,
ogImage: meta.open_graph_image,
globals: globals,
globals: globals
%}
{%- else -%}
{% render "static/metadata/static.liquid"
fullUrl:fullUrl,
oembedUrl:oembedUrl,
pageTitle:meta.title,
pageDescription:meta.description,
ogImage:meta.open_graph_image,
globals:globals,
{% render 'static/metadata/static.liquid',
fullUrl: fullUrl,
oembedUrl: oembedUrl,
pageTitle: meta.title,
pageDescription: meta.description,
ogImage: meta.open_graph_image,
globals: globals
%}
{%- endif %}
{% render "static/metadata/base.liquid"
pageTitle:meta.title,
globals:globals,
eleventy:eleventy,
appVersion:appVersion,
{% render 'static/metadata/base.liquid',
pageTitle: meta.title,
globals: globals,
eleventy: eleventy,
appVersion: appVersion
%}

Some files were not shown because too many files have changed in this diff Show more