From 55c20df3b55ff227eeb1c99bfb90441dea30d44f Mon Sep 17 00:00:00 2001 From: Joao Figueiredo Date: Fri, 13 Jun 2025 23:36:21 +0100 Subject: [PATCH 1/4] first try --- .gitignore | 6 ++++++ blocks-register.php | 21 +++++++++++++++++++++ build/space-status/block.json | 15 +++++++++++++++ build/space-status/index.asset.php | 1 + build/space-status/index.js | 1 + package.json | 15 +++++++++++++++ src/space-status/block.json | 13 +++++++++++++ src/space-status/editor.css | 0 src/space-status/index.js | 12 ++++++++++++ src/space-status/style.css | 1 + 10 files changed, 85 insertions(+) create mode 100644 blocks-register.php create mode 100644 build/space-status/block.json create mode 100644 build/space-status/index.asset.php create mode 100644 build/space-status/index.js create mode 100644 package.json create mode 100644 src/space-status/block.json create mode 100644 src/space-status/editor.css create mode 100644 src/space-status/index.js create mode 100644 src/space-status/style.css diff --git a/.gitignore b/.gitignore index 7e532df..90124a4 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,9 @@ wp-config.php # Note: If you wish to whitelist themes, # uncomment the next line #/wp-content/themes + +# ---> Node.js +/node_modules/ +/package-lock.json + + diff --git a/blocks-register.php b/blocks-register.php new file mode 100644 index 0000000..e336d05 --- /dev/null +++ b/blocks-register.php @@ -0,0 +1,21 @@ + 'ssi_render_block', + ] ); +} +add_action( 'init', 'ssi_register_space_status_block' ); + +/** + * Server‑side markup for the block. + */ +function ssi_render_block( array $attributes, string $content ) : string { + // Re‑use existing helper & CSS class logic. + return ssi_shortcode(); +} \ No newline at end of file diff --git a/build/space-status/block.json b/build/space-status/block.json new file mode 100644 index 0000000..5445335 --- /dev/null +++ b/build/space-status/block.json @@ -0,0 +1,15 @@ +{ + "apiVersion": 3, + "name": "wp-spaceapi-consumer/space-status", + "title": "Space Status", + "description": "Show whether the space is open or closed (SpaceAPI consumer).", + "category": "widgets", + "icon": "info", + "textdomain": "wp-spaceapi-consumer", + "style": "file:./style.css", + "editorStyle": "file:./editor.css", + "editorScript": "file:./index.js", + "supports": { + "html": false + } +} \ No newline at end of file diff --git a/build/space-status/index.asset.php b/build/space-status/index.asset.php new file mode 100644 index 0000000..f246a90 --- /dev/null +++ b/build/space-status/index.asset.php @@ -0,0 +1 @@ + array('react-jsx-runtime', 'wp-blocks', 'wp-i18n', 'wp-server-side-render'), 'version' => 'e81eff0b8644d0be4dac'); diff --git a/build/space-status/index.js b/build/space-status/index.js new file mode 100644 index 0000000..ce0184c --- /dev/null +++ b/build/space-status/index.js @@ -0,0 +1 @@ +(()=>{"use strict";var e={n:r=>{var s=r&&r.__esModule?()=>r.default:()=>r;return e.d(s,{a:s}),s},d:(r,s)=>{for(var t in s)e.o(s,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:s[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)};window.wp.i18n;const r=window.wp.blocks,s=window.wp.serverSideRender;var t=e.n(s);const o=window.ReactJSXRuntime;(0,r.registerBlockType)("wp-spaceapi-consumer/space-status",{edit:()=>(0,o.jsx)(t(),{block:"wp-spaceapi-consumer/space-status"}),save:()=>null})})(); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..e27bbd7 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "wp-spaceapi-consumer", + "version": "0.0.0-private", + "private": true, + "scripts": { + "build": "wp-scripts build", + "start": "wp-scripts start" + }, + "devDependencies": { + "@wordpress/scripts": "^30.18.0" + }, + "engines": { + "node": ">=18.0.0" + } +} \ No newline at end of file diff --git a/src/space-status/block.json b/src/space-status/block.json new file mode 100644 index 0000000..fab63ba --- /dev/null +++ b/src/space-status/block.json @@ -0,0 +1,13 @@ +{ + "apiVersion": 3, + "name": "wp-spaceapi-consumer/space-status", + "title": "Space Status", + "description": "Show whether the space is open or closed (SpaceAPI consumer).", + "category": "widgets", + "icon": "info", + "textdomain": "wp-spaceapi-consumer", + "style": "file:./style.css", + "editorStyle": "file:./editor.css", + "editorScript": "file:./index.js", + "supports": { "html": false } +} \ No newline at end of file diff --git a/src/space-status/editor.css b/src/space-status/editor.css new file mode 100644 index 0000000..e69de29 diff --git a/src/space-status/index.js b/src/space-status/index.js new file mode 100644 index 0000000..c01d125 --- /dev/null +++ b/src/space-status/index.js @@ -0,0 +1,12 @@ +import { __ } from '@wordpress/i18n'; +import { registerBlockType } from '@wordpress/blocks'; +import ServerSideRender from '@wordpress/server-side-render'; + +registerBlockType( 'wp-spaceapi-consumer/space-status', { + edit: () => ( + + ), + save: () => null, // dynamic block — markup comes from PHP +} ); \ No newline at end of file diff --git a/src/space-status/style.css b/src/space-status/style.css new file mode 100644 index 0000000..97e7011 --- /dev/null +++ b/src/space-status/style.css @@ -0,0 +1 @@ +@import url('../wp-spaceapi-consumer-style.css'); \ No newline at end of file From b21a0f03aa2d5dc86a71acd4555cc37cf5830dbc Mon Sep 17 00:00:00 2001 From: Joao Figueiredo Date: Sat, 14 Jun 2025 00:37:12 +0100 Subject: [PATCH 2/4] fix 1 --- README.md | 9 +++++++++ src/space-status/editor.css | 7 +++++++ src/space-status/style.css | 2 +- wp-spaceapi-consumer.php | 8 +++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f447ec..8c65ef5 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ Small WordPress plugin to consume an SpaceAPI endpoint and indicate on the WordP ## Usage +### WordPress Editor Block (Gutenberg) + +You can use the `Space Status` block in the WordPress editor to display the status of the SpaceAPI endpoint. + ### Shortcode You can use the shortcode `[space_status]` to display the status of the SpaceAPI endpoint on your WordPress site. @@ -13,3 +17,8 @@ You can use the shortcode `[space_status]` to display the status of the SpaceAPI ### Widget You can also use the widget `SpaceAPI Status` to display the status of the SpaceAPI endpoint in your WordPress sidebar or footer. + +## Changes + +### 0.4.x +- Added WordPress Editor Block (Gutenberg) support \ No newline at end of file diff --git a/src/space-status/editor.css b/src/space-status/editor.css index e69de29..babbfd2 100644 --- a/src/space-status/editor.css +++ b/src/space-status/editor.css @@ -0,0 +1,7 @@ +/* Editor-only: make the pill obvious & easy to select */ +.wp-block-wp-spaceapi-consumer-space-status { + display: inline-block; + padding: 4px 8px; + border: 1px dashed var(--wp-admin-theme-color, #007cba); + border-radius: 9999px; +} diff --git a/src/space-status/style.css b/src/space-status/style.css index 97e7011..9e2fe47 100644 --- a/src/space-status/style.css +++ b/src/space-status/style.css @@ -1 +1 @@ -@import url('../wp-spaceapi-consumer-style.css'); \ No newline at end of file +@import url('../../wp-spaceapi-consumer-style.css'); \ No newline at end of file diff --git a/wp-spaceapi-consumer.php b/wp-spaceapi-consumer.php index c3b38a3..16fb186 100644 --- a/wp-spaceapi-consumer.php +++ b/wp-spaceapi-consumer.php @@ -4,7 +4,7 @@ * Plugin Slug: wp-spaceapi-consumer * Plugin URI: https://gitea.alluna.pt/jfig/wp-spaceapi-consumer * Description: WordPress plugin to consume a SpaceAPI endpoint and indicate if the Space is Open or Closed - * Version: 0.3.0 + * Version: 0.4.0 * Author: Joao Figueiredo, LCD Porto Team, ChatGPT o3 * Author URI: https://lcdporto.org * License: MIT @@ -167,4 +167,10 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) { } ); } +// Gutenberg block support (dynamic Space Status block) +if ( function_exists( 'register_block_type' ) ) { + require_once plugin_dir_path( __FILE__ ) . 'blocks-register.php'; +} + + // End of file From 88b145d6b30af0d00260326b83335b2de0e90633 Mon Sep 17 00:00:00 2001 From: Joao Figueiredo Date: Sat, 14 Jun 2025 00:51:49 +0100 Subject: [PATCH 3/4] change Block icon to door --- build/space-status/block.json | 2 +- src/space-status/block.json | 2 +- wp-spaceapi-consumer.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/space-status/block.json b/build/space-status/block.json index 5445335..58d5e10 100644 --- a/build/space-status/block.json +++ b/build/space-status/block.json @@ -4,7 +4,7 @@ "title": "Space Status", "description": "Show whether the space is open or closed (SpaceAPI consumer).", "category": "widgets", - "icon": "info", + "icon": "door", "textdomain": "wp-spaceapi-consumer", "style": "file:./style.css", "editorStyle": "file:./editor.css", diff --git a/src/space-status/block.json b/src/space-status/block.json index fab63ba..f0666d1 100644 --- a/src/space-status/block.json +++ b/src/space-status/block.json @@ -4,7 +4,7 @@ "title": "Space Status", "description": "Show whether the space is open or closed (SpaceAPI consumer).", "category": "widgets", - "icon": "info", + "icon": "door", "textdomain": "wp-spaceapi-consumer", "style": "file:./style.css", "editorStyle": "file:./editor.css", diff --git a/wp-spaceapi-consumer.php b/wp-spaceapi-consumer.php index 16fb186..d19b1d1 100644 --- a/wp-spaceapi-consumer.php +++ b/wp-spaceapi-consumer.php @@ -4,7 +4,7 @@ * Plugin Slug: wp-spaceapi-consumer * Plugin URI: https://gitea.alluna.pt/jfig/wp-spaceapi-consumer * Description: WordPress plugin to consume a SpaceAPI endpoint and indicate if the Space is Open or Closed - * Version: 0.4.0 + * Version: 0.4.1 * Author: Joao Figueiredo, LCD Porto Team, ChatGPT o3 * Author URI: https://lcdporto.org * License: MIT From 5bd7dcd9d2623df499f23662eceb719ca3bba659 Mon Sep 17 00:00:00 2001 From: Joao Figueiredo Date: Sat, 14 Jun 2025 01:02:38 +0100 Subject: [PATCH 4/4] change Block icon to building --- build/space-status/block.json | 2 +- src/space-status/block.json | 2 +- wp-spaceapi-consumer.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/space-status/block.json b/build/space-status/block.json index 58d5e10..6a4f361 100644 --- a/build/space-status/block.json +++ b/build/space-status/block.json @@ -4,7 +4,7 @@ "title": "Space Status", "description": "Show whether the space is open or closed (SpaceAPI consumer).", "category": "widgets", - "icon": "door", + "icon": "building", "textdomain": "wp-spaceapi-consumer", "style": "file:./style.css", "editorStyle": "file:./editor.css", diff --git a/src/space-status/block.json b/src/space-status/block.json index f0666d1..7f4391f 100644 --- a/src/space-status/block.json +++ b/src/space-status/block.json @@ -4,7 +4,7 @@ "title": "Space Status", "description": "Show whether the space is open or closed (SpaceAPI consumer).", "category": "widgets", - "icon": "door", + "icon": "building", "textdomain": "wp-spaceapi-consumer", "style": "file:./style.css", "editorStyle": "file:./editor.css", diff --git a/wp-spaceapi-consumer.php b/wp-spaceapi-consumer.php index d19b1d1..16250cd 100644 --- a/wp-spaceapi-consumer.php +++ b/wp-spaceapi-consumer.php @@ -4,7 +4,7 @@ * Plugin Slug: wp-spaceapi-consumer * Plugin URI: https://gitea.alluna.pt/jfig/wp-spaceapi-consumer * Description: WordPress plugin to consume a SpaceAPI endpoint and indicate if the Space is Open or Closed - * Version: 0.4.1 + * Version: 0.4.2 * Author: Joao Figueiredo, LCD Porto Team, ChatGPT o3 * Author URI: https://lcdporto.org * License: MIT