Add button for code blocks

This commit is contained in:
2026-01-20 07:53:37 +01:00
parent d3e087ad6e
commit 56e51b1c3c
8 changed files with 178 additions and 102 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
_agent-data/

View File

@@ -145,6 +145,14 @@ Key settings:
## Features and usage ## Features and usage
### 0) Editor toolbar: Code block button
The plugin adds a custom button to the DokuWiki editor toolbar for quickly inserting `<code>` blocks.
When editing a page, click the code block button (angle brackets icon `<>`) in the toolbar to wrap selected text in `<code></code>` tags, or to insert an empty code block at the cursor position.
This complements DokuWiki's built-in monospace formatting (`''`) by providing quick access to HTML code blocks.
### 1) List files by glob pattern ### 1) List files by glob pattern
``` ```

View File

@@ -10,9 +10,20 @@ use dokuwiki\Extension\EventHandler;
class action_plugin_luxtools extends ActionPlugin class action_plugin_luxtools extends ActionPlugin
{ {
/** @inheritdoc */ /** @inheritdoc */
public function register(EventHandler $controller) public function register(Doku_Event_Handler $controller)
{ {
$controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'addScripts'); $controller->register_hook(
"TPL_METAHEADER_OUTPUT",
"BEFORE",
$this,
"addScripts",
);
$controller->register_hook(
"TOOLBAR_DEFINE",
"AFTER",
$this,
"addToolbarButton",
);
} }
/** /**
@@ -22,22 +33,43 @@ class action_plugin_luxtools extends ActionPlugin
* @param mixed $param * @param mixed $param
* @return void * @return void
*/ */
public function addScripts(Event $event, $param) public function addScripts(Event $event, $param)
{ {
$base = DOKU_BASE . 'lib/plugins/luxtools/js/'; $base = DOKU_BASE . "lib/plugins/luxtools/js/";
$scripts = array( $scripts = [
'lightbox.js', "lightbox.js",
'gallery-thumbnails.js', "gallery-thumbnails.js",
'open-service.js', "open-service.js",
'scratchpads.js', "scratchpads.js",
'main.js' "main.js",
); ];
foreach ($scripts as $script) { foreach ($scripts as $script) {
$event->data['script'][] = array( $event->data["script"][] = [
'type' => 'text/javascript', "type" => "text/javascript",
'src' => $base . $script "src" => $base . $script,
); ];
} }
} }
/**
* Add custom toolbar button for code blocks.
*
* @param Event $event
* @param mixed $param
* @return void
*/
public function addToolbarButton(Event $event, $param)
{
$event->data[] = [
"type" => "format",
"title" => $this->getLang("toolbar_code_title"),
"icon" => "../../plugins/luxtools/images/code.png",
"key" => "C",
"open" => "<code>",
"sample" => $this->getLang("toolbar_code_sample"),
"close" => "</code>",
"block" => false,
];
}
} }

View File

