Skip to content

cs1969/dokuwiki-plugin-runtimevar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RuntimeVar Plugin for DokuWiki

A powerful DokuWiki plugin that provides dynamic text replacement for user information, dates, groups, and other runtime data. Pages using this plugin are automatically non-cacheable to ensure fresh content.

Features

  • Dynamic User Information: Display current user details, groups, and authentication status
  • Date and Time Variables: Current dates, timestamps, and time-based values
  • Page Context: Current page name and namespace information
  • Random Values: Generate random numbers for dynamic content
  • Automatic Cache Control: Pages with runtime variables are automatically non-cacheable
  • Session-Based Authentication Information: Compatible with various auth plugins including authchained used with authplain+authldap

Installation

General

  1. Download and install the plugin in your DokuWiki lib/plugins/ directory
  2. The plugin should be located at: lib/plugins/runtimevar/
  3. Enable the plugin in DokuWiki's configuration if necessary
  4. There is no language and configuration support (needed)

Note: This plugin is not available via DokuWiki's official plugin manager as it's hosted on GitHub only.

Details

Method 1: Git Clone (Recommended)

cd /path/to/your/dokuwiki/lib/plugins
git clone https://github.com/cs1969/dokuwiki-plugin-runtimevar.git runtimevar
# On Debian/Ubuntu systems:
chown -R www-data:www-data runtimevar

Method 2: Manual Download

  1. Download the latest source code from GitHub
  2. Click "Code" → "Download ZIP"
  3. Extract and rename the folder to runtimevar
  4. Upload to lib/plugins/runtimevar/ in your DokuWiki installation
  5. Ensure proper file permissions

Usage

Use the following syntax in your wiki pages:

{{runtimevar #METHOD}}

Replace #METHOD with one of the available methods below.

Available Methods

User Information

Method Description Example Output
#USER User login name john_doe or guest
#USERNAME User display name John Doe or Unregistered guest user
#GROUPS User groups (comma-separated) USER, ADMIN, ALL, other Auth Groups

Date and Time

Method Description Example Output
#YY Two-digit year 24
#YYYY Four-digit year 2024
#MM Month with leading zero 01 - 12
#DD Day with leading zero 01 - 31
#YYYY-MM-DD ISO date format 2024-01-13
#YYYY-MM-DD-HH-MM-SS Full timestamp 2024-01-13-10-30-45
#YYYYMMDD Compact date format 20240113
#HHMMSS Time format 103045
#HH-MM-SS Time with separators 10-30-45
#TIMESTAMP Unix timestamp 1705141845

Page Context

Method Description Example Output
#PAGE Current page name without namespace start
#NAMESPACE Current namespace wiki or : for root

System Information

Method Description Example Output
#RANDOM Random number 54872
#USERAGENT Browser user agent Mozilla/5.0...
#IP Client IP address 192.168.1.100

Examples

Dynamic User Greeting

Hello {{runtimevar #USERNAME}}! You are logged in as {{runtimevar #USER}} and belong to groups: {{runtimevar #GROUPS}}.

Time-Based Content

This page was generated on {{runtimevar #YYYY-MM-DD}} at {{runtimevar #HH-MM-SS}}. Current timestamp: {{runtimevar #TIMESTAMP}}

Conditional Links (using other plugins)``

  • [[:start]]
  • [[private:{{runtimevar #USER}}:start|My Private Area]]
  • [[special:page_{{runtimevar #YYYYMMDD}}|Today's Special]]

Group Handling

The #GROUPS method provides intelligent group management (Information):

  • Authenticated users: Show their actual groups + default group + ALL group
  • Guest users: Always show the ALL group
  • Default group: Automatically added and shown in UPPERCASE if not present
  • ALL group: Always shown for all users
  • Case handling: ADMIN, ALL, and default group (normaly USER) are always uppercase

Note: This maybe useful for ACL related issues. Just show the current user groups with {{runtimevar #GROUPS}} in any page...

Caching Behavior

Important: Pages containing {{runtimevar}} patterns are automatically marked as non-cacheable. The plugin:

  • Adds ~~NOCACHE~~ flag to pages with runtime variables
  • Forces cache expiration on every request
  • Ensures fresh content for all users
  • No manual ~~NOCACHE~~ markup required

Error Handling

  • Unknown methods return: ?runtimevar?
  • Robust fallback mechanisms for user detection
  • Session-based authentication for reliability
  • Compatible with various DokuWiki auth plugins

Technical Notes

  • The plugin hooks into PARSER_WIKITEXT_PREPROCESS for early processing
  • Uses session data ($_SESSION[DOKU_COOKIE]) for reliable user detection
  • Compatible with authchained and other authentication plugins
  • All virtual groups (DEFAULT, ALL) are displayed in uppercase

Support

This plugin was initially developed for internal intranet use and is provided as-is. While it's stable for our use case, it may not cover all edge cases for public deployments.

For community usage:

  • Feel free to fork the repository for your own modifications
  • Create issues for bug reports in the repository
  • Feature requests are welcome but may not be implemented by the maintainer
  • Consider creating your own fork for significant extensions

Note: There are no current plans to submit this plugin to the official DokuWiki repository.

Contact: dokuwiki@schmifu.de (Christian)


RuntimeVar Plugin - Making DokuWiki content more dynamic and user-aware!

About

Dynamic text replacement plugin for DokuWiki

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages