Skip to content

Commit bc227e1

Browse files
authored
Merge pull request #15 from pfefferle/refactor/filter-based-architecture
Refactor to filter-based architecture
2 parents f3a9367 + f49831f commit bc227e1

29 files changed

Lines changed: 3130 additions & 604 deletions

.gitattributes

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22
.editorconfig export-ignore
33
.git export-ignore
44
.gitignore export-ignore
5+
.gitattributes export-ignore
6+
.github export-ignore
7+
.wordpress-org export-ignore
8+
.wp-env.json export-ignore
59
.travis.yml export-ignore
610
.codeclimate.yml export-ignore
711
.data export-ignore
8-
.github export-ignore
9-
.gitattributes export-ignore
10-
.wordpress-org export-ignore
11-
Gruntfile.js export-ignore
12-
LINGUAS export-ignore
13-
Makefile export-ignore
14-
CODE_OF_CONDUCT.md export-ignore
15-
LICENSE.md export-ignore
1612
_site export-ignore
1713
bin export-ignore
14+
CODE_OF_CONDUCT.md export-ignore
1815
composer.json export-ignore
1916
composer.lock export-ignore
2017
docker-compose.yml export-ignore
18+
Gruntfile.js export-ignore
2119
gulpfile.js export-ignore
22-
package.json export-ignore
20+
LICENSE.md export-ignore
21+
LINGUAS export-ignore
22+
Makefile export-ignore
2323
node_modules export-ignore
2424
npm-debug.log export-ignore
25-
phpcs.xml export-ignore
2625
package.json export-ignore
26+
package-lock.json export-ignore
27+
phpcs.xml export-ignore
2728
phpunit.xml export-ignore
2829
phpunit.xml.dist export-ignore
2930
tests export-ignore
30-
node_modules export-ignore
3131
vendor export-ignore

.github/workflows/phpcs.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
name: PHP_CodeSniffer
2-
on: push
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- '**/*.php'
8+
- 'composer.json'
9+
- 'composer.lock'
10+
- 'phpcs.xml'
11+
- '.github/workflows/phpcs.yml'
12+
pull_request:
13+
paths:
14+
- '**/*.php'
15+
- 'composer.json'
16+
- 'composer.lock'
17+
- 'phpcs.xml'
18+
- '.github/workflows/phpcs.yml'
319
jobs:
420
phpcs:
521
runs-on: ubuntu-latest
622
steps:
723
- name: Checkout
8-
uses: actions/checkout@v2
24+
uses: actions/checkout@v4
925
- name: Setup PHP
1026
uses: shivammathur/setup-php@v2
1127
with:
1228
php-version: '7.4'
1329
coverage: none
1430
tools: composer, cs2pr
15-
- name: Get Composer cache directory
16-
id: composer-cache
17-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
18-
- name: Setup cache
19-
uses: pat-s/always-upload-cache@v1.1.4
20-
with:
21-
path: ${{ steps.composer-cache.outputs.dir }}
22-
# Use the hash of composer.json as the key for your cache if you do not commit composer.lock.
23-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
24-
#key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
25-
restore-keys: ${{ runner.os }}-composer-
26-
- name: Install dependencies
27-
run: composer install --prefer-dist --no-progress
31+
- name: Install Composer dependencies for PHP
32+
uses: ramsey/composer-install@v3
2833
- name: Detect coding standard violations
29-
run: ./vendor/bin/phpcs -n -q
34+
run: ./vendor/bin/phpcs

.github/workflows/phpunit.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: PHPUnit
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths:
7+
- '**/*.php'
8+
- 'composer.json'
9+
- 'composer.lock'
10+
- 'phpunit.xml.dist'
11+
- '.github/workflows/phpunit.yml'
12+
pull_request:
13+
paths:
14+
- '**/*.php'
15+
- 'composer.json'
16+
- 'composer.lock'
17+
- 'phpunit.xml.dist'
18+
- '.github/workflows/phpunit.yml'
19+
20+
jobs:
21+
phpunit:
22+
runs-on: ubuntu-latest
23+
services:
24+
mysql:
25+
image: mariadb:10.4
26+
env:
27+
MARIADB_ROOT_PASSWORD: root
28+
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
29+
ports:
30+
- 3306:3306
31+
options: >-
32+
--health-cmd="healthcheck.sh --connect --innodb_initialized"
33+
--health-interval=5s
34+
--health-timeout=2s
35+
--health-retries=3
36+
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
php-version: ['7.2', '8.3']
41+
wp-version: ['latest']
42+
include:
43+
- php-version: '7.2'
44+
wp-version: '6.5'
45+
46+
name: PHP ${{ matrix.php-version }} / WP ${{ matrix.wp-version }}
47+
steps:
48+
- name: Install svn
49+
run: sudo apt-get update && sudo apt-get install -y subversion
50+
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Setup PHP
55+
uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: ${{ matrix.php-version }}
58+
extensions: mbstring, intl
59+
ini-values: post_max_size=256M, max_execution_time=180
60+
coverage: none
61+
62+
- name: Install Composer dependencies
63+
uses: ramsey/composer-install@v3
64+
65+
- name: Setup Test Environment
66+
run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }}
67+
68+
- name: Run PHPUnit
69+
run: vendor/bin/phpunit

