Class WeblogPlugin

  • All Implemented Interfaces:
    ParserStagePlugin, Plugin

    public class WeblogPlugin
    extends java.lang.Object
    implements Plugin, ParserStagePlugin

    Builds a simple weblog. The pageformat can use the following params:

    %p - Page name

    Parameters:

    • page - which page is used to do the blog; default is the current page.
    • entryFormat - how to display the date on pages, using the J2SE SimpleDateFormat syntax. Defaults to the current locale's DateFormat.LONG format for the date, and current locale's DateFormat.SHORT for the time. Thus, for the US locale this will print dates similar to this: September 4, 2005 11:54 PM
    • days - how many days the weblog aggregator should show. If set to "all", shows all pages.
    • pageformat - What the entry pages should look like.
    • startDate - Date when to start. Format is "ddMMyy."
    • maxEntries - How many entries to show at most.
    • preview - How many characters of the text to show on the preview page.

    The "days" and "startDate" can also be sent in HTTP parameters, and the names are "weblog.days" and "weblog.startDate", respectively.

    The weblog plugin also adds an attribute to each page it is on: "weblogplugin.isweblog" is set to "true". This can be used to quickly peruse pages which have weblogs.

    Since:
    1.9.21
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ATTR_ISWEBLOG
      The attribute which is stashed to the WikiPage attributes to check if a page is a weblog or not.
      static java.lang.String DEFAULT_DATEFORMAT
      The default date format used in the blog entry page names.
      static java.lang.String PARAM_ALLOWCOMMENTS
      Parameter name for the allowComments.
      static java.lang.String PARAM_DAYS
      Parameter name for the days.
      static java.lang.String PARAM_ENTRYFORMAT
      Parameter name for the entryFormat.
      static java.lang.String PARAM_MAXENTRIES
      Parameter name for the maxEntries.
      static java.lang.String PARAM_PAGE
      Parameter name for the page.
      static java.lang.String PARAM_PREVIEW
      Parameter name for the preview.
      static java.lang.String PARAM_STARTDATE
      Parameter name for the startDate.
    • Constructor Summary

      Constructors 
      Constructor Description
      WeblogPlugin()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String execute​(Context context, java.util.Map<java.lang.String,​java.lang.String> params)
      This is the main entry point for any plugin.
      void executeParser​(PluginElement element, Context context, java.util.Map<java.lang.String,​java.lang.String> params)
      Mark us as being a real weblog.
      java.util.List<Page> findBlogEntries​(Engine engine, java.lang.String baseName, java.util.Date start, java.util.Date end)
      Attempts to locate all pages that correspond to the blog entry pattern.
      static java.lang.String makeEntryPage​(java.lang.String pageName)
      Return just the basename for entires without date and entry numebr.
      static java.lang.String makeEntryPage​(java.lang.String pageName, java.lang.String date)
      Returns the entry page without the entry number.
      static java.lang.String makeEntryPage​(java.lang.String pageName, java.lang.String date, java.lang.String entryNum)
      Create an entry name based on the blogname, a date, and an entry number.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • makeEntryPage

        public static java.lang.String makeEntryPage​(java.lang.String pageName,
                                                     java.lang.String date,
                                                     java.lang.String entryNum)
        Create an entry name based on the blogname, a date, and an entry number.
        Parameters:
        pageName - Name of the blog
        date - The date (in ddMMyy format)
        entryNum - The entry number.
        Returns:
        A formatted page name.
      • makeEntryPage

        public static java.lang.String makeEntryPage​(java.lang.String pageName)
        Return just the basename for entires without date and entry numebr.
        Parameters:
        pageName - The name of the blog.
        Returns:
        A formatted name.
      • makeEntryPage

        public static java.lang.String makeEntryPage​(java.lang.String pageName,
                                                     java.lang.String date)
        Returns the entry page without the entry number.
        Parameters:
        pageName - Blog name.
        date - The date.
        Returns:
        A base name for the blog entries.
      • execute

        public java.lang.String execute​(Context context,
                                        java.util.Map<java.lang.String,​java.lang.String> params)
                                 throws PluginException
        This is the main entry point for any plugin. The parameters are parsed, and a special parameter called "_body" signifies the name of the plugin body, i.e. the part of the plugin that is not a parameter of the form "key=value". This has been separated using an empty line.

        Note that it is preferred that the plugin returns XHTML-compliant HTML (i.e. close all tags, use <br /> instead of <br>, etc.

        Specified by:
        execute in interface Plugin
        Parameters:
        context - The current WikiContext.
        params - A Map which contains key-value pairs. Any parameter that the user has specified on the wiki page will contain String-String parameters, but it is possible that at some future date, JSPWiki will give you other things that are not Strings.
        Returns:
        HTML, ready to be included into the rendered page.
        Throws:
        PluginException - In case anything goes wrong.
      • findBlogEntries

        public java.util.List<PagefindBlogEntries​(Engine engine,
                                                    java.lang.String baseName,
                                                    java.util.Date start,
                                                    java.util.Date end)
        Attempts to locate all pages that correspond to the blog entry pattern. Will only consider the days on the dates; not the hours and minutes.
        Parameters:
        engine - Engine which is used to get the pages
        baseName - The basename (e.g. "Main" if you want "Main_blogentry_xxxx")
        start - The date which is the first to be considered
        end - The end date which is the last to be considered
        Returns:
        a list of pages with their FIRST revisions.
      • executeParser

        public void executeParser​(PluginElement element,
                                  Context context,
                                  java.util.Map<java.lang.String,​java.lang.String> params)
        Mark us as being a real weblog. Method which is executed during parsing.
        Specified by:
        executeParser in interface ParserStagePlugin
        Parameters:
        element - The JDOM element which has already been connected to the Document.
        context - WikiContext, as usual.
        params - Parsed parameters for the plugin.