@@ -69,6 +69,7 @@ RSYNC_ARGS=(
--exclude=deploy.sh --exclude=deploy.sh
--exclude=.git/ --exclude=.git/
--exclude=_dokuwiki/ --exclude=_dokuwiki/
--exclude=_agent-data/
--exclude=.github/ --exclude=.github/
--exclude=.vscode/ --exclude=.vscode/
--exclude=_test/ --exclude=_test/

BIN
images/code.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

3
images/code.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#333" d="M5.5 4L2 8l3.5 4 1-1.5L4 8l2.5-2.5L5.5 4zm5 0l-1 1.5L12 8l-2.5 2.5 1 1.5L14 8l-3.5-4z"/>
</svg>

After

Width:  |  Height:  |  Size: 203 B

View File

@@ -7,53 +7,69 @@
* @author Gina Haeussge <osd@foosel.net> * @author Gina Haeussge <osd@foosel.net>
*/ */
$lang['filename'] = 'Dateiname'; $lang["filename"] = "Dateiname";
$lang['filesize'] = 'Dateigröße'; $lang["filesize"] = "Dateigröße";
$lang['lastmodified'] = 'Letzte Änderung'; $lang["lastmodified"] = "Letzte Änderung";
$lang['openlocation'] = 'Ort öffnen'; $lang["openlocation"] = "Ort öffnen";
$lang['error_nomatch'] = 'Keine Treffer'; $lang["error_nomatch"] = "Keine Treffer";
$lang['error_outsidejail'] = 'Zugriff verweigert'; $lang["error_outsidejail"] = "Zugriff verweigert";
$lang['empty_files'] = 'Keine Dateien'; $lang["empty_files"] = "Keine Dateien";
$lang['empty_images'] = 'Keine Bilder'; $lang["empty_images"] = "Keine Bilder";
$lang['menu'] = 'luxtools'; $lang["menu"] = "luxtools";
$lang['settings'] = 'luxtools-Einstellungen'; $lang["settings"] = "luxtools-Einstellungen";
$lang['legend'] = 'Einstellungen'; $lang["legend"] = "Einstellungen";
$lang['btn_save'] = 'Speichern'; $lang["btn_save"] = "Speichern";
$lang['saved'] = 'Einstellungen gespeichert.'; $lang["saved"] = "Einstellungen gespeichert.";
$lang['err_save'] = 'Einstellungen konnten nicht gespeichert werden. Bitte Schreibrechte für conf/local.php prüfen.'; $lang["err_save"] =
$lang['err_security'] = 'Sicherheits-Token ungültig. Bitte erneut versuchen.'; "Einstellungen konnten nicht gespeichert werden. Bitte Schreibrechte für conf/local.php prüfen.";
$lang["err_security"] = "Sicherheits-Token ungültig. Bitte erneut versuchen.";
$lang["paths"] =
"Erlaubte Basis-Pfade (eine pro Zeile). Optional: Pfad mit A>-Alias ergaenzen.";
$lang["scratchpad_paths"] =
"Scratchpad-Dateien (eine pro Zeile). Jeder Dateipfad muss eine Erweiterung enthalten. Mit einer folgenden A>-Zeile wird der Pad-Name gesetzt, der im Wiki verwendet wird.";
$lang["extensions"] = "Kommagetrennte Liste erlaubter Dateiendungen.";
$lang['paths'] = 'Erlaubte Basis-Pfade (eine pro Zeile). Optional: Pfad mit A>-Alias ergaenzen.'; $lang["listing_defaults"] = "Listen-Standardwerte";
$lang['scratchpad_paths'] = 'Scratchpad-Dateien (eine pro Zeile). Jeder Dateipfad muss eine Erweiterung enthalten. Mit einer folgenden A>-Zeile wird der Pad-Name gesetzt, der im Wiki verwendet wird.'; $lang["default_sort"] =
$lang['extensions'] = 'Kommagetrennte Liste erlaubter Dateiendungen.'; "Standard-Sortierschlüssel (name|iname|ctime|mtime|size).";
$lang["default_order"] = "Standard-Sortierreihenfolge (asc|desc).";
$lang["default_style"] = "Standard-Ausgabeformat (list|olist|table).";
$lang["default_tableheader"] = "Tabellenkopf standardmäßig anzeigen.";
$lang["default_foldersfirst"] = "Ordner standardmäßig vor Dateien sortieren.";
$lang["default_recursive"] = "Unterverzeichnisse standardmäßig einbeziehen.";
$lang["default_titlefile"] = "Standard-Name der Titeldatei (z.B. _title.txt).";
$lang["default_cache"] =
"Seiten-Caching standardmäßig aktivieren (0 deaktiviert Caching).";
$lang["default_randlinks"] =
"Standardmäßig Cache-Busting-Parameter auf Basis mtime hinzufügen.";
$lang["default_showsize"] =
"Dateigröße standardmäßig anzeigen (falls unterstützt).";
$lang["default_showdate"] =
"Änderungsdatum standardmäßig anzeigen (falls unterstützt).";
$lang["default_listsep"] =
'Standard-Trennzeichen für Listenausgabe (z.B. ", ").';
$lang["default_maxheight"] =
"Standard max-height in px für Scroll-Container (-1 deaktiviert).";
$lang['listing_defaults'] = 'Listen-Standardwerte'; $lang["defaults"] =
$lang['default_sort'] = 'Standard-Sortierschlüssel (name|iname|ctime|mtime|size).'; "Legacy-Standardoptionen (fortgeschritten). Vorhandene Werte werden weiterhin berücksichtigt, sind aber nicht mehr über die UI konfigurierbar.";
$lang['default_order'] = 'Standard-Sortierreihenfolge (asc|desc).'; $lang["thumb_placeholder"] =
$lang['default_style'] = 'Standard-Ausgabeformat (list|olist|table).'; "MediaManager-ID für den Platzhalter der Galerie-Thumbnails.";
$lang['default_tableheader'] = 'Tabellenkopf standardmäßig anzeigen.'; $lang["gallery_thumb_scale"] =
$lang['default_foldersfirst'] = 'Ordner standardmäßig vor Dateien sortieren.'; "Skalierungsfaktor für Galerie-Thumbnails. 2 erzeugt schärfere Thumbnails auf HiDPI-Displays (Anzeige bleibt 150×150).";
$lang['default_recursive'] = 'Unterverzeichnisse standardmäßig einbeziehen.'; $lang["open_service_url"] =
$lang['default_titlefile'] = 'Standard-Name der Titeldatei (z.B. _title.txt).'; "URL des lokalen Client-Dienstes für {{open>...}} (z.B. http://127.0.0.1:8765).";
$lang['default_cache'] = 'Seiten-Caching standardmäßig aktivieren (0 deaktiviert Caching).';
$lang['default_randlinks'] = 'Standardmäßig Cache-Busting-Parameter auf Basis mtime hinzufügen.';
$lang['default_showsize'] = 'Dateigröße standardmäßig anzeigen (falls unterstützt).';
$lang['default_showdate'] = 'Änderungsdatum standardmäßig anzeigen (falls unterstützt).';
$lang['default_listsep'] = 'Standard-Trennzeichen für Listenausgabe (z.B. ", ").';
$lang['default_maxheight'] = 'Standard max-height in px für Scroll-Container (-1 deaktiviert).';
$lang['defaults'] = 'Legacy-Standardoptionen (fortgeschritten). Vorhandene Werte werden weiterhin berücksichtigt, sind aber nicht mehr über die UI konfigurierbar.'; $lang["scratchpad_edit"] = "Scratchpad bearbeiten";
$lang['thumb_placeholder'] = 'MediaManager-ID für den Platzhalter der Galerie-Thumbnails.'; $lang["scratchpad_save"] = "Speichern";
$lang['gallery_thumb_scale'] = 'Skalierungsfaktor für Galerie-Thumbnails. 2 erzeugt schärfere Thumbnails auf HiDPI-Displays (Anzeige bleibt 150×150).'; $lang["scratchpad_cancel"] = "Abbrechen";
$lang['open_service_url'] = 'URL des lokalen Client-Dienstes für {{open>...}} (z.B. http://127.0.0.1:8765).'; $lang["scratchpad_err_nopath"] = "Scratchpad-Pfad fehlt";
$lang["scratchpad_err_badpath"] = "Ungültiger Scratchpad-Pfad";
$lang["scratchpad_err_unknown"] = "Unbekannter Scratchpad-Name";
$lang["scratchpad_err_unreadable"] = "Scratchpad-Datei ist nicht lesbar";
$lang['scratchpad_edit'] = 'Scratchpad bearbeiten'; $lang["toolbar_code_title"] = "Code-Block";
$lang['scratchpad_save'] = 'Speichern'; $lang["toolbar_code_sample"] = "Ihr Code hier";
$lang['scratchpad_cancel'] = 'Abbrechen';
$lang['scratchpad_err_nopath'] = 'Scratchpad-Pfad fehlt';
$lang['scratchpad_err_badpath'] = 'Ungültiger Scratchpad-Pfad';
$lang['scratchpad_err_unknown'] = 'Unbekannter Scratchpad-Name';
$lang['scratchpad_err_unreadable'] = 'Scratchpad-Datei ist nicht lesbar';

View File

@@ -7,54 +7,69 @@
* @author Gina Haeussge <osd@foosel.net> * @author Gina Haeussge <osd@foosel.net>
*/ */
$lang['filename'] = 'Filename'; $lang["filename"] = "Filename";
$lang['filesize'] = 'Filesize'; $lang["filesize"] = "Filesize";
$lang['lastmodified'] = 'Last modified'; $lang["lastmodified"] = "Last modified";
$lang['openlocation'] = 'Open Location'; $lang["openlocation"] = "Open Location";
$lang['error_nomatch'] = 'No match'; $lang["error_nomatch"] = "No match";
$lang['error_outsidejail'] = 'Access denied'; $lang["error_outsidejail"] = "Access denied";
$lang['empty_files'] = 'No Files'; $lang["empty_files"] = "No Files";
$lang['empty_images'] = 'No Images'; $lang["empty_images"] = "No Images";
$lang['menu'] = 'luxtools'; $lang["menu"] = "luxtools";
$lang['settings'] = 'luxtools settings'; $lang["settings"] = "luxtools settings";
$lang['legend'] = 'Settings'; $lang["legend"] = "Settings";
$lang['btn_save'] = 'Save'; $lang["btn_save"] = "Save";
$lang['saved'] = 'Settings saved.'; $lang["saved"] = "Settings saved.";
$lang['err_save'] = 'Could not save settings. Please check write permissions for conf/local.php.'; $lang["err_save"] =
$lang['err_security'] = 'Security token mismatch. Please retry.'; "Could not save settings. Please check write permissions for conf/local.php.";
$lang["err_security"] = "Security token mismatch. Please retry.";
$lang["paths"] =
"Allowed base paths (one per line). Optional: follow a path with A> alias.";
$lang["scratchpad_paths"] =
"Scratchpad files (one per line). Each file path must include the extension. Use a following A> line to set the pad name used in the wiki.";
$lang["extensions"] =
"Comma-separated list of allowed file extensions to list.";
$lang['paths'] = 'Allowed base paths (one per line). Optional: follow a path with A> alias.'; $lang["listing_defaults"] = "Listing defaults";
$lang['scratchpad_paths'] = 'Scratchpad files (one per line). Each file path must include the extension. Use a following A> line to set the pad name used in the wiki.'; $lang["default_sort"] = "Default sort key (name|iname|ctime|mtime|size).";
$lang['extensions'] = 'Comma-separated list of allowed file extensions to list.'; $lang["default_order"] = "Default sort order (asc|desc).";
$lang["default_style"] = "Default output style (list|olist|table).";
$lang["default_tableheader"] = "Render table header row by default.";
$lang["default_foldersfirst"] = "Group folders before files by default.";
$lang["default_recursive"] = "Recurse into subdirectories by default.";
$lang["default_titlefile"] = "Default title file name (e.g. _title.txt).";
$lang["default_cache"] = "Enable page caching by default (0 disables caching).";
$lang["default_randlinks"] =
"Add cache-busting query parameter based on mtime by default.";
$lang["default_showsize"] = "Show file size by default (where supported).";
$lang["default_showdate"] =
"Show last modified date by default (where supported).";
$lang["default_tablecolumns"] =
'Default table columns (comma-separated). Available: name, size, date. Example: "name,size,date" shows all columns.';
$lang["default_listsep"] =
'Default separator used in list-style rendering (e.g. ", ").';
$lang["default_maxheight"] =
"Default max-height in px for scroll container (-1 disables).";
$lang['listing_defaults'] = 'Listing defaults'; $lang["defaults"] =
$lang['default_sort'] = 'Default sort key (name|iname|ctime|mtime|size).'; "Legacy default options string (advanced). Existing values are still honored, but this is no longer configurable via the UI.";
$lang['default_order'] = 'Default sort order (asc|desc).'; $lang["thumb_placeholder"] =
$lang['default_style'] = 'Default output style (list|olist|table).'; "MediaManager ID for the gallery thumbnail placeholder.";
$lang['default_tableheader'] = 'Render table header row by default.'; $lang["gallery_thumb_scale"] =
$lang['default_foldersfirst'] = 'Group folders before files by default.'; "Gallery thumbnail scale factor. Use 2 for sharper thumbnails on HiDPI screens (still displayed as 150×150).";
$lang['default_recursive'] = 'Recurse into subdirectories by default.'; $lang["open_service_url"] =
$lang['default_titlefile'] = 'Default title file name (e.g. _title.txt).'; "Local client service URL for the {{open>...}} button (e.g. http://127.0.0.1:8765).";
$lang['default_cache'] = 'Enable page caching by default (0 disables caching).';
$lang['default_randlinks'] = 'Add cache-busting query parameter based on mtime by default.';
$lang['default_showsize'] = 'Show file size by default (where supported).';
$lang['default_showdate'] = 'Show last modified date by default (where supported).';
$lang['default_tablecolumns'] = 'Default table columns (comma-separated). Available: name, size, date. Example: "name,size,date" shows all columns.';
$lang['default_listsep'] = 'Default separator used in list-style rendering (e.g. ", ").';
$lang['default_maxheight'] = 'Default max-height in px for scroll container (-1 disables).';
$lang['defaults'] = 'Legacy default options string (advanced). Existing values are still honored, but this is no longer configurable via the UI.'; $lang["scratchpad_edit"] = "Edit scratchpad";
$lang['thumb_placeholder'] = 'MediaManager ID for the gallery thumbnail placeholder.'; $lang["scratchpad_save"] = "Save";
$lang['gallery_thumb_scale'] = 'Gallery thumbnail scale factor. Use 2 for sharper thumbnails on HiDPI screens (still displayed as 150×150).'; $lang["scratchpad_cancel"] = "Cancel";
$lang['open_service_url'] = 'Local client service URL for the {{open>...}} button (e.g. http://127.0.0.1:8765).'; $lang["scratchpad_err_nopath"] = "Scratchpad path missing";
$lang["scratchpad_err_badpath"] = "Invalid scratchpad path";
$lang["scratchpad_err_unknown"] = "Unknown scratchpad pad name";
$lang["scratchpad_err_unreadable"] = "Scratchpad file is not readable";
$lang['scratchpad_edit'] = 'Edit scratchpad'; $lang["toolbar_code_title"] = "Code Block";
$lang['scratchpad_save'] = 'Save'; $lang["toolbar_code_sample"] = "your code here";
$lang['scratchpad_cancel'] = 'Cancel';
$lang['scratchpad_err_nopath'] = 'Scratchpad path missing';
$lang['scratchpad_err_badpath'] = 'Invalid scratchpad path';
$lang['scratchpad_err_unknown'] = 'Unknown scratchpad pad name';
$lang['scratchpad_err_unreadable'] = 'Scratchpad file is not readable';