You are here: start » Snippets » dokuwiki » Filelist Plugin

Filelist Plugin

Description

The filelist plugin provides a syntax for adding linked and sorted lists of files as selected by wildcard based glob patterns to a wiki page and thus allows dynamically including file listings of arbitrary filesystem locations and media namespaces. Using the additional filename command, one can also add a single link to a file out of a list anywhere in the text, which can be used to automatically keep download links for software releases up to date with the most recent upload.

In case you come across any bugs in this plugin, don't hesitate to report them.

The Git repository of the plugin can be found at Github.

Updates

Last updated: 2009/11/16

  • 2009/11/16:
    • Adds new feature: Recursive filelistings for displaying whole directory trees
    • Adds new sorting option: Sort by filename case insensitive
    • Fixes 26, 37, 40
    • Added german translation
  • 2008/04/04:
    • Now respects ACLs in media mode and file permissions in direct mode. Files need to be readable in order to be displayed.
    • :!: Users of Dokuwiki version up to 2007-06-26b: With the release of Dokuwiki version 2007-05-05, the date format got changed1). The filelist plugin incorporates this change, thus dates will not be displayed properly on versions below 2008-05-05.
  • 2008/03/13:
    • Should fix 24
  • 2008/03/02:
    • Fixes 21, 22
    • Implements 23 (filelist output is now enclosed in an additional div with class filelist-plugin which can be used to apply specific css to anything contained inside)
  • 2008/01/24:
    • (Hopefully ;-)) fixes 19
    • tested with Linux only as I currently have no access to a Windows-box, so Windows-users please give feedback!
  • 2007/11/05:
    • Initial release

Acknowledgements

Based on an idea by demod.

Installation

With plugin manager

Let the manager do the dirty work, just give him this link to eat: plugin-filelist.tar.gz

Without plugin manager

  1. Download the plugin: plugin-filelist.tar.gz
  2. Extract it into your dokuwiki plugin folder (eg lib/plugins)

Configuration

The filelist plugin has three configurable options:

Option Description
allow_in_comments Whether to allow the usage of the filelist/filename syntax in comments by the discussion plugin. Defaults to 0 and thus prohibition of the plugin usage in this scenario.
allowed_absolute_paths A comma-separated whitelist of all paths beneath which to allow the scanning using the filelist/filename syntax. Defaults to the Dokuwiki basedir DOKU_INC.
web_paths A comma-separated list of URLs via which the previously defined absolut paths are reachable to wiki users. This list MUST contain exactly the same amount of entries as allowed_absolute_paths. Defaults to the Dokuwiki base-URL DOKU_URL as a mapping for DOKU_INC.

Usage

The filelist plugin provides two new commands to be used in wiki pages, filelist and filename. The general command syntax for both is the following:

