Attached is a PageViewCountPlugin that I wrote for my own wiki. The plugin allows you to display how many hits there are on specific pages..


To install PageViewCountPlugin using the binary distribution:
  1. Put the binary distribution under WEB-INF/lib
  2. Restart JSPWiki

Usage #

Just insert the line below to the page LeftMenu :
[{INSERT org.simon.jspwiki.plugin.PageViewCountPlugin}] 

Demo Site#

You can view the author(SimonLei)'s wiki It's a wiki in Chinese.

Change Log#

Feb.20,2004 : Fix the bug, now it will close the input stream and output stream. --SimonLei

May 2004 : Made some minor changes:

  • write the Page Count.txt file into the Wiki directory so users can see the page
  • write the list out in sorted order so it looks nice
  • allow a count parameter to be able to set the count to a specific value
  • only do counting when the context is "list" or "find" or "prefs". Multiple edit/preview cycles do not increase the count. FindPage and UserPreference are also counted. (They are special pages)
Source file is an attachment called --Foster Schucker

Suggestion box#

KeithWhittingham says: The current plugin saves the counters in a pseudo wiki page which, as Janne puts it, "might be a nice idea". The problem is that users can edit it and reset your counters to any value. One solution is to make the page read only, another is for the plugin to save the counters somewhere else.
While the page can be edited, the changes don't stick. The page count code that runs every so often (I have mine set for 5 mins) creates a new page when it runs. The way it works is on startup it reads the page counts and puts them into memory. Every time the page plugin is called it increments the memory count. Every so often it writes the new page to disk with the memory values. The only way the page counts can be reset is if someone uses the count= change I made to the plugin or uses the soon to be implemented Delete function. -- Foster Schucker


In this case Count.txt appears in the recent changes. I don't like that. Heres my version: I store the Count.txt in the workdir which also will be used for the lucene indexes (You can set it in the I also added code to close the input streams when there is an exception in writing the files (missing close() in catch clause).


--Christoph Sauer

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
PageViewCount.jar 4.8 kB 2 20-Feb-2004 10:44 SimonLei
java 4.1 kB 2 20-Feb-2004 10:44 SimonLei
i3g 4.9 kB 1 05-Jan-2006 14:45 Christoph Sauer
new 5.1 kB 1 02-May-2004 19:08 FosterSchucker
« This page (revision-41) was last changed on 26-Sep-2007 11:46 by HarryMetske