diff --git a/.eleventy.js b/.eleventy.js index 9157ae3..622a9b2 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -55,7 +55,7 @@ module.exports = function(eleventyConfig) { }); return { - pathPrefix:"blog", + pathPrefix: process.env.PATH_PREFIX || '/', dir: { data: "data", input: "content", diff --git a/.gitignore b/.gitignore index 07f0cbd..7722e70 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules **/.obsidian dist *.mp3 +*.mp4 .env .DS_Store */.vscode diff --git a/.vscode/launch.json b/.vscode/launch.json index dc6a541..6da3a18 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,9 +4,6 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ - - - { "type": "node", "request": "launch", diff --git a/.vscode/settings.json b/.vscode/settings.json index d12ec1c..0d91422 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,17 @@ "files.exclude": { // "dist/": true "**/.obsidian/": true - } + }, + "files.associations": { + "*.md": "markdown-eleventy" + }, + + "terminal.integrated.env.osx": { + "VSCODE_HISTFILE": "${workspaceFolder}/.vscode/.zsh_history", + }, + "[markdown-eleventy]": { + "editor.wordWrap": "on", + "editor.wordWrapColumn": 80, // Optional: Set to your preferred wrap column + "editor.quickSuggestions": false // Optional: Disable suggestions for Markdown +} } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6c6ba63..a948861 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,19 +2,28 @@ "version": "2.0.0", "tasks": [ { - "label": "Simple Browser", - "command": "${input:openSimpleBrowser}", - "problemMatcher": [] - } - ], - "inputs": [ - { - "id": "openSimpleBrowser", - "type": "command", - "command": "simpleBrowser.show", - "args": [ - "http://localhost:8081" - ] + "label": "Deploy Site", + "type": "shell", + "command": "./deploy.sh", + "options": { + "env": { + "PRODUCTION_SERVER": "rpg", + "PRODUCTION_PATH": "/docker/rpg.ascorrea.com/apps/html", + "SITE_URL": "https://rpg.ascorrea.com", + "CDN_URL": "https://podcast.rpg.cdn.ascorrea.com", + "FOUNDRY_BASE_URL": "https://podcast.rpg.cdn.ascorrea.com", + "PATH_PREFIX": "/" + } + }, + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/content/episodes/episodes.11tydata.js b/content/episodes/episodes.11tydata.js index b76d95a..00d5b9f 100644 --- a/content/episodes/episodes.11tydata.js +++ b/content/episodes/episodes.11tydata.js @@ -1,17 +1,83 @@ -const {seasonEpisodeFormat} = require('../../utils/filters'); +const {seasonEpisodeFormat, episodeNumber} = require('../../utils/filters'); +const fs = require('fs/promises'); +path = require('path') module.exports = { "layout": "episode", "tags":['episode'], "eleventyComputed": { "episode": "{{page.fileSlug | episodeNumber: episode}}", - "image": "{{page.url}}/../image.jpg", - "podcast": (data) => { - return { - "enclosureUrl": data.podcast.enclosureUrl ||`${data.site.cdn}/${seasonEpisodeFormat(null, data).toLowerCase()}.mp3`, - "transcriptUrl": data.podcast.transcriptUrl ||`${data.site.cdn}/${seasonEpisodeFormat(null, data).toLowerCase()}.srt`, - "title": data.podcast.title || `${seasonEpisodeFormat(null, data)}: ${data.title || "Episode " + data.episode}`, - "image" : data.podcast.image || data.image || "{{page.url}}/../image.jpg" - }} + "image": async (data) => { + const image_locations_promises = [ + data.image, + `${data.page.filePathStem}.jpg`, + `${data.page.filePathStem}.png`, + '../image.jpg', + '../image.png', + '../../image.jpg', + '../../image.png' + ].filter(image_path=>image_path).map((image_path)=> + fs.access(path.resolve(data.page.inputPath, image_path)) + .then(()=>path.resolve(data.page.filePathStem, image_path)) + .catch(()=>null) + ) + return (await Promise.all(image_locations_promises)).find(i=>i) + }, + "podcast": podcastData } +} + +async function podcastData (data) { + var file_stem + if (data.season === 1) { + file_stem = `ep${data.episode}` + } else { + file_stem = `${seasonEpisodeFormat(null, data).toLowerCase()}` + } + const mp3_exists_promise = new Promise ((resolve, reject) => { + if (data.podcast.enclosureUrl) { + resolve(data.podcast.enclosureUrl) + } else { + const url = `${data.site.cdn}/${file_stem}.mp3` + console.log(`Inferring URL @ ${url} for ${data.page.url}`) + fetch(url, { method: "HEAD" }) + .then((res)=>{ + if (res.ok) { + resolve(`${url}`) + } else { + reject(new Error(`No file at ${url}`)); + } + }) + } + }).catch((e)=>{return null}) + + const transcript_exists_promise = new Promise ((resolve, reject) => { + if (data.podcast.transcriptUrl) { + resolve(data.podcast.transcriptUrl) + } else { + const url = `${data.site.cdn}/${file_stem}.srt` + console.log(`Inferring URL @ ${url}`) + fetch(url, { method: "HEAD" }) + .then((res)=>{ + if (res.ok) { + resolve(`${url}`) + } else { + reject(new Error(`No file at ${url}`)); + } + }) + } + }).catch((e)=>{return null}) + + const result = { + "enclosureUrl": await mp3_exists_promise, + "transcriptUrl": await transcript_exists_promise, + "title": data.podcast.title || `${seasonEpisodeFormat(null, data)}: ${data.title || "Episode " + data.episode}`, + "image" : data.podcast.image || data.image + } + + if (result.enclosureUrl != null) { + return result + } else { + return false + } } \ No newline at end of file diff --git a/content/episodes/s01/s01.11tydata.js b/content/episodes/s01/s01.11tydata.js index 8aaec86..b47d698 100644 --- a/content/episodes/s01/s01.11tydata.js +++ b/content/episodes/s01/s01.11tydata.js @@ -1,3 +1,4 @@ +const podcastData = require('../episodes.11tydata').eleventyComputed.podcast; module.exports = { "season": 1, @@ -6,8 +7,9 @@ module.exports = { ], "stylesheets": ["/css/s04.css"], "eleventyComputed": { - "podcast": (data)=>({ - "title": `E${data.episode}: ${data.title}` - }) + "podcast": async (data)=>{ + var result = {...await podcastData(data),"title": `E${data.episode}: ${data.title}`} + return result } +} } \ No newline at end of file diff --git a/content/episodes/s02/image.jpg b/content/episodes/s02/image.jpg new file mode 100755 index 0000000..a0ac99d Binary files /dev/null and b/content/episodes/s02/image.jpg differ diff --git a/content/episodes/search-index.11ty.js b/content/episodes/search-index.11ty.js new file mode 100644 index 0000000..86a5ef2 --- /dev/null +++ b/content/episodes/search-index.11ty.js @@ -0,0 +1,23 @@ +import markdownit from 'markdown-it'; +import { convert } from 'html-to-text'; +const md = markdownit({html: true}) + +class SearchIndex { + data() { + return {eleventyExcludeFromCollections:["episode"], layout: null} + } + + render (data) { + const documents = data.collections.episode.map((episode)=>{ + return { + url:`${this.url(episode.url)}`, + title: episode.data.title, + text: convert (episode.content), + season: episode.data.season, + episode: episode.data.episode + }}) + return JSON.stringify(documents); + } +} + +export default SearchIndex \ No newline at end of file diff --git a/content/episodes/search.hbs b/content/episodes/search.hbs new file mode 100644 index 0000000..47e3d27 --- /dev/null +++ b/content/episodes/search.hbs @@ -0,0 +1,84 @@ +--- +layout: base-with-heading +title: Search Episodes +eleventyExcludeFromCollections: ["episode"] +override:tags: [] +override:eleventyComputed: [] +--- + + + +
+
+ + +
+
+
    +
    +
    + + \ No newline at end of file diff --git a/content/members/index.hbs b/content/members/index.hbs index b5516b5..bb57271 100644 --- a/content/members/index.hbs +++ b/content/members/index.hbs @@ -3,7 +3,7 @@ layout: base-with-heading title: Member Content links: - name: Foundry - url: /foundry + url: /foundry/game image: /images/fvtt-solid-512.png - name: Discord url: discord diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..7d46669 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +# Exit on errors +set -e + +# Configuration (environment variables) +BUILD_DIR=".tmp_build" # Temporary directory for the build +PRODUCTION_SERVER="${PRODUCTION_SERVER:-}" # Ensure this is set in the environment +PRODUCTION_PATH="${PRODUCTION_PATH:-}" # Ensure this is set in the environment +PATH_PREFIX="${PATH_PREFIX:-}" # Ensure this is set in the environment +SITE_URL="${SITE_URL:-}" # Ensure this is set in the environment +CDN_URL="${CDN_URL:-}" # Ensure this is set in the environment +FOUNDRY_BASE_URL="${FOUNDRY_BASE_URL:-}" # Ensure this is set in the environment + +# Function to clean up the temporary directory +cleanup() { + echo "Cleaning up temporary files..." + rm -rf "$BUILD_DIR" +} + +# Set trap to clean up on script exit or interruption +trap cleanup EXIT + +# Function to check environment variables +check_env() { + if [[ -z "$PRODUCTION_SERVER" ]]; then + echo "Error: PRODUCTION_SERVER is not set. Please set it and try again." + exit 1 + fi + + if [[ -z "$PRODUCTION_PATH" ]]; then + echo "Error: PRODUCTION_PATH is not set. Please set it and try again." + exit 1 + fi + + if [[ -z "$PATH_PREFIX" ]]; then + echo "Error: PATH_PREFIX is not set. Please set it and try again." + exit 1 + fi + + if [[ -z "$SITE_URL" ]]; then + echo "Error: SITE_URL is not set. Please set it and try again." + exit 1 + fi + + if [[ -z "$CDN_URL" ]]; then + echo "Error: CDN_URL is not set. Please set it and try again." + exit 1 + fi + + if [[ -z "$FOUNDRY_BASE_URL" ]]; then + echo "Error: FOUNDRY_BASE_URL is not set. Please set it and try again." + exit 1 + fi +} + +# Check environment variables +check_env + +# Step 1: Build the site to a temporary directory +echo "Building the site..." +npx @11ty/eleventy --output="$BUILD_DIR" + +# Step 2: Deploy using rsync +echo "Deploying to production..." +rsync -avz --delete "$BUILD_DIR/" "$PRODUCTION_SERVER:$PRODUCTION_PATH" + +# Step 3: Fix permissions on the remote server +echo "Fixing permissions on the server..." +ssh "$PRODUCTION_SERVER" << EOF + find "$PRODUCTION_PATH" -type f -exec chmod 665 {} \; # Set permissions for files + find "$PRODUCTION_PATH" -type d -exec chmod 775 {} \; # Set permissions for directories +EOF + +echo "Deployment complete!" \ No newline at end of file diff --git a/layouts/episode.hbs b/layouts/episode.hbs index c8c27c2..da83724 100644 --- a/layouts/episode.hbs +++ b/layouts/episode.hbs @@ -5,12 +5,12 @@ eleventyComputed: ---
    -
    +

    {{#if title}}{{{title}}}{{else}}Episode {{episode}}{{/if}}

    Season {{season}}, Episode {{episode}}
    {{formatDate this.date "MMMM d, yyyy"}}
    - {{#if podcast.enclosureUrl}} + {{#if podcast}} Download {{#if podcast.transcriptUrl}}| Transcript{{/if}}
    diff --git a/layouts/podcast.11ty.js b/layouts/podcast.11ty.js index 83b7203..50a36d4 100644 --- a/layouts/podcast.11ty.js +++ b/layouts/podcast.11ty.js @@ -65,7 +65,7 @@ class PodcastFeed { if (episode.data.podcast.transcriptUrl) { item.customElements.push({ 'podcast:transcript': {_attr:{ url:`${episode.data.podcast.transcriptUrl}`, - type:"application/srt", + type:"application/x-subrip", language:"en-us" }} }) diff --git a/package-lock.json b/package-lock.json index cd4009c..9e756b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "dotenv": "^16.4.5", "handlebars-helpers": "^0.10.0", "html-minifier": "^4.0.0", + "html-to-text": "^9.0.5", "htmlparser2": "^9.1.0", "luxon": "^3.5.0", "markdown-it": "^14.1.0", @@ -409,6 +410,19 @@ "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz", "integrity": "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==" }, + "node_modules/@selderee/plugin-htmlparser2": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@selderee/plugin-htmlparser2/-/plugin-htmlparser2-0.11.0.tgz", + "integrity": "sha512-P33hHGdldxGabLFjPPpaTxVolMrzrcegejx+0GxjrIb9Zv48D8yAIA/QTDR2dFl7Uz7urX8aX6+5bCZslr+gWQ==", + "license": "MIT", + "dependencies": { + "domhandler": "^5.0.3", + "selderee": "^0.11.0" + }, + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, "node_modules/@tokenizer/token": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/@tokenizer/token/-/token-0.3.0.tgz", @@ -1227,6 +1241,15 @@ "node": ">=0.10" } }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/default-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/default-compare/-/default-compare-1.0.0.tgz", @@ -2237,6 +2260,41 @@ "node": ">=0.10.0" } }, + "node_modules/html-to-text": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-9.0.5.tgz", + "integrity": "sha512-qY60FjREgVZL03vJU6IfMV4GDjGBIoOyvuFdpBDIX9yTlDw0TjxVBQp+P8NvpdIXNJvfWBTNul7fsAQJq2FNpg==", + "license": "MIT", + "dependencies": { + "@selderee/plugin-htmlparser2": "^0.11.0", + "deepmerge": "^4.3.1", + "dom-serializer": "^2.0.0", + "htmlparser2": "^8.0.2", + "selderee": "^0.11.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/html-to-text/node_modules/htmlparser2": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", + "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3", + "domutils": "^3.0.1", + "entities": "^4.4.0" + } + }, "node_modules/htmlparser2": { "version": "9.1.0", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-9.1.0.tgz", @@ -2515,6 +2573,15 @@ "node": ">=0.10.0" } }, + "node_modules/leac": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/leac/-/leac-0.6.0.tgz", + "integrity": "sha512-y+SqErxb8h7nE/fiEX07jsbuhrpO9lL8eca7/Y1nuWV2moNlXhyd59iDGcRf6moVyDMbmTNzL40SUyrFU/yDpg==", + "license": "MIT", + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, "node_modules/linkify-it": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", @@ -7535,6 +7602,19 @@ "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", "integrity": "sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q==" }, + "node_modules/parseley": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/parseley/-/parseley-0.12.1.tgz", + "integrity": "sha512-e6qHKe3a9HWr0oMRVDTRhKce+bRO8VGQR3NyVwcjwrbhMmFCX9KszEV35+rn4AdilFAq9VPxP/Fe1wC9Qjd2lw==", + "license": "MIT", + "dependencies": { + "leac": "^0.6.0", + "peberminta": "^0.9.0" + }, + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, "node_modules/pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -7544,6 +7624,15 @@ "node": ">=0.10.0" } }, + "node_modules/peberminta": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/peberminta/-/peberminta-0.9.0.tgz", + "integrity": "sha512-XIxfHpEuSJbITd1H3EeQwpcZbTLHc+VVr8ANI9t5sit565tsI4/xK3KWTUFE2e6QiangUkh3B0jihzmGnNrRsQ==", + "license": "MIT", + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, "node_modules/peek-readable": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/peek-readable/-/peek-readable-5.3.1.tgz", @@ -7969,6 +8058,18 @@ "node": ">=14.0.0" } }, + "node_modules/selderee": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/selderee/-/selderee-0.11.0.tgz", + "integrity": "sha512-5TF+l7p4+OsnP8BCCvSyZiSPc4x4//p5uPwK8TCnVPJYRmU2aYKMpOXvw8zM5a5JvuuCGN1jmsMwuU2W02ukfA==", + "license": "MIT", + "dependencies": { + "parseley": "^0.12.0" + }, + "funding": { + "url": "https://ko-fi.com/killymxi" + } + }, "node_modules/self-closing-tags": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/self-closing-tags/-/self-closing-tags-1.0.1.tgz", diff --git a/package.json b/package.json index 2b332b9..d2e08b3 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "dotenv": "^16.4.5", "handlebars-helpers": "^0.10.0", "html-minifier": "^4.0.0", + "html-to-text": "^9.0.5", "htmlparser2": "^9.1.0", "luxon": "^3.5.0", "markdown-it": "^14.1.0",