Files

143 lines
7.4 KiB
PowerShell

param(
[Parameter(Mandatory)][string]$Env
)
. "$PSScriptRoot\common.ps1"
$environment = Get-TestLabEnvironment -Name $Env
$seedPhp = @'
<?php
$books = [
['Genesis', 'Gen', 'Genesis 1:1', 'Gen 1:1'],
['Exodus', 'Exod', 'Exodus 3:14', 'Exod 3:14'],
['Leviticus', 'Lev', 'Leviticus 19:18', 'Lev 19:18'],
['Numbers', 'Num', 'Numbers 6:24', 'Num 6:24'],
['Deuteronomy', 'Deut', 'Deuteronomy 6:5', 'Deut 6:5'],
['Joshua', 'Josh', 'Joshua 1:9', 'Josh 1:9'],
['Judges', 'Judg', 'Judges 6:12', 'Judg 6:12'],
['Ruth', 'Ruth', 'Ruth 1:16', 'Ruth 1:16'],
['1 Samuel', '1 Sam', '1 Samuel 16:7', '1 Sam 16:7'],
['2 Samuel', '2 Sam', '2 Samuel 7:22', '2 Sam 7:22'],
['1 Kings', '1 Kgs', '1 Kings 8:27', '1 Kgs 8:27'],
['2 Kings', '2 Kgs', '2 Kings 6:17', '2 Kgs 6:17'],
['1 Chronicles', '1 Chr', '1 Chronicles 16:34', '1 Chr 16:34'],
['2 Chronicles', '2 Chr', '2 Chronicles 7:14', '2 Chr 7:14'],
['Ezra', 'Ezra', 'Ezra 7:10', 'Ezra 7:10'],
['Nehemiah', 'Neh', 'Nehemiah 8:10', 'Neh 8:10'],
['Esther', 'Esth', 'Esther 4:14', 'Esth 4:14'],
['Job', 'Job', 'Job 19:25', 'Job 19:25'],
['Psalms', 'Ps', 'Psalms 23:1', 'Ps 23:1'],
['Proverbs', 'Prov', 'Proverbs 3:5', 'Prov 3:5'],
['Ecclesiastes', 'Eccl', 'Ecclesiastes 3:1', 'Eccl 3:1'],
['Song of Solomon', 'Song', 'Song of Solomon 2:4', 'Song 2:4'],
['Isaiah', 'Isa', 'Isaiah 40:31', 'Isa 40:31'],
['Jeremiah', 'Jer', 'Jeremiah 29:11', 'Jer 29:11'],
['Lamentations', 'Lam', 'Lamentations 3:22', 'Lam 3:22'],
['Ezekiel', 'Ezek', 'Ezekiel 36:26', 'Ezek 36:26'],
['Daniel', 'Dan', 'Daniel 3:17', 'Dan 3:17'],
['Hosea', 'Hos', 'Hosea 6:3', 'Hos 6:3'],
['Joel', 'Joel', 'Joel 2:28', 'Joel 2:28'],
['Amos', 'Amos', 'Amos 5:24', 'Amos 5:24'],
['Obadiah', 'Obad', 'Obadiah 1:15', 'Obad 1:15'],
['Jonah', 'Jonah', 'Jonah 2:2', 'Jonah 2:2'],
['Micah', 'Mic', 'Micah 6:8', 'Mic 6:8'],
['Nahum', 'Nah', 'Nahum 1:7', 'Nah 1:7'],
['Habakkuk', 'Hab', 'Habakkuk 2:4', 'Hab 2:4'],
['Zephaniah', 'Zeph', 'Zephaniah 3:17', 'Zeph 3:17'],
['Haggai', 'Hag', 'Haggai 2:9', 'Hag 2:9'],
['Zechariah', 'Zech', 'Zechariah 4:6', 'Zech 4:6'],
['Malachi', 'Mal', 'Malachi 3:10', 'Mal 3:10'],
['Matthew', 'Matt', 'Matthew 5:16', 'Matt 5:16'],
['Mark', 'Mk', 'Mark 10:45', 'Mk 10:45'],
['Luke', 'Lk', 'Luke 2:10', 'Lk 2:10'],
['John', 'Jn', 'John 3:16', 'Jn 3:16'],
['Acts', 'Acts', 'Acts 1:8', 'Acts 1:8'],
['Romans', 'Rom', 'Romans 8:28', 'Rom 8:28'],
['1 Corinthians', '1 Cor', '1 Corinthians 13:4', '1 Cor 13:4'],
['2 Corinthians', '2 Cor', '2 Corinthians 5:17', '2 Cor 5:17'],
['Galatians', 'Gal', 'Galatians 5:22', 'Gal 5:22'],
['Ephesians', 'Eph', 'Ephesians 2:8', 'Eph 2:8'],
['Philippians', 'Phil', 'Philippians 4:13', 'Phil 4:13'],
['Colossians', 'Col', 'Colossians 3:23', 'Col 3:23'],
['1 Thessalonians', '1 Thess', '1 Thessalonians 5:16', '1 Thess 5:16'],
['2 Thessalonians', '2 Thess', '2 Thessalonians 3:3', '2 Thess 3:3'],
['1 Timothy', '1 Tim', '1 Timothy 4:12', '1 Tim 4:12'],
['2 Timothy', '2 Tim', '2 Timothy 1:7', '2 Tim 1:7'],
['Titus', 'Titus', 'Titus 2:11', 'Titus 2:11'],
['Philemon', 'Phlm', 'Philemon 1:6', 'Phlm 1:6'],
['Hebrews', 'Heb', 'Hebrews 11:1', 'Heb 11:1'],
['James', 'Jas', 'James 1:5', 'Jas 1:5'],
['1 Peter', '1 Pet', '1 Peter 5:7', '1 Pet 5:7'],
['2 Peter', '2 Pet', '2 Peter 3:9', '2 Pet 3:9'],
['1 John', '1 Jn', '1 John 1:9', '1 Jn 1:9'],
['2 John', '2 Jn', '2 John 1:6', '2 Jn 1:6'],
['3 John', '3 Jn', '3 John 1:4', '3 Jn 1:4'],
['Jude', 'Jude', 'Jude 1:24', 'Jude 1:24'],
['Revelation', 'Rev', 'Revelation 21:4', 'Rev 21:4'],
];
$translations = [
['WEB', 'World English Bible'],
['KJV', 'King James Version'],
['ASV', 'American Standard Version'],
['YLT', 'Young\'s Literal Translation'],
];
$content = '<div class="brt-test-page">';
$content .= '<style>.brt-test-page{box-sizing:border-box;width:min(1520px,calc(100vw - 120px));max-width:none;margin-left:50%;transform:translateX(-50%);font-family:system-ui,-apple-system,Segoe UI,sans-serif}.brt-test-page *{box-sizing:border-box}.brt-test-page p{max-width:760px;margin:0 0 18px;color:#4b5563}.brt-test-grid{display:grid;grid-template-columns:minmax(120px,.65fr) repeat(4,minmax(130px,1fr));border:1px solid #d7dee8;border-bottom:0;border-right:0;background:#fff}.brt-test-row{display:contents}.brt-test-head,.brt-test-book,.brt-test-cell{border-right:1px solid #d7dee8;border-bottom:1px solid #d7dee8;padding:10px 12px}.brt-test-head{position:sticky;top:0;z-index:1;background:#f3f6fa;font-weight:800}.brt-test-book{font-weight:800;background:#fff}.brt-test-cell{min-width:0}.brt-test-cell .ref-pair{display:flex;flex-direction:column;align-items:flex-start;gap:6px}.brt-test-cell a{display:inline-block;max-width:100%;font-weight:700;line-height:1.25;white-space:normal;overflow-wrap:anywhere}@media(max-width:980px){.brt-test-page{width:min(100%,calc(100vw - 36px))}.brt-test-grid{display:block;border:0}.brt-test-head{display:none}.brt-test-row{display:grid;grid-template-columns:1fr;border:1px solid #d7dee8;margin:0 0 12px}.brt-test-book{background:#f3f6fa}.brt-test-cell{display:grid;grid-template-columns:54px 1fr;gap:10px}.brt-test-cell:before{content:attr(data-version);font-weight:800;color:#4b5563}}}</style>';
$content .= '<p>This page intentionally includes one full-name and one abbreviated Bible reference for every book of the Bible across all installed local translations.</p>';
$content .= '<div class="brt-test-grid">';
$content .= '<div class="brt-test-head">Book</div>';
foreach ($translations as $translation) {
$content .= '<div class="brt-test-head">' . esc_html($translation[0]) . '</div>';
}
foreach ($books as $book) {
[$name, $abbr, $fullRef, $abbrRef] = $book;
$content .= '<div class="brt-test-row">';
$content .= '<div class="brt-test-book">' . esc_html($name) . '</div>';
foreach ($translations as $translation) {
[$code, $label] = $translation;
$content .= '<div class="brt-test-cell" data-version="' . esc_attr($code) . '"><div class="ref-pair">';
$content .= '<span>' . esc_html($fullRef) . '</span>';
$content .= '<span>' . esc_html($abbrRef) . '</span>';
$content .= '</div></div>';
}
$content .= '</div>';
}
$content .= '</div></div>';
$existing = get_page_by_path('bible-reference-tooltip-test');
$post_data = [
'post_title' => 'Bible Reference Tooltip Test',
'post_name' => 'bible-reference-tooltip-test',
'post_type' => 'page',
'post_status' => 'publish',
'post_content' => $content,
];
if ($existing) {
$post_data['ID'] = $existing->ID;
$page_id = wp_update_post($post_data, true);
} else {
$page_id = wp_insert_post($post_data, true);
}
if (is_wp_error($page_id)) {
fwrite(STDERR, $page_id->get_error_message());
exit(1);
}
update_option('show_on_front', 'page');
update_option('page_on_front', (int) $page_id);
$settings = get_option('brt_settings', []);
if (is_array($settings)) {
$settings['translation'] = $settings['translation'] ?? 'WEB';
update_option('brt_settings', $settings, false);
}
echo 'seeded front page ' . $page_id . ' with ' . count($books) . ' books, ' . count($translations) . ' translations, and ' . (count($books) * count($translations) * 2) . ' reference links';
'@
Write-ContainerPhpFile $environment '/tmp/brt-seed-front.php' $seedPhp
Invoke-WpCli $environment 'wp eval-file /tmp/brt-seed-front.php --path=/var/www/html' | Out-Host