.wp-env.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"core": null,
3+
"plugins": [ "." ],
4+
"port": 8891,
5+
"testsPort": 8892,
6+
"env": {
7+
"tests": {
8+
"config": {
9+
"WP_ENVIRONMENT_TYPE": "production"
10+
},
11+
"mappings": {
12+
"wp-content/plugins/nodeinfo": "."
13+
}
14+
}
15+
},
16+
"lifecycleScripts": {
17+
"afterStart": "npx wp-env run cli wp rewrite structure /%year%/%monthnum%/%postname%/"
18+
}
19+
}

README.md

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
- Contributors: pfefferle
44
- Donate link: https://notiz.blog/donate/
55
- Tags: nodeinfo, fediverse, ostatus, diaspora, activitypub
6-
- Requires at least: 4.9
6+
- Requires at least: 6.6
77
- Tested up to: 6.9
8-
- Stable tag: 2.3.1
9-
- Requires PHP: 5.6
8+
- Stable tag: 3.0.0
9+
- Requires PHP: 7.2
1010
- License: MIT
1111
- License URI: https://opensource.org/licenses/MIT
1212

@@ -18,12 +18,80 @@ NodeInfo and NodeInfo2 for WordPress!
1818

1919
This plugin provides a barebone JSON file with basic "node"-informations. The file can be extended by other WordPress plugins, like [OStatus](https://wordpress.org/plugins/ostatus-for-wordpress/), [Diaspora](https://github.com/pfefferle/wordpress-dandelion) or [ActivityPub](https://wordpress.org/plugins/activitypub/)/[Pterotype](https://wordpress.org/plugins/pterotype/).
2020

21+
### What information does this plugin share?
22+
23+
The plugin exposes the following public information about your site:
24+
25+
* **Software**: WordPress version (major version only for privacy)
26+
* **Usage statistics**: Number of users, posts, and comments
27+
* **Site info**: Your site name and description
28+
* **Protocols**: Which federation protocols your site supports (e.g., ActivityPub)
29+
* **Services**: Which external services your site can connect to (e.g., RSS feeds)
30+
31+
This information helps other servers in the Fediverse discover and interact with your site.
32+
33+
### Supported NodeInfo versions
34+
35+
This plugin supports all major NodeInfo specification versions:
36+
37+
* **NodeInfo 1.0** and **1.1** - Original specifications
38+
* **NodeInfo 2.0**, **2.1**, and **2.2** - Current specifications with extended metadata
39+
* **NodeInfo2** - Alternative single-endpoint format
40+
41+
### Endpoints
42+
43+
After activation, the following endpoints become available:
44+
45+
* `/.well-known/nodeinfo` - Discovery document (start here)
46+
* `/wp-json/nodeinfo/2.2` - NodeInfo 2.2 (recommended)
47+
* `/wp-json/nodeinfo/2.1` - NodeInfo 2.1
48+
* `/wp-json/nodeinfo/2.0` - NodeInfo 2.0
49+
* `/wp-json/nodeinfo/1.1` - NodeInfo 1.1
50+
* `/wp-json/nodeinfo/1.0` - NodeInfo 1.0
51+
* `/.well-known/x-nodeinfo2` - NodeInfo2 format
52+
2153
## Frequently Asked Questions
2254

55+
### Why do I need this plugin?
56+
57+
If you want your WordPress site to be part of the Fediverse (decentralized social networks like Mastodon), this plugin helps other servers discover information about your site. It works together with plugins like [ActivityPub](https://wordpress.org/plugins/activitypub/) to make your site fully federated.
58+
59+
### Is any private information shared?
60+
61+
No. Only public information about your site is shared, such as your site name, description, and post counts. No personal user data or private content is exposed.
62+
63+
### How can I verify it's working?
64+
65+
Visit `https://yoursite.com/.well-known/nodeinfo` in your browser. You should see a JSON document with links to the NodeInfo endpoints.
66+
67+
### Can other plugins extend the NodeInfo data?
68+
69+
Yes! This plugin is designed to be extensible. Other plugins can use WordPress filters to add their own protocols, services, or metadata. For example, the ActivityPub plugin automatically adds `activitypub` to the supported protocols list.
70+
71+
### How do I know if everything is configured correctly?
72+
73+
Go to **Tools > Site Health** in your WordPress admin. The plugin adds two health checks:
74+
75+
* **NodeInfo Well-Known Endpoint** - Verifies that `/.well-known/nodeinfo` is accessible
76+
* **NodeInfo REST Endpoint** - Verifies that the NodeInfo 2.2 REST endpoint returns valid data
77+
78+
If either check fails, you'll see recommendations on how to fix the issue.
79+
2380
## Changelog
2481

2582
Project and support maintained on github at [pfefferle/wordpress-nodeinfo](https://github.com/pfefferle/wordpress-nodeinfo).
2683

84+
### 3.0.0
85+
86+
* Refactored to filter-based architecture for better extensibility
87+
* Added support for NodeInfo 2.2
88+
* Added separate integration classes for each NodeInfo version (1.0, 1.1, 2.0, 2.1, 2.2)
89+
* Added PSR-4 style autoloader
90+
* Updated schemas to match official NodeInfo specifications with enums and constraints
91+
* Added `nodeinfo_protocols` filter for plugins to register protocols
92+
* Added `software.homepage` field for NodeInfo 2.1 and 2.2
93+
* Added Site Health checks to verify endpoints are accessible
94+
2795
### 2.3.1
2896

2997
* mask version number

composer.json

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,49 @@
11
{
2-
"name": "pfefferle/wordpress-nodeinfo",
3-
"description": "NodeInfo and NodeInfo2 for WordPress!",
4-
"require": {
5-
"php": ">=5.6.0",
6-
"composer/installers": "^1.0 || ^2.0"
7-
},
8-
"type": "wordpress-plugin",
9-
"license": "MIT",
10-
"authors": [
11-
{
12-
"name": "Matthias Pfefferle",
13-
"homepage": "https://notiz.blog"
14-
}
15-
],
16-
"extra": {
17-
"installer-name": "nodeinfo"
18-
},
19-
"require-dev": {
20-
"phpunit/phpunit": "^5.7.21 || ^6.5 || ^7.5 || ^8",
21-
"phpcompatibility/php-compatibility": "*",
22-
"phpcompatibility/phpcompatibility-wp": "*",
23-
"squizlabs/php_codesniffer": "3.*",
24-
"wp-coding-standards/wpcs": "*",
25-
"yoast/phpunit-polyfills": "^3.0",
26-
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0"
27-
},
28-
"config": {
29-
"allow-plugins": true
30-
},
31-
"allow-plugins": {
32-
"composer/installers": true
33-
},
34-
"scripts": {
35-
"test": [
36-
"composer install",
37-
"bin/install-wp-tests.sh wordpress wordpress wordpress",
38-
"vendor/bin/phpunit"
39-
]
40-
}
2+
"name": "pfefferle/wordpress-nodeinfo",
3+
"description": "NodeInfo and NodeInfo2 for WordPress!",
4+
"type": "wordpress-plugin",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Matthias Pfefferle",
9+
"homepage": "https://notiz.blog"
10+
}
11+
],
12+
"require": {
13+
"php": ">=7.2",
14+
"composer/installers": "^1.0 || ^2.0"
15+
},
16+
"require-dev": {
17+
"phpunit/phpunit": "^8 || ^9",
18+
"phpcompatibility/php-compatibility": "*",
19+
"phpcompatibility/phpcompatibility-wp": "*",
20+
"squizlabs/php_codesniffer": "3.*",
21+
"wp-coding-standards/wpcs": "dev-develop",
22+
"yoast/phpunit-polyfills": "^4.0",
23+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
24+
"sirbrillig/phpcs-variable-analysis": "^2.11",
25+
"phpcsstandards/phpcsextra": "^1.1.0"
26+
},
27+
"extra": {
28+
"installer-name": "nodeinfo"
29+
},
30+
"config": {
31+
"allow-plugins": true
32+
},
33+
"scripts": {
34+
"test": [
35+
"composer install",
36+
"bin/install-wp-tests.sh nodeinfo-test root nodeinfo-test test-db latest true",
37+
"vendor/bin/phpunit"
38+
],
39+
"test:wp-env": [
40+
"wp-env run tests-cli --env-cwd=\"wp-content/plugins/nodeinfo\" vendor/bin/phpunit"
41+
],
42+
"lint": [
43+
"vendor/bin/phpcs"
44+
],
45+
"lint:fix": [
46+
"vendor/bin/phpcbf"
47+
]
48+
}
4149
}

docker-compose.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)