Dashboard > blojsom > ... > Available Plugins > Hit Counter Plugin
  blojsom Log In   View a printable version of the current page.  
  Hit Counter Plugin
Added by Andreas Schaefer, last edited by Andreas Schaefer on May 30, 2006  (view change)
Labels: 
(None)

Availability

The HitCounter plugin can be downloaded from the blojsom plugins download page.

Overview

HitCounter Plugin generates two maps of hit counts sorted first by date and then by flavor and the other way around. In addition one can generate an bar chart image of the hit counters (now all flavors are supported). The plugin only lists a certain amount of days on per day basis and all the data afterwards go into a single bucket called 'rest'.

Screenshot

Changelog

v0.1 (24-03-2006): Initial release. Requires Blojsom 2.28 or later (feel free to test it on earlier version it may run).
v0.2 (30-05-2006): Bugfix release including the support for all flavors for the histogram and additional properties for the image setup.

Build

HitCounter Plugin uses Maven 1.x to build the source.

maven

Installation

The HitCounter plugin are actually two plugins: one for the counting the hits and the other to generate the hit count histogram. In order to display the image you also must install a servlet.
Note: All the setup files (properties, velocity template as well as a patch for the web.xml file) can be found inside the archive. The counter histogram plugin/servlet is optional and so you can disregard any installation instruction for it if you do not plan to use it.

Place the blojsom.counter.plugin-version.jar in your WEB-INF/lib directory.

For the Hit Counter add the following line in your global /WEB-INF/plugin.properties file:

counter-log=com.madplanet.blojsom.counter.CounterLogPlugin

For the Hit Counter Histogram add the following line in your global /WEB-INF/plugin.properties file:

counter-histogram=com.madplanet.blojsom.counter.CounterHistogramPlugin

You may then add "counter-log" as well as the "counter-histogram" to one of the flavor-based plugin chains. These plugin chains can be found in the individual user's plugin.properties file.
Note: that 'counter-log' should be placed somewhere at the end of the chain and that, if used, the 'counter-histogram' plugin is listed aftewards!

html.blojsom-plugin-chain=..., all-entries, ..., counter-log, counter-histogram

Add the HitCounterServlet that will generate the dynamic graph image. This is referenced in /WEB-INF/web.xml.

<servlet>
  <servlet-name>CounterLogHistogram</servlet-name>
  <servlet-class>com.madplanet.blojsom.counter.CounterHistogramServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>CounterLogHistogram</servlet-name>
  <url-pattern>/counterloghistogram</url-pattern>
</servlet-mapping>

Place the counter.properties and counter.histrogram.properties file in the respective /WEB-INF/blog-id directory.

On environment without display make sure the following property is set:

-Djava.awt.headless=true

Usage

Copy paste the following snippet to your template or include the template counter_html.vm inside your template which would look like this:

<div>
<h5>Counter:</h5>
#parse("counter_html.vm")
</div>

Note you can can select any of the listings or the image separately.

<h3>Counters:</h3>
## This part lists all the hit counters by flavors and then date by date
## ---------------------------------------------------------------------
#if($COUNTER_HISTORY)
    #foreach( $group in $COUNTER_HISTORY.getFlavorIterator() )
        <p>Flavor: $group.getFlavor() </p>
        #foreach( $counter in $group.getCounterIterator() )
            <p>&nbsp;&nbsp;&nbsp;$counter.getLogDate():&nbsp;$counter.getCount()</p>
        #end
        <p>&nbsp;&nbsp;&nbsp;Rest:&nbsp;$COUNTER_HISTORY.getUnlistedCounter( $group.getFlavor() ).getCount()</p>
    #end
#end

## This part lists all the hit counters by dates and then flavor by flavor
## -----------------------------------------------------------------------
#if($COUNTER_HISTORY)
    #foreach( $group in $COUNTER_HISTORY.getDateIterator() )
        <p>Date: $group.getLogDate() </p>
        #foreach( $counter in $group.getCounterIterator() )
            <p>&nbsp;&nbsp;&nbsp;$counter.getFlavor():&nbsp;$counter.getCount()</p>
        #end
    #end
    <p>Unlisted Totals</p>
    #foreach( $group in $COUNTER_HISTORY.getFlavorIterator() )
        <p>&nbsp;&nbsp;&nbsp;$group.getFlavor():&nbsp;$COUNTER_HISTORY.getUnlistedCounter( $group.getFlavor() ).getCount()</p>
    #end
#end

## This part displays the hits are bar chart diagram (make sure you setup the servlet, too)
## ----------------------------------------------------------------------------------------
#if($COUNTER_HISTORY)
    <br>
    <p>Histogram</p>
    <img src="$BLOJSOM_BLOG.getBlogBaseURL()/counterloghistogram?flavor=html" alt="counter log histogram HTML" border="1">
    <br>
    <img src="$BLOJSOM_BLOG.getBlogBaseURL()/counterloghistogram?flavor=rss2" alt="counter log histogram RSS2" border="1">
#end

Configuration

You can configure the place of the hit counter file, the supported flavors and the number of days that are managed on a day per day basis:

# The relative or absolute path to the log file
counter-filename=./hit.counter.log
# Comma separated list of flavors where the counter collects data
hit-count-flavors=html,rss2
# Number of days the hit counter lists the counts on a per day basis
max-dates-listed=10

You can configure the size of the display, the margins and border thickness as well as the colors of the various parts of the histogram:

# Height of display (image without the margins)
display-height=50
# Width of display (image without the margins)
display-width=100
# Margin thickness (Note: left margin is calculate dynamically)
margin-thickness=10
# Border Thickness of the display (is part of the display)
border-thickness=2

# Background Color of the Margin
margin-background-color=ffffff
# Background Color of the Display
display-background-color=ebebeb
# Color of the Border
border-color=000000
# Color of the Bars
bar-color=ff0000

# Interval to refresh Image in seconds
repaint-interval=120
# List of flavors an image is created for. This can be commented out to create an image
# for every flavor the hit counter maintains data for
supported-flavors=html
# This is an example for supporting to flavors like HTML and RSS
# supported-flavors=html,rss2

The color settings are hex colors (RGB). E.g. red is represented as ff0000, green is 00ff00, blue is 0000ff.

The other settings are pixels.

Usage and URL Parameters

Context Attributes and Types

The following table describes the context attributes that are available and their associated type.

Context key Input or Output Type Description
COUNTER_HISTORY Output com.madplanet.blojsom.counter.CounterManager Manages the hit counter maps as well as provides the necessary iterators

Site running on a free Atlassian Confluence Open Source Project License granted to blojsom. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators