-
-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor to filter-based architecture #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add autoloader for PSR-4 style class loading - Split endpoints into controller/ folder (Nodeinfo\Controller namespace) - Add integration/ folder for WordPress-specific implementations - NodeInfo endpoint uses filters for extensibility (other plugins can hook in) - NodeInfo2 endpoint is self-contained with filters for customization - Add Nodeinfo namespace to all classes - Follow WordPress coding standards for file/class naming This aligns with the architecture used in wordpress-activitypub plugin, making it easier for other plugins to extend NodeInfo data via filters.
Each NodeInfo version now has its own integration class that: - Registers its version to the endpoint enum - Adds its discovery and JRD links - Provides version-specific schema - Implements version-specific data via filters This allows other plugins to add new NodeInfo versions or modify existing ones by hooking into the appropriate filters. New filters: - nodeinfo_versions: Register supported versions - nodeinfo_discovery_links: Add discovery document links - nodeinfo_jrd_links: Add WebFinger/Host-Meta links - nodeinfo_schema: Modify the JSON schema
Move JRD (WebFinger/Host-Meta) discovery link generation to the controller's jrd() method, which translates nodeinfo_discovery_links to JRD format. This removes duplicate jrd_link methods from individual integration classes since they now only need to register their discovery links once.
- Replace docker-compose with wp-env (ports 8889/8890) - Update phpcs.xml to match ActivityPub standards - Update composer.json with modern dev dependencies - Restructure tests to tests/phpunit/ directory - Add PHPUnit workflow for CI - Update PHPCS workflow with modern actions - Bump minimum PHP to 7.2 and WordPress to 6.5
- Fix missing @Package tag in nodeinfo.php - Add phpcs:ignore for lowercase software name (per NodeInfo spec) - Remove unused $request parameter in get_discovery() - Add unit tests for NodeInfo endpoint - Add unit tests for NodeInfo2 endpoint - Add unit tests for helper functions
Remove MARIADB_DATABASE from service config to let the install script create the database instead of MariaDB creating it automatically.
- Remove coverage config from phpunit.xml.dist (not supported in PHPUnit 8) - Fix test_get_masked_version: function always masks, test format instead - Fix test_invalid_version: returns 400 (enum validation) not 404 - Fix test_nodeinfo2_endpoint_registered: use regex route pattern
Schema descriptions are not user-facing and should not be translated.
- Add missing schema method to NodeInfo 1.1 integration - Add NodeInfo 2.2 integration with: - instance object (name, description) - activeWeek in usage.users - repository in software
Adds stricter schema validation for NodeInfo versions 1.0, 1.1, 2.0, 2.1, and 2.2, including enums, patterns, and minimums for properties. Introduces protocol handling hooks for NodeInfo 2.x versions and updates supported protocol/service lists. Adds homepage to software metadata for 2.1 and 2.2, and improves documentation with schema links.
Updated the plugin version in nodeinfo.php from 2.3.1 to 3.0.0 to reflect a new release. No other changes were made.
Raised minimum WordPress and PHP versions, updated stable tag to 3.0.0, and added changelog for major refactor, NodeInfo 2.2 support, new integration classes, PSR-4 autoloader, schema updates, protocol filter, and homepage field.
Added sections describing the information shared by the plugin, supported NodeInfo versions, available endpoints, and frequently asked questions. This improves documentation for users and developers integrating with the plugin.
Introduces a Health_Check class to provide Site Health tests for NodeInfo endpoints, verifying accessibility of the well-known and REST endpoints. Updates documentation and plugin initialization to include these checks, helping users diagnose configuration issues.
All WordPress core functions and classes are now called with a leading backslash to ensure global namespace resolution and avoid conflicts with custom functions. Site Health checks initialization was moved to an admin-only hook for better separation of concerns.
- Add deprecated Nodeinfo_Endpoint class for backwards compatibility - Update package.json with wp-env scripts and remove grunt - Change wp-env ports to avoid conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the NodeInfo plugin to a modern filter-based architecture, enabling better extensibility for other plugins. The major enhancement is adding support for NodeInfo 2.2 and introducing a PSR-4 autoloader with a clean separation of concerns through controller and integration classes.
Key Changes
- Implemented filter-based architecture with separate integration classes for each NodeInfo version (1.0, 1.1, 2.0, 2.1, 2.2)
- Added PSR-4 autoloader and reorganized code structure into
controller/andintegration/folders - Introduced Site Health checks to verify endpoint accessibility
- Updated schemas to match official NodeInfo specifications with proper enums and validation
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
tests/phpunit/tests/class-test-nodeinfo-endpoint.php |
Test suite for NodeInfo endpoints with version discovery tests |
tests/phpunit/tests/class-test-nodeinfo2-endpoint.php |
Test suite for NodeInfo2 endpoint functionality |
tests/phpunit/tests/class-test-functions.php |
Tests for helper functions (active users, version masking) |
tests/phpunit/bootstrap.php |
PHPUnit bootstrap configuration |
includes/controller/class-nodeinfo.php |
Main NodeInfo REST controller with filter-based data retrieval |
includes/controller/class-nodeinfo2.php |
NodeInfo2 REST controller implementation |
includes/integration/class-nodeinfo10.php through class-nodeinfo22.php |
Version-specific integration classes implementing schemas and data providers |
includes/functions.php |
Helper functions for user activity and version formatting |
includes/class-autoloader.php |
PSR-4 autoloader following WordPress naming conventions |
includes/class-health-check.php |
Site Health integration for endpoint verification |
includes/class-nodeinfo-endpoint.php |
Deprecated wrapper for backwards compatibility |
nodeinfo.php |
Main plugin file with initialization logic |
phpcs.xml |
Updated PHP CodeSniffer configuration |
phpunit.xml.dist |
Updated PHPUnit configuration |
composer.json |
Updated dependencies and minimum PHP version (7.2) |
package.json |
Added wp-env and updated scripts |
.wp-env.json |
WordPress environment configuration for development |
.github/workflows/phpunit.yml |
CI workflow for PHPUnit tests |
.github/workflows/phpcs.yml |
CI workflow for code standards |
README.md |
Comprehensive documentation updates with FAQ and changelog |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Add backslash to @return WP_REST_Response types - Add fields parameter to get_users for performance - Add version 2.2 to test coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Refactors the plugin to use a filter-based architecture, aligning with the pattern used in wordpress-activitypub.
This makes it easier for other plugins to extend NodeInfo data by hooking into filters rather than modifying core files.
Changes
controller/andintegration/foldersNodeinfonamespace to all classesNodeinfo\Controller\Nodeinfo) uses filters for all dataNodeinfo\Controller\Nodeinfo2) is self-contained with WordPress defaultsNew Structure
Available Filters
NodeInfo (1.0, 1.1, 2.0, 2.1, 2.2):
nodeinfo_versions- Registered versionsnodeinfo_discovery_links- Discovery links (also used for JRD)nodeinfo_schema- REST API schemanodeinfo_data_software- Software infonodeinfo_data_protocols- Protocols arraynodeinfo_data_services- Services (inbound/outbound)nodeinfo_data_usage- Usage statisticsnodeinfo_data_metadata- Metadatanodeinfo_data- Complete responsenodeinfo_protocols- Shared filter for protocols (2.0+)NodeInfo2 (1.0):
nodeinfo2_data_server- Server infonodeinfo2_data_protocols- Protocols arraynodeinfo2_data_services- Servicesnodeinfo2_data_usage- Usage statisticsnodeinfo2_data_metadata- Metadatanodeinfo2_data- Complete responseSchema Updates
All schemas now match the official NodeInfo specifications with:
Example Usage
Test Plan
/.well-known/nodeinfoand verify discovery document/wp-json/nodeinfo/2.2returns valid NodeInfo 2.2/wp-json/nodeinfo/2.1returns valid NodeInfo 2.1/wp-json/nodeinfo/2.0returns valid NodeInfo 2.0/wp-json/nodeinfo/1.1returns valid NodeInfo 1.1/wp-json/nodeinfo/1.0returns valid NodeInfo 1.0/wp-json/nodeinfo2/1.0returns valid NodeInfo2nodeinfo_datafiltercomposer phpcs- should passcomposer phpunit- should pass