diff --git a/README.md b/README.md index 7a327eb..ad234a9 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,7 @@ It is likely unsuited for wider adoption without modification. luxtools provides DokuWiki syntax that: -- Lists files from configured host filesystem roots (glob pattern) -- Lists a directory's direct children (files + folders) +- Lists a directory's direct children (files + folders) or files matching a glob pattern - Renders an image thumbnail gallery (with lightbox) - Provides "open this folder/path" links for local workflows - Embeds file-backed scratchpads with a minimal inline editor (no wiki revisions) @@ -155,14 +154,23 @@ This complements DokuWiki's built-in monospace formatting (`''`) by providing qu ### 1) List files by glob pattern +The `{{directory>...}}` syntax (or `{{files>...}}` for backwards compatibility) can handle both directory listings and glob patterns. When a glob pattern is used, it renders as a table: + ``` -{{files>/Scape/projects/*&style=list}} -{{files>/Scape/projects/*&style=table&tableheader=1&showsize=1&showdate=1}} -{{files>/Scape/projects/*&recursive=1&sort=mtime&order=desc}} +{{directory>/Scape/projects/*}} +{{directory>/Scape/projects/*&tableheader=1&showsize=1&showdate=1}} +{{directory>/Scape/projects/*&recursive=1&sort=mtime&order=desc}} +``` + +Or using the legacy `files` keyword (same behavior): +``` +{{files>/Scape/projects/*}} +{{files>/Scape/projects/*&tableheader=1&showsize=1&showdate=1}} ``` Notes: - Pattern matching is performed per-directory (safe glob via fnmatch). +- Always renders as a table. - A directory can have a title file (default: `_title.txt`) to override the displayed folder name. ### 2) List a directory (folders + files) as a table @@ -221,7 +229,7 @@ Behaviour: Scratchpads render the referenced file as wikitext and (when you have edit rights on the host page) provide an inline editor that saves directly to the backing file. -## Inline options reference (files/images/directory) +## Inline options reference (directory/images) The listing syntaxes accept options appended with &key=value: @@ -236,14 +244,7 @@ The listing syntaxes accept options appended with &key=value: | randlinks | 0\|1 | Adds a cache-busting query parameter based on mtime. | | showsize | 0\|1 | Show file size (where supported). | | showdate | 0\|1 | Show last modified date (where supported). | -| listsep | ", " | Separator used in list-style rendering for extra fields. | | maxheight | 500 | Container max-height in pixels; -1 disables scroll container. | - -Additionally for `{{files>...}}`: - -| Option | Values | Notes | -|---|---|---| -| style | list\|olist\|table | Output style. | | tableheader | 0\|1 | Render table header row. | diff --git a/_test/SyntaxTest.php b/_test/SyntaxTest.php index 2db7ac2..de05207 100644 --- a/_test/SyntaxTest.php +++ b/_test/SyntaxTest.php @@ -71,13 +71,14 @@ class plugin_luxtools_test extends DokuWikiTest /** * This function checks that all files are listed in not recursive mode. + * Uses {{files>...}} syntax for backwards compatibility (now handled by directory syntax). */ public function test_not_recursive() { global $conf; - // Render filelist - $instructions = p_get_instructions('{{files>' . TMP_DIR . '/filelistdata/*&style=list&direct=1}}'); + // Render filelist using files syntax (now handled by directory plugin) + $instructions = p_get_instructions('{{files>' . TMP_DIR . '/filelistdata/*&direct=1}}'); $xhtml = p_render('xhtml', $instructions, $info); // We should find: @@ -91,11 +92,12 @@ class plugin_luxtools_test extends DokuWikiTest /** * This function checks that all files are listed in recursive mode. + * Uses {{files>...}} syntax for backwards compatibility (now handled by directory syntax). */ public function test_recursive() { - // Render filelist - $instructions = p_get_instructions('{{files>' . TMP_DIR . '/filelistdata/*&style=list&direct=1&recursive=1}}'); + // Render filelist using files syntax (now handled by directory plugin) + $instructions = p_get_instructions('{{files>' . TMP_DIR . '/filelistdata/*&direct=1&recursive=1}}'); $xhtml = p_render('xhtml', $instructions, $info); // We should find: @@ -114,54 +116,46 @@ class plugin_luxtools_test extends DokuWikiTest } /** - * This function checks that the unordered list mode - * generates the expected XHTML structure. + * This function checks the rendering when style=list is explicitly specified. + * Note: The files syntax is now handled by directory syntax and always renders as table. + * This test is kept for backwards compatibility testing but expects table structure. */ public function testUnorderedList() { - // Render filelist + // Render filelist with explicit style=list (now ignored, renders as table) $instructions = p_get_instructions('{{files>' . TMP_DIR . '/filelistdata/*&style=list&direct=1&recursive=1}}'); $xhtml = p_render('xhtml', $instructions, $info); $doc = new Document(); $doc->html($xhtml); + // Now renders as a table instead of list $structure = [ 'div.luxtools-plugin' => 1, - 'div.luxtools-plugin > ul' => 1, - 'div.luxtools-plugin > ul > li' => 3, - 'div.luxtools-plugin > ul > li:nth-child(1)' => 1, - 'div.luxtools-plugin > ul > li:nth-child(1) a' => 'example.txt', - 'div.luxtools-plugin > ul > li:nth-child(2) ul' => 1, - 'div.luxtools-plugin > ul > li:nth-child(2) ul > li' => 1, - 'div.luxtools-plugin > ul > li:nth-child(2) ul > li a' => 'example2.txt', + 'div.luxtools-plugin table' => 1, ]; $this->structureCheck($doc, $structure); } /** - * This function checks that the ordered list mode - * generates the expected XHTML structure. + * This function checks the rendering when style=olist is explicitly specified. + * Note: The files syntax is now handled by directory syntax and always renders as table. + * This test is kept for backwards compatibility testing but expects table structure. */ public function testOrderedList() { - // Render filelist + // Render filelist with explicit style=olist (now ignored, renders as table) $instructions = p_get_instructions('{{files>' . TMP_DIR . '/filelistdata/*&style=olist&direct=1&recursive=1}}'); $xhtml = p_render('xhtml', $instructions, $info); $doc = new Document(); $doc->html($xhtml); + // Now renders as a table instead of ordered list $structure = [ 'div.luxtools-plugin' => 1, - 'div.luxtools-plugin > ol' => 1, - 'div.luxtools-plugin > ol > li' => 3, - 'div.luxtools-plugin > ol > li:nth-child(1)' => 1, - 'div.luxtools-plugin > ol > li:nth-child(1) a' => 'example.txt', - 'div.luxtools-plugin > ol > li:nth-child(2) ol' => 1, - 'div.luxtools-plugin > ol > li:nth-child(2) ol > li' => 1, - 'div.luxtools-plugin > ol > li:nth-child(2) ol > li a' => 'example2.txt', + 'div.luxtools-plugin table' => 1, ]; $this->structureCheck($doc, $structure); diff --git a/admin/main.php b/admin/main.php index baeca73..049e5a8 100644 --- a/admin/main.php +++ b/admin/main.php @@ -15,7 +15,6 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin 'extensions', 'default_sort', 'default_order', - 'default_style', 'default_tableheader', 'default_foldersfirst', 'default_recursive', @@ -25,7 +24,6 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin 'default_showsize', 'default_showdate', 'default_tablecolumns', - 'default_listsep', 'default_maxheight', 'thumb_placeholder', 'gallery_thumb_scale', @@ -73,7 +71,6 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin $newConf['default_sort'] = $INPUT->str('default_sort'); $newConf['default_order'] = $INPUT->str('default_order'); - $newConf['default_style'] = $INPUT->str('default_style'); $newConf['default_tableheader'] = (int)$INPUT->bool('default_tableheader'); $newConf['default_foldersfirst'] = (int)$INPUT->bool('default_foldersfirst'); $newConf['default_recursive'] = (int)$INPUT->bool('default_recursive'); @@ -83,7 +80,6 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin $newConf['default_showsize'] = (int)$INPUT->bool('default_showsize'); $newConf['default_showdate'] = (int)$INPUT->bool('default_showdate'); $newConf['default_tablecolumns'] = $INPUT->str('default_tablecolumns'); - $newConf['default_listsep'] = $INPUT->str('default_listsep'); $newConf['default_maxheight'] = $INPUT->str('default_maxheight'); $newConf['thumb_placeholder'] = $INPUT->str('thumb_placeholder'); @@ -155,17 +151,6 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin echo ''; echo '
'; - // default_style - $defaultStyle = (string)$this->getConf('default_style'); - echo '
'; - // default_tableheader $checked = $this->getConf('default_tableheader') ? ' checked="checked"' : ''; echo '
'; - // default_listsep - echo '
'; - // default_maxheight echo '