2025-01-20 14:14:44 +01:00
|
|
|
<?PHP
|
|
|
|
/**
|
2025-01-22 15:10:59 +01:00
|
|
|
* Compiles the static parts of the concordance checker web interface.
|
2025-01-20 14:14:44 +01:00
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
require_once __DIR__ . '/provideEnv.php';
|
|
|
|
|
|
|
|
# if (!(file_put_contents(__DIR__ . '/static/json/openapi.json', json_encode(QAApiDesc::describeApi())))) {
|
|
|
|
# throw new Exception("Failed to save OpenAPI description");
|
|
|
|
# }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the json for a translation file.
|
|
|
|
*
|
|
|
|
* @param string $lang Language.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function generateTranslationFile(string $lang):string {
|
|
|
|
|
|
|
|
$tlLoader = new MDTlLoader("mdConc", $lang);
|
|
|
|
|
2025-01-22 15:10:59 +01:00
|
|
|
$output = [
|
2025-01-20 14:14:44 +01:00
|
|
|
'concordance_checker' => $tlLoader->tl('concordance', 'concordance', 'concordance_checker'),
|
2025-01-22 15:10:59 +01:00
|
|
|
'intro' => $tlLoader->tl('concordance', 'concordance', 'intro'),
|
|
|
|
'one_line_per_entry' => $tlLoader->tl('concordance', 'concordance', 'one_line_per_entry'),
|
|
|
|
'submit' => $tlLoader->tl('concordance', 'concordance', 'submit'),
|
|
|
|
'passed' => $tlLoader->tl('concordance', 'concordance', 'passed'),
|
|
|
|
'not_yet_matched' => $tlLoader->tl('concordance', 'concordance', 'not_yet_matched'),
|
|
|
|
'input' => $tlLoader->tl('concordance', 'concordance', 'input'),
|
|
|
|
'generate_code_snippet' => $tlLoader->tl('concordance', 'concordance', 'generate_code_snippet'),
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach (ConcordanceChecker::getLists() as $list) {
|
|
|
|
$output[$list] = $tlLoader->tl('concordance', 'concordance', $list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return MD_STD::json_encode($output);
|
2025-01-20 14:14:44 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2025-01-20 14:22:25 +01:00
|
|
|
/**
|
|
|
|
* Generates the json for a translation file.
|
|
|
|
*
|
|
|
|
* @param string $lang Language.
|
|
|
|
*
|
|
|
|
* @return array<string, string>
|
|
|
|
*/
|
|
|
|
function generateTranslationFilesForMatchOptions(string $lang):array {
|
|
|
|
|
|
|
|
$tlLoader = new MDTlLoader("mdConc", $lang);
|
|
|
|
$output = [];
|
|
|
|
foreach (ConcordanceChecker::getLists() as $list) {
|
2025-01-22 15:10:59 +01:00
|
|
|
$options = [];
|
|
|
|
foreach ((new ConcordanceChecker($list))->getMatchOptions($lang) as $value) {
|
|
|
|
$options[(string)$value['id']] = $value['name'];
|
|
|
|
}
|
|
|
|
$output[$list] = MD_STD::json_encode($options);
|
2025-01-20 14:22:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2025-01-20 14:14:44 +01:00
|
|
|
/**
|
|
|
|
* Generate index.htm.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function generateAppShell():string {
|
|
|
|
|
|
|
|
return '<!DOCTYPE HTML>
|
2025-01-22 15:10:59 +01:00
|
|
|
<html
|
|
|
|
data-allowed-langs="' . htmlspecialchars(implode(',', ALLOWED_LANGS)) . '"
|
|
|
|
data-lists="' . htmlspecialchars(implode(',', ConcordanceChecker::getLists())) . '"
|
|
|
|
>
|
2025-01-20 14:14:44 +01:00
|
|
|
<head>
|
|
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
|
|
|
<link rel="stylesheet" type="text/css" href="static/css/qa.css?' . uniqid() . '" />
|
|
|
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
|
|
<meta name="theme-color" content="#aa4400" />
|
|
|
|
|
2025-01-22 15:10:59 +01:00
|
|
|
<title>Concordance checker :: museum-digital</title>
|
|
|
|
<meta name="twitter:title" content="Concordance checker :: museum-digital" />
|
|
|
|
<meta property="og:title" content="Concordance checker :: museum-digital" />
|
2025-01-20 14:14:44 +01:00
|
|
|
|
|
|
|
<meta name="twitter:card" content="summary" />
|
|
|
|
<meta name="twitter:site" content="@museumdigital" />
|
|
|
|
|
2025-01-22 15:10:59 +01:00
|
|
|
<meta name="description" content="Use museum-digital\'s concordance list checker to prepare imports" />
|
2025-01-20 14:14:44 +01:00
|
|
|
<meta name="author" content="Joshua Ramon Enslin" />
|
|
|
|
<meta name="dc.creator" content="Joshua Ramon Enslin" />
|
|
|
|
|
|
|
|
<meta name="keywords" content="Imports, museum-digital, concordance" />
|
|
|
|
|
|
|
|
<link rel="shortcut icon" sizes="128x128" href="/static/img/mdlogo-code.svg" />
|
|
|
|
<link rel="apple-touch-icon" sizes="192x192" href="/static/img/mdlogo-code-128px.png" />
|
|
|
|
<meta property="twitter:image" content="/static/img/mdlogo-code.svg" />
|
|
|
|
<meta property="og:image" content="/static/img/mdlogo-code.svg" />
|
|
|
|
|
|
|
|
</head>
|
2025-01-22 15:10:59 +01:00
|
|
|
<body class="loading">
|
2025-01-20 14:14:44 +01:00
|
|
|
|
2025-01-22 15:10:59 +01:00
|
|
|
<!-- <script src="/static/js/qa.js?' . uniqid() . '" type="text/javascript" async></script> -->
|
2025-01-20 14:14:44 +01:00
|
|
|
<script src="/static/js/qa.min.js?' . uniqid() . '" type="text/javascript" async></script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2025-01-22 15:10:59 +01:00
|
|
|
const ALLOWED_LANGS = ['de', 'en'];
|
2025-01-20 14:14:44 +01:00
|
|
|
const SERVED_ROOT = __DIR__ . '/public/';
|
|
|
|
const SERVED_JSON_ROOT = __DIR__ . '/public/static/json/';
|
|
|
|
|
|
|
|
if (!is_dir(SERVED_JSON_ROOT)) {
|
|
|
|
echo "Will generate JSON root directory (" . SERVED_JSON_ROOT . ")" . PHP_EOL;
|
|
|
|
MD_STD::mkdir(SERVED_JSON_ROOT);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (ALLOWED_LANGS as $lang) {
|
|
|
|
echo "Will generate JSON list of translations for language: " . $lang . PHP_EOL;
|
|
|
|
file_put_contents(SERVED_JSON_ROOT . 'tls.' . $lang . '.json', generateTranslationFile($lang));
|
2025-01-20 14:22:25 +01:00
|
|
|
foreach (generateTranslationFilesForMatchOptions($lang) as $list => $tls) {
|
|
|
|
file_put_contents(SERVED_JSON_ROOT . 'tls.' . $list . '.' . $lang . '.json', $tls);
|
|
|
|
}
|
2025-01-20 14:14:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "Will generate app shell" . PHP_EOL;
|
|
|
|
file_put_contents(SERVED_ROOT . 'index.htm', generateAppShell());
|
|
|
|
|
|
|
|
echo "Will minify CSS" . PHP_EOL;
|
|
|
|
exec("minify \\
|
|
|
|
-o " . escapeshellarg(__DIR__ . '/public/static/css/qa.min.css') . '\\
|
|
|
|
' . escapeshellarg(__DIR__ . '/public/static/css/editMenu.css') . '\\
|
|
|
|
' . escapeshellarg(__DIR__ . '/public/static/css/dialogue.css') . '\\
|
|
|
|
' . escapeshellarg(__DIR__ . '/public/static/css/qa.css'));
|
|
|
|
|
|
|
|
echo "Will minify JS" . PHP_EOL;
|
|
|
|
exec("minify \\
|
|
|
|
-o " . escapeshellarg(__DIR__ . '/public/static/js/qa.min.js') . '\
|
|
|
|
' . escapeshellarg(__DIR__ . '/public/static/js/qa.js'));
|