Connect personal and function seals to the central organisation and native signatures

This commit is contained in:
unimatrixgit 2026-11-15 04:47:06 +01:00
commit 35659152ba
2 changed files with 433 additions and 93 deletions

View file

@ -0,0 +1,46 @@
"""Install CI-approved custom integration adapters and merge the seal catalogue."""
from pathlib import Path
import json
import os
import subprocess
import sys
root = Path(__file__).resolve().parents[1]
target = Path('/home/dunerealms/apps/integrations')
names = ('sync-public-profile.php', 'sync-staff-seals.php', 'managed-signatures.php')
for name in names:
subprocess.run(['php', '-l', str(root / 'integrations' / name)], check=True)
catalogue = json.loads((root / 'artwork/seals/great-migration/catalogue.json').read_text())
entries = {}
for key, metadata in catalogue.items():
entries[key] = dict(metadata)
for size, field in ((150, 'footer150'), (300, 'standard300')):
name = f'{key}-{size}.png'
source = root / 'web/assets/seals' / name
if not source.is_file() or source.read_bytes()[:8] != b'\x89PNG\r\n\x1a\n':
raise ValueError(f'Missing PNG: {name}')
entries[key][field] = '/assets/seals/' + name
if '--apply' not in sys.argv:
print(f'Plan: {len(entries)} seals, three custom adapters; no changes applied')
sys.exit(0)
def atomic(path, content):
temporary = path.with_name(path.name + '.migration-new')
temporary.write_bytes(content)
temporary.chmod(0o644)
os.replace(temporary, path)
# Artwork becomes reachable before any adapter starts referring to it.
for folder in ('osticket/assets/seals', 'mybb/assets/seals'):
destination = target / folder
destination.mkdir(parents=True, exist_ok=True)
for key in entries:
for size in (150, 300):
name = f'{key}-{size}.png'
atomic(destination / name, (root / 'web/assets/seals' / name).read_bytes())
manifest = target / 'seal-manifest.json'
existing = json.loads(manifest.read_text())
existing.update(entries) # Keep every historical asset and entitlement.
atomic(manifest, (json.dumps(existing, indent=2)+'\n').encode())
atomic(target / 'organisation-seals.json', (root / 'integrations/organisation-seals.json').read_bytes())
for name in names:
atomic(target / name, (root / 'integrations' / name).read_bytes())
print(f'Installed {len(entries)} seals and three custom adapters; native core unchanged')

View file

@ -0,0 +1,22 @@
"""Export approved raster originals; preserve alpha and never alter source art."""
from pathlib import Path
import json
from PIL import Image
root = Path(__file__).resolve().parents[1]
sources = root / 'artwork/seals/great-migration'
destination = root / 'web/assets/seals'
destination.mkdir(parents=True, exist_ok=True)
manifest = {}
catalogue = json.loads((sources / 'catalogue.json').read_text())
for source in sorted(sources.glob('*-v1.png')):
with Image.open(source) as image:
if 'A' not in image.getbands() or image.getchannel('A').getextrema()[0] != 0:
raise ValueError(f'Missing transparency: {source.name}')
for size in (150, 300):
output = destination / f'{source.stem}-{size}.png'
image.convert('RGBA').resize((size, size), Image.Resampling.LANCZOS).save(output, optimize=True)
manifest[source.stem] = {**catalogue[source.stem], 'footer150': f'/assets/seals/{source.stem}-150.png',
'standard300': f'/assets/seals/{source.stem}-300.png'}
(sources / 'export-manifest.json').write_text(json.dumps(manifest, indent=2)+'\n')
print(f'Exported {len(manifest)} transparent seals in two sizes')