Skip to content

Commit 409a7b1

Browse files
authored
Block editor integration: pre-publish panel + per-post share toggle (#139)
1 parent d300a97 commit 409a7b1

36 files changed

Lines changed: 2120 additions & 303 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
The editor's Bluesky panel now has a switch to turn sharing on or off for an individual post; switching it off after a post was shared removes it from Bluesky.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Before publishing, the editor now shows whether a post will be shared to Bluesky, how it will appear, and how its text measures against Bluesky’s character limit.

atmosphere.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
\define( 'ATMOSPHERE_PLUGIN_URL', \plugin_dir_url( __FILE__ ) );
2525
\define( 'ATMOSPHERE_PLUGIN_FILE', __FILE__ );
2626

27+
/**
28+
* Post meta key: per-post opt-out from sharing to Bluesky.
29+
*
30+
* Stored as a registered, REST-exposed boolean so the block-editor panel
31+
* can bind a toggle to it. '1' (true) means the author switched sharing
32+
* off for this post; absent/empty means the default — sharing is on.
33+
*/
34+
\define( 'ATMOSPHERE_META_DISABLED', 'atmosphere_disabled' );
35+
2736
/*
2837
* Custom autoloader for Atmosphere classes — maps the Atmosphere
2938
* namespace to includes/ using WordPress filename conventions.

build/editor-plugin/block.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 3,
4+
"name": "atmosphere/editor-plugin",
5+
"title": "ATmosphere Editor Panel",
6+
"category": "widgets",
7+
"description": "Document sidebar panel to control whether a post is shared to Bluesky.",
8+
"icon": "share",
9+
"textdomain": "atmosphere",
10+
"editorScript": "file:./plugin.js"
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-i18n', 'wp-plugins'), 'version' => '8cd5c929567d05cbfdf7');

build/editor-plugin/plugin.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/pre-publish-panel/block.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 3,
4+
"name": "atmosphere/pre-publish-panel",
5+
"title": "ATmosphere Pre-Publish Panel",
6+
"category": "widgets",
7+
"description": "Shows whether a post will publish to Bluesky, the strategy, and the character count before publishing.",
8+
"icon": "share",
9+
"textdomain": "atmosphere",
10+
"editorScript": "file:./plugin.js"
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '8fa0d7dd1bccedfa1d37');

build/pre-publish-panel/plugin.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/php-class-structure.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ wordpress-atmosphere/
2020
│ ├── class-api.php # DPoP-authenticated PDS request layer with nonce retry.
2121
│ ├── class-autoloader.php # Custom WordPress-style autoloader.
2222
│ ├── class-backfill.php # Bulk re-sync of existing posts.
23+
│ ├── class-block-editor.php # Enqueues the block-editor panels (share toggle + pre-publish).
2324
│ ├── class-handle.php # Domain-handle setup helper (writes /.well-known/atproto-did).
2425
│ ├── class-post-types.php # Supported post-type discovery and option storage.
2526
│ ├── class-publisher.php # Atomic applyWrites for both Bluesky post + standard.site document.
@@ -42,6 +43,11 @@ wordpress-atmosphere/
4243
│ │ ├── class-nonce-storage.php # DPoP nonce persistence.
4344
│ │ └── class-resolver.php # handle → DID → PDS → auth server resolution chain.
4445
│ │
46+
│ ├── rest/ # REST API controllers (WP_REST_Controller subclasses).
47+
│ │ ├── class-client-metadata-controller.php # Public OAuth client-metadata endpoint.
48+
│ │ └── admin/ # Authenticated, editor-only controllers.
49+
│ │ └── class-pre-publish-controller.php # Pre-publish projection for the editor panel.
50+
│ │
4551
│ ├── transformer/ # WordPress → AT Protocol record transformers.
4652
│ │ ├── class-base.php # Abstract base.
4753
│ │ ├── class-comment.php # Comment → app.bsky.feed.post (reply).
@@ -51,8 +57,9 @@ wordpress-atmosphere/
5157
│ │ ├── class-publication.php # Site → site.standard.publication.
5258
│ │ └── class-tid.php # AT Protocol Timestamp ID generation.
5359
│ │
54-
│ └── wp-admin/ # Admin functionality.
55-
│ └── class-admin.php # Settings page, sidebar panel, REST handlers.
60+
│ └── wp-admin/ # Admin screens.
61+
│ ├── class-admin.php # Settings page, OAuth callback, menu wiring.
62+
│ └── class-settings-fields.php # Settings API field rendering.
5663
5764
├── integrations/ # Third-party plugin integrations.
5865
│ └── class-load.php # Integration loader stub.
@@ -162,6 +169,8 @@ namespace Atmosphere\OAuth;
162169
namespace Atmosphere\Transformer;
163170
namespace Atmosphere\Content_Parser;
164171
namespace Atmosphere\Integrations;
172+
namespace Atmosphere\Rest; // Public REST controllers.
173+
namespace Atmosphere\Rest\Admin; // Authenticated, editor-only REST controllers.
165174
namespace Atmosphere\WP_Admin;
166175
namespace Atmosphere\Tests;
167176
```
@@ -212,7 +221,9 @@ class Publisher {
212221
| AT Protocol record transformers | `includes/transformer/` | `Atmosphere\Transformer` |
213222
| OAuth flow components | `includes/oauth/` | `Atmosphere\OAuth` |
214223
| Content parsers (NSID-typed `content` producers) | `includes/content-parser/` | `Atmosphere\Content_Parser` |
215-
| Admin screens / REST handlers | `includes/wp-admin/` | `Atmosphere\WP_Admin` |
224+
| Public REST controllers (`WP_REST_Controller`) | `includes/rest/` | `Atmosphere\Rest` |
225+
| Authenticated/editor-only REST controllers | `includes/rest/admin/` | `Atmosphere\Rest\Admin` |
226+
| Admin screens | `includes/wp-admin/` | `Atmosphere\WP_Admin` |
216227
| Third-party plugin integrations | `integrations/` | `Atmosphere\Integrations` |
217228

218229
### Creating a New Subdirectory
@@ -227,6 +238,24 @@ After adding or renaming a class file under the `Atmosphere` namespace, no Compo
227238

228239
## Architectural Patterns
229240

241+
### REST Controllers
242+
243+
Every REST endpoint is a `WP_REST_Controller` subclass under `includes/rest/`
244+
(public) or `includes/rest/admin/` (authenticated / editor-only), mirroring
245+
the wordpress-activitypub plugin's layout. Each controller declares its route
246+
via `register_routes()`; they are all instantiated together in
247+
`Atmosphere::register_rest_controllers()` on `rest_api_init`.
248+
249+
Route namespaces are versioned deliberately:
250+
251+
- **`atmosphere/v1`** — the public OAuth `client-metadata` endpoint. Its URL is
252+
the OAuth `client_id`, an external contract, so the version string is frozen
253+
and must not change.
254+
- **`atmosphere/1.0`** — admin/editor routes (e.g. the pre-publish preview).
255+
256+
New admin routes should use `atmosphere/1.0`, set `show_in_index => false`, and
257+
gate access with a `permission_callback`.
258+
230259
### Transformer Pattern
231260

232261
The transformer pattern (`includes/transformer/`) is the canonical way to add a new AT Protocol record type:

0 commit comments

Comments
 (0)