feat: redmine_tonalmine plugin for default and per-account appearance
Admins set the default mode, contrast and color on Settings > Display, shown as three labelled form rows below the Theme select. Logged-in users' choices are saved on their account and override only the parts they changed; anonymous visitors get the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
77040e24a8
commit
20b7269df2
@@ -6,7 +6,8 @@ import { writeFileSync, readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { ROLES, kebab, paletteCss } from './scheme.mjs';
|
||||
|
||||
// The first palette is the default. Ids must match PALETTES in tonalmine/javascripts/theme.js.
|
||||
// The first palette is the default. Ids must match PALETTES in tonalmine/javascripts/theme.js
|
||||
// and redmine_tonalmine/lib/redmine_tonalmine/appearance.rb.
|
||||
// An optional third entry is a Material Theme Builder export folder (light.css, dark.css and the
|
||||
// -mc/-hc contrast variants):
|
||||
// its roles are copied as-is instead of generated, and the seed only drives success/warning.
|
||||
@@ -53,8 +54,12 @@ const theme = resolve(process.cwd(), '../../tonalmine');
|
||||
const out = `${theme}/stylesheets/palettes.css`;
|
||||
writeFileSync(out, css);
|
||||
|
||||
// Keep theme.js in sync: every palette id must appear in its PALETTES list.
|
||||
// Keep theme.js and the plugin's validation in sync: every palette id must appear in their PALETTES lists.
|
||||
const js = readFileSync(`${theme}/javascripts/theme.js`, 'utf8');
|
||||
const missing = PALETTES.map(([id]) => id).filter((id) => !js.includes(`'${id}'`));
|
||||
if (missing.length) { console.error(`theme.js is missing palettes: ${missing.join(', ')}`); process.exit(1); }
|
||||
const rb = readFileSync(resolve(theme, '../redmine_tonalmine/lib/redmine_tonalmine/appearance.rb'), 'utf8');
|
||||
const rbIds = rb.match(/PALETTES = %w\[([^\]]*)\]/)[1].split(/\s+/);
|
||||
const rbMissing = PALETTES.map(([id]) => id).filter((id) => !rbIds.includes(id));
|
||||
if (rbMissing.length) { console.error(`appearance.rb is missing palettes: ${rbMissing.join(', ')}`); process.exit(1); }
|
||||
console.log(`Wrote ${PALETTES.length} palettes to ${out}`);
|
||||
|
||||
Reference in New Issue
Block a user