On 19/10/06, Jean-Lou Dupont <xwiki@jldupont.com> wrote:
>
>
> well, if you can "wrap" your output in an HTML "div"
element (as example), then you can have a Javascript procedure embedded
in the xwiki menubar (on the left-hand side) to capture "div"
element's content and save it to an xwiki document.
>
> you can also get the full HTML area of the page if you want;
just use a "DOM inspector" like the one you can plug to Firefox
to get the element's ID.
>
> jld.
>
> ________________________________
From: Frank A Nuzzi [mailto:fanuzzi@us.ibm.com]
> Sent: October 19, 2006 15:41
> To: robin@soal.org
> Cc: xwiki-dev@objectweb.org
>
> Subject: Re: [xwiki-dev] Dynamic Page to Static Page
>
>
>
>
> Robin,
> Is there no way to do this from
within xwiki?
> Thanks,
>
> Frank (Tony) Nuzzi
> AIS - Install Solution Developer
> Phone 838-3781, t/l 678-3781
> External E-mail - fanuzzi@us.ibm.com
>
>
>
> "Robin Fernandes"
<rewbs.soal@gmail.com>
>
> 10/12/2006 06:03 PM
>
> Please respond to
> robin@soal.org
>
>
> To xwiki-dev@objectweb.org
>
> cc
>
>
> Subject Re: [xwiki-dev] Dynamic
Page to Static Page
>
>
>
>
>
>
>
> Thinking about it, I'm not sure why I felt XML-RPC was necessary.
:)
> Here's a simpler example that does it all over straight http get/post.
> Requires the apache commons httpclient lib, which requires commons
> logging and commons codec.
>
> ---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
> package org.soal.XWikiPost;
>
> import java.io.IOException;
> import org.apache.commons.httpclient.*;
> import org.apache.commons.httpclient.cookie.CookiePolicy;
> import org.apache.commons.httpclient.methods.GetMethod;
> import org.apache.commons.httpclient.methods.PostMethod;
>
> public class XWikiPoster {
> //----( Configuration
[change me!] )----
> static
final String SERVER = "http://my.xwiki.com";
> static
final String USERNAME = "myName"; // exactly how you'd
enter
> static
final String PASSWORD = "myPass"; // them in the web login
form
> static final
String SPACE = "Sandbox";
> static
final String DYNAMIC = "Dynamic";
> static
final String STATIC = "Static";
> //--------------------------------------
>
>
> static HttpClient
client = new HttpClient();
>
> public static
void main(String[] args) throws HttpException, IOException {
>
client.getParams().setParameter("http.protocol.cookie-policy",
> CookiePolicy.BROWSER_COMPATIBILITY);
>
login();
>
String renderedContent
= getRenderedContent(SPACE, DYNAMIC);
>
postContent(SPACE,
STATIC, renderedContent);
> }
>
> private static
void login() throws HttpException, IOException {
>
String url = String.format("%s/xwiki/bin/login/XWiki/XWikiLogin",
SERVER);
>
PostMethod method = new
PostMethod(url);
>
method.addParameter("j_username",
USERNAME);
>
method.addParameter("j_password",
PASSWORD);
>
method.addParameter("j_rememberme",
"false");
>
int statusCode = client.executeMethod(method);
>
if (statusCode !=
HttpStatus.SC_OK) {
>
System.err.println("Login
response (redirect is normal): " +
> method.getStatusLine());
>
}
> }
>
> private
static String getRenderedContent(String space, String page)
> throws IOException, HttpException {
>
String template="xpage=plain";
>
String url = String.format("%s/xwiki/bin/view/%s/%s?%s",
SERVER,
> space, page, template);
>
GetMethod method
= new GetMethod(url);
>
int statusCode =
client.executeMethod(method);
>
if (statusCode !=
HttpStatus.SC_OK) {
>
System.err.println("Get response:
" + method.getStatusLine());
>
}
>
String responseBody
= new String(method.getResponseBody());
>
return responseBody;
> }
>
> private
static void postContent(String space, String page, String
> content) throws HttpException, IOException {
>
String url = String.format("%s/xwiki/bin/save/%s/%s",
SERVER, space, page);
>
PostMethod method =
new PostMethod(url);
>
method.addParameter("content",
content);
>
int statusCode =
client.executeMethod(method);
>
if (statusCode !=
HttpStatus.SC_OK) {
>
System.err.println("Save
response (redirect is normal): " +
> method.getStatusLine());
>
}
> }
>
> }
> ---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
>
> Regards,
> Robin.
>
> On 12/10/06, Robin Fernandes <rewbs.soal@gmail.com> wrote:
> > Hi,
> >
> > There's probably several ways to do this... the first one that
comes
> > to my mind is to write an XML-RPC client to grab the rendered
content
> > from one page and save it back into another. Then set up a cron
job to
> > kick off your XML-RPC client periodically. A simple implementation
of
> > the XML-RPC client is below.
> >
> > Alternatively you could write the code to do the copy in
a groovy
> > script in another XWiki document and hit it periodically.
> >
> > ---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
> >
> > package com.ibm.robinf.xwikixmlrpcclient;
> >
> > import java.io.IOException;
> > import java.net.MalformedURLException;
> > import java.util.Hashtable;
> > import java.util.Vector;
> >
> > import org.apache.xmlrpc.XmlRpcClient;
> > import org.apache.xmlrpc.XmlRpcException;
> >
> > /**
> > * @author Robin
> > */
> > public class XWikiRPCTest {
> > //----( Configuration [change
me!] )----
> > protected final static String
XMLRPC_SERVER_URL =
> > "http://mywiki.blah.com/xwiki/bin/xmlrpc/confluence";
> > protected final static String
DYNAMIC = "Play.Dynamic";
> > protected final static String
STATIC = "Play.Static";
> > protected final static String WIKI_NAME
= "robin_fernandesatukibmcom";
> > protected final static String
PASSWORD = "WXYZ";
> > //--------------------------------------
> >
> > protected XmlRpcClient client;
> >
> > public XWikiRPCTest() throws
MalformedURLException {
> > client
= new XmlRpcClient(XMLRPC_SERVER_URL);
> > }
> >
> > public static void main(String[]
args) throws XmlRpcException, IOException {
> > XWikiRPCTest
myRPCTest = new XWikiRPCTest();
> > String
token = myRPCTest.login();
> > String
renderedContent = myRPCTest.getRenderedContent(DYNAMIC, token);
> > Hashtable<String,
String> staticPage = myRPCTest.getPage(STATIC, token);
> > staticPage.put("content",
renderedContent);
> > myRPCTest.putPage(staticPage,
token);
> >
myRPCTest.logout(token);
> > }
> >
> > private String getRenderedContent(String
pageName, String token)
> > throws XmlRpcException, IOException {
> > Hashtable<String,
String> dynamicPage = getPage(DYNAMIC, token);
> > String
rawContent = dynamicPage.get("content");
> >
> > Vector<String>
params = new Vector<String>(4);
> > params.add(token);
> > params.add("Play");
> > params.add(pageName);
> > params.add(rawContent);
> >
> > String
renderedContent = (String)
> > client.execute("confluence1.renderContent", params);
> > return
renderedContent;
> > }
> >
> > protected String login() throws
XmlRpcException, IOException {
> > String
loginToken;
> > Vector<String>
loginParams = new Vector<String>(2);
> >
loginParams.add(WIKI_NAME);
> > loginParams.add(PASSWORD);
> > loginToken
= (String) client.execute ("confluence1.login", loginParams);
> > System.out.println("Login:
" + loginToken);
> > return
loginToken;
> > }
> >
> > protected void logout(String
loginToken) throws XmlRpcException, IOException {
> > Vector<String>
logoutParams = new Vector<String>(1);
> >
logoutParams.add(loginToken);
> > System.out.println("Logout:
" + client.execute
> > ("confluence1.logout", logoutParams));
> > }
> >
> > private Hashtable<String, String>
getPage(String pageName, String
> > token) throws XmlRpcException, IOException {
> > Vector<String> params
= new Vector<String>();
> > params.add(token);
> > params.add(pageName);
> > Hashtable<String, String>
page = (Hashtable<String, String>)
> > client.execute("confluence1.getPage", params);
> > return page;
> > }
> >
> > private void putPage(Hashtable
page, String token) throws
> > XmlRpcException, IOException {
> > Vector<Object> params
= new Vector<Object>();
> > params.add(token);
> > params.add(page);
> > client.execute ("confluence1.storePage",
params);
> > }
> >
> > }
> > ---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
> >
> > Cheers,
> > Robin
> >
> >
> > On 12/10/06, fanuzzi@us.ibm.com <fanuzzi@us.ibm.com>
wrote:
> > > All,
> > > Here is what I am wanting to do. I have
a page that generates some dynamic data via a plug-in and every so
often I was to "snap-shot" it to a static page. Mean,
take the dynamic page data and create a static xwiki page from it.
> > >
> > > 1) Is it possible to do?
> > > 2) If so, how do I do it.
> > >
> > > Thanks,
> > >
> > > Tony Nuzzi
> > >
> > >
> > >
> > >
> > > --
> > > You receive this message as a subscriber of the xwiki-dev@objectweb.org
mailing list.
> > > To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
> > > For general help: mailto:sympa@objectweb.org?subject=help
> > > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
> > >
> > >
> > >
> >
>
>
> --
> You receive this message as a subscriber of the xwiki-dev@objectweb.org
mailing list.
> To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
> For general help: mailto:sympa@objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.408 / Virus Database: 268.13.5/483 - Release Date: 18/10/2006
>
>
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.408 / Virus Database: 268.13.5/483 - Release Date:
18/10/2006
>
>
> --
> You receive this message as a subscriber of the xwiki-dev@objectweb.org
mailing list.
> To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
> For general help: mailto:sympa@objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>
--
You receive this message as a subscriber of the xwiki-dev@objectweb.org
mailing list.
To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws