NotationSiteFiles constructor
Reads files (path → text). The manifest is site/site.json, else
site.json; the pages are pages/*.txt (else site/pages/*.txt), the
components components/*.txt (and site/components/*.txt). Any other
file is not read. catalog says which words the notation already has
(a component of such a name is said).
The app's shared state is app.txt beside the pages (site/app.txt
beside site/pages/), read with readNotationAppState;
appStatePartial says more of it is coming (a stream). The manifest is
read as the site's source (notationSourceManifest): a site needs none.
What of the manifest's theme is not read (a key a theme does not
have, a color name nothing defines: themeProblems) is among
problems, at its line of the manifest. themeColors: the color names
of the design system the site is shown under, which its theme may name.
Implementation
NotationSiteFiles(Map<String, String> files, {Catalog? catalog, bool appStatePartial = false, Iterable<String> themeColors = const []})
: files = {for (final e in files.entries) notationSitePath(e.key): e.value},
_catalog = catalog ?? Catalog.current {
final text = this.files['site/${SiteManifest.fileName}'] ?? this.files[SiteManifest.fileName];
if (text != null && text.trim().isNotEmpty) {
try {
final read = readMap(jsonDecode(text)) ?? const <String, Object?>{};
final source = notationSourceManifest(read);
hasManifest = source != null;
manifest = source ?? const {};
for (final p in themeProblems(manifest['theme'], colors: themeColors)) {
problems.add((path: manifestPath, line: themeKeyLine(text, p.path), message: '$manifestPath ${['theme', ...p.path].join('.')}: ${p.message}'));
}
} on FormatException catch (e) {
hasManifest = true;
problems.add((path: manifestPath, line: null, message: '$manifestPath is not JSON (${e.message}): its variables, theme and pages were not read'));
}
}
final appPath = appStatePath;
final ofApp = <NotationSiteProblem>[];
if (appPath != null) {
final app = appState = readNotationAppState(this.files[appPath]!, catalog: _catalog, partial: appStatePartial);
for (final i in app.issues) {
ofApp.add((path: appPath, line: i.line, message: i.message));
}
}
variables = notationSiteVariables(manifest['variables'], appState, say: (line, message) => ofApp.add((path: appPath!, line: line, message: message)));
problems.addAll(ofApp..sort((a, b) => (a.line ?? 0) - (b.line ?? 0)));
_readComponents();
_checkRings();
}