NAME
Kwiki::ReferrerLog - Kwiki ReferrerLog Class
DESCRIPTION
This module logs all referers coming from external sites to your Kwiki wiki, and displays them in a convenient, stylable table. That's all. It's very basic but you can easily redefine/change most of the functionality by overriding the appropriate methods (see below).
OPTIONS
Mandatory
Additionally to the standard installation procedure of a Kwiki::Plugin this module needs two more options set for functioning correctly.
site_uri: This module needs the site_uri parameter configured in your config.yaml (or what else your config file might be) and set to a correct value. The value of the site_uri parameter will be used for sorting out the internal referrers. So setting this correctly might be of interest to you.
Example: If your Kwiki installation is located at http://www.example.com/kwiki/index.cgi you should set the site_uri option to http://www.example.com/kwiki/
display_class: You have to configure the Kwiki::ReferrerLog module as your plugin for the display-action. This sounds harder than it is.
Simply set add the following line to you config.yaml: display_class: Kwiki::ReferrerLog
Optional
The following options can be overriden in your config.yaml file:
keep_days: This determines after which number of days, a log entry gets deleted from the store, if there weren't any requests coming in from that URL. Don't set this value too high. (default is: 2)
date_format: The date format that is used in the display of logged referrers. This is directly passed to the strftime function of the POSIX package, so don't hate me, if you specify a wrong pattern (default is: %d.%m.%Y %H:%M)
METHODS
The behaviour of the Kwiki::ReferrerLog module can be changed quite easily. Simply stuff the module in your @ISA array (or use it as a base class) and override selected methods. The module provides the following methods, which can be overridden:
referrerlog(): This method loads the stored referrers and renders the template for showing the result back to the browser. It is registered as the action-method for this module.
log_referrer: This method logs the referrer. For this it checks if the referrer comes from an external site. If this is not the case, the control flow leaves the method. Otherwise the stored referrers are loaded and the current one is appended to the list. Afterwards it checks, if some of the referrers are older than the configured value for keep_days. If this is the case, the corresponding referrers are deleted from the list.
file_path: This method returns a relative path to the location of the referrer log file (default: "referrerlog/referrers.log" in plugin_directory).
load_log: This method loads the stored referrer entries and returns them as an hash reference, that contains, keyed by referring URLs, array references.
The following example should clarify the structure:
store_log: This method takes a hash reference as described above and stores it, so that the load_log method can retrieve it later.
date_fmt: This method uses the date_format configuration option, to format the timestamp that is passed as the first and only parameter, as the user/admin wishes.
delete_old_logs: This method is called before every call to store_log, and deletes entries, that are older than the number of days specified by the keep_days option (see above).
AUTHOR
Benjamin Reitzammer cpan@nur-eine-i.de
COPYRIGHT
Copyright (c) 2004. Benjamin Reitzammer. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
SEE ALSO
POSIX for strftime date format syntax, Storable is used for referrer storage