Files
cmkiss/js/config-default.js
biosiasandClaude Sonnet 5 16395fa7c5 Rename project from cmjs to cmkiss (AI)
Updates every in-repo mention: README.md title/prose/example paths,
code comments in config-default.js and router.js, and the IndexedDB
DB_NAME prefix in cache.js (cmjs-cache-v3 -> cmkiss-cache-v3).

The DB_NAME change has the same effect as a schema-version bump --
every returning visitor's browser opens a fresh, empty cache under the
new name and the old cmjs-cache-v3 database is left as orphaned
storage. Harmless (cache.js degrades to live-fetch when the cache is
empty), noted in a comment there rather than left as an unexplained
side effect.

Two things this commit does NOT cover, both outside this checkout:
- The local directory itself (still /home/user/Projects/cmjs) --
  renamed separately right after this commit.
- The git hosting-side repo name/remote URL
  (git.astronomickaexpedice.cz, Astronomicka_Expedice/cmjs.git) --
  requires server-side access this session doesn't have; needs a
  manual rename on the host plus a local `git remote set-url` update
  to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 14:56:09 +02:00

43 lines
2.3 KiB
JavaScript

// Shipped defaults for BASE_URL, MARKED_URL, ARTICLES_URL, plus the loader
// that lets an optional local js/config.js (gitignored — not part of this
// repo's history; see "Local configuration" in the README) override any of
// them. Every other module imports from THIS file, not config.js directly —
// config.js might not exist at all (nothing has created one yet, or it was
// deleted), and a plain `import ... from './config.js'` would then break
// the whole module graph with no way to catch it. A dynamic import() can be
// caught, so that's what resolves it below; top-level await makes every
// module that imports this one wait for that resolution before it runs,
// same as if these were plain synchronous exports.
//
// config.js, if present, only needs to export whichever of these it wants
// to change — anything it doesn't export falls back to the default here.
// All paths are derived from this module's own location via import.meta.url,
// so they resolve correctly regardless of where the embedding HTML page lives.
const DEFAULT_BASE_URL = new URL('../', import.meta.url).href;
const DEFAULT_MARKED_URL = new URL('../vendor/marked.min.js', import.meta.url).href;
const DEFAULT_ARTICLES_URL = new URL('articles/', DEFAULT_BASE_URL).href;
let overrides = {};
try {
overrides = await import('./config.js');
} catch {
// No local config.js (or it failed to load) — shipped defaults stand.
}
// Base URL of the repo root — strings/ and templates/ live here, one level
// up from this file (e.g. https://example.com/).
export const BASE_URL = overrides.BASE_URL ?? DEFAULT_BASE_URL;
// Path to the marked.js vendor script — lives in vendor/, a sibling of this
// file's own js/ directory, not alongside the app's own modules.
export const MARKED_URL = overrides.MARKED_URL ?? DEFAULT_MARKED_URL;
// Base URL of the articles/ folder. Defaults to a sibling of this file's own
// js/ directory (the repo root's own articles/), but articles don't have to
// live anywhere near the rest of cmkiss — override it in config.js to point
// anywhere under the same origin, or even a different one, CORS permitting.
// Whatever it resolves to must still be a directory nginx serves a JSON (or
// HTML) autoindex listing for — see "nginx configuration" in the README.
export const ARTICLES_URL = overrides.ARTICLES_URL ?? DEFAULT_ARTICLES_URL;