morciuch 2002/09/17 13:11:55
Modified: webapp/WEB-INF/conf JetspeedResources.properties
portlets.xreg
webapp/WEB-INF/templates/vm/portlets/html
customizer-portletset-add.vm
Added: src/java/org/apache/jetspeed/portal/portlets
PreviewPortlet.java
webapp/WEB-INF/psml/role/user/html preview.psml
webapp/WEB-INF/templates/vm/layouts/html preview.vm
webapp/WEB-INF/templates/vm/screens/html preview.vm
Log:
Initial implementation of customizer portlet preview (see Bugzilla issue# 11565).
Very much work in progress with outstanding issues documented in Bugziilla.
This feature is activated by setting customizer.preview.enable=true in jr.props. Two
alternative preview methods exist:
1. Using PreviewPortlet and preview.psml (default).
2. Using preview.vm template (may be uncommented in customizer-portletset-add.vm).
Revision Changes Path
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/PreviewPortlet.java
Index: PreviewPortlet.java
===================================================================
package org.apache.jetspeed.portal.portlets;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// jetspeed
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.services.PortletFactory;
import org.apache.jetspeed.portal.PortletControl;
import org.apache.jetspeed.services.PortalToolkit;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
//import org.apache.jetspeed.util.rewriter.PreviewRewriter;
import org.apache.jetspeed.util.template.JetspeedLink;
import org.apache.jetspeed.util.template.JetspeedLinkFactory;
// ecs
import org.apache.ecs.ClearElement;
import org.apache.ecs.ConcreteElement;
// turbine
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.velocity.TurbineVelocity;
import org.apache.velocity.context.Context;
// java
import java.io.StringReader;
/**
* Preview portlet. Displays content of potlet
* defined in parameter "previewedPortletName".
*
* @version $Id: PreviewPortlet.java,v 1.1 2002/09/17 20:11:54 morciuch Exp $
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Mark Orciuch</a>
*/
public class PreviewPortlet extends AbstractPortlet
{
/**
* @param rundata The RunData object for the current request
*/
public ConcreteElement getContent(RunData rundata)
{
Context context = TurbineVelocity.getContext(rundata);
context.put( "data", rundata);
TurbineVelocity.getContext(rundata).put("jetspeed", new
org.apache.jetspeed.util.template.JetspeedTool(rundata));
ConcreteElement result = null;
String controlName =
rundata.getParameters().getString("previewedControlName");
String portletName =
rundata.getParameters().getString("previewedPortletName");
if ( portletName == null )
{
JetspeedLink jsLink = null;
try
{
jsLink = JetspeedLinkFactory.getInstance(rundata);
rundata.setRedirectURI(
jsLink.setUser(
rundata.getUser().getUserName(), "default.psml")
.addPathInfo("template", "Customize")
.addPathInfo("media-type", "html")
.toString()
);
JetspeedLinkFactory.putInstance(jsLink);
jsLink = null;
return new ClearElement("");
} catch (Exception e)
{
Log.error(e);
rundata.setScreenTemplate("Home");
return new ClearElement("");
}
//return new ClearElement("You must specify portlet to preview using
[previewedPortletName] parameter");
}
Portlet portlet = null;
try
{
portlet = PortletFactory.getPortlet(portletName, "PreviewPortlet");
PortletControl control = controlName == null ?
PortalToolkit.getControl((String)null) :
PortalToolkit.getControl(controlName);
control = null;
if ( control != null )
{
JetspeedRunData jdata = (JetspeedRunData)rundata;
// Use the profile's skin
//portlet.getPortletConfig().setSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
control.setPortlet(portlet);
control.init();
result = control.getContent(rundata);
}
else if ( portlet != null )
{
result = portlet.getContent(rundata);
}
if ( result != null && !result.toString().equals("") )
{
/*String html = result.toString();
String currentURL = rundata.getRequest().getRequestURI();
Log.debug("PreviewPortlet: currentURL = " + currentURL + " reader
value = " + html);
PreviewRewriter rewriter = new PreviewRewriter(currentURL,
currentURL , currentURL, portletName);
result = new ClearElement(rewriter.rewrite(new
StringReader(html)));*/
}
else
{
// The portlet already streamed its content - return a stub
result = new ClearElement("");
}
}
catch ( Exception e )
{
Log.error(e);
result = new ClearElement("This resource is temporarily unavailable");
}
rundata.setLayout("preview");
return result;
}
}
1.89 +6 -1
jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
Index: JetspeedResources.properties
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- JetspeedResources.properties 11 Sep 2002 18:30:55 -0000 1.88
+++ JetspeedResources.properties 17 Sep 2002 20:11:54 -0000 1.89
@@ -477,6 +477,11 @@
# navigations
URILookup.customize.uri=/portal/action/controls.Customize?reset=on
+#
+# Activate the portlet preview feature
+#
+customizer.preview.enable=false
+
#########################################
# New User Registration mail support #
#########################################
1.27 +9 -0 jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg
Index: portlets.xreg
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- portlets.xreg 19 Jul 2002 20:56:19 -0000 1.26
+++ portlets.xreg 17 Sep 2002 20:11:55 -0000 1.27
@@ -175,4 +175,13 @@
<category>weather</category>
</portlet-entry>
+ <portlet-entry name="PreviewPortlet" hidden="true" type="instance"
application="false">
+ <security-ref parent="default"/>
+ <classname>org.apache.jetspeed.portal.portlets.PreviewPortlet</classname>
+ <parameter name="_showtitlebar" value="false" hidden="false"
+ cachedOnName="true" cachedOnValue="true"/>
+ <media-type ref="html"/>
+ <url cachedOnURL="true"/>
+ </portlet-entry>
+
</registry>
1.1 jakarta-jetspeed/webapp/WEB-INF/psml/role/user/html/preview.psml
Index: preview.psml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<portlets id="P-ef3de2fb40-10061">
<controller name="RowController"/>
<entry id="P-ef8bd3fd6c-10001" parent="PreviewPortlet"/>
</portlets>
1.1
jakarta-jetspeed/webapp/WEB-INF/templates/vm/layouts/html/preview.vm
Index: preview.vm
===================================================================
## preview.vm
## Turbine Velocity Screen Layout to show just the screen contents
## (the normal navigation is not included)
## $Header:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/layouts/html/preview.vm,v 1.1
2002/09/17 20:11:55 morciuch Exp $
<html>
<head>
<base href="$clink.External" />
<link href="$clink.setURI($config.getString("site.stylesheet")).Absolute"
type="text/css" rel="stylesheet" />
</head>
<body bgcolor="#ffffff">
$screen_placeholder
<br><br>
<a href="javascript:void(0)" onClick="self.close()">Close window</a>
</body>
</html>
1.13 +6 -1
jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-add.vm
Index: customizer-portletset-add.vm
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/customizer-portletset-add.vm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- customizer-portletset-add.vm 17 Sep 2002 00:23:22 -0000 1.12
+++ customizer-portletset-add.vm 17 Sep 2002 20:11:55 -0000 1.13
@@ -78,7 +78,12 @@
</td>
## Display checkbox for portlet selection
<td valign="top" align="left">
- #if ($portlet.Title) $portlet.Title #else $portlet.Name #end
+ #if ($config.getBoolean("customizer.preview.enable", false) ==
true)
+ <a target="_blank"
href="$jslink.setRole("user","preview.psml").addQueryData("previewedPortletName",$portlet.Name).addQueryData("previewedControlName","ClearPortletControl")">#if
($portlet.Title) $portlet.Title #else $portlet.Name #end</a>
+ ##<a target="_blank"
href="$jslink.setTemplate("preview").addQueryData("p",$portlet.Name).addQueryData("c","ClearPortletControl")">#if
($portlet.Title) $portlet.Title #else $portlet.Name #end</a>
+ #else
+ #if ($portlet.Title) $portlet.Title #else $portlet.Name #end
+ #end
</td>
<td valign="top" align="left">
#if ($portlet.Description) $portlet.Description #else
$l10n.CUSTOMIZER_NODESCRIPTION #end
1.1
jakarta-jetspeed/webapp/WEB-INF/templates/vm/screens/html/preview.vm
Index: preview.vm
===================================================================
## preview.vm
## Turbine Velocity Screen to show just the content of a single portal element
## as specified by the request "p" parameter
## $Header:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/screens/html/preview.vm,v 1.1
2002/09/17 20:11:55 morciuch Exp $
#set($portlet = $data.getRequest().getParameter("p"))
#set($control = ($data.getRequest().getParameter("c")))
$jetspeed.getPortletFromRegistry($!portlet,$!control)
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>