{{[ command ]>[ pattern ][ parameterlist ]}}
  • command must be either filelist or filename.
  • pattern is a searching pattern for files to include in the generated list, defined using the pattern syntax of the unix fnmatch function. An example: If you want to include all files ending on .txt in the folder some/path/2), you would use some/path/*.txt as the pattern (and the parameter direct=1, see parameters below). Analogue to this, to include all jpeg media files in :some:namespace, you'd use :some:namespace:*.jpg.
  • parameterlist can be used to define optional, & separated parameters (defined as key-value-pairs). For a list of supported parameters, see below.

Paths

The filelist plugin supports both absolute as well as relative paths into the filesystem or Dokuwiki media namespaces. All paths are checked against a whitelist of allowed paths for scanning (as defined via the configuration setting ''allowed_absolute_paths''). Paths which are not located below these whitelisted paths are not allowed for globbing and thus filelist/filename calls to such paths fail. Per default, the Dokuwiki basedir as defined in DOKU_INC is included in this whitelist and mapped to the Dokuwiki base-URL, DOKU_URL.

Relative paths into the filesystem are interpreted relative to the Dokuwiki basedir. Relative media paths (without a leading : that is) are interpreted relative to the namespace of the currently active page. Thus, :snippets:dokuwiki:* and * would be interpreted the same on the current page :snippets:dokuwiki:filelist.

Parameters

Name Description Possible values Default
direct Whether to interpret the given pattern as a direct path in the file system or as an dokuwiki media id. Defaults to media id. 0 or 1 0
sort The property by which to sort the internal file list. By default, the file name is used, with upper case being sorted before lower case (use iname for a case insensitive sorting criteria). name, iname, ctime, mtime, size name
order Whether to sort the internal file list ascending or descending. Sorting in ascending order is the default. asc, desc asc
filelist specific parameters
offset The offset in the internal file list from which on to display the list. Default is an offset of 0. any numeric value 0
limit The number of files to display, beginning at index offset. A number of 0 means to display all available files. any numeric value 0
style The style to use for display. list creates an unordered bullet list (the default), olist an ordered list, table a table view and page a heading/section based view of the selected files. list, olist, table, page list
tableheader Whether to show the table header describing the table columns. Off by default. 0 or 1 0
tableshowdate Whether to show the file modification date in the table view. Off by default. 0 or 1 0
tableshowsize Whether to show the file size in the table view. Off by default. 0 or 1 0
recursive Whether to do a recursive file crawl starting at the defined basepath. If this parameter is set to 1, the whitecard part of the search pattern is applied to each found subdirectory. If no files are found, the subdirectory is not included in the search result. All display styles besides table will show the result in a hierarchical structure; table will first flatten the result by prepending all found files with there subtree pathname (note that this happens before sorting). 0 or 1 0
titlefile The filename of a file which to lookup in each subtree if recursive is set to 1 and whose content to use as title for the directory. It will be ignored in the results of the filelisting itself. Defaults to _title.txt. Example: A _title.txt file containing “My special title” found during a crawl on the subpath my/subpath will be rendered as having the name “My special title” instead of “subpath”. any filename _title.txt
filename specific parameters
index Which specific item to select for display from the internal file list. The default is the first one. any numeric value 0

Examples

filename

{{filename>:snippets:dokuwiki:*filelist*}}

turns into

plugin-filelist.tar.gz

filelist

Example 1
{{filelist>:snippets:dokuwiki:plugin-*.tar.gz&style=table&tableheader=1&tableshowdate=1&tableshowsize=1}}

turns into

FilenameFilesizeLast modified
plugin-blockquote.tar.gz12.8 KiB2008/05/04 11:19
plugin-bloglinks.tar.gz9.8 KiB2008/07/07 21:07
plugin-charter.tar.gz372.7 KiB2008/12/21 21:37
plugin-filelist.tar.gz7.2 KiB2009/11/16 19:36
plugin-keyboard.tar.gz10.1 KiB2008/05/04 11:51
plugin-linkback.tar.gz29.8 KiB2008/12/07 13:02
plugin-rate.tar.gz2.4 KiB2008/12/05 14:53
Example 2
Example 3
{{filelist>lib/images/*&style=olist&direct=1&recursive=1&sort=iname}}

turns into

  1. admin
    1. acl.png
    2. config.png
    3. plugin.png
    4. popularity.png
    5. README
    6. revert.png
    7. usermanager.png
  2. arrow_down.gif
  3. arrow_up.gif
  4. at.gif
  5. blank.gif
  6. close.png
  7. del.png
  8. diff.png
  9. edit.gif
  10. error.png
  11. fileicons
    1. bz2.png
    2. c.png
    3. conf.png
    4. cpp.png
    5. cs.png
    6. css.png
    7. deb.png
    8. doc.png
    9. file.png
    10. gif.png
    11. gz.png
    12. htm.png
    13. html.png
    14. index.php
    15. java.png
    16. jpeg.png
    17. jpg.png
    18. js.png
    19. lua.png
    20. odc.png
    21. odf.png
    22. odg.png
    23. odi.png
    24. odp.png
    25. ods.png
    26. odt.png
    27. pdf.png
    28. php.png
    29. pl.png
    30. png.png
    31. ppt.png
    32. ps.png
    33. py.png
    34. rar.png
    35. rb.png
    36. rpm.png
    37. rtf.png
    38. swf.png
    39. sxc.png
    40. sxd.png
    41. sxi.png
    42. sxw.png
    43. tar.png
    44. tgz.png
    45. txt.png
    46. xls.png
    47. xml.png
    48. zip.png
  12. history.png
  13. index.html
  14. info.png
  15. interwiki
    1. amazon.de.gif
    2. amazon.gif
    3. amazon.uk.gif
    4. bug.gif
    5. coral.gif
    6. doku.gif
    7. dokubug.gif
    8. google.gif
    9. meatball.gif
    10. phpfn.gif
    11. sb.gif
    12. wiki.gif
    13. wp.gif
    14. wpde.gif
    15. wpes.gif
    16. wpfr.gif
    17. wpjp.gif
    18. wpmeta.gif
    19. wppl.gif
  16. interwiki.png
  17. larger.gif
  18. license
    1. badge
      1. cc-by-nc-nd.png
      2. cc-by-nc-sa.png
      3. cc-by-nc.png
      4. cc-by-nd.png
      5. cc-by-sa.png
      6. cc-by.png
      7. cc.png
      8. gnufdl.png
      9. publicdomain.png
    2. button
      1. cc-by-nc-nd.png
      2. cc-by-nc-sa.png
      3. cc-by-nc.png
      4. cc-by-nd.png
      5. cc-by-sa.png
      6. cc-by.png
      7. cc.png
      8. gnufdl.png
      9. publicdomain.png
  19. list-minus.gif
  20. list-plus.gif
  21. loading.gif
  22. magnifier.png
  23. minus.gif
  24. multiupload.png
  25. notify.png
  26. ns.png
  27. page.png
  28. pencil.png
  29. plus.gif
  30. smaller.gif
  31. smileys
    1. delete.gif
    2. fixme.gif
    3. icon_arrow.gif
    4. icon_biggrin.gif
    5. icon_confused.gif
    6. icon_cool.gif
    7. icon_cry.gif
    8. icon_doubt.gif
    9. icon_doubt2.gif
    10. icon_eek.gif
    11. icon_evil.gif
    12. icon_exclaim.gif
    13. icon_frown.gif
    14. icon_fun.gif
    15. icon_idea.gif
    16. icon_kaddi.gif
    17. icon_lol.gif
    18. icon_mrgreen.gif
    19. icon_neutral.gif
    20. icon_question.gif
    21. icon_razz.gif
    22. icon_redface.gif
    23. icon_rolleyes.gif
    24. icon_sad.gif
    25. icon_silenced.gif
    26. icon_smile.gif
    27. icon_smile2.gif
    28. icon_surprised.gif
    29. icon_twisted.gif
    30. icon_wink.gif
  32. success.png
  33. throbber.gif
  34. toolbar
    1. bold.png
    2. chars.png
    3. h.png
    4. h1.png
    5. h2.png
    6. h3.png
    7. h4.png
    8. h5.png
    9. hequal.png
    10. hminus.png
    11. hplus.png
    12. hr.png
    13. image.png
    14. italic.png
    15. link.png
    16. linkextern.png
    17. mono.png
    18. ol.png
    19. sig.png
    20. smiley.png
    21. strike.png
    22. ul.png
    23. underline.png
  35. trash.png
  36. up.png
  37. wrap.gif
1) use of strftime instead of date on $conf['dformat']
2) relative to your dokuwiki root

Discussion

BonBonBonBon, 2008/02/27 06:52

Very cool plugin !!

Kai-MartinKai-Martin, 2008/03/05 17:15

Very useful! Now I can link lots of files in my wiki without the hassle to keep them up-to-date. —<(kaimartin)>—

RichRich, 2008/03/13 11:23

I get this error message when using your plugin:

Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. in C:\Inetpub\wwwroot\lib\plugins\filelist\syntax.php on line 135

fooselfoosel, 2008/03/14 00:13

As already indicated at 24, this should now be fixed. :-)

AlekseyAleksey, 2008/05/06 16:31

Thanks for the nice plugin. I was hoping to use to list files on a windows share, can it do that? I was using the usual DokuWiki linking syntax for that, e.g. {{filelist>\\server\dir1\dir2\*&direct=1}}

but got [n/a: Access denied]

I did add the “\\server\dir1” path to the list of allowed path and also added an entry in the URL paths (although I do not understand the meaning of that second path). Any ideas?

fooselfoosel, 2008/05/15 21:10

I don't have a development system under windows available, and no windows shares, but I'll do my best to fix this anyways – might find some suitable test environment at work with luck, or victim to test stuff out. Please open a bugreport in the bugtracker though, so that the problem has no chance to disappear from my radar. Thanks in advance.

Jay WaltherJay Walther, 2008/11/19 19:47

I was also having this problem with a windows directory list, here is what I found that will work, it is a little clunky, and part of my problem was windows allowing special characters in the foldername that linux is not happy with '&'. We mounted the windows volume using SAMBA called windows and I put a link into my dokuwiki directory to /mnt

seems to work just fine

DamianDamian, 2009/11/23 20:40

Could you solve it? Thanks

Juan CollasJuan Collas, 2008/05/15 21:00

I moved my data directory out of the wiki installation for security reasons, and the plugin no longer finds those files when configured for media access.

I've traced this to line 31 of syntax.php, which probably needs to be changed to check if the $conf['savedir'] is an absolute path, and if so, not prepend the DOKU_INC path prefix.

fooselfoosel, 2008/05/15 21:07

Could you please open a bug in the bugtracker for this issue? Thanks in advance.

Jean-ChristopheJean-Christophe, 2008/09/05 23:05

Is it possible to view the files in sub-directories?

Digna GonzálezDigna González, 2008/09/17 23:18

Where can I send the Spanish language files?

marc wimmermarc wimmer, 2008/11/07 17:29

great plugin!

i make a list of images…do you think i could display the image directly somehow? <img…

thanks in advance,

marc

www.downgrade-vista.comwww.downgrade-vista.com, 2008/12/21 22:00

Great Plug In !

I would like however to add comments to each single file listed.

Maybe this could be possible handing *.txt files with an embedded comment on each file ?

Juan CollasJuan Collas, 2009/03/29 15:18

Feature request:

an option that would allow the user to link to all the files in the filelist as a zip/gz file, which would allow the easy downloading of a long list of specified files.

Thanks for an excellent plugin

xarumanxxarumanx, 2009/11/17 09:10

I second that!

Mark WolfgruberMark Wolfgruber, 2009/07/20 03:09

i moved my data-dir out of the htdocs and then i get an errormessage.
i modified in the syntax.php line ~30:

-- $this->mediadir = rp(DOKU_INC.'/'.$conf['savedir'].'/media').'/';
++ $this->mediadir = rp($conf['savedir'].'/media').'/';
Peter EnnisPeter Ennis, 2009/10/07 19:30

I noticed the data plugin allows sorting by column. Seen in plugins and templates pages. Is that planned for filelist?

Karl GrohmuellerKarl Grohmueller, 2009/11/19 11:30

Very cool!

Is ist possible to sort for extensions (first all *.jpg, then all *.pdf)

Maybe I don't understand the parameters “iname”, “ctime”, “mtime” of the sort command …

Thank You for any help

Karl

fooselfoosel, 2010/03/02 17:18

Sorting by extension or file type is currently not supported.

MortenMorten, 2010/01/23 15:08

Thanks for the plugin.

Is it possible to have a FileName-expression rendered inline instead of as a separate paragraph?

fooselfoosel, 2010/03/02 17:29

It actually is supposed to be inline, you just discovered a bug. Must have crept in sometime when I worked on the file listing feature. I added a ticket to the bug tracker: 41

ChrisChris, 2010/03/02 07:59

Hello,

I am not able to use the plugin in case of using abosulte paths.

I want to list files and folders in my server \\192.168.1.1\

So I try modify metadata.php to add absolute path as follows

$meta['allowed_absolute_paths'] = array('\\192.168.1.1');
$meta['web_paths'] = array('\\192.168.1.1');

and use the following code

{{filelist>\\192.168.1.1}}

but it shows

[n/a: No match]

So what should I do to correct it?

Thanks!

fooselfoosel, 2010/03/02 17:15

You are editing the wrong file. $meta indicates you tried to modify lib/plugins/filelist/conf/metadata.php. As its name suggests, this only contains the metadata for use by the configuration plugin. The values you are looking for are set in lib/plugins/filelist/conf/default.php. Editing this file directly isn't recommended though, as it would be overwritten upon updating the plugin. Configuration values in Dokuwiki are stored in conf/local.php, even those for plugins.

I'd highly recommend using the configuration plugin (Admin > Configuration Settings) for changing these settings, its way less error prone than the manual approach.

Also, make sure you leave the current default settings there as well if you want to use the filelist plugin also e.g. to list media files somewhere on your wiki.

Last but not least, the absolute Path HAS to be reachable by your server, otherwise the plugin won't be able to find anything as it simply can't access the files to list (I take it you use a windows server, otherwise the above path name probably won't have a chance to work).

KrtistofKrtistof, 2010/03/05 12:25

Hi,

I have some trouble with this great plug-in, when i put :

[n/a: No match]

My path : C:\serveur\xampp\htdocs\wiki\data\pages/ and http://127.0.0.1/wiki/data/pages/

on the config panel

Is the Xampp Win Xp problem ?

Thanks a lot

fooselfoosel, 2010/03/06 00:54

My guess would be you actually want to have something along the lines of C:\serveur\xampp\htdocs\wiki\data\media/ and http://127.0.0.1/wiki/data/media/ as your paths, PDFs (or rather media files in general) should not even be located in the pages subdirectory (that belongs to the actual wiki texts alone). You could achieve the same thing with {{filelist>:ACE:*.pdf&style=list}}.

kristofkristof, 2010/03/08 14:04

Ok, it work !

Thanks a lot

Enter your comment
If you can't read the letters on the image, download this .wav file to get them read to you.
 
snippets/dokuwiki/filelist.txt · Last modified: 2010/01/03 15:40 by foosel