Refactor project structure

This commit is contained in:
2026-01-09 11:45:27 +01:00
parent c11d9bdb8c
commit c20b482616
12 changed files with 51 additions and 1 deletions

View File

@@ -48,6 +48,14 @@ If you install this plugin manually, make sure it is installed in:
If the folder is called differently, DokuWiki will not load it.
## Project structure (developer notes)
This repository follows DokuWiki's plugin conventions at the top level (e.g. `syntax.php`, `conf/`, `lang/`, endpoints like `file.php`).
Reusable PHP code lives in `src/` and is loaded via `autoload.php`.
When adding new internal classes under the `dokuwiki\plugin\luxtools\` namespace, place them in `src/<ClassName>.php`.
## Configuration
luxtools is configured via its dedicated admin page:

View File

@@ -5,6 +5,8 @@ namespace dokuwiki\plugin\luxtools\test;
use dokuwiki\plugin\luxtools\Path;
use DokuWikiTest;
require_once(__DIR__ . '/../autoload.php');
/**
* Path related tests for the luxtools plugin
*

View File

@@ -5,6 +5,8 @@ namespace dokuwiki\plugin\luxtools\test;
use dokuwiki\plugin\luxtools\ScratchpadMap;
use DokuWikiTest;
require_once(__DIR__ . '/../autoload.php');
/**
* ScratchpadMap tests for the luxtools plugin
*

30
autoload.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/**
* luxtools plugin autoloader.
*
* DokuWiki will often load plugin entrypoints (syntax.php, action.php, ...)
* directly. We keep those files small and place reusable code in src/.
*
* This file registers a minimal autoloader for the plugin namespace.
*/
spl_autoload_register(static function ($class) {
$prefix = 'dokuwiki\\plugin\\luxtools\\';
$prefixLen = strlen($prefix);
if (strncmp($class, $prefix, $prefixLen) !== 0) {
return;
}
$relative = substr($class, $prefixLen);
if ($relative === '') {
return;
}
$file = __DIR__ . '/src/' . str_replace('\\', '/', $relative) . '.php';
if (is_file($file)) {
require_once $file;
}
});

View File

@@ -4,6 +4,8 @@
use dokuwiki\plugin\luxtools\Path;
require_once(__DIR__ . '/autoload.php');
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../');
if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); // we gzip ourself here
require_once(DOKU_INC . 'inc/init.php');

View File

@@ -5,6 +5,8 @@
use dokuwiki\plugin\luxtools\Path;
use dokuwiki\plugin\luxtools\ScratchpadMap;
require_once(__DIR__ . '/autoload.php');
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../');
require_once(DOKU_INC . 'inc/init.php');

View File

@@ -280,7 +280,7 @@ class Crawler
*/
protected function loadIgnores()
{
$file = __DIR__ . '/conf/ignore.txt';
$file = __DIR__ . '/../conf/ignore.txt';
$ignore = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$ignore = array_map(static fn($line) => trim(preg_replace('/\s*#.*$/', '', $line)), $ignore);
$ignore = array_filter($ignore);

View File

@@ -5,6 +5,8 @@ use dokuwiki\plugin\luxtools\Crawler;
use dokuwiki\plugin\luxtools\Output;
use dokuwiki\plugin\luxtools\Path;
require_once(__DIR__ . '/../autoload.php');
/**
* luxtools Plugin: Abstract base class for file-listing syntax handlers.
*

View File

@@ -4,6 +4,8 @@ use dokuwiki\Extension\SyntaxPlugin;
use dokuwiki\plugin\luxtools\Path;
use dokuwiki\plugin\luxtools\ScratchpadMap;
require_once(__DIR__ . '/../autoload.php');
/**
* luxtools Plugin: Scratchpad syntax.
*