diff --git a/.wporg/assets/blueprints/blueprint.json b/.wporg/assets/blueprints/blueprint.json new file mode 100644 index 00000000..b2424ba6 --- /dev/null +++ b/.wporg/assets/blueprints/blueprint.json @@ -0,0 +1,34 @@ +{ + "landingPage": "/sample-page/", + "preferredVersions": { + "php": "8.0", + "wp": "latest" + }, + "steps": [ + { + "step": "login", + "username": "admin", + "password": "password" + }, + { + "step": "setSiteOptions", + "options": { + "permalink_structure": "/%year%/%monthnum%/%day%/%postname%/" + } + }, + { + "step": "installPlugin", + "pluginZipFile": { + "resource": "wordpress.org/plugins", + "slug": "chatrix" + } + }, + { + "step": "runPHP", + "code": "
Below you can see \"Chatrix\" block in action. You can add it anywhere using either /chatrix
or by looking up chatrix when choosing which block to insert.
Even though its not functional in this Playground demo, since it requires its own service worker and that is not compatible with the Playground (running WordPress in your browser) at the moment, you can at least see how it looks and it can be added anywhere you can add a Gutenberg block :)
';\n\n$chatrix_block_2col = <<Below you can see “Chatrix” block in action. You can add it anywhere using either /chatrix
or by looking up chatrix when choosing which block to insert.
Here can be some login instructions of participating in the chat window on the right side:
\n\nUnfortunately, it's not possible to login into Matrix inside of Playground demo, since it requires its own service worker and that is not compatible with the Playground at the moment. You can explore how it looks and how it can be added anywhere you can add a Gutenberg block :)
\n\nCHATRIXBLOCK2COLUMNS;\n\n$sample_page_post_id = 2;\n\nwp_update_post( array(\n 'ID' => $sample_page_post_id,\n 'post_title' => 'Chatrix [Regular]',\n 'post_content' => $chatrix_block_simple\n) );\n\nwp_insert_post( array(\n 'ID' => 3,\n 'post_title' => 'Chatrix [2 Column]',\n 'post_type' => 'page',\n 'post_status' => 'publish',\n 'post_content' => $chatrix_block_2col\n) );\n\nwp_insert_post( array(\n 'ID' => 4,\n 'post_title' => 'Chatrix [Popup]',\n 'post_type' => 'page',\n 'post_status' => 'publish',\n 'post_content' => 'On this page, you can see the popup widget at the bottom right of your screen. Click on it to show Chatrix.
'\n) );\n\nupdate_option( 'chatrix_settings', array(\n 'homeserver' => 'matrix.org',\n 'room' => '#matrix:matrix.org',\n 'show_on' => 'specific',\n 'pages' => array(\n 0 => '4'\n )\n) );", + "progress": { + "caption": "Setting Chatrix instances" + } + } + ] +} diff --git a/.wporg/assets/readme.md b/.wporg/assets/readme.md new file mode 100644 index 00000000..624f8ad9 --- /dev/null +++ b/.wporg/assets/readme.md @@ -0,0 +1,3 @@ +Run `update_blueprint.sh` after making changes in `blueprint_runphp_step_code.php` so that `.wporg/assets/blueprints/blueprint.json` is updated. + +[See blueprint in action on playground](https://playground.wordpress.net/?blueprint-url=https://raw.githubusercontent.com/automattic/chatrix/main/.wporg/assets/blueprints/blueprint.json) diff --git a/.wporg/blueprint_runphp_step_code.php b/.wporg/blueprint_runphp_step_code.php new file mode 100644 index 00000000..83ae3329 --- /dev/null +++ b/.wporg/blueprint_runphp_step_code.php @@ -0,0 +1,65 @@ +Below you can see "Chatrix" block in action. You can add it anywhere using either /chatrix
or by looking up chatrix when choosing which block to insert.
Even though its not functional in this Playground demo, since it requires its own service worker and that is not compatible with the Playground (running WordPress in your browser) at the moment, you can at least see how it looks and it can be added anywhere you can add a Gutenberg block :)
'; + +$chatrix_block_2col = <<Below you can see “Chatrix” block in action. You can add it anywhere using either /chatrix
or by looking up chatrix when choosing which block to insert.
Here can be some login instructions of participating in the chat window on the right side:
+ +Unfortunately, it's not possible to login into Matrix inside of Playground demo, since it requires its own service worker and that is not compatible with the Playground at the moment. You can explore how it looks and how it can be added anywhere you can add a Gutenberg block :)
+ +CHATRIXBLOCK2COLUMNS; + +$sample_page_post_id = 2; + +wp_update_post( array( + 'ID' => $sample_page_post_id, + 'post_title' => 'Chatrix [Regular]', + 'post_content' => $chatrix_block_simple +) ); + +wp_insert_post( array( + 'ID' => 3, + 'post_title' => 'Chatrix [2 Column]', + 'post_type' => 'page', + 'post_status' => 'publish', + 'post_content' => $chatrix_block_2col +) ); + +wp_insert_post( array( + 'ID' => 4, + 'post_title' => 'Chatrix [Popup]', + 'post_type' => 'page', + 'post_status' => 'publish', + 'post_content' => 'On this page, you can see the popup widget at the bottom right of your screen. Click on it to show Chatrix.
' +) ); + +update_option( 'chatrix_settings', array( + 'homeserver' => 'matrix.org', + 'room' => '#matrix:matrix.org', + 'show_on' => 'specific', + 'pages' => array( + 0 => '4' + ) +) ); diff --git a/.wporg/update_blueprint.sh b/.wporg/update_blueprint.sh new file mode 100644 index 00000000..a2304576 --- /dev/null +++ b/.wporg/update_blueprint.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +if ! command -v jq &> /dev/null ; then + echo "jq is not installed. Please install jq (https://jqlang.github.io/jq/) before running this script." +fi + +# Get the directory of the script +script_dir="$(dirname "$(readlink -f "$0")")" + +blueprint_location="$script_dir/assets/blueprints/blueprint.json" +phpsrc_location="$script_dir/blueprint_runphp_step_code.php" + +jq --arg newCode "$(cat $phpsrc_location)" '.steps[] |= if .step == "runPHP" then .code = $newCode else . end' $blueprint_location > updated_blueprint.json + +rm $blueprint_location +mv updated_blueprint.json $blueprint_location