From 1343a0e1e70994909dbcdd943ed7a53f61ea3b2b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 4 Jun 2021 15:29:18 -0300 Subject: move url spec into its own file --- src/upd8.js | 90 +------------------------------------------------------ src/url-spec.js | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 89 deletions(-) create mode 100644 src/url-spec.js diff --git a/src/upd8.js b/src/upd8.js index 586afe95..e9babd26 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -110,6 +110,7 @@ import { } from 'fs/promises'; import genThumbs from './gen-thumbs.js'; +import urlSpec from './url-spec.js'; import * as pageSpecs from './page/index.js'; import find from './util/find.js'; @@ -241,95 +242,6 @@ let queueSize; let languages; -const urlSpec = { - data: { - prefix: 'data/', - - paths: { - root: '', - path: '<>', - - album: 'album/<>', - artist: 'artist/<>', - track: 'track/<>' - } - }, - - localized: { - // TODO: Implement this. - // prefix: '_languageCode', - - paths: { - root: '', - path: '<>', - - home: '', - - album: 'album/<>/', - albumCommentary: 'commentary/album/<>/', - - artist: 'artist/<>/', - artistGallery: 'artist/<>/gallery/', - - commentaryIndex: 'commentary/', - - flashIndex: 'flash/', - flash: 'flash/<>/', - - groupInfo: 'group/<>/', - groupGallery: 'group/<>/gallery/', - - listingIndex: 'list/', - listing: 'list/<>/', - - newsIndex: 'news/', - newsEntry: 'news/<>/', - - staticPage: '<>/', - tag: 'tag/<>/', - track: 'track/<>/' - } - }, - - shared: { - paths: { - root: '', - path: '<>', - - utilityRoot: 'util', - staticRoot: 'static', - - utilityFile: 'util/<>', - staticFile: 'static/<>' - } - }, - - media: { - prefix: 'media/', - - paths: { - root: '', - path: '<>', - - albumCover: 'album-art/<>/cover.jpg', - albumWallpaper: 'album-art/<>/bg.jpg', - albumBanner: 'album-art/<>/banner.jpg', - trackCover: 'album-art/<>/<>.jpg', - artistAvatar: 'artist-avatar/<>.jpg', - flashArt: 'flash-art/<>.jpg' - } - } -}; - -// This gets automatically switched in place when working from a baseDirectory, -// so it should never be referenced manually. -urlSpec.localizedWithBaseDirectory = { - paths: withEntries( - urlSpec.localized.paths, - entries => entries.map(([key, path]) => [key, '<>/' + path]) - ) -}; - const urls = generateURLs(urlSpec); // Note there isn't a 'find track data files' function. I plan on including the diff --git a/src/url-spec.js b/src/url-spec.js new file mode 100644 index 00000000..22b3bc8b --- /dev/null +++ b/src/url-spec.js @@ -0,0 +1,92 @@ +import {withEntries} from './util/sugar.js'; + +const urlSpec = { + data: { + prefix: 'data/', + + paths: { + root: '', + path: '<>', + + album: 'album/<>', + artist: 'artist/<>', + track: 'track/<>' + } + }, + + localized: { + // TODO: Implement this. + // prefix: '_languageCode', + + paths: { + root: '', + path: '<>', + + home: '', + + album: 'album/<>/', + albumCommentary: 'commentary/album/<>/', + + artist: 'artist/<>/', + artistGallery: 'artist/<>/gallery/', + + commentaryIndex: 'commentary/', + + flashIndex: 'flash/', + flash: 'flash/<>/', + + groupInfo: 'group/<>/', + groupGallery: 'group/<>/gallery/', + + listingIndex: 'list/', + listing: 'list/<>/', + + newsIndex: 'news/', + newsEntry: 'news/<>/', + + staticPage: '<>/', + tag: 'tag/<>/', + track: 'track/<>/' + } + }, + + shared: { + paths: { + root: '', + path: '<>', + + utilityRoot: 'util', + staticRoot: 'static', + + utilityFile: 'util/<>', + staticFile: 'static/<>' + } + }, + + media: { + prefix: 'media/', + + paths: { + root: '', + path: '<>', + + albumCover: 'album-art/<>/cover.jpg', + albumWallpaper: 'album-art/<>/bg.jpg', + albumBanner: 'album-art/<>/banner.jpg', + trackCover: 'album-art/<>/<>.jpg', + artistAvatar: 'artist-avatar/<>.jpg', + flashArt: 'flash-art/<>.jpg' + } + } +}; + +// This gets automatically switched in place when working from a baseDirectory, +// so it should never be referenced manually. +urlSpec.localizedWithBaseDirectory = { + paths: withEntries( + urlSpec.localized.paths, + entries => entries.map(([key, path]) => [key, '<>/' + path]) + ) +}; + +export default urlSpec; -- cgit 1.3.0-6-gf8a5