A few things I'd point out. Hopefully these don't sound like harsh criticism
- they're just observations and probably reflect my incomplete understanding
of what you're trying to do.
. I'd probably return an XML document rather than HTML. Easier to
parse on the other side. Include a ContentType="text/xml" in the <%@ Page %>
header and rip out all that HTML goop. Just put a Response.Write of the XML
in your Page_Load in the codebehind.
. Your Inherits attribute is wrong - it should inherit from
FlexWiki.Web.TopicResolver.
. You're using FlexWiki 1.8, right?
. You're assuming that the input is XML. Why? Is that so you can
resolve multiple names all at once? It might be better to POST an XML
document in that case rather than use a query string parameter - you're
going to run into trouble encoding complex data as XML in a query string. At
the very least, you should use multiple query string parameters, e.g.
http://your.server.com/wiki/TopicResolver?input1=foo
<http://your.server.com/wiki/TopicResolver?input1=foo&input2=bar&input3=quux
> &input2=bar&input3=quux. It's just simpler and more "web friendly".
. I'm not sure I understand why you're using a stringbuilder or why
you're recursing. Aren't you just getting a simple list of candidate names
in and returning a list of links? Is it that you want FlexWiki to parse the
input apart? That seems like a job for the calling application, not
FlexWiki.
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lionel
Cuir
Sent: Thursday, July 05, 2007 1:18 PM
To: 'FlexWiki Users Mailing List'
Subject: Re: [Flexwiki-users] Integrating flexwiki with a 'normal' ASP.NET
site
What would you think of this code? (please note that this is my first time I
get into FlexWiki sources, and my .net experience is very little as far as
asp.net is involved...)
*** TopicResolver.aspx ***
<%@ Page language="c#" Codebehind="TopicResolver.aspx.cs"
AutoEventWireup="false" Inherits="FlexWiki.Web.Default2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title id="title">TopicResolver</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content=
<http://schemas.microsoft.com/intellisense/ie5>
"http://schemas.microsoft.com/intellisense/ie5">
<%= InsertStylesheetReferences() %>
</HEAD>
<body class='Dialog'>
<% Resolve(); %>
</body>
</HTML>
*** TopicResolver.aspx.cs ***
public class TopicResolver : BasePage
{
ContentBase _cb;
protected void Resolve()
{
string input = Request.QueryString["input"];
string nameSpace = Request.QueryString["nameSpace"];
if (nameSpace == null)
nameSpace = DefaultNamespace;
_cb = TheFederation.ContentBaseForNamespace(nameSpace);
XmlDocument doc = new XmlDocument();
doc.LoadXml(input);
ManageNodeRecursively(doc.DocumentElement);
string output = doc.InnerXml;
Response.Write(output);
}
void ManageNodeRecursively(XmlNode node)
{
// Manages the value of this node, if any.
string txt = node.Value;
string[] allTokens = txt.Split(new string[] { " ",
Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
bool anyChangeMade = false;
StringBuilder sb = new StringBuilder();
foreach (string token in allTokens)
{
if (!_cb.TopicExistsLocally(token))
sb.Append(token);
else
{
sb.Append(TheLinkMaker.LinkToTopic(token));
anyChangeMade = true;
}
sb.Append(' ');
}
if (anyChangeMade)
node.Value = sb.ToString(0, sb.Length - 1);
// Then manages its subnodes, if any.
foreach (XmlNode subNode in node.ChildNodes)
ManageNodeRecursively(subNode);
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flexwiki-users mailing list
Flexwiki-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flexwiki-users