Agent Plugin
Identify a browser using configurable rules
Introduction
This plugin allows to identify a browser according to it's the user_agent string it supplies in the query.
Syntax Rules
- Use
%AGENT% to print out the whole user_agent information.
- Your Browser identifies as: %AGENT%
- Use
%AGENT{check="TYPE}% to choose predefined version independent identification.
- Your Browser identifies as: %AGENT{check="TYPE"}%
- Use
%AGENT{check="VERSION"}% to choose predefined version dependent identification.
- Your Browser identifies as: %AGENT{check="VERSION"}%
- Use
%AGENT{check="msie firefox3 firefox4 safari"}% to select your own ID set - note that most specific rule names must be listed first
- Your Browser yields: %AGENT{check="msie firefox3 firefox4 safari"}%
- Add
none="idontknow" to choose a different fallback id from "%AGENTPLUGIN_NONE%"
- Use
%AGENT{check="gecko6 gecko7" none="nogecko" expgecko6="Gecko.*6" expgecko7="Gecko.*7"}% to specify seldomly needed checks
- Your Browser yields: %AGENT{check="gecko6 gecko7" none="nogecko" expgecko6="Gecko.*6" expgecko7="Gecko.*7"}%
- Any non-alphanumeric character will be removed from the listes IDs for the check whilst the original ID will be returned:
%AGENT{check=".msie .firefox .safari" none=""}%
- Your Browser yields "%AGENT{check=".msie .firefox .safari"}%"
AgentPlugin Global Settings
Plugin settings are stored as preferences variables. To reference a plugin setting write
%<plugin>_<setting>%, i.e.
%AGENTPLUGIN_SHORTDESCRIPTION%
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Identify a browser using configurable rules
- Fallback value for non-matching user agents:
- Predefined ID sets - note that most specific rule names must be listed first:
- Set CHECKTYPE = msie safari firefox netscape
- Set CHECKVERSION = msie50 msie52 msie5 msie6 msie7 msie8 msie9 msie safari firefox1 firefox2 firefox30 firefox31 firefox32 firefox33 firefox34 firefox35 firefox36 firefox3 firefox40 firefox netscape4 netscape6 netscape7 netscape
- Then, define expressions the user_agent information should be checked against to return the above identifiers:
- Set EXPMSIE = MSIE
- Set EXPMSIE5 = MSIE 5
- Set EXPMSIE50 = MSIE 5.0
- Set EXPMSIE52 = MSIE 5.2
- Set EXPMSIE6 = MSIE 6
- Set EXPMSIE7 = MSIE 7
- Set EXPMSIE8 = MSIE 8
- Set EXPMSIE9 = MSIE 9
- Set EXPSAFARI = Safari
- Set EXPFIREFOX = Firefox
- Set EXPFIREFOX1 = Firefox/1
- Set EXPFIREFOX2 = Firefox/2
- Set EXPFIREFOX3 = Firefox/3
- Set EXPFIREFOX30 = Firefox/3.0
- Set EXPFIREFOX31 = Firefox/3.1
- Set EXPFIREFOX32 = Firefox/3.2
- Set EXPFIREFOX33 = Firefox/3.3
- Set EXPFIREFOX34 = Firefox/3.4
- Set EXPFIREFOX35 = Firefox/3.5
- Set EXPFIREFOX36 = Firefox/3.6
- Set EXPFIREFOX40 = Firefox/4.0
- Set EXPNETSCAPE = Netscape
- Set EXPNETSCAPE4 = Netscape/4
- Set EXPNETSCAPE6 = Netscape/6
- Set EXPNETSCAPE7 = Netscape/7
- Debug plugin: (See output in
data/debug.txt)
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
- Download the ZIP file from the Plugin web (see below)
- Unzip
AgentPlugin.zip in your twiki installation directory. Content: | File: | Description: |
data/TWiki/AgentPlugin.txt | Plugin topic |
lib/TWiki/Plugins/AgentPlugin.pm | Plugin Perl module |
- Visit
configure in your TWiki installation, and enable the plugin in the {Plugins} section.
- Test if the plugin is correctly installed:
- Your Browser identifies as "%AGENT%"
Plugin Info
Related Topics: TWikiPreferences,
TWikiPlugins