The MostPopularPlugin is a CeryleWikiPlugin that lists the most popular pages on the wiki. This requires the events API be present.

Usage#

You can use it without any parameters, and you can shorten the name to simply "MostPopular", e.g.:

   [{MostPopular}]

Parameters:#

All parameters are optional. The default is to provide the top ten pages, without the hit count or date displayed.

max = 'all' or a number
Limits the number of ranked pages to the provided number. If the value is "all" the entire wiki will be listed. No parameter (the default) will list only the top ten most popular pages.
exclude = 'Page1 Page2 Page3'
Excludes the whitespace- or comma-delimited list of pages from the output. A good starting point for this list might be: 'Main Welcome LeftMenu PageIndex RecentChanges'.
showcount = 'true' | 'false'
If true, includes the hit count for the page.
showdate = 'true' | 'false' | 'format'
If 'true', includes the creation date of the cache (i.e., when the count began). If provided as a format string, the accepted values are (case insensitive): 'short', 'medium', 'long', or 'full'. The default (for 'true' or any error) is the medium format (these match the formats described in DateFormat). Alternately, the format can be specified as any of the int values in DateFormat, but because these aren't meant to be public values, there's a risk they could change depending on Java version.
debug = 'true' | 'false'
If true, output more verbose messages.

Clearing the "memory"#

The page hit count is stored in a cache that is written from memory to the file system when the wiki is shut down, then read again when the wiki is started up again. The stored cache is located in $WIKI_HOME/work/MostPopularPlugin.ser. Deleting this file will remove the cache and start the count from zero. This file is only available to the wiki administrator — there is no user-level facility to clear the cache.

TO DO#

Possibly add the 'output' parameter to format the output as a list, table, etc.

Comments/Discussion#

... When I try to use MostPopular using this syntax:

   [{MostPopular debug='true'}]
... I am getting this error. Any idea why?
Plugin execution failed, stack trace follows:

java.lang.ArrayIndexOutOfBoundsException: 0
	at org.ceryle.wiki.plugin.mostpopular.MostPopularPlugin.execute(MostPopularPlugin.java:176)
	at com.ecyrd.jspwiki.plugin.PluginManager.execute(PluginManager.java:380)
	at com.ecyrd.jspwiki.parser.PluginContent.getText(PluginContent.java:88)
	at org.jdom.output.XMLOutputter.printTextRange(XMLOutputter.java:1054)
	at org.jdom.output.XMLOutputter.printElement(XMLOutputter.java:934)
	at org.jdom.output.XMLOutputter.printContentRange(XMLOutputter.java:1007)
	at org.jdom.output.XMLOutputter.outputElementContent(XMLOutputter.java:445)
	at com.ecyrd.jspwiki.render.XHTMLRenderer.getString(XHTMLRenderer.java:61)
	at com.ecyrd.jspwiki.render.RenderingManager.getHTML(RenderingManager.java:254)
	at com.ecyrd.jspwiki.render.RenderingManager.getHTML(RenderingManager.java:295)
	at com.ecyrd.jspwiki.WikiEngine.textToHTML(WikiEngine.java:1374)
	at com.ecyrd.jspwiki.WikiEngine.getHTML(WikiEngine.java:1320)
	at com.ecyrd.jspwiki.tags.InsertPageTag.doWikiStartTag(InsertPageTag.java:128)
	at com.ecyrd.jspwiki.tags.WikiTagBase.doStartTag(WikiTagBase.java:88)
	at org.apache.jsp.templates.ButtonMenu2.PageContent_jsp._jspx_meth_wiki_005fInsertPage_005f0(PageContent_jsp.java:424)
	at org.apache.jsp.templates.ButtonMenu2.PageContent_jsp._jspService(PageContent_jsp.java:104)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
	at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
	at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:609)
	at com.ecyrd.jspwiki.tags.ContentTag.doEndTag(ContentTag.java:126)
	at org.apache.jsp.templates.ButtonMenu2.ViewTemplate_jsp._jspx_meth_wiki_005fContent_005f0(ViewTemplate_jsp.java:378)
	at org.apache.jsp.templates.ButtonMenu2.ViewTemplate_jsp._jspService(ViewTemplate_jsp.java:121)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)
	at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
	at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:609)
	at com.ecyrd.jspwiki.tags.IncludeTag.doEndTag(IncludeTag.java:83)
	at org.apache.jsp.Wiki_jsp._jspService(Wiki_jsp.java:114)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.ecyrd.jspwiki.ui.WikiServletFilter.doFilter(WikiServletFilter.java:100)
	at com.ecyrd.jspwiki.ui.WikiJSPFilter.doFilter(WikiJSPFilter.java:82)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:595)

Parameters to the plugin

* _bounds'='[I@18a4aef
* _cmdline'='debug='true'


I am getting the same exception, but was able to fix it by changing line 143 of MostPopularPlugin to

        int max = Math.min(pagelist.length,10);

But I still have problems: The actionPerformed(WikiEvent event) Method of the MostPopularListener, get's called but ((WikiPageEvent)event).getPageName() is allways null, so the cache inside countPage(String pageName) does not get updated.

It seems, that the Listener is not called or initialized correctly. The actionPerformed is only called two times and both times, the pageName is not inside the event. I debugged the constructor of WikiPageEvent and saw, that in normal the pagename get's set correctly.

Any Idea? We use jspwiki 2.8.3-svn-18

--Lukas Weberruss, 03-Dez-2009 19:07


MostPopularListener disappears in WikiEventManager a few cliks after.

synchronized ( set ) { for ( Iterator it = set.iterator(); it.hasNext(); ) { WikiEventListener listener = (WikiEventListener)it.next(); //log.info("-=-=-=-=-=-=-=-=-=-Sprawdzam teraz listenern "+listener.getClass().getName()+" "); if ( listener instanceof MostPopularListener ) { mostPopularListener = (MostPopularListener) listener; break; } } }

% My solution (not optimal is serialization every time Maby this will help link --Thomas Knap

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
rar
CerylePlugins.rar 196.1 kB 1 21-May-2012 15:57 Tomek Knap
« This page (revision-7) was last changed on 21-May-2012 15:54 by Tomek Knap