Build the standalone plugin with pinned HG shared files

This commit is contained in:
parkel committed 2026-11-18 15:21:05 +01:00
1 parent 50a4dd2ad6
commit d72ccf8ea6
4 files changed
+85 -6

No files matched your search

+4 -6
View File
@@ -76,10 +76,8 @@ De checks injecteren tijdelijke instellingen via filters en onderscheppen e-mail
Maak een nieuw ZIP vanuit een geteste commit. Bewaar vóór vervanging de bestaande plugin en instellingen van de doelwebsite. Upload en activeer alleen binnen die website; stel per installatie het ontvangstadres en de teksten in. Draai deze plugin niet gelijktijdig met de oude klantplugin omdat beide dezelfde compatibiliteitsshortcode registreren. Bij de bestaande website zijn de klantinstellingen expliciet overgenomen bij de overstap.
## HG-beheernavigatie
## Gedeeld HG-beheer
Beide plugins bundelen dezelfde includes/hg-admin-menu.php en assets/hg-admin-menu.css (component 1.0.0).
Werk deze kopieën samen bij. De class wordt éénmaal geladen; iedere plugin meldt zijn eigen scherm aan.
Eén HG Plugins-menu met overzicht, accentkleur en alleen de actieve modules. Geen aparte kernplugin nodig.
Bestaande admin.php?page=hg-contactform / hg-registrations-links blijven geldig.
Plugin-assets gebruiken de geregistreerde submenu-hook; alleen beheerders hebben toegang.
De installatie-ZIP bevat het HG-beheermenu en de updater. De build controleert de vastgelegde bestanden in `shared.lock.json`. [Gedeelde code](https://code.hosting.hippogrief.nl/hippogrief/wp-plugins)
Open **HG Plugins → Updates** om openbare plug-inreleases te controleren. [Openbare releases](https://code.hosting.hippogrief.nl/hippogrief/wp-plugins/releases)
+3
View File
@@ -2,7 +2,10 @@
"""Build a WordPress-installable ZIP from this checkout."""
from pathlib import Path
import zipfile
from sync_shared import verify_shared
root=Path(__file__).resolve().parents[1]
verify_shared(root)
destination=root/'dist/hg-contactform.zip'
destination.parent.mkdir(exist_ok=True)
files=[root/'hg-contactform.php',root/'readme.txt',root/'LICENSE']
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
"""Sync or verify the shared HG files bundled by a standalone plugin."""
import argparse
import hashlib
import json
from pathlib import Path
import re
import subprocess
SOURCE_URL = 'https://code.hosting.hippogrief.nl/hippogrief/wp-plugins'
SHARED_FILES = (
'assets/hg-admin-menu.css',
'includes/hg-admin-menu.php',
'includes/hg-plugin-updates.php',
'scripts/sync_shared.py',
)
def verify_shared(root: Path) -> None:
try:
lock = json.loads((root / 'shared.lock.json').read_text())
if lock['source'] != SOURCE_URL or not re.fullmatch(r'[0-9a-f]{40}', lock['commit']):
raise ValueError('invalid source or commit')
if set(lock['sha256']) != set(SHARED_FILES):
raise ValueError('unexpected shared file list')
for name in SHARED_FILES:
checksum = hashlib.sha256((root / name).read_bytes()).hexdigest()
if checksum != lock['sha256'][name]:
raise ValueError(f'checksum differs for {name}')
except (OSError, ValueError, TypeError, KeyError) as error:
raise SystemExit(f'HG shared files failed verification: {error}') from error
def sync_shared(root: Path, source: Path, ref: str) -> None:
git = ['git', '-C', str(source)]
commit = subprocess.check_output(
git + ['rev-parse', '--verify', '--end-of-options', f'{ref}^{{commit}}'],
text=True,
).strip()
shared_paths = {name: f'shared/{name}' for name in SHARED_FILES}
shared_paths['scripts/sync_shared.py'] = 'shared/sync_shared.py'
files = {
name: subprocess.check_output(git + ['show', f'{commit}:{remote_path}'])
for name, remote_path in shared_paths.items()
}
for name, contents in files.items():
(root / name).write_bytes(contents)
lock = {
'source': SOURCE_URL,
'commit': commit,
'sha256': {name: hashlib.sha256(contents).hexdigest() for name, contents in files.items()},
}
(root / 'shared.lock.json').write_text(json.dumps(lock, indent=2) + '\n')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--source', type=Path, help='Path to a checkout of wp-plugins')
parser.add_argument('--ref', help='Tag or commit to copy from the shared checkout')
options = parser.parse_args()
if bool(options.source) != bool(options.ref):
parser.error('--source and --ref must be supplied together')
plugin_root = Path(__file__).resolve().parents[1]
if options.source:
sync_shared(plugin_root, options.source, options.ref)
verify_shared(plugin_root)
+10
View File
@@ -0,0 +1,10 @@
{
"source": "https://code.hosting.hippogrief.nl/hippogrief/wp-plugins",
"commit": "b812c041a91981b1034d65f2e4ee1daff6cefaf6",
"sha256": {
"assets/hg-admin-menu.css": "a2af6a52dc9abef9127a9d26903b9809c1001720a89f7d85f4c22bc7d8b7f581",
"includes/hg-admin-menu.php": "0723f681aeb651f1737de686ba8657e8f7adc7c53073a47025fcd1565bbe1047",
"includes/hg-plugin-updates.php": "337705f1a5f1901080c5a5450a8f2e4f394a9fa8a4a7975ec5a2371fe2e55a52",
"scripts/sync_shared.py": "a803f6d9dbcd34e6023397d9a61cd028bd04867cd0309c5b709e4282be752871"
}
}