jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r627262 [2/2] - /incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/
Date Wed, 13 Feb 2008 06:15:49 GMT
Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Search.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Search.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Search.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Search.jsp Tue Feb 12 22:15:47
2008
@@ -0,0 +1,100 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.*" %>
+<%@ page import="com.ecyrd.jspwiki.auth.permissions.*" %>
+<%@ page import="java.util.*" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWikiSearch");
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.FIND );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    // Get the search results
+    Collection list = null;
+    String query = request.getParameter( "query");
+    String go    = request.getParameter("go");
+    
+    if( query != null )
+    {
+        log.info("Searching for string "+query);
+
+        try
+        {
+            list = wiki.findPages( query );
+
+            //
+            //  Filter down to only those that we actually have a permission to view
+            //
+            AuthorizationManager mgr = wiki.getAuthorizationManager();
+        
+            ArrayList filteredList = new ArrayList();
+            
+            for( Iterator i = list.iterator(); i.hasNext(); )
+            {
+                SearchResult r = (SearchResult)i.next();
+            
+                WikiPage p = r.getPage();
+            
+                PagePermission pp = new PagePermission( p, PagePermission.VIEW_ACTION );
+
+                try
+                {            
+                    if( mgr.checkPermission( wikiContext.getWikiSession(), pp ) )
+                    {
+                        filteredList.add( r );
+                    }
+                }
+                catch( Exception e ) { log.error( "Searching for page "+p, e ); }
+            }
+        
+            pageContext.setAttribute( "searchresults",
+                                      filteredList,
+                                      PageContext.REQUEST_SCOPE );
+        }
+        catch( Exception e )
+        {
+            wikiContext.getWikiSession().addMessage( e.getMessage() );
+        }
+        
+        query = TextUtil.replaceEntities( query );
+
+        pageContext.setAttribute( "query",
+                                  query,
+                                  PageContext.REQUEST_SCOPE );
+        
+        //
+        //  Did the user click on "go"?
+        //           
+        if( go != null )
+        {
+            if( list != null && list.size() > 0 )
+            {
+                SearchResult sr = (SearchResult) list.iterator().next();
+                
+                WikiPage wikiPage = sr.getPage();
+                
+                String url = wikiContext.getViewURL( wikiPage.getName() );
+                
+                response.sendRedirect( url );
+                
+                return;
+            }
+        }                              
+    }
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" /><%
+    log.debug("SEARCH COMPLETE");
+%>

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/SisterSites.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/SisterSites.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/SisterSites.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/SisterSites.jsp Tue Feb
12 22:15:47 2008
@@ -0,0 +1,37 @@
+<%@ page import="java.util.*,com.ecyrd.jspwiki.*" %>
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="java.text.*" %>
+<%@ page import="com.ecyrd.jspwiki.rss.*" %>
+<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ taglib uri="/WEB-INF/oscache.tld" prefix="oscache" %>
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+<%
+    /*
+     *  This JSP creates support for the SisterSites standard,
+     *  as specified by http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
+     *
+     *  FIXME: Does not honor the ACL's on the pages.
+     */
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, "rss" );
+    if(!wikiContext.hasAccess( response )) return;
+    
+    Set allPages = wiki.getReferenceManager().findCreated();
+    
+    response.setContentType("text/plain; charset=UTF-8");
+    for( Iterator i = allPages.iterator(); i.hasNext(); )
+    {
+        String pageName = (String)i.next();
+        
+        // Let's not add attachments.
+        // TODO: This is a kludge and not forward-compatible.
+        
+        if( pageName.indexOf("/") != -1 ) continue; 
+        String url = wiki.getViewURL( pageName );
+        
+        out.write( url + " " + pageName + "\n" );
+    }
+ %>
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Upload.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Upload.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Upload.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Upload.jsp Tue Feb 12 22:15:47
2008
@@ -0,0 +1,24 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<% 
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.UPLOAD );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    // Set the content type and include the response content
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "UploadTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/UserPreferences.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/UserPreferences.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/UserPreferences.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/UserPreferences.jsp Tue
Feb 12 22:15:47 2008
@@ -0,0 +1,100 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.VariableManager" %>
+<%@ page import="com.ecyrd.jspwiki.WikiContext" %>
+<%@ page import="com.ecyrd.jspwiki.WikiSession" %>
+<%@ page import="com.ecyrd.jspwiki.WikiEngine" %>
+<%@ page import="com.ecyrd.jspwiki.auth.UserManager" %>
+<%@ page import="com.ecyrd.jspwiki.auth.WikiSecurityException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.login.CookieAssertionLoginModule" %>
+<%@ page import="com.ecyrd.jspwiki.auth.user.DuplicateUserException" %>
+<%@ page import="com.ecyrd.jspwiki.auth.user.UserProfile" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.DecisionRequiredException" %>
+<%@ page import="com.ecyrd.jspwiki.ui.EditorManager" %>
+<%@ page import="com.ecyrd.jspwiki.preferences.*" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.PREFS );
+    if(!wikiContext.hasAccess( response )) return;
+    
+    // Extract the user profile and action attributes
+    UserManager userMgr = wiki.getUserManager();
+    WikiSession wikiSession = wikiContext.getWikiSession();
+
+    if( request.getParameter(EditorManager.PARA_EDITOR) != null )
+    {
+    	String editor = request.getParameter(EditorManager.PARA_EDITOR);
+    	session.setAttribute(EditorManager.PARA_EDITOR,editor);
+    }
+    // Are we saving the profile?
+    if( "saveProfile".equals(request.getParameter("action")) )
+    {
+        UserProfile profile = userMgr.parseProfile( wikiContext );
+         
+        // Validate the profile
+        userMgr.validateProfile( wikiContext, profile );
+
+        // If no errors, save the profile now & refresh the principal set!
+        if ( wikiSession.getMessages( "profile" ).length == 0 )
+        {
+            try
+            {
+                userMgr.setUserProfile( wikiSession, profile );
+                CookieAssertionLoginModule.setUserCookie( response, profile.getFullname()
);
+            }
+            catch( DuplicateUserException e )
+            {
+                // User collision! (full name or wiki name already taken)
+                wikiSession.addMessage( "profile", e.getMessage() );
+            }
+            catch( DecisionRequiredException e )
+            {
+                String redirect = wiki.getURL(WikiContext.VIEW,"ApprovalRequiredForUserProfiles",null,true);
+                response.sendRedirect( redirect );
+                return;
+            }
+            catch( WikiSecurityException e )
+            {
+                // Something went horribly wrong! Maybe it's an I/O error...
+                wikiSession.addMessage( "profile", e.getMessage() );
+            }
+        }
+        if ( wikiSession.getMessages( "profile" ).length == 0 )
+        {
+            String redirectPage = request.getParameter( "redirect" );
+            response.sendRedirect( wiki.getViewURL(redirectPage) );
+            return;
+        }
+    }
+    if( "setAssertedName".equals(request.getParameter("action")) )
+    {
+        Preferences.reloadPreferences(pageContext);
+        String assertedName = request.getParameter("assertedName");
+        CookieAssertionLoginModule.setUserCookie( response, assertedName );
+
+        String redirectPage = request.getParameter( "redirect" );
+        String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wiki.getViewURL(
redirectPage );
+
+        log.info( "Redirecting user to " + viewUrl );
+        response.sendRedirect( viewUrl );
+        return;
+    }
+    if( "clearAssertedName".equals(request.getParameter("action")) )
+    {
+        CookieAssertionLoginModule.clearUserCookie( response );
+        response.sendRedirect( wikiContext.getURL(WikiContext.NONE,"Logout.jsp") );
+        return;
+    }
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Vote.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Vote.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Vote.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Vote.jsp Tue Feb 12 22:15:47
2008
@@ -0,0 +1,23 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.plugin.VotePlugin" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%><%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+    String pagereq = wikiContext.getName();
+    
+    String vote    = request.getParameter("vote");
+    log.info("Vote '"+pagereq+"' from "+request.getRemoteAddr()+" by "+request.getRemoteUser()
);
+
+    VotePlugin plugin = new VotePlugin();
+
+    plugin.vote( wikiContext, TextUtil.isPositive( vote ) ? 1 : -1 );
+
+    response.sendRedirect( wiki.getBaseURL()+"Wiki.jsp?page=VoteOk" );
+%>
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Wiki.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Wiki.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Wiki.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Wiki.jsp Tue Feb 12 22:15:47
2008
@@ -0,0 +1,47 @@
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.*" %>
+<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ page import="org.apache.commons.lang.time.StopWatch" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+    if(!wikiContext.hasAccess( response )) return;
+    String pagereq = wikiContext.getName();
+
+    // Redirect if the request was for a 'special page'
+    String redirect = wiki.getRedirectURL( wikiContext );
+    if( redirect != null )
+    {
+        response.sendRedirect( redirect );
+        return;
+    }
+    
+    StopWatch sw = new StopWatch();
+    sw.start();
+    WatchDog w = wiki.getCurrentWatchDog();
+    try {
+        w.enterState("Generating VIEW response for "+wikiContext.getPage(),60);
+    
+        // Set the content type and include the response content
+        response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+        String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                                wikiContext.getTemplate(),
+                                                                "ViewTemplate.jsp" );
+
+%><wiki:Include page="<%=contentPage%>" /><%
+    }
+    finally
+    {
+        sw.stop();
+        if( log.isDebugEnabled() ) log.debug("Total response time from server on page "+pagereq+":
"+sw);
+        w.exitState();
+    }
+%>
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Workflow.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Workflow.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Workflow.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/Workflow.jsp Tue Feb 12
22:15:47 2008
@@ -0,0 +1,94 @@
+<%@ page import="java.util.Collection" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="com.ecyrd.jspwiki.WikiContext" %>
+<%@ page import="com.ecyrd.jspwiki.WikiSession" %>
+<%@ page import="com.ecyrd.jspwiki.WikiEngine" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.Decision" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.DecisionQueue" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.NoSuchOutcomeException" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.Outcome" %>
+<%@ page import="com.ecyrd.jspwiki.workflow.Workflow" %>
+<%@ page errorPage="/Error.jsp" %>
+<%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
+
+<%! 
+    Logger log = Logger.getLogger("JSPWiki"); 
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, WikiContext.WORKFLOW );
+    if(!wikiContext.hasAccess( response )) return;
+    
+    // Extract the wiki session
+    WikiSession wikiSession = wikiContext.getWikiSession();
+    
+    // Get the current decisions
+    DecisionQueue dq = wiki.getWorkflowManager().getDecisionQueue();
+
+    if( "decide".equals(request.getParameter("action")) )
+    {
+        try
+        {
+          // Extract parameters for decision ID & decision outcome
+          int id = Integer.parseInt( request.getParameter( "id" ) );
+          String outcomeKey = request.getParameter("outcome");
+          Outcome outcome = Outcome.forName( outcomeKey );
+          // Iterate through our actor decisions and see if we can find an ID match
+          Collection decisions = dq.getActorDecisions(wikiSession);
+          for (Iterator it = decisions.iterator(); it.hasNext();)
+          {
+            Decision d = (Decision)it.next();
+            if (d.getId() == id)
+            {
+              // Cool, we found it. Now make the decision.
+              dq.decide(d, outcome);
+            }
+          }
+        }
+        catch ( NumberFormatException e )
+        {
+           log.warn("Could not parse integer from parameter 'decision'. Somebody is being
naughty.");
+        }
+        catch ( NoSuchOutcomeException e )
+        {
+           log.warn("Could not look up Outcome from parameter 'outcome'. Somebody is being
naughty.");
+        }
+    }
+    if( "abort".equals(request.getParameter("action")) )
+    {
+        try
+        {
+          // Extract parameters for decision ID & decision outcome
+          int id = Integer.parseInt( request.getParameter( "id" ) );
+          // Iterate through our owner decisions and see if we can find an ID match
+          Collection workflows = wiki.getWorkflowManager().getOwnerWorkflows(wikiSession);
+          for (Iterator it = workflows.iterator(); it.hasNext();)
+          {
+            Workflow w = (Workflow)it.next();
+            if (w.getId() == id)
+            {
+              // Cool, we found it. Now kill the workflow.
+              w.abort();
+            }
+          }
+        }
+        catch ( NumberFormatException e )
+        {
+           log.warn("Could not parse integer from parameter 'decision'. Somebody is being
naughty.");
+        }
+    }
+    
+    // Stash the current decisions/workflows
+    request.setAttribute("decisions",   dq.getActorDecisions(wikiSession));
+    request.setAttribute("workflows",   wiki.getWorkflowManager().getOwnerWorkflows(wikiSession));
+    request.setAttribute("wikiSession", wikiSession);
+    
+    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
+                                                            wikiContext.getTemplate(),
+                                                            "ViewTemplate.jsp" );
+%><wiki:Include page="<%=contentPage%>" />
+

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/atom.css
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/atom.css?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/atom.css (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/atom.css Tue Feb 12 22:15:47
2008
@@ -0,0 +1,82 @@
+feed {
+  display:block;
+  font-family:verdana, sans-serif;
+  margin:2%;
+  font-size:90%;
+  color:#000000;
+  background:#ffffff;
+}
+
+title {
+  display:block;
+  font-size:1.3em;
+  color:inherit;
+  background:inherit;
+  font-weight:bold;
+}
+
+tagline, link {
+  display:block;
+  font-size:0.9em;
+}
+
+id, modified {
+  display:none;
+}
+
+generator {
+  display:block;
+  font-size:0.9em;
+}
+
+info {
+  display:block;
+  margin:3em 4em 3em 4em;
+  color:#CC3333;
+  background:#FFFF66;
+  border:solid #CCCC66 2px;
+  text-align:center;
+  padding:1.5em;
+  font-family:mono;
+  font-size:0.8em;
+}
+
+entry {
+  display:block;
+  color:inherit;
+  background:inherit;
+  padding:0;
+  margin:1em 1em 4em 1em;
+  
+}
+
+entry modified, entry name {
+  display:inline;
+  color:#999999;
+  background:inherit;
+  font-size:0.8em;
+}
+
+entry created, entry issued, entry id {
+  display:none;
+}
+
+entry title {
+  display:block;
+  font-size:1em;
+  font-weight:bold;
+  color:inherit;
+  background:inherit;
+  padding:1em 1em 0em 1em;
+  margin:0;
+  border-top:solid 1px #dddddd;
+}
+
+content {
+  display:block;
+  font-size:0.9em;
+  color:inherit;
+  background:inherit;
+  padding:1em;
+  line-height:1.5em;
+}
\ No newline at end of file

Added: incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/rss.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/rss.jsp?rev=627262&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/rss.jsp (added)
+++ incubator/jspwiki/branches/JSPWIKI_STRIPES_BRANCH/src/webdocs/rss.jsp Tue Feb 12 22:15:47
2008
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<%@ page import="java.util.*,com.ecyrd.jspwiki.*" %>
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="java.text.*" %>
+<%@ page import="com.ecyrd.jspwiki.rss.*" %>
+<%@ page import="com.ecyrd.jspwiki.util.*" %>
+<%@ taglib uri="/WEB-INF/oscache.tld" prefix="oscache" %>
+
+<%!
+    Logger log = Logger.getLogger("JSPWiki");
+%>
+
+<%
+    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    // Create wiki context and check for authorization
+    WikiContext wikiContext = wiki.createContext( request, "rss" );
+    if(!wikiContext.hasAccess( response )) return;
+    WikiPage    wikipage    = wikiContext.getPage();
+
+    // Redirect if baseURL not set or RSS generation not on
+    if( wiki.getBaseURL().length() == 0 )
+    {
+        response.sendError( 500, "The jspwiki.baseURL property has not been defined for this
wiki - cannot generate RSS" );
+        return;
+    }
+    
+    if( wiki.getRSSGenerator() == null )
+    {
+        response.sendError( 404, "RSS feeds are disabled at administrator request" );
+        return;
+    }
+
+    if( wikipage == null || !wiki.pageExists(wikipage.getName()) )
+    {
+        response.sendError( 404, "No such page "+wikipage.getName() );
+        return;
+    }
+
+    WatchDog w = wiki.getCurrentWatchDog();
+    w.enterState("Generating RSS",60);
+    
+    // Set the mode and type for the feed
+    String      mode        = request.getParameter("mode");
+    String      type        = request.getParameter("type");
+    
+    if( mode == null || !(mode.equals(RSSGenerator.MODE_BLOG) || mode.equals(RSSGenerator.MODE_WIKI))
) 
+    	   mode = RSSGenerator.MODE_BLOG;
+    if( type == null || !(type.equals(RSSGenerator.RSS10) || type.equals(RSSGenerator.RSS20)
|| type.equals(RSSGenerator.ATOM)) ) 
+    	   type = RSSGenerator.RSS20;
+    
+    // Force the TranslatorReader to output absolute URLs
+    // regardless of the current settings.
+    wikiContext.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
+
+    // Set the content type and include the response content
+    response.setContentType( RSSGenerator.getContentType(type)+"; charset=UTF-8");
+
+    StringBuffer result = new StringBuffer();
+    SimpleDateFormat iso8601fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+
+    Properties properties = wiki.getWikiProperties();
+    String channelDescription = wiki.getRequiredProperty( properties, RSSGenerator.PROP_CHANNEL_DESCRIPTION
);
+    String channelLanguage    = wiki.getRequiredProperty( properties, RSSGenerator.PROP_CHANNEL_LANGUAGE
);
+
+    //
+    //  Now, list items.
+    //
+    List changed;
+    
+    if( mode.equals("blog") )
+    {
+        com.ecyrd.jspwiki.plugin.WeblogPlugin plug = new com.ecyrd.jspwiki.plugin.WeblogPlugin();
+        changed = plug.findBlogEntries(wiki.getPageManager(), 
+                                       wikipage.getName(),
+                                       new Date(0L),
+                                       new Date());
+    }
+    else
+    {
+        changed = wiki.getVersionHistory( wikipage.getName() );
+    }
+    
+    //
+    //  Check if nothing has changed, so we can just return a 304
+    //
+    boolean hasChanged = false;
+    Date    latest     = new Date(0);
+
+    for( Iterator i = changed.iterator(); i.hasNext(); )
+    {
+        WikiPage p = (WikiPage) i.next();
+
+        if( !HttpUtil.checkFor304( request, p ) ) hasChanged = true;
+        if( p.getLastModified().after( latest ) ) latest = p.getLastModified();
+    }
+
+    if( !hasChanged && changed.size() > 0 )
+    {
+        response.sendError( HttpServletResponse.SC_NOT_MODIFIED );
+        w.exitState();
+        return;
+    }
+
+    response.addDateHeader("Last-Modified",latest.getTime());
+    response.addHeader("ETag", HttpUtil.createETag(wikipage) );
+%>
+<%-- <oscache:cache time="300"> --%>
+<%
+    out.println(wiki.getRSSGenerator().generateFeed( wikiContext, changed, mode, type ));
+%>
+<%-- </oscache:cache> --%>
+<% w.exitState(); %>



Mime
View raw message