Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,16 @@ in `Packages.awesomeAliases` in `config/app.php`:
Both importers and the Markdown parser are registered in `Application::services()`.
The console command receives its importers through CakePHP's container.

## Featured plugin logos
## Administration

Set an optional logo URL or image path alongside the package name in
`Packages.featured` in `config/app.php`:
Sign in with GitHub, then grant your account admin access:

```php
'featured' => [
'cakedc/users' => ['logo' => '/img/plugins/users.svg'],
'vendor/plugin' => ['logo' => 'https://example.com/plugin-logo.png'],
'friendsofcake/crud' => ['logo' => null],
],
```bash
ddev exec bin/cake migrations migrate
ddev exec bin/cake users your-github-username --role admin --active yes
```

A null or broken logo falls back to the name-based emblem. Each entry can hold
additional metadata alongside `logo` as needed.
Manage users at `/admin/users` and featured plugins at `/admin/featured-plugins`.

## Get social auth working

Expand Down
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
"php": "^8.5",
"admad/cakephp-social-auth": "^2.2",
"cakephp/authentication": "^4.0",
"cakephp/authorization": "^3.0",
"cakephp/cakephp": "5.4.*",
"cakephp/migrations": "^5.0.0",
"cakephp/plugin-installer": "^2.0",
"dereuromark/cakephp-tags": "^3.0",
"friendsofcake/search": "^7.5",
"josbeir/cakephp-interact": "^0.2",
"josbeir/cakephp-interact": "^0.2.1",
"josbeir/cakephp-vite": "^0.1.4",
"knplabs/packagist-api": "^3.0",
"league/commonmark": "^2.7",
Expand All @@ -36,12 +37,14 @@
},
"autoload": {
"psr-4": {
"App\\": "src/"
"App\\": "src/",
"Admin\\": "plugins/Admin/src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Test\\": "tests/",
"Admin\\Test\\": "plugins/Admin/tests/",
"Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
}
},
Expand Down
94 changes: 83 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions config/Migrations/20261113090000_AddUserAccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);

use Migrations\BaseMigration;

class AddUserAccess extends BaseMigration
{
/**
* Existing GitHub accounts start as active ordinary users.
*/
public function change(): void
{
$this->table('users')
->addColumn('role', 'string', ['limit' => 16, 'default' => 'user'])
->addColumn('is_active', 'boolean', ['default' => true])
->update();
}
}
52 changes: 52 additions & 0 deletions config/Migrations/20261113090100_AddFeaturedPlugins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);

use Migrations\BaseMigration;

class AddFeaturedPlugins extends BaseMigration
{
/**
* Snapshot the previous configuration once, independent of catalogue availability.
*/
public function up(): void
{
$this->table('featured_plugins')
->addColumn('package', 'string', ['limit' => 191])
->addColumn('enabled', 'boolean', ['default' => true])
->addColumn('logo', 'string', ['limit' => 2048, 'null' => true])
->addColumn('title', 'string', ['null' => true])
->addColumn('description', 'text', ['null' => true])
->addTimestamps('created', 'modified')
->addIndex(['package'], ['unique' => true])
->create();
$featured = [
// Optional logo URL or image path; null uses a name-based emblem.
'cakedc/users' => ['logo' => null],
'dereuromark/cakephp-ide-helper' => ['logo' => 'https://dereuromark.github.io/cakephp-ide-helper/logo.svg'],
'dereuromark/cakephp-queue' => ['logo' => 'https://dereuromark.github.io/cakephp-queue/logo.svg'],
'dereuromark/cakephp-tools' => ['logo' => 'https://dereuromark.github.io/cakephp-tools/logo.svg'],
'friendsofcake/cakepdf' => ['logo' => null],
'friendsofcake/crud' => ['logo' => null],
'friendsofcake/search' => ['logo' => null],
'josbeir/cakephp-interact' => ['logo' => 'https://www.cakeinteract.dev/docs/branding/interact-mark.svg'],
'josbeir/cakephp-vite' => ['logo' => null],
'josegonzalez/cakephp-upload' => ['logo' => null],
'lordsimal/cakephp-sentry' => ['logo' => null],
'markstory/asset_compress' => ['logo' => null],
];

$rows = [];
foreach ($featured as $package => $metadata) {
$rows[] = ['package' => $package, 'enabled' => true, 'logo' => $metadata['logo'], 'created' => date('Y-m-d H:i:s')];
}
$this->table('featured_plugins')->insert($rows)->saveData();
}

/**
* Remove only the editorial configuration on rollback.
*/
public function down(): void
{
$this->table('featured_plugins')->drop()->save();
}
}
Binary file modified config/Migrations/schema-dump-default.lock
Binary file not shown.
15 changes: 0 additions & 15 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,6 @@
'Packages' => [
// Resolve moved or ambiguous Awesome-list repositories to an exact Composer package name.
'awesomeAliases' => [],
'featured' => [
// Optional logo URL or image path; null uses a name-based emblem.
'cakedc/users' => ['logo' => null],
'dereuromark/cakephp-ide-helper' => ['logo' => 'https://dereuromark.github.io/cakephp-ide-helper/logo.svg'],
'dereuromark/cakephp-queue' => ['logo' => 'https://dereuromark.github.io/cakephp-queue/logo.svg'],
'dereuromark/cakephp-tools' => ['logo' => 'https://dereuromark.github.io/cakephp-tools/logo.svg'],
'friendsofcake/cakepdf' => ['logo' => null],
'friendsofcake/crud' => ['logo' => null],
'friendsofcake/search' => ['logo' => null],
'josbeir/cakephp-interact' => ['logo' => 'https://www.cakeinteract.dev/docs/branding/interact-mark.svg'],
'josbeir/cakephp-vite' => ['logo' => null],
'josegonzalez/cakephp-upload' => ['logo' => null],
'lordsimal/cakephp-sentry' => ['logo' => null],
'markstory/asset_compress' => ['logo' => null],
],
],

'CakeVite' => [
Expand Down
2 changes: 2 additions & 0 deletions config/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@
'Tags',
'ADmad/SocialAuth',
'Authentication',
'Authorization',
'Admin',
'IdeHelper' => ['onlyDebug' => true],
];
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
<file>tests/</file>
<file>config/</file>
<file>templates/</file>
<file>plugins/Admin/</file>
</ruleset>
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ parameters:
bootstrapFiles:
- config/bootstrap.php
paths:
- plugins/Admin/
- src/
- config/app.php
- templates/
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<testsuites>
<testsuite name="app">
<directory>tests/TestCase/</directory>
<directory>plugins/Admin/tests/TestCase/</directory>
</testsuite>
<!-- Add plugin test suites here. -->
</testsuites>
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
use: { baseURL: 'http://127.0.0.1:8765', trace: 'retain-on-failure' },
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
webServer: {
command: 'php tests/browser/setup.php && php -S 127.0.0.1:8765 -t webroot webroot/index.php 2>tmp/browser-server.log',
command: 'php tests/browser/setup.php && php -d session.save_path=tmp/browser-sessions -S 127.0.0.1:8765 -t webroot webroot/index.php 2>tmp/browser-server.log',
url: 'http://127.0.0.1:8765',
reuseExistingServer: false,
env: {
Expand Down
19 changes: 19 additions & 0 deletions plugins/Admin/config/form-templates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);

/**
* DaisyUI form markup shared by the admin islands.
*/
return [
'button' => '<button{{attrs}}>{{text}}</button>',
'checkbox' => '<input type="checkbox" name="{{name}}" value="{{value}}"{{attrs}}>',
'checkboxWrapper' => '<div>{{label}}</div>',
'error' => '<div class="text-sm text-error" id="{{id}}">{{content}}</div>',
'input' => '<input type="{{type}}" name="{{name}}"{{attrs}}>',
'inputContainer' => '<div class="fieldset gap-2">{{content}}</div>',
'inputContainerError' => '<div class="fieldset gap-2">{{content}}{{error}}</div>',
'label' => '<label class="label"{{attrs}}>{{text}}</label>',
'nestingLabel' => '{{hidden}}<label{{attrs}}>{{input}}{{text}}</label>',
'select' => '<select name="{{name}}"{{attrs}}>{{content}}</select>',
'textarea' => '<textarea name="{{name}}"{{attrs}}>{{value}}</textarea>',
];
34 changes: 34 additions & 0 deletions plugins/Admin/src/AdminPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);

namespace Admin;

use Cake\Core\BasePlugin;
use Cake\Routing\RouteBuilder;

/**
* App-specific administration, using the host's identity and domain services.
*/
class AdminPlugin extends BasePlugin
{
/**
* Only declared endpoints are reachable; there are no plugin fallbacks.
*/
public function routes(RouteBuilder $routes): void
{
$routes->plugin('Admin', ['path' => '/admin'], function (RouteBuilder $builder): void {
$builder->get('/', [
'controller' => 'Users',
'action' => 'home',
], 'admin:home');
$builder->get('/users', [
'controller' => 'Users',
'action' => 'index',
], 'admin:users');
$builder->get('/featured-plugins', [
'controller' => 'FeaturedPlugins',
'action' => 'index',
], 'admin:featured');
});
}
}
Loading
Loading