fix: complete CHRNX responsive edge states
This commit is contained in:
15 files changed
+384
-35
No files matched your search
@@ -3,7 +3,34 @@ set -eu
|
||||
|
||||
chrnx_image_script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
chrnx_image_root=$(dirname -- "$chrnx_image_script_dir")
|
||||
chrnx_image_output="$chrnx_image_root/assets/images/generated"
|
||||
chrnx_image_default_output="$chrnx_image_root/assets/images/generated"
|
||||
chrnx_image_output=${1:-"$chrnx_image_default_output"}
|
||||
case "$chrnx_image_output" in
|
||||
/*) ;;
|
||||
*)
|
||||
echo "Image output must be an explicit absolute path." >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
if [ "$chrnx_image_output" = "/" ] || [ "$chrnx_image_output" = "$chrnx_image_root" ]; then
|
||||
echo "Refusing broad image output path: $chrnx_image_output" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ "$chrnx_image_output" != "$chrnx_image_default_output" ]; then
|
||||
chrnx_image_safe_tmp=${TMPDIR:-/tmp}
|
||||
chrnx_image_safe_tmp=${chrnx_image_safe_tmp%/}
|
||||
case "$chrnx_image_output" in
|
||||
"$chrnx_image_safe_tmp"/chrnx-*) ;;
|
||||
*)
|
||||
echo "Temporary image output must be an existing chrnx-* directory under $chrnx_image_safe_tmp." >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
if [ ! -d "$chrnx_image_output" ]; then
|
||||
echo "Temporary image output does not exist: $chrnx_image_output" >&2
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
chrnx_image_tmp=$(mktemp -d "${TMPDIR:-/tmp}/chrnx-images.XXXXXX")
|
||||
trap 'rm -rf -- "$chrnx_image_tmp"' EXIT HUP INT TERM
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ $chrnx_seed_host = wp_parse_url( home_url( '/' ), PHP_URL_HOST );
|
||||
if ( ! in_array( $chrnx_seed_host, array( 'localhost', '127.0.0.1' ), true ) ) {
|
||||
WP_CLI::error( 'Refusing to seed a non-local WordPress site.' );
|
||||
}
|
||||
$chrnx_seed_scenario = isset( $args[0] ) && is_string( $args[0] ) ? $args[0] : 'default';
|
||||
$chrnx_seed_scenarios = array( 'default', 'featured-1', 'featured-2', 'featured-3', 'subscribe-unpublished', 'subscribe-unavailable' );
|
||||
if ( ! in_array( $chrnx_seed_scenario, $chrnx_seed_scenarios, true ) ) {
|
||||
WP_CLI::error( 'Unknown local fixture scenario.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Read one fixture JSON document from the mapped theme.
|
||||
@@ -114,7 +119,7 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_index => $chrnx_seed_post ) {
|
||||
wp_set_object_terms( $chrnx_seed_post_id, array(), 'chrnx_show', false );
|
||||
}
|
||||
|
||||
foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration' ) as $chrnx_seed_meta_key ) {
|
||||
foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration', 'canonical_episode_url' ) as $chrnx_seed_meta_key ) {
|
||||
delete_post_meta( $chrnx_seed_post_id, $chrnx_seed_meta_key );
|
||||
}
|
||||
if ( isset( $chrnx_seed_post['episodeNumber'] ) ) {
|
||||
@@ -123,6 +128,9 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_index => $chrnx_seed_post ) {
|
||||
if ( isset( $chrnx_seed_post['episodeDuration'] ) ) {
|
||||
update_post_meta( $chrnx_seed_post_id, 'chrnx_episode_duration', chrnx_sanitize_episode_duration( $chrnx_seed_post['episodeDuration'] ) );
|
||||
}
|
||||
if ( isset( $chrnx_seed_post['canonicalEpisodeUrl'] ) ) {
|
||||
update_post_meta( $chrnx_seed_post_id, 'canonical_episode_url', chrnx_sanitize_canonical_episode_url( $chrnx_seed_post['canonicalEpisodeUrl'] ) );
|
||||
}
|
||||
$chrnx_seed_post_ids[ $chrnx_seed_post['fixtureKey'] ] = $chrnx_seed_post_id;
|
||||
}
|
||||
|
||||
@@ -132,21 +140,35 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_post ) {
|
||||
$chrnx_seed_sticky_ids[] = $chrnx_seed_post_ids[ $chrnx_seed_post['fixtureKey'] ];
|
||||
}
|
||||
}
|
||||
update_option( 'sticky_posts', $chrnx_seed_sticky_ids );
|
||||
$chrnx_seed_featured_count = 3;
|
||||
if ( preg_match( '/^featured-([123])$/', $chrnx_seed_scenario, $chrnx_seed_match ) ) {
|
||||
$chrnx_seed_featured_count = absint( $chrnx_seed_match[1] );
|
||||
update_option( '_chrnx_fixture_featured_limit', $chrnx_seed_featured_count );
|
||||
} else {
|
||||
delete_option( '_chrnx_fixture_featured_limit' );
|
||||
}
|
||||
update_option( 'sticky_posts', array_slice( $chrnx_seed_sticky_ids, 0, $chrnx_seed_featured_count ) );
|
||||
update_option( 'blogname', 'CHRNX' );
|
||||
update_option( 'blogdescription', 'Ideas made tangible.' );
|
||||
update_option( 'show_on_front', 'page' );
|
||||
update_option( 'page_on_front', $chrnx_seed_page_ids['home'] );
|
||||
update_option( 'page_for_posts', 0 );
|
||||
update_option( 'chrnx_subscribe_page_id', $chrnx_seed_page_ids['subscribe'] );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $chrnx_seed_page_ids['subscribe'],
|
||||
'post_status' => 'subscribe-unpublished' === $chrnx_seed_scenario ? 'draft' : 'publish',
|
||||
)
|
||||
);
|
||||
update_option( 'chrnx_subscribe_page_id', 'subscribe-unavailable' === $chrnx_seed_scenario ? 0 : $chrnx_seed_page_ids['subscribe'] );
|
||||
update_option( 'permalink_structure', '/%postname%/' );
|
||||
flush_rewrite_rules( false );
|
||||
|
||||
WP_CLI::log(
|
||||
sprintf(
|
||||
'CHRNX_FIXTURES pages=%d posts=%d front=%d',
|
||||
'CHRNX_FIXTURES pages=%d posts=%d front=%d scenario=%s',
|
||||
count( $chrnx_seed_page_ids ),
|
||||
count( $chrnx_seed_post_ids ),
|
||||
$chrnx_seed_page_ids['home']
|
||||
$chrnx_seed_page_ids['home'],
|
||||
$chrnx_seed_scenario
|
||||
)
|
||||
);
|
||||
@@ -4,6 +4,15 @@ set -eu
|
||||
chrnx_script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
chrnx_project_dir=$(dirname -- "$chrnx_script_dir")
|
||||
chrnx_docker_cli_dir=${CHRNX_DOCKER_CLI_DIR:-/opt/homebrew/opt/docker/bin}
|
||||
chrnx_seed_scenario=${1:-default}
|
||||
|
||||
case "$chrnx_seed_scenario" in
|
||||
default|featured-1|featured-2|featured-3|subscribe-unpublished|subscribe-unavailable) ;;
|
||||
*)
|
||||
echo "Unknown local fixture scenario: $chrnx_seed_scenario" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -x "$chrnx_docker_cli_dir/docker" ]; then
|
||||
echo "Docker CLI not found at the approved Colima path: $chrnx_docker_cli_dir/docker" >&2
|
||||
@@ -19,4 +28,4 @@ case "$chrnx_seed_probe" in
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
PATH="$chrnx_docker_cli_dir:$PATH" npm exec -- wp-env run cli wp eval-file wp-content/themes/chrnx/scripts/seed-test-content.php
|
||||
PATH="$chrnx_docker_cli_dir:$PATH" npm exec -- wp-env run cli wp eval-file wp-content/themes/chrnx/scripts/seed-test-content.php "$chrnx_seed_scenario"
|
||||
Reference in new issue
Block a user