diff options
-rw-r--r-- | package.json | 24 | ||||
-rw-r--r-- | src/aggregate.js (renamed from src/util/aggregate.js) | 4 | ||||
-rw-r--r-- | src/cli.js (renamed from src/util/cli.js) | 8 | ||||
-rw-r--r-- | src/common-util/colors.js (renamed from src/util/colors.js) | 0 | ||||
-rw-r--r-- | src/common-util/search-spec.js (renamed from src/util/search-spec.js) | 0 | ||||
-rw-r--r-- | src/common-util/serialize.js (renamed from src/util/serialize.js) | 0 | ||||
-rw-r--r-- | src/common-util/sort.js (renamed from src/util/sort.js) | 0 | ||||
-rw-r--r-- | src/common-util/sugar.js (renamed from src/util/sugar.js) | 16 | ||||
-rw-r--r-- | src/common-util/wiki-data.js (renamed from src/util/wiki-data.js) | 0 | ||||
-rw-r--r-- | src/content/dependencies/generateAlbumSocialEmbed.js | 9 | ||||
-rw-r--r-- | src/content/dependencies/generateSocialEmbed.js | 11 | ||||
-rw-r--r-- | src/content/dependencies/generateTrackSocialEmbed.js | 14 | ||||
-rw-r--r-- | src/data/things/language.js | 2 | ||||
-rw-r--r-- | src/data/things/static-page.js | 9 | ||||
-rw-r--r-- | src/external-links.js (renamed from src/util/external-links.js) | 0 | ||||
-rw-r--r-- | src/html.js (renamed from src/util/html.js) | 0 | ||||
-rw-r--r-- | src/node-utils.js (renamed from src/util/node-utils.js) | 0 | ||||
-rw-r--r-- | src/page/static.js | 1 | ||||
-rw-r--r-- | src/replacer.js (renamed from src/util/replacer.js) | 0 | ||||
-rw-r--r-- | src/urls.js | 20 | ||||
-rw-r--r-- | src/validators.js (renamed from src/data/validators.js) | 2 | ||||
-rw-r--r-- | src/web-routes.js | 2 | ||||
-rw-r--r-- | src/write/build-modes/live-dev-server.js | 2 | ||||
-rw-r--r-- | src/write/build-modes/static-build.js | 15 |
24 files changed, 70 insertions, 69 deletions
diff --git a/package.json b/package.json index 8c7d8d50..73bd40a1 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "dev": "eslint src && node src/upd8.js" }, "imports": { - "#aggregate": "./src/util/aggregate.js", + "#aggregate": "./src/aggregate.js", "#cacheable-object": "./src/data/cacheable-object.js", - "#colors": "./src/util/colors.js", + "#colors": "./src/common-util/colors.js", "#composite": "./src/data/composite.js", "#composite/control-flow": "./src/data/composite/control-flow/index.js", "#composite/data": "./src/data/composite/data/index.js", @@ -29,31 +29,31 @@ "#composite/things/track-section": "./src/data/composite/things/track-section/index.js", "#content-dependencies": "./src/content/dependencies/index.js", "#content-function": "./src/content-function.js", - "#cli": "./src/util/cli.js", + "#cli": "./src/cli.js", "#data-checks": "./src/data/checks.js", - "#external-links": "./src/util/external-links.js", + "#external-links": "./src/external-links.js", "#find": "./src/find.js", - "#html": "./src/util/html.js", + "#html": "./src/html.js", "#import-heck": "./src/import-heck.js", "#language": "./src/data/language.js", "#page-specs": "./src/page/index.js", - "#node-utils": "./src/util/node-utils.js", + "#node-utils": "./src/node-utils.js", "#repl": "./src/write/build-modes/repl.js", - "#replacer": "./src/util/replacer.js", + "#replacer": "./src/replacer.js", "#reverse": "./src/reverse.js", "#search": "./src/search.js", - "#search-spec": "./src/util/search-spec.js", + "#search-spec": "./src/common-util/search-spec.js", "#serialize": "./src/data/serialize.js", - "#sort": "./src/util/sort.js", - "#sugar": "./src/util/sugar.js", + "#sort": "./src/common-util/sort.js", + "#sugar": "./src/common-util/sugar.js", "#test-lib": "./test/lib/index.js", "#thing": "./src/data/thing.js", "#things": "./src/data/things/index.js", "#thumbs": "./src/gen-thumbs.js", "#urls": "./src/urls.js", - "#validators": "./src/data/validators.js", + "#validators": "./src/validators.js", "#web-routes": "./src/web-routes.js", - "#wiki-data": "./src/util/wiki-data.js", + "#wiki-data": "./src/common-util/wiki-data.js", "#yaml": "./src/data/yaml.js" }, "engines": { diff --git a/src/util/aggregate.js b/src/aggregate.js index c7648c4c..92c66b73 100644 --- a/src/util/aggregate.js +++ b/src/aggregate.js @@ -1,5 +1,5 @@ -import {colors} from './cli.js'; -import {empty, typeAppearance} from './sugar.js'; +import {colors} from '#cli'; +import {empty, typeAppearance} from '#sugar'; // Utility function for providing useful interfaces to the JS AggregateError // class. diff --git a/src/util/cli.js b/src/cli.js index a40a911f..bd4ec685 100644 --- a/src/util/cli.js +++ b/src/cli.js @@ -1,14 +1,8 @@ // Utility functions for CLI- and de8ugging-rel8ted stuff. -// -// A 8unch of these depend on process.stdout 8eing availa8le, so they won't -// work within the 8rowser. - -const {process} = globalThis; -import {sortByName} from './sort.js'; +import {sortByName} from '#sort'; export const ENABLE_COLOR = - process && ((process.env.CLICOLOR_FORCE && process.env.CLICOLOR_FORCE === '1') ?? (process.env.CLICOLOR && process.env.CLICOLOR === '1' && diff --git a/src/util/colors.js b/src/common-util/colors.js index 7298c46a..7298c46a 100644 --- a/src/util/colors.js +++ b/src/common-util/colors.js diff --git a/src/util/search-spec.js b/src/common-util/search-spec.js index 3d05c021..3d05c021 100644 --- a/src/util/search-spec.js +++ b/src/common-util/search-spec.js diff --git a/src/util/serialize.js b/src/common-util/serialize.js index eb18a759..eb18a759 100644 --- a/src/util/serialize.js +++ b/src/common-util/serialize.js diff --git a/src/util/sort.js b/src/common-util/sort.js index ea1e024a..ea1e024a 100644 --- a/src/util/sort.js +++ b/src/common-util/sort.js diff --git a/src/util/sugar.js b/src/common-util/sugar.js index 7dd173a0..90d47b7c 100644 --- a/src/util/sugar.js +++ b/src/common-util/sugar.js @@ -6,8 +6,6 @@ // It will likely only do exactly what I want it to, and only in the cases I // decided were relevant enough to 8other handling. -import {colors} from './cli.js'; - // Apparently JavaScript doesn't come with a function to split an array into // chunks! Weird. Anyway, this is an awesome place to use a generator, even // though we don't really make use of the 8enefits of generators any time we @@ -461,14 +459,12 @@ export function* iterateMultiline(content, iterator, { const columnNumber = index - startOfLine; - let where = null; - if (formatWhere) { - where = - colors.yellow( - (isMultiline - ? `line: ${lineNumber + 1}, col: ${columnNumber + 1}` - : `pos: ${index + 1}`)); - } + const where = + (formatWhere && isMultiline + ? `line: ${lineNumber + 1}, col: ${columnNumber + 1}` + : formatWhere + ? `pos: ${index + 1}` + : null); countLineBreaks(index, length); diff --git a/src/util/wiki-data.js b/src/common-util/wiki-data.js index f97ecd63..f97ecd63 100644 --- a/src/util/wiki-data.js +++ b/src/common-util/wiki-data.js diff --git a/src/content/dependencies/generateAlbumSocialEmbed.js b/src/content/dependencies/generateAlbumSocialEmbed.js index 54574e45..ad02e180 100644 --- a/src/content/dependencies/generateAlbumSocialEmbed.js +++ b/src/content/dependencies/generateAlbumSocialEmbed.js @@ -6,7 +6,7 @@ export default { 'generateAlbumSocialEmbedDescription', ], - extraDependencies: ['absoluteTo', 'language', 'urls'], + extraDependencies: ['absoluteTo', 'language'], relations(relation, album) { return { @@ -41,7 +41,7 @@ export default { return data; }, - generate: (data, relations, {absoluteTo, language, urls}) => + generate: (data, relations, {absoluteTo, language}) => language.encapsulate('albumPage.socialEmbed', embedCapsule => relations.socialEmbed.slots({ title: @@ -65,10 +65,7 @@ export default { imagePath: (data.hasImage - ? '/' + - urls - .from('shared.root') - .to('media.albumCover', data.coverArtDirectory, data.coverArtFileExtension) + ? ['media.albumCover', data.coverArtDirectory, data.coverArtFileExtension] : null), })), }; diff --git a/src/content/dependencies/generateSocialEmbed.js b/src/content/dependencies/generateSocialEmbed.js index 85a0f4d3..513ea518 100644 --- a/src/content/dependencies/generateSocialEmbed.js +++ b/src/content/dependencies/generateSocialEmbed.js @@ -1,5 +1,5 @@ export default { - extraDependencies: ['html', 'language', 'wikiData'], + extraDependencies: ['absoluteTo', 'html', 'language', 'wikiData'], sprawl({wikiInfo}) { return { @@ -23,10 +23,10 @@ export default { headingContent: {type: 'string'}, headingLink: {type: 'string'}, - imagePath: {type: 'string'}, + imagePath: {validate: v => v.strictArrayOf(v.isString)}, }, - generate(data, slots, {html, language}) { + generate(data, slots, {absoluteTo, html, language}) { switch (slots.mode) { case 'html': return html.tags([ @@ -40,7 +40,10 @@ export default { }), slots.imagePath && - html.tag('meta', {property: 'og:image', content: slots.imagePath}), + html.tag('meta', { + property: 'og:image', + content: absoluteTo(...slots.imagePath), + }), ]); case 'json': diff --git a/src/content/dependencies/generateTrackSocialEmbed.js b/src/content/dependencies/generateTrackSocialEmbed.js index d8e21e38..7cb37af2 100644 --- a/src/content/dependencies/generateTrackSocialEmbed.js +++ b/src/content/dependencies/generateTrackSocialEmbed.js @@ -4,7 +4,7 @@ export default { 'generateTrackSocialEmbedDescription', ], - extraDependencies: ['absoluteTo', 'language', 'urls'], + extraDependencies: ['absoluteTo', 'language'], relations(relation, track) { return { @@ -39,7 +39,7 @@ export default { return data; }, - generate: (data, relations, {absoluteTo, language, urls}) => + generate: (data, relations, {absoluteTo, language}) => language.encapsulate('trackPage.socialEmbed', embedCapsule => relations.socialEmbed.slots({ title: @@ -60,15 +60,9 @@ export default { imagePath: (data.imageSource === 'album' - ? '/' + - urls - .from('shared.root') - .to('media.albumCover', data.albumDirectory, data.coverArtFileExtension) + ? ['media.albumCover', data.albumDirectory, data.coverArtFileExtension] : data.imageSource === 'track' - ? '/' + - urls - .from('shared.root') - .to('media.trackCover', data.albumDirectory, data.trackDirectory, data.coverArtFileExtension) + ? ['media.trackCover', data.albumDirectory, data.trackDirectory, data.coverArtFileExtension] : null), })), }; diff --git a/src/data/things/language.js b/src/data/things/language.js index e9aa58be..800c4471 100644 --- a/src/data/things/language.js +++ b/src/data/things/language.js @@ -115,7 +115,7 @@ export class Language extends Thing { }, // List of descriptors for providing to external link utilities when using - // language.formatExternalLink - refer to util/external-links.js for info. + // language.formatExternalLink - refer to #external-links for info. externalLinkSpec: { flags: {update: true, expose: true}, update: {validate: isExternalLinkSpec}, diff --git a/src/data/things/static-page.js b/src/data/things/static-page.js index 03274979..52a09c31 100644 --- a/src/data/things/static-page.js +++ b/src/data/things/static-page.js @@ -7,7 +7,7 @@ import {sortAlphabetically} from '#sort'; import Thing from '#thing'; import {isName} from '#validators'; -import {contentString, directory, name, simpleString} +import {contentString, directory, flag, name, simpleString} from '#composite/wiki-properties'; export class StaticPage extends Thing { @@ -30,9 +30,12 @@ export class StaticPage extends Thing { }, directory: directory(), - content: contentString(), + stylesheet: simpleString(), script: simpleString(), + content: contentString(), + + absoluteLinks: flag(), }); static [Thing.findSpecs] = { @@ -48,6 +51,8 @@ export class StaticPage extends Thing { 'Short Name': {property: 'nameShort'}, 'Directory': {property: 'directory'}, + 'Absolute Links': {property: 'absoluteLinks'}, + 'Style': {property: 'stylesheet'}, 'Script': {property: 'script'}, 'Content': {property: 'content'}, diff --git a/src/util/external-links.js b/src/external-links.js index 43c09265..43c09265 100644 --- a/src/util/external-links.js +++ b/src/external-links.js diff --git a/src/util/html.js b/src/html.js index 0fe424df..0fe424df 100644 --- a/src/util/html.js +++ b/src/html.js diff --git a/src/util/node-utils.js b/src/node-utils.js index 345d10aa..345d10aa 100644 --- a/src/util/node-utils.js +++ b/src/node-utils.js diff --git a/src/page/static.js b/src/page/static.js index c9d806ff..733844de 100644 --- a/src/page/static.js +++ b/src/page/static.js @@ -12,6 +12,7 @@ export function pathsForTarget(staticPage) { { type: 'page', path: ['staticPage', staticPage.directory], + absoluteLinks: staticPage.absoluteLinks, contentFunction: { name: 'generateStaticPage', diff --git a/src/util/replacer.js b/src/replacer.js index e3f5623e..e3f5623e 100644 --- a/src/util/replacer.js +++ b/src/replacer.js diff --git a/src/urls.js b/src/urls.js index 83a8b904..5e334c1e 100644 --- a/src/urls.js +++ b/src/urls.js @@ -300,16 +300,18 @@ export function getURLsFromRoot({ return (targetFullKey, ...args) => { const [groupKey, subKey] = targetFullKey.split('.'); - return ( - '/' + + const toResult = (groupKey === 'localized' && baseDirectory - ? to( - 'localizedWithBaseDirectory.' + subKey, - baseDirectory, - ...args - ) - : to(targetFullKey, ...args)) - ); + ? to('localizedWithBaseDirectory.' + subKey, baseDirectory, ...args) + : groupKey === 'localizedDefaultLanguage' + ? to('localized.' + subKey, ...args) + : to(targetFullKey, ...args)); + + if (getOrigin(toResult)) { + return toResult; + } else { + return '/' + toResult; + } }; } diff --git a/src/data/validators.js b/src/validators.js index 84e08cb8..3b23e8f6 100644 --- a/src/data/validators.js +++ b/src/validators.js @@ -543,7 +543,7 @@ export function isContentString(content) { const parts = [ actionPart, surroundings, - `(${where})`, + `(${colors.yellow(where)})`, ].filter(Boolean); illegalAggregate.push(new TypeError(parts.join(` `))); diff --git a/src/web-routes.js b/src/web-routes.js index 762b26c3..b93607d6 100644 --- a/src/web-routes.js +++ b/src/web-routes.js @@ -34,7 +34,7 @@ export const stationaryCodeRoutes = [ }, { - from: path.join(codeSrcPath, 'util'), + from: path.join(codeSrcPath, 'common-util'), to: ['staticSharedUtil.root'], statically: 'copy', }, diff --git a/src/write/build-modes/live-dev-server.js b/src/write/build-modes/live-dev-server.js index dd29c93e..28969de2 100644 --- a/src/write/build-modes/live-dev-server.js +++ b/src/write/build-modes/live-dev-server.js @@ -458,7 +458,7 @@ export async function go({ language, pagePath: servePath, pagePathStringFromRoot: pathname.replace(/^\//, ''), - to, + to: page.absoluteLinks ? absoluteTo : to, }); const topLevelResult = diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index d40e1cb7..7eb73474 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -27,6 +27,7 @@ import { } from '#cli'; import { + getOrigin, getPagePathname, getURLsFrom, getURLsFromRoot, @@ -321,7 +322,7 @@ export async function go({ language, pagePath, pagePathStringFromRoot: pathname, - to, + to: page.absoluteLinks ? absoluteTo : to, }); let pageHTML, oEmbedJSON; @@ -436,12 +437,18 @@ async function writePage({ ].filter(Boolean)); } +function filterNoOrigin(route) { + return !getOrigin(route.to); +} + function writeWebRouteSymlinks({ outputPath, webRoutes, }) { const symlinkRoutes = - webRoutes.filter(route => route.statically === 'symlink'); + webRoutes + .filter(route => route.statically === 'symlink') + .filter(filterNoOrigin); const promises = symlinkRoutes.map(async route => { @@ -481,7 +488,9 @@ async function writeWebRouteCopies({ webRoutes, }) { const copyRoutes = - webRoutes.filter(route => route.statically === 'copy'); + webRoutes + .filter(route => route.statically === 'copy') + .filter(filterNoOrigin); const promises = copyRoutes.map(async route => { |