[Mono-docs-list] Monodoc aspx .1
Ben Maurer
bmaurer@users.sourceforge.net
14 Jul 2003 18:53:34 -0500
--=-BiBJeMUlahPZJkTDParJ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Ok, here is a version with .config files. If you install the patch, it
will use the new config thingy. Also, note the change to the handler, it
no longer hardcodes the path.
-- Ben
--=-BiBJeMUlahPZJkTDParJ
Content-Disposition: attachment; filename=monodoc.patch
Content-Type: text/plain; name=monodoc.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
? Makefile.in
? Makefile
? monodoc.dll
? Mono.Website.Handlers.dll
Index: .cvsignore
===================================================================
RCS file: /cvs/public/monodoc/browser/.cvsignore,v
retrieving revision 1.3
diff -u -r1.3 .cvsignore
--- .cvsignore 14 Jul 2003 00:40:30 -0000 1.3
+++ .cvsignore 14 Jul 2003 23:59:17 -0000
@@ -1,6 +1 @@
-*dbg
-*tree
-Makefile
-Makefile.in
-Mono.Website.Handlers.dll
-monodoc.dll
+monodoc.config
Index: ChangeLog
===================================================================
RCS file: /cvs/public/monodoc/browser/ChangeLog,v
retrieving revision 1.46
diff -u -r1.46 ChangeLog
--- ChangeLog 11 Jul 2003 02:00:07 -0000 1.46
+++ ChangeLog 14 Jul 2003 23:59:17 -0000
@@ -1,3 +1,14 @@
+2003-07-13 Ben Maurer <bmaurer@users.sourceforge.net>
+ * browser.cs: Added support for visiting nodes from the root tree.
+ ie, the root: urls.
+ * ecma-provider.cs: Render the root: url with a list of namespaces
+ * provider.cs: Send the root:/xxx to the help sources. Handle
+ root:
+ * xhtml-provider.cs: handle root:. Returns the inner html of <body> like
+ other providers
+ * monohb-provider.cs: Fix typo that makes header purple in moz. return
+ the <body> node, not <html>.
+
2003-07-10 Ben Maurer <bmaurer@users.sourceforge.net>
* mono-ecma.xsl: Don't generate the excess monodoc namespaces.
Index: Makefile.am
===================================================================
RCS file: /cvs/public/monodoc/browser/Makefile.am,v
retrieving revision 1.19
diff -u -r1.19 Makefile.am
--- Makefile.am 14 Jul 2003 00:40:30 -0000 1.19
+++ Makefile.am 14 Jul 2003 23:59:17 -0000
@@ -1,7 +1,7 @@
monodocdir = $(libdir)/monodoc
assemblydir = $(libdir)
monodoc_DATA = browser.exe assembler.exe monodoc.xml
-assembly_DATA = monodoc.dll Mono.Website.Handlers.dll
+assembly_DATA = monodoc.dll Mono.Website.Handlers.dll monodoc.config
CSC=mcs
@@ -30,6 +30,9 @@
Mono.Website.Handlers.dll: $(srcdir)/website-handler.cs
$(CSC) -debug website-handler.cs -out:Mono.Website.Handlers.dll -target:library -r:monodoc.dll -r:System.Web
+
+monodoc.config: monodoc.config.in
+ sed -e 's^\@monodocdir\@^$(monodocdir)^g' < $(srcdir)/monodoc.config.in > monodoc.config
b: browser.exe
mono --debug browser.exe
Index: browser.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/browser.cs,v
retrieving revision 1.38
diff -u -r1.38 browser.cs
--- browser.cs 13 Jul 2003 22:23:21 -0000 1.38
+++ browser.cs 14 Jul 2003 23:59:17 -0000
@@ -102,7 +102,7 @@
TreeBrowser tree_browser;
IndexBrowser index_browser;
- RootTree help_tree;
+ internal RootTree help_tree;
// For the status bar.
uint context_id;
@@ -530,10 +530,16 @@
public override void Go ()
{
+ string res;
Node x;
- string res = n.tree.HelpSource.GetText (url, out x);
- ((Browser)browser).Render (res, n, url);
+ // The root tree has no help source
+ if (n.tree.HelpSource != null)
+ res = n.tree.HelpSource.GetText (url, out x);
+ else
+ res = ((RootTree)n.tree).RenderUrl (url, out x);
+
+ browser.Render (res, n, url);
}
}
@@ -555,23 +561,25 @@
if (tree_view.Selection.GetSelected (out model, ref iter)){
Node n = (Node) iter_to_node [iter];
-
- if (n.tree.HelpSource == null)
- return;
-
- string url = n.URL;
- //
- // Try the tree-based urls first.
- //
+ string url = n.URL;
Node match;
- string s = n.tree.HelpSource.GetText (url, out match);
- if (s != null){
- ((Browser)browser).Render (s, null, url);
- browser.history.AppendHistory (new NodePageVisit (browser, n, url));
- return;
+ string s;
+
+ if (n.tree.HelpSource != null)
+ {
+ //
+ // Try the tree-based urls first.
+ //
+
+ s = n.tree.HelpSource.GetText (url, out match);
+ if (s != null){
+ ((Browser)browser).Render (s, null, url);
+ browser.history.AppendHistory (new NodePageVisit (browser, n, url));
+ return;
+ }
}
-
+
//
// Try the url resolver next
//
@@ -602,7 +610,7 @@
public static IndexBrowser MakeIndexBrowser (Browser browser)
{
- IndexReader ir = IndexReader.Load ("monodoc.index");
+ IndexReader ir = browser.help_tree.GetIndex ();
if (ir == null)
return null;
Index: ecma-provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/ecma-provider.cs,v
retrieving revision 1.52
diff -u -r1.52 ecma-provider.cs
--- ecma-provider.cs 13 Jul 2003 22:23:21 -0000 1.52
+++ ecma-provider.cs 14 Jul 2003 23:59:17 -0000
@@ -385,6 +385,17 @@
public override string GetText (string url, out Node match_node)
{
match_node = null;
+
+ if (url == "root:")
+ {
+ StringBuilder sb = new StringBuilder ();
+
+ foreach (Node ns_node in Tree.Nodes)
+ sb.AppendFormat ("<a href='{0}'>{1}</a></br>", ns_node.Element, ns_node.Element.Substring (2));
+
+ return sb.ToString ();
+ }
+
if (url.StartsWith ("ecma:"))
return GetTextFromUrl (url);
Index: monodoc.config.in
===================================================================
RCS file: monodoc.config.in
diff -N monodoc.config.in
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ monodoc.config.in 14 Jul 2003 23:59:17 -0000
@@ -0,0 +1,3 @@
+<config>
+ <path docsPath="@monodocdir@" />
+</config>
Index: monohb-provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/monohb-provider.cs,v
retrieving revision 1.5
diff -u -r1.5 monohb-provider.cs
--- monohb-provider.cs 13 Jul 2003 22:23:21 -0000 1.5
+++ monohb-provider.cs 14 Jul 2003 23:59:17 -0000
@@ -29,7 +29,7 @@
string cssClass = ((XmlElement)node).GetAttribute("class");
if (cssClass != null && (cssClass == "topframe" || cssClass == "navbar" || cssClass == "copyright"))
{
- node.RemoveAll();
+ node.ParentNode.RemoveChild (node);
}
}
@@ -62,7 +62,7 @@
bodynode.RemoveChild(firstheading);
bodynode.InnerXml = "<table width=\"100%\">" +
- "<tr bgcolor=\"#b0c4dae\"><td><i></i>Mono Handbook<h3>" + headinginner + "</h3></td></tr></table><p />" +
+ "<tr bgcolor=\"#b0c4de\"><td><i></i>Mono Handbook<h3>" + headinginner + "</h3></td></tr></table><p />" +
bodynode.InnerXml;
}
catch {
@@ -126,7 +126,9 @@
}
}
- return docToProcess;
+ XmlDocument ret = new XmlDocument ();
+ ret.LoadXml (docToProcess.GetElementsByTagName("body")[0].OuterXml);
+ return ret;
}
}
}
Index: provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/provider.cs,v
retrieving revision 1.36
diff -u -r1.36 provider.cs
--- provider.cs 13 Jul 2003 22:23:21 -0000 1.36
+++ provider.cs 14 Jul 2003 23:59:17 -0000
@@ -16,6 +16,7 @@
using System.IO;
using System.Text;
using System.Collections;
+using System.Configuration;
using System.Xml;
using ICSharpCode.SharpZipLib.Zip;
@@ -536,9 +537,24 @@
}
public class RootTree : Tree {
+ string basedir;
+
public static RootTree LoadTree ()
{
- return LoadTree (".");
+ string basedir;
+ string myPath = System.Reflection.Assembly.GetExecutingAssembly ().Location;
+ string cfgFile = Path.ChangeExtension (myPath, ".config");
+ if (!File.Exists (cfgFile)) {
+ Console.Error.WriteLine ("*** WARNING: Config file not found, using . as the root path");
+ basedir = ".";
+ return LoadTree (basedir);
+ }
+
+ XmlDocument d = new XmlDocument ();
+ d.Load (cfgFile);
+ basedir = d.SelectSingleNode ("config/path").Attributes ["docsPath"].Value;
+
+ return LoadTree (basedir);
}
//
@@ -549,7 +565,8 @@
XmlDocument doc = new XmlDocument ();
RootTree root = new RootTree ();
-
+ root.basedir = basedir;
+
//
// Load the layout
//
@@ -623,7 +640,7 @@
break;
case "xhtml":
try {
- hs = new XhtmlHelpSource (sources_dir + basefile, false);
+ hs = new XhtmlHelpSource (basefilepath, false);
} catch (FileNotFoundException) {
Console.Error.WriteLine ("Error: did not find one of the files in sources/"+basefile);
break;
@@ -644,6 +661,7 @@
if (hs == null)
continue;
root.help_sources.Add (hs);
+ root.name_to_hs [path] = hs;
Node parent = (Node) root.name_to_node [path];
if (parent == null){
@@ -664,6 +682,7 @@
// Maintains the name to node mapping
//
Hashtable name_to_node = new Hashtable ();
+ Hashtable name_to_hs = new Hashtable ();
void Populate (Node parent, XmlNodeList xml_node_list)
{
@@ -681,7 +700,7 @@
}
string name = e.InnerText;
- Node n = parent.LookupNode (label, name);
+ Node n = parent.LookupNode (label, "root:/" + name);
n.EnsureNodes ();
name_to_node [name] = n;
XmlNodeList children = xml_node.SelectNodes ("./node");
@@ -815,7 +834,20 @@
/// URL.
/// </summary>
public string RenderUrl (string url, out Node match_node)
- {
+ {
+ if (url.StartsWith ("root:"))
+ {
+ match_node = null;
+ if (url == "root:") {
+ StringBuilder sb = new StringBuilder ("<h1>Welcome to Monodoc</h1>");
+ foreach (Node n in Nodes)
+ sb.AppendFormat ("<a href='{0}'>{1}</a></br>", n.Element, n.Caption);
+ return sb.ToString ();
+
+ } else
+ return ((HelpSource)name_to_hs [url.Substring (6)]).GetText ("root:", out match_node);
+ }
+
if (url.StartsWith ("source-id:")){
string rest = url.Substring (10);
int p = rest.IndexOf (":");
@@ -864,6 +896,11 @@
match_node = null;
return null;
}
+
+ public IndexReader GetIndex ()
+ {
+ return IndexReader.Load (Path.Combine (basedir, "monodoc.index"));
+ }
public static void MakeIndex ()
{
@@ -877,7 +914,7 @@
hs.PopulateIndex (index_maker);
}
- index_maker.Save ("monodoc.index");
+ index_maker.Save (Path.Combine (root.basedir, "monodoc.index"));
Console.WriteLine ("Documentation index updated");
}
}
Index: website-handler.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/website-handler.cs,v
retrieving revision 1.1
diff -u -r1.1 website-handler.cs
--- website-handler.cs 14 Jul 2003 00:40:30 -0000 1.1
+++ website-handler.cs 14 Jul 2003 23:59:17 -0000
@@ -24,7 +24,7 @@
static RootTree help_tree;
static MonodocHandler ()
{
- help_tree = RootTree.LoadTree ("/devel/install/lib/monodoc/");
+ help_tree = RootTree.LoadTree ();
}
void IHttpHandler.ProcessRequest (HttpContext context)
Index: xhtml-provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/xhtml-provider.cs,v
retrieving revision 1.12
diff -u -r1.12 xhtml-provider.cs
--- xhtml-provider.cs 13 Jul 2003 22:23:21 -0000 1.12
+++ xhtml-provider.cs 14 Jul 2003 23:59:17 -0000
@@ -56,6 +56,27 @@
public override string GetText (string url, out Node match_node)
{
match_node = null;
+
+ if (url == "root:") {
+ StringBuilder sb = new StringBuilder ();
+ foreach (Node n in Tree.Nodes) {
+ if (n.IsLeaf) {
+ sb.AppendFormat ("<a href='{0}'>{1}</a></br>",
+ n.Element.Replace ("source-id:NNN", "source-id:" + SourceID),
+ n.Caption);
+ } else {
+ sb.AppendFormat ("<h2>{0}</h2>", n.Caption);
+ foreach (Node subNode in n.Nodes) {
+ sb.AppendFormat ("<a href='{0}'>{1}</a></br>",
+ subNode.Element.Replace ("source-id:NNN", "source-id:" + SourceID),
+ subNode.Caption);
+ }
+ }
+ }
+
+ return sb.ToString ();
+ }
+
if (url.IndexOf (XHTML_PREFIX) > -1)
return GetTextFromUrl (url);
@@ -228,7 +249,7 @@
XmlDocument processedDoc = ProcessContent(newdoc);
XmlDocument docForMonodoc = RewriteLinks(processedDoc, url);
- return docForMonodoc.InnerXml;
+ return docForMonodoc.DocumentElement.InnerXml; // get rid of <body>
}
else if (s != null && (fname.EndsWith (".gif") || fname.EndsWith (".jpeg") || fname.EndsWith (".jpg") || fname.EndsWith(".png")))
--=-BiBJeMUlahPZJkTDParJ--