You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2008/02/13 06:54:24 UTC
svn commit: r627255 [34/41] - in
/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src: ./ com/ com/ecyrd/
com/ecyrd/jspwiki/ com/ecyrd/jspwiki/action/ com/ecyrd/jspwiki/attachment/
com/ecyrd/jspwiki/auth/ com/ecyrd/jspwiki/auth/acl/ com/ecyrd/jspwiki...
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,446 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.BodyContent;
+import javax.servlet.jsp.tagext.BodyTag;
+
+import com.ecyrd.jspwiki.*;
+import com.ecyrd.jspwiki.action.AttachActionBean;
+import com.ecyrd.jspwiki.action.NoneActionBean;
+import com.ecyrd.jspwiki.attachment.Attachment;
+import com.ecyrd.jspwiki.parser.JSPWikiMarkupParser;
+import com.ecyrd.jspwiki.parser.MarkupParser;
+import com.ecyrd.jspwiki.providers.ProviderException;
+
+/**
+ * Provides a generic link tag for all kinds of linking
+ * purposes.
+ * <p>
+ * If parameter <i>jsp</i> is defined, constructs a URL pointing
+ * to the specified JSP page, under the baseURL known by the WikiEngine.
+ * Any ParamTag name-value pairs contained in the body are added to this
+ * URL to provide support for arbitrary JSP calls.
+ * <p>
+ * @since 2.3.50
+ */
+public class LinkTag
+ extends WikiLinkTag
+ implements ParamHandler, BodyTag
+{
+ static final long serialVersionUID = 0L;
+
+ private String m_version = null;
+ private String m_class = null;
+ private String m_style = null;
+ private String m_title = null;
+ private String m_target = null;
+ private String m_compareToVersion = null;
+ private String m_rel = null;
+ private String m_jsp = null;
+ private String m_ref = null;
+ private String m_context = WikiContext.VIEW;
+ private String m_accesskey = null;
+ private String m_templatefile = null;
+
+ private boolean m_absolute = false;
+ private boolean m_overrideAbsolute = false;
+
+ private Map<String,String> m_containedParams;
+
+ private BodyContent m_bodyContent;
+
+ public void initTag()
+ {
+ super.initTag();
+ m_version = m_class = m_style = m_title = m_target = m_compareToVersion = m_rel = m_jsp = m_ref = m_accesskey = m_templatefile = null;
+ m_context = WikiContext.VIEW;
+ m_absolute = false;
+ }
+
+ public void setTemplatefile( String key )
+ {
+ m_templatefile = key;
+ }
+
+ public void setAccessKey( String key )
+ {
+ m_accesskey = key;
+ }
+
+ public void setAbsolute( String arg )
+ {
+ m_overrideAbsolute = true;
+ m_absolute = TextUtil.isPositive( arg );
+ }
+
+ public String getVersion()
+ {
+ return m_version;
+ }
+
+ public void setVersion( String arg )
+ {
+ m_version = arg;
+ }
+
+ public void setClass( String arg )
+ {
+ m_class = arg;
+ }
+
+ public void setStyle( String style )
+ {
+ m_style = style;
+ }
+
+ public void setTitle( String title )
+ {
+ m_title = title;
+ }
+
+ public void setTarget( String target )
+ {
+ m_target = target;
+ }
+
+ public void setCompareToVersion( String ver )
+ {
+ m_compareToVersion = ver;
+ }
+
+ public void setRel( String rel )
+ {
+ m_rel = rel;
+ }
+
+ public void setRef( String ref )
+ {
+ m_ref = ref;
+ }
+
+ public void setJsp( String jsp )
+ {
+ m_jsp = jsp;
+ }
+
+ public void setContext( String context )
+ {
+ m_context = context;
+ }
+
+ /**
+ * Support for ParamTag supplied parameters in body.
+ */
+ public void setContainedParameter( String name, String value )
+ {
+ if( name != null )
+ {
+ if( m_containedParams == null )
+ {
+ m_containedParams = new HashMap<String,String>();
+ }
+ m_containedParams.put( name, value );
+ }
+ }
+
+
+ /**
+ * This method figures out what kind of an URL should be output. It mirrors heavily
+ * on JSPWikiMarkupParser.handleHyperlinks();
+ *
+ * @return
+ * @throws ProviderException
+ */
+ private String figureOutURL()
+ throws ProviderException
+ {
+ // Init container parameters if not set
+ if( m_containedParams == null )
+ {
+ m_containedParams = new HashMap<String,String>();
+ }
+
+ // Set up the URL parameters map
+ String url = null;
+ WikiEngine engine = m_actionBean.getEngine();
+ HttpServletResponse response = (HttpServletResponse)pageContext.getResponse();
+ Map<String,String> urlParams = new HashMap<String,String>();
+
+ if( m_pageName == null )
+ {
+ if( m_page != null )
+ {
+ m_pageName = m_page.getName();
+ }
+ }
+
+ if( m_templatefile != null )
+ {
+ urlParams.putAll( m_containedParams );
+ String template = engine.getTemplateDir();
+ url = response.encodeURL( m_actionBean.getContext().getURL( NoneActionBean.class, "templates/"+template+"/"+m_templatefile, urlParams, false ) );
+ }
+ else if( m_jsp != null )
+ {
+ urlParams.putAll( m_containedParams );
+ //url = m_wikiContext.getURL( WikiContext.NONE, m_jsp, params );
+ url = response.encodeURL( m_actionBean.getContext().getURL( NoneActionBean.class, m_jsp, urlParams, m_absolute ) );
+ }
+ else if( m_ref != null )
+ {
+ int interwikipoint;
+
+ if( JSPWikiMarkupParser.isExternalLink(m_ref) )
+ {
+ url = m_ref;
+ }
+ else if( (interwikipoint = m_ref.indexOf(":")) != -1 )
+ {
+ String extWiki = m_ref.substring( 0, interwikipoint );
+ String wikiPage = m_ref.substring( interwikipoint+1 );
+
+ url = engine.getInterWikiURL( extWiki );
+
+ if( url != null )
+ {
+ url = TextUtil.replaceString( url, "%s", wikiPage );
+ }
+ }
+ else if( m_ref.startsWith("#") )
+ {
+ // Local link
+ }
+ else if( TextUtil.isNumber(m_ref) )
+ {
+ // Reference
+ }
+ else
+ {
+ int hashMark = -1;
+
+ Map<String,String> parms = new HashMap<String,String>();
+ if (m_version != null)
+ {
+ parms.put("version", getVersion());
+ }
+
+ //
+ // Internal wiki link, but is it an attachment link?
+ //
+ WikiPage p = engine.getPage( m_pageName );
+
+ if( p instanceof Attachment )
+ {
+ url = m_actionBean.getContext().getURL( AttachActionBean.class, m_pageName );
+ }
+ else if( (hashMark = m_ref.indexOf('#')) != -1 )
+ {
+ // It's an internal Wiki link, but to a named section
+
+ String namedSection = m_ref.substring( hashMark+1 );
+ String reallink = m_ref.substring( 0, hashMark );
+
+ reallink = MarkupParser.cleanLink( reallink );
+
+ String matchedLink;
+ String sectref = "";
+ if( (matchedLink = engine.getFinalPageName( reallink )) != null )
+ {
+ sectref = "section-"+engine.encodeName(matchedLink)+"-"+namedSection;
+ sectref = "#"+sectref.replace('%', '_');
+ }
+ else
+ {
+ matchedLink = reallink;
+ }
+
+ url = makeBasicURL( m_context, matchedLink, parms, m_absolute ) + sectref;
+ }
+ else
+ {
+ String reallink = MarkupParser.cleanLink( m_ref );
+
+ url = makeBasicURL( m_context, reallink, parms, m_absolute );
+ }
+ }
+ }
+ else if( m_pageName != null && m_pageName.length() > 0 )
+ {
+ WikiPage p = engine.getPage( m_pageName );
+
+ if ( m_version != null )
+ {
+ urlParams.put("version", getVersion());
+ }
+ urlParams.putAll( m_containedParams );
+
+ if( p instanceof Attachment )
+ {
+ url = response.encodeURL( m_actionBean.getContext().getURL( AttachActionBean.class, m_pageName, urlParams, m_absolute ) );
+ }
+ else
+ {
+ url = makeBasicURL( m_context, m_pageName, urlParams, m_absolute );
+ }
+ }
+ else
+ {
+ String page = engine.getFrontPage();
+ url = makeBasicURL( m_context, page, null, m_absolute );
+ }
+
+ return url;
+ }
+
+ private String makeBasicURL( String context, String page, Map<String,String>parms, boolean absolute )
+ {
+ String url;
+ WikiEngine engine = m_actionBean.getEngine();
+ WikiContext wikiContext = (WikiContext)m_actionBean;
+
+ if( context.equals( WikiContext.DIFF ) )
+ {
+ int r1 = 0;
+ int r2 = 0;
+
+ if( DiffLinkTag.VER_LATEST.equals(getVersion()) )
+ {
+ WikiPage latest = engine.getPage( page, WikiProvider.LATEST_VERSION );
+
+ r1 = latest.getVersion();
+ }
+ else if( DiffLinkTag.VER_PREVIOUS.equals(getVersion()) )
+ {
+ r1 = wikiContext.getPage().getVersion() - 1;
+ r1 = (r1 < 1 ) ? 1 : r1;
+ }
+ else if( DiffLinkTag.VER_CURRENT.equals(getVersion()) )
+ {
+ r1 = wikiContext.getPage().getVersion();
+ }
+ else
+ {
+ r1 = Integer.parseInt( getVersion() );
+ }
+
+ if( DiffLinkTag.VER_LATEST.equals(m_compareToVersion) )
+ {
+ WikiPage latest = engine.getPage( page, WikiProvider.LATEST_VERSION );
+
+ r2 = latest.getVersion();
+ }
+ else if( DiffLinkTag.VER_PREVIOUS.equals(m_compareToVersion) )
+ {
+ r2 = wikiContext.getPage().getVersion() - 1;
+ r2 = (r2 < 1 ) ? 1 : r2;
+ }
+ else if( DiffLinkTag.VER_CURRENT.equals(m_compareToVersion) )
+ {
+ r2 = wikiContext.getPage().getVersion();
+ }
+ else
+ {
+ r2 = Integer.parseInt( m_compareToVersion );
+ }
+
+ parms.put("r1", String.valueOf(r1));
+ parms.put("r2", String.valueOf(r2));
+ }
+
+ url = wikiContext.getContext().getURL( m_actionBean.getClass(), m_pageName, parms, m_absolute );
+
+ return url;
+ }
+
+ public int doWikiStartTag() throws Exception
+ {
+ return EVAL_BODY_BUFFERED;
+ }
+
+ public int doEndTag()
+ {
+ try
+ {
+ if( !m_overrideAbsolute )
+ {
+ // TODO: see WikiContext.getURL(); this check needs to be specified somewhere.
+ WikiEngine engine = m_actionBean.getEngine();
+ m_absolute = "absolute".equals( engine.getWikiProperties().getProperty( WikiEngine.PROP_REFSTYLE ) );
+ }
+
+ JspWriter out = pageContext.getOut();
+ String url = figureOutURL();
+
+ StringBuffer sb = new StringBuffer( 20 );
+
+ sb.append( (m_class != null) ? "class=\""+m_class+"\" " : "" );
+ sb.append( (m_style != null) ? "style=\""+m_style+"\" " : "" );
+ sb.append( (m_target != null ) ? "target=\""+m_target+"\" " : "" );
+ sb.append( (m_title != null ) ? "title=\""+m_title+"\" " : "" );
+ sb.append( (m_rel != null ) ? "rel=\""+m_rel+"\" " : "" );
+ sb.append( (m_accesskey != null) ? "accesskey=\""+m_accesskey+"\" " : "" );
+
+ switch( m_format )
+ {
+ case URL:
+ out.print( url );
+ break;
+ default:
+ case ANCHOR:
+ out.print("<a "+sb.toString()+" href=\""+url+"\">");
+ break;
+ }
+
+ // Add any explicit body content. This is not the intended use
+ // of LinkTag, but happens to be the way it has worked previously.
+ if( m_bodyContent != null )
+ {
+ String linktext = m_bodyContent.getString().trim();
+ out.write( linktext );
+ }
+
+ // Finish off by closing opened anchor
+ if( m_format == ANCHOR ) out.print("</a>");
+ }
+ catch( Exception e )
+ {
+ // Yes, we want to catch all exceptions here, including RuntimeExceptions
+ log.error( "Tag failed", e );
+ }
+
+ return EVAL_PAGE;
+ }
+
+ public void setBodyContent( BodyContent bc )
+ {
+ m_bodyContent = bc;
+ }
+
+ public void doInitBody() throws JspException
+ {
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToParentTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToParentTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToParentTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToParentTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,76 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2003 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.attachment.Attachment;
+
+/**
+ * Writes a link to a parent of a Wiki page.
+ *
+ * <P><B>Attributes</B></P>
+ * <UL>
+ * <LI>page - Page name to refer to. Default is the current page.
+ * <LI>format - either "anchor" or "url" to output either an <A>... or just the HREF part of one.
+ * </UL>
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class LinkToParentTag
+ extends LinkToTag
+{
+ private static final long serialVersionUID = 0L;
+
+ public int doWikiStartTag()
+ throws IOException
+ {
+ //
+ // We just simply set the page to be our parent page
+ // and call the superclass.
+ //
+ if( m_page != null && m_page instanceof Attachment )
+ {
+ setPage( ((Attachment)m_page).getParentName() );
+ }
+ else
+ {
+ String name = m_page.getName();
+
+ int entrystart = name.indexOf("_blogentry_");
+
+ if( entrystart != -1 )
+ {
+ setPage( name.substring( 0, entrystart ) );
+ }
+
+ int commentstart = name.indexOf("_comments_");
+
+ if( commentstart != -1 )
+ {
+ setPage( name.substring( 0, commentstart ) );
+ }
+ }
+
+ return super.doWikiStartTag();
+ }
+
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/LinkToTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,145 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.jsp.JspWriter;
+
+import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.action.AttachActionBean;
+import com.ecyrd.jspwiki.action.ViewActionBean;
+import com.ecyrd.jspwiki.attachment.Attachment;
+
+/**
+ * Writes a link to a Wiki page. Body of the link becomes the actual text.
+ * The link is written regardless to whether the page exists or not.
+ *
+ * <P><B>Attributes</B></P>
+ * <UL>
+ * <LI>page - Page name to refer to. Default is the current page.
+ * <LI>format - either "anchor" or "url" to output either an <A>... or just the HREF part of one.
+ * <LI>template - Which template should we link to.
+ * <LI>title - Is used in page actions to display hover text (tooltip)
+ * <LI>accesskey - Set an accesskey (ALT+[Char])
+ * </UL>
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class LinkToTag
+ extends WikiLinkTag
+{
+ private static final long serialVersionUID = 0L;
+
+ private String m_version = null;
+ public String m_title = "";
+ public String m_accesskey = "";
+
+ public void initTag()
+ {
+ super.initTag();
+ m_version = null;
+ }
+
+ public String getVersion()
+ {
+ return m_version;
+ }
+
+ public void setVersion( String arg )
+ {
+ m_version = arg;
+ }
+
+ public void setTitle( String title )
+ {
+ m_title = title;
+ }
+
+ public void setAccesskey( String access )
+ {
+ m_accesskey = access;
+ }
+
+
+ public int doWikiStartTag()
+ throws IOException
+ {
+ String pageName = m_pageName;
+ boolean isattachment = false;
+
+ if( m_pageName == null )
+ {
+ if( m_page != null )
+ {
+ pageName = m_page.getName();
+
+ isattachment = (m_page instanceof Attachment);
+ }
+ else
+ {
+ return SKIP_BODY;
+ }
+ }
+
+ WikiContext context = (WikiContext)m_actionBean;
+ JspWriter out = pageContext.getOut();
+ String url;
+ String linkclass;
+
+ Map<String,String> urlParams = new HashMap<String,String>();
+ if ( getVersion() != null )
+ {
+ urlParams.put("version",getVersion());
+ }
+
+ if( isattachment )
+ {
+ url = context.getContext().getURL(AttachActionBean.class, pageName, urlParams);
+ linkclass = "attachment";
+ }
+ else
+ {
+ if( getTemplate() != null )
+ {
+ urlParams.put("skin", getTemplate());
+ }
+ url = context.getContext().getURL( ViewActionBean.class, pageName, urlParams );
+ linkclass = "wikipage";
+ }
+
+ switch( m_format )
+ {
+ case ANCHOR:
+ out.print("<a class=\""+linkclass+"\" href=\""+url+"\" accesskey=\""
+ + m_accesskey + "\" title=\"" + m_title + "\">");
+ break;
+ case URL:
+ out.print( url );
+ break;
+ }
+
+ return EVAL_BODY_INCLUDE;
+ }
+
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/MessagesTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/MessagesTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/MessagesTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/MessagesTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,124 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.TextUtil;
+import com.ecyrd.jspwiki.WikiSession;
+
+/**
+ * Returns or clears the current messages associated with the user's wiki
+ * session. This tag accepts four attributes: <ul> <li><code>action</code> -
+ * if "clear", the messsages will be cleared. Otherwise, this tag will always
+ * print the set of current messages as either a single <p> tag (if there
+ * is only one message) or a bulleted list (if there is more than one).</li>
+ * <li><code>prefix</code> - the string to prepend to the list of errors, if
+ * there are any; default is empty string</li> <li><code>topic</code> - a
+ * collection for messages, for example those associated with a particular web
+ * form. If not suppled, defaults to a generic (non-specific) collection</li>
+ * <li><code>div</code> - the <code>div</code> class to wrap the
+ * messages in; if not supplied, <code>information</code> is assumed</li></ul>
+ * @author Andrew Jaquith
+ * @since 2.3.54
+ */
+public class MessagesTag extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ private String m_action = null;
+
+ private String m_prefix = "";
+
+ private String m_topic = null;
+
+ private String m_div = "information";
+
+ private static final String CLEAR = "clear";
+
+ public void initTag()
+ {
+ super.initTag();
+ m_action = m_topic = null;
+ m_prefix = "";
+ m_div = "information";
+ }
+
+
+ public void setTopic( String topic )
+ {
+ m_topic = topic;
+ }
+
+ public void setPrefix( String prefix )
+ {
+ m_prefix = prefix;
+ }
+
+ public void setDiv( String div )
+ {
+ m_div = div;
+ }
+
+ public void setAction( String action )
+ {
+ m_action = action.toLowerCase();
+ }
+
+ public final int doWikiStartTag() throws IOException
+ {
+ WikiSession session = m_actionBean.getWikiSession();
+ if ( CLEAR.equals( m_action ) )
+ {
+ if ( m_topic == null )
+ {
+ session.clearMessages();
+ }
+ else
+ {
+ session.clearMessages( m_topic );
+ }
+ }
+ else
+ {
+ String[] messages = ( m_topic == null ) ? session.getMessages() : session.getMessages( m_topic );
+ if ( messages.length > 0 )
+ {
+ StringBuffer sb = new StringBuffer();
+ if ( messages.length == 1 )
+ {
+ sb.append( "<div class=\"" + m_div + "\">" + m_prefix + TextUtil.replaceEntities(messages[0]) + "</div>" );
+ }
+ else
+ {
+ sb.append( "<div class=\"" + m_div + "\">" + m_prefix );
+ sb.append( "<ul>" );
+ for( int i = 0; i < messages.length; i++ )
+ {
+ sb.append( "<li>" + TextUtil.replaceEntities(messages[i]) + "</li>" );
+ }
+ sb.append( "</ul></div>" );
+ }
+ pageContext.getOut().println( sb.toString() );
+ }
+ }
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NextVersionTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NextVersionTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NextVersionTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NextVersionTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,52 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+/**
+ * Writes the version number of the next version of the page.
+ *
+ * @author Janne Jalkanen
+ * @since 2.2
+ */
+public class NextVersionTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ if ( m_page != null )
+ {
+ int version = m_page.getVersion();
+
+ if( version == -1 )
+ version = -1;
+ else
+ version++;
+
+ pageContext.getOut().print( version );
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NoSuchPageTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NoSuchPageTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NoSuchPageTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/NoSuchPageTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,82 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.WikiPage;
+import com.ecyrd.jspwiki.providers.ProviderException;
+
+/**
+ * Includes the body in case there is no such page available.
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class NoSuchPageTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ private String m_pageName;
+
+ public void initTag()
+ {
+ super.initTag();
+ m_pageName = null;
+ }
+
+ public void setPage( String name )
+ {
+ m_pageName = name;
+ }
+
+ public String getPage()
+ {
+ return m_pageName;
+ }
+
+ public int doWikiStartTag()
+ throws IOException,
+ ProviderException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+ WikiPage page;
+
+ if( m_pageName == null )
+ {
+ page = m_page;
+ }
+ else
+ {
+ page = engine.getPage( m_pageName );
+ }
+
+ // System.out.println("Checking "+page);
+
+ if( page != null && engine.pageExists( page.getName(), page.getVersion() ) )
+ {
+ return SKIP_BODY;
+ }
+
+ return EVAL_BODY_INCLUDE;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageDateTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageDateTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageDateTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageDateTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,93 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Writes the modification date of the page, formatted
+ * as specified in the attribute "format".
+ *
+ * <UL>
+ * <LI>format = A string describing which format you want to use.
+ * This is exactly like in "java.text.SimpleDateFormat".
+ * </UL>
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+
+// FIXME: Should also take the current user TimeZone into account.
+
+public class PageDateTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public static final String DEFAULT_FORMAT = "dd-MMM-yyyy HH:mm:ss zzz";
+
+ private String m_format = null;
+
+ public void initTag()
+ {
+ super.initTag();
+ m_format = null;
+ }
+
+ public String getFormat()
+ {
+ if( m_format == null )
+ return DEFAULT_FORMAT;
+
+ return m_format;
+ }
+
+ public void setFormat( String arg )
+ {
+ m_format = arg;
+ }
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ if( m_page != null )
+ {
+ Date d = m_page.getLastModified();
+
+ //
+ // Date may be null if the page does not exist.
+ //
+ if( d != null )
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat( getFormat() );
+
+ pageContext.getOut().write( fmt.format( d ) );
+ }
+ else
+ {
+ pageContext.getOut().write( "<never>" );
+ }
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageExistsTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageExistsTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageExistsTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageExistsTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,46 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.providers.ProviderException;
+
+/**
+ * Includes the body in case the set page does exist.
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+
+// FIXME: Logically, this should probably be the master one, then
+// NoSuchPageTag should be the one that derives from this.
+public class PageExistsTag
+ extends NoSuchPageTag
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException,
+ ProviderException
+ {
+ return (super.doWikiStartTag() == SKIP_BODY) ? EVAL_BODY_INCLUDE : SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageInfoLinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageInfoLinkTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageInfoLinkTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageInfoLinkTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,100 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import javax.servlet.jsp.JspWriter;
+
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.action.PageInfoActionBean;
+
+/**
+ * Writes a link to the Wiki PageInfo. Body of the link becomes the actual text.
+ *
+ * <P><B>Attributes</B></P>
+ * <UL>
+ * <LI>page - Page name to refer to. Default is the current page.
+ * <LI>title - Is used in page actions to display hover text (tooltip)
+ * <LI>accesskey - Set an accesskey (ALT+[Char])
+ * </UL>
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+// FIXME: Refactor together with LinkToTag and EditLinkTag.
+public class PageInfoLinkTag
+ extends WikiLinkTag
+{
+ private static final long serialVersionUID = 0L;
+ public String m_title = "";
+ public String m_accesskey = "";
+
+ public void setTitle( String title )
+ {
+ m_title = title;
+ }
+
+ public void setAccesskey( String access )
+ {
+ m_accesskey = access;
+ }
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+ String pageName = m_pageName;
+
+ if( m_pageName == null )
+ {
+ if( m_page != null )
+ {
+ pageName = m_page.getName();
+ }
+ else
+ {
+ return SKIP_BODY;
+ }
+ }
+
+ if( engine.pageExists(pageName) )
+ {
+ JspWriter out = pageContext.getOut();
+
+ String url = m_actionBean.getContext().getURL( PageInfoActionBean.class, pageName );
+
+ switch( m_format )
+ {
+ case ANCHOR:
+ out.print("<a class=\"pageinfo\" href=\""+url+"\" accesskey=\""
+ + m_accesskey + "\" title=\"" + m_title + "\">");
+ break;
+ case URL:
+ out.print( url );
+ break;
+ }
+
+ return EVAL_BODY_INCLUDE;
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageNameTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageNameTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageNameTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageNameTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,57 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.attachment.Attachment;
+
+/**
+ * Returns the currently requested page name.
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class PageNameTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+
+ if( m_page != null )
+ {
+ if( m_page instanceof Attachment )
+ {
+ pageContext.getOut().print( ((Attachment)m_page).getFileName() );
+ }
+ else
+ {
+ pageContext.getOut().print( engine.beautifyTitle( m_page.getName() ) );
+ }
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageSizeTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageSizeTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageSizeTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageSizeTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,66 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.providers.ProviderException;
+
+/**
+ * Returns the currently requested page or attachment size.
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class PageSizeTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+
+ try
+ {
+ if( m_page != null )
+ {
+ long size = m_page.getSize();
+
+ if( size == -1 && engine.pageExists(m_page) ) // should never happen with attachments
+ {
+ size = engine.getPureText( m_page.getName(), m_page.getVersion() ).length();
+ m_page.setSize( size );
+ }
+
+ pageContext.getOut().write( Long.toString(size) );
+ }
+ }
+ catch( ProviderException e )
+ {
+ log.warn("Providers did not work: ",e);
+ pageContext.getOut().write("Error determining page size: "+e.getMessage());
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageTypeTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageTypeTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageTypeTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageTypeTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,78 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.attachment.Attachment;
+
+/**
+ * Includes the body, if the current page is of proper type.
+ *
+ * <B>Attributes</B>
+ * <UL>
+ * <LI>type - either "page", "attachment" or "weblogentry"
+ * </UL>
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class PageTypeTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ private String m_type;
+
+ public void initTag()
+ {
+ super.initTag();
+ m_type = null;
+ }
+
+ public void setType( String arg )
+ {
+ m_type = arg.toLowerCase();
+ }
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ if( m_page != null )
+ {
+ if( m_type.equals("attachment") && m_page instanceof Attachment )
+ {
+ return EVAL_BODY_INCLUDE;
+ }
+
+ if( m_type.equals("page") && !(m_page instanceof Attachment) )
+ {
+ return EVAL_BODY_INCLUDE;
+ }
+
+ if( m_type.equals("weblogentry") && !(m_page instanceof Attachment) && m_page.getName().indexOf("_blogentry_") != -1 )
+ {
+ return EVAL_BODY_INCLUDE;
+ }
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageVersionTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageVersionTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageVersionTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PageVersionTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,53 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+/**
+ * Writes the version of the current page. If this is
+ * marked as the current version, then includes body as text instead of
+ * version number.
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class PageVersionTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ if( m_page != null )
+ {
+ int version = m_page.getVersion();
+
+ if( version > 0 )
+ {
+ pageContext.getOut().print( Integer.toString(version) );
+ return SKIP_BODY;
+ }
+ }
+
+ return EVAL_BODY_INCLUDE;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamHandler.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamHandler.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamHandler.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamHandler.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,32 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+
+/**
+ * Interface to be implemented by any tag that wishes to contain
+ * a wiki:param tag for passing dynamic name-value pairs.
+ * <p>
+ * Note that the implementing tag must also accept body content.
+ */
+public interface ParamHandler
+{
+ public void setContainedParameter( String n, String v );
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParamTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,84 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package com.ecyrd.jspwiki.tags;
+
+import javax.servlet.jsp.tagext.BodyContent;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.Tag;
+
+/**
+ * ParamTag submits name-value pairs to the first enclosing
+ * ParamHandler instance. Name and value are strings, and can
+ * be given as tag attributes, or alternatively the value can be
+ * given as the body contents of this tag.
+ * <p>
+ * The name-value pair is passed to the closest containing
+ * ancestor tag that implements ParamHandler.
+ */
+public class ParamTag
+ extends BodyTagSupport
+{
+
+ private static final long serialVersionUID = -4671059568218551633L;
+ private String m_name;
+ private String m_value;
+
+ public void release()
+ {
+ m_name = m_value = null;
+ }
+
+ public void setName( String s )
+ {
+ m_name = s;
+ }
+
+ public void setValue( String s )
+ {
+ m_value = s;
+ }
+
+ public int doEndTag()
+ {
+ Tag t = null;
+ while( (t = getParent()) != null && !(t instanceof ParamHandler) )
+ ;
+ if( t != null )
+ {
+ String val = m_value;
+ if( val == null )
+ {
+ BodyContent bc = getBodyContent();
+ if( bc != null )
+ {
+ val = bc.getString();
+ }
+ }
+ if( val != null )
+ {
+ ((ParamHandler)t).setContainedParameter( m_name, val );
+ }
+ }
+
+
+ return EVAL_PAGE;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/ParentPageNameTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,74 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.attachment.Attachment;
+
+/**
+ * Returns the parent of the currently requested page. Weblog entries are recognized
+ * as subpages of the weblog page.
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class ParentPageNameTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+
+ if( m_page != null )
+ {
+ if( m_page instanceof Attachment )
+ {
+ pageContext.getOut().print( engine.beautifyTitle( ((Attachment)m_page).getParentName()) );
+ }
+ else
+ {
+ String name = m_page.getName();
+
+ int entrystart = name.indexOf("_blogentry_");
+
+ if( entrystart != -1 )
+ {
+ name = name.substring( 0, entrystart );
+ }
+
+ int commentstart = name.indexOf("_comments_");
+
+ if( commentstart != -1 )
+ {
+ name = name.substring( 0, commentstart );
+ }
+
+ pageContext.getOut().print( engine.beautifyTitle(name) );
+ }
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PermissionTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,195 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+import java.security.Permission;
+
+import org.apache.commons.lang.StringUtils;
+
+import com.ecyrd.jspwiki.*;
+import com.ecyrd.jspwiki.action.GroupContext;
+import com.ecyrd.jspwiki.auth.AuthorizationManager;
+import com.ecyrd.jspwiki.auth.authorize.Group;
+import com.ecyrd.jspwiki.auth.permissions.AllPermission;
+import com.ecyrd.jspwiki.auth.permissions.GroupPermission;
+import com.ecyrd.jspwiki.auth.permissions.PermissionFactory;
+import com.ecyrd.jspwiki.auth.permissions.WikiPermission;
+
+/**
+ * Tells whether the user in the current wiki context possesses a particular
+ * permission. The permission is typically a PagePermission (e.g., "edit", "view",
+ * "delete", "comment", "upload"). It may also be a wiki-wide WikiPermission
+ * ("createPages", "createGroups", "editProfile", "editPreferences", "login")
+ * or the administrator permission ("allPermission"). GroupPermissions
+ * (e.g., "viewGroup", "editGroup", "deleteGroup").
+ * <p>
+ * Since 2.6, it is possible to list several permissions or use negative permissions,
+ * e.g.
+ * <pre>
+ * <wiki:Permission permission="edit|rename|view">
+ * You have edit, rename, or view permissions!
+ * </wiki:Permission>
+ * </pre>
+ *
+ * or
+ *
+ * <pre>
+ * <wiki:Permission permission="!upload">
+ * You do not have permission to upload!
+ * </wiki:Permission>
+ * </pre>
+ *
+ * @author Janne Jalkanen
+ * @author Andrew Jaquith
+ * @since 2.0
+ */
+public class PermissionTag
+ extends WikiTagBase
+{
+ private static final String ALL_PERMISSION = "allPermission";
+ private static final String CREATE_GROUPS = "createGroups";
+ private static final String CREATE_PAGES = "createPages";
+ private static final String DELETE_GROUP = "deleteGroup";
+ private static final String EDIT = "edit";
+ private static final String EDIT_GROUP = "editGroup";
+ private static final String EDIT_PREFERENCES = "editPreferences";
+ private static final String EDIT_PROFILE = "editProfile";
+ private static final String LOGIN = "login";
+ private static final String VIEW_GROUP = "viewGroup";
+
+ private static final long serialVersionUID = 3761412993048982325L;
+
+ private String[] m_permissionList;
+
+ /**
+ * Initializes the tag.
+ */
+ public void initTag()
+ {
+ super.initTag();
+ m_permissionList = null;
+ }
+
+ /**
+ * Sets the permissions to look for (case sensitive). See above for the format.
+ *
+ * @param permission A list of permissions
+ */
+ public void setPermission( String permission )
+ {
+ m_permissionList = StringUtils.split(permission,'|');
+ }
+
+ /**
+ * Checks a single permission.
+ *
+ * @param permission
+ * @return
+ */
+ private boolean checkPermission( String permission )
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+ WikiSession session = m_actionBean.getWikiSession();
+ AuthorizationManager mgr = engine.getAuthorizationManager();
+ boolean gotPermission = false;
+
+ if ( CREATE_GROUPS.equals( permission ) || CREATE_PAGES.equals( permission )
+ || EDIT_PREFERENCES.equals( permission ) || EDIT_PROFILE.equals( permission )
+ || LOGIN.equals( permission ) )
+ {
+ gotPermission = mgr.checkPermission( session, new WikiPermission( engine.getApplicationName(), permission ) );
+ }
+ else if ( VIEW_GROUP.equals( permission ) )
+ {
+ Group group = ((GroupContext)m_actionBean).getGroup();
+ Permission perm = new GroupPermission( group.getName(), GroupPermission.VIEW_ACTION );
+ gotPermission = mgr.checkPermission( session, perm );
+ }
+ else if ( EDIT_GROUP.equals( permission ) )
+ {
+ Group group = ((GroupContext)m_actionBean).getGroup();
+ Permission perm = new GroupPermission( group.getName(), GroupPermission.VIEW_ACTION );
+ gotPermission = mgr.checkPermission( session, perm );
+ }
+ else if ( DELETE_GROUP.equals( permission ) )
+ {
+ Group group = ((GroupContext)m_actionBean).getGroup();
+ Permission perm = new GroupPermission( group.getName(), GroupPermission.VIEW_ACTION );
+ gotPermission = mgr.checkPermission( session, perm );
+ }
+ else if ( ALL_PERMISSION.equals( permission ) )
+ {
+ gotPermission = mgr.checkPermission( session, new AllPermission( engine.getApplicationName() ) );
+ }
+ else if ( m_actionBean instanceof WikiContext && m_page != null )
+ {
+ //
+ // Edit tag also checks that we're not trying to edit an
+ // old version: they cannot be edited.
+ //
+ if( EDIT.equals(permission) )
+ {
+ WikiPage latest = engine.getPage( m_page.getName() );
+ if( m_page.getVersion() != WikiProvider.LATEST_VERSION &&
+ latest.getVersion() != m_page.getVersion() )
+ {
+ return false;
+ }
+ }
+
+ Permission p = PermissionFactory.getPagePermission( m_page, permission );
+ gotPermission = mgr.checkPermission( session,
+ p );
+ }
+
+ return gotPermission;
+ }
+
+ /**
+ * Initializes the tag.
+ * @return the result of the tag: SKIP_BODY or EVAL_BODY_CONTINUE
+ * @throws IOException this exception will never be thrown
+ */
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ for( int i = 0; i < m_permissionList.length; i++ )
+ {
+ String perm = m_permissionList[i];
+
+ boolean hasPermission = false;
+
+ if( perm.charAt(0) == '!' )
+ {
+ hasPermission = !checkPermission( perm.substring(1) );
+ }
+ else
+ {
+ hasPermission = checkPermission( perm );
+ }
+
+ if( hasPermission )
+ return EVAL_BODY_INCLUDE;
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PluginTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,131 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2004 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyContent;
+
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.plugin.PluginException;
+import com.ecyrd.jspwiki.plugin.PluginManager;
+
+/**
+ * Inserts any Wiki plugin. The body of the tag becomes then
+ * the body for the plugin.
+ * <P><B>Attributes</B></P>
+ * <UL>
+ * <LI>plugin - name of the plugin you want to insert.
+ * <LI>args - An argument string for the tag.
+ * </UL>
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class PluginTag
+ extends WikiBodyTag
+{
+ private static final long serialVersionUID = 0L;
+
+ private String m_plugin;
+ private String m_args;
+
+ private boolean m_evaluated = false;
+
+ public void release()
+ {
+ super.release();
+ m_plugin = m_args = null;
+ m_evaluated = false;
+ }
+
+ public void setPlugin( String p )
+ {
+ m_plugin = p;
+ }
+
+ public void setArgs( String a )
+ {
+ m_args = a;
+ }
+
+ public int doWikiStartTag() throws JspException, IOException
+ {
+ m_evaluated = false;
+ return EVAL_BODY_BUFFERED;
+ }
+
+ private String executePlugin( String plugin, String args, String body )
+ throws PluginException, IOException
+ {
+ WikiEngine engine = m_wikiContext.getEngine();
+ PluginManager pm = engine.getPluginManager();
+
+ m_evaluated = true;
+
+ Map<String,Object> argmap = pm.parseArgs( args );
+
+ if( body != null )
+ {
+ argmap.put( "_body", body );
+ }
+
+ String result = pm.execute( m_wikiContext, plugin, argmap );
+
+ return result;
+ }
+
+ public int doEndTag()
+ throws JspException
+ {
+ if( !m_evaluated )
+ {
+ try
+ {
+ pageContext.getOut().write( executePlugin( m_plugin, m_args, null ) );
+ }
+ catch( Exception e )
+ {
+ log.error( "Failed to insert plugin", e );
+ throw new JspException( "Tag failed, check logs: "+e.getMessage() );
+ }
+ }
+ return EVAL_PAGE;
+ }
+
+ public int doAfterBody()
+ throws JspException
+ {
+ try
+ {
+ BodyContent bc = getBodyContent();
+
+ getPreviousOut().write( executePlugin( m_plugin, m_args, ((bc != null) ? bc.getString() : null) ) );
+ }
+ catch( Exception e )
+ {
+ log.error( "Failed to insert plugin", e );
+ throw new JspException( "Tag failed, check logs: "+e.getMessage() );
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/PreviousVersionTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,50 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+/**
+ * Outputs the version number of the previous version of this page.
+ *
+ * @author Janne Jalkanen
+ * @since 2.2
+ */
+public class PreviousVersionTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ if ( m_page != null )
+ {
+ int version = m_page.getVersion();
+
+ version--;
+
+ if( version > 0 )
+ pageContext.getOut().print( version );
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSCoffeeCupLinkTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,78 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+import javax.servlet.jsp.JspWriter;
+
+import com.ecyrd.jspwiki.WikiEngine;
+
+/**
+ * Writes an image link to the RSS file with the Coffee Cup
+ * for Userland aggregation.
+ * <p>
+ * This class will be removed in JSPWiki 2.6.
+ *
+ * @author Janne Jalkanen
+ * @deprecated
+ * @since 2.0
+ */
+public class RSSCoffeeCupLinkTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ protected String m_title;
+
+ public void initTag()
+ {
+ super.initTag();
+ m_title = null;
+ }
+
+ public void setTitle( String title )
+ {
+ m_title = title;
+ }
+
+ public String getTitle()
+ {
+ return m_title;
+ }
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+
+ String rssURL = engine.getGlobalRSSURL();
+
+ if( rssURL != null )
+ {
+ JspWriter out = pageContext.getOut();
+ out.print("<a href=\"http://127.0.0.1:5335/system/pages/subscriptions/?url="+rssURL+"\">");
+ out.print("<img src=\""+engine.getBaseURL()+"images/xmlCoffeeCup.png\"");
+ out.print("title=\""+getTitle()+"\"/>");
+ out.print("</a>");
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSImageLinkTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,76 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import javax.servlet.jsp.JspWriter;
+
+import com.ecyrd.jspwiki.WikiEngine;
+import com.ecyrd.jspwiki.action.NoneActionBean;
+
+/**
+ * Writes an image link to the RSS file.
+ *
+ * @author Janne Jalkanen
+ * @since 2.0
+ */
+public class RSSImageLinkTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ protected String m_title;
+
+ public void initTag()
+ {
+ super.initTag();
+ m_title = null;
+ }
+
+ public void setTitle( String title )
+ {
+ m_title = title;
+ }
+
+ public String getTitle()
+ {
+ return m_title;
+ }
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+
+ String rssURL = engine.getGlobalRSSURL();
+
+ if( rssURL != null )
+ {
+ JspWriter out = pageContext.getOut();
+ out.print("<a href=\""+rssURL+"\">");
+ out.print("<img src=\""+m_actionBean.getContext().getURL( NoneActionBean.class,"images/xml.png")+"\"");
+ out.print(" alt=\"[RSS]\" title=\""+getTitle()+"\"/>");
+ out.print("</a>");
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RSSLinkTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,55 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import java.io.IOException;
+
+import com.ecyrd.jspwiki.WikiEngine;
+
+/**
+ * Writes a link to the RSS file (using the "link" attribute).
+ * <p>
+ * This tag is now deprecated - please use the new FeedDiscoveryTag.
+ *
+ * @author Janne Jalkanen
+ * @deprecated
+ * @see FeedDiscoveryTag
+ * @since 2.0
+ */
+public class RSSLinkTag
+ extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ public final int doWikiStartTag()
+ throws IOException
+ {
+ WikiEngine engine = m_actionBean.getEngine();
+
+ String rssURL = engine.getGlobalRSSURL();
+
+ if( rssURL != null )
+ {
+ pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS feed\" href=\""+rssURL+"\" />");
+ }
+
+ return SKIP_BODY;
+ }
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/RequestResourceTag.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,74 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import com.ecyrd.jspwiki.ui.TemplateManager;
+
+/**
+ * Provides easy access to TemplateManager.addResourceRequest(). You may use
+ * any of the request types defined there.
+ *
+ * @author jalkanen
+ *
+ */
+public class RequestResourceTag extends WikiTagBase
+{
+ private static final long serialVersionUID = 0L;
+
+ private String m_type;
+ private String m_resource;
+
+ public void initTag()
+ {
+ super.initTag();
+ m_type = m_resource = null;
+ }
+
+ public int doWikiStartTag() throws Exception
+ {
+ if( m_type != null && m_resource != null )
+ {
+ TemplateManager.addResourceRequest( m_actionBean, m_type, m_resource );
+ }
+
+ return SKIP_BODY;
+ }
+
+ public String getResource()
+ {
+ return m_resource;
+ }
+
+ public void setResource(String r)
+ {
+ m_resource = r;
+ }
+
+ public String getType()
+ {
+ return m_type;
+ }
+
+ public void setType(String type)
+ {
+ m_type = type;
+ }
+
+}
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorInfo.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorInfo.java?rev=627255&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorInfo.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/com/ecyrd/jspwiki/tags/SearchResultIteratorInfo.java Tue Feb 12 21:53:55 2008
@@ -0,0 +1,44 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package com.ecyrd.jspwiki.tags;
+
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.VariableInfo;
+
+/**
+ * Just provides the TEI data for IteratorTag.
+ *
+ * @since 2.0
+ */
+public class SearchResultIteratorInfo extends TagExtraInfo
+{
+ public VariableInfo[] getVariableInfo(TagData data)
+ {
+ VariableInfo[] var = { new VariableInfo( data.getAttributeString("id"),
+ "com.ecyrd.jspwiki.SearchResult",
+ true,
+ VariableInfo.NESTED )
+ };
+
+ return var;
+
+ }
+}