[Mono-docs-list] Patch to render "overview" pages for each provider

Ben Maurer bmaurer@users.sourceforge.net
12 Jul 2003 15:42:32 -0500


--=-cPKQHxsTLwZfpiMG8VKK
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

In preperation for ASPX monodoc, I am working on making the navigation
around monodoc easier when just viewing the pages, not the tree menu.
The attached patch will allow a user to get an overview of all the
available helpsources, and for the ECMA provider to get a list of
sources.

Is this patch OK to commit?

--=-cPKQHxsTLwZfpiMG8VKK
Content-Disposition: attachment; filename=monodocroot.patch
Content-Type: text/x-patch; name=monodocroot.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

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	12 Jul 2003 20:51:20 -0000
@@ -1,3 +1,9 @@
+2003-07-12  Ben Maurer <bmaurer@users.sourceforge.net>
+	* browser.cs: Added support for visiting nodes from the root tree.
+	* ecma-provider.cs: Render the root: url with a list of namespaces
+	* provider.cs: Send the root:/xxx to the help sources. Handle
+	root:
+
 2003-07-10  Ben Maurer <bmaurer@users.sourceforge.net>
 
 	* mono-ecma.xsl: Don't generate the excess monodoc namespaces.
Index: browser.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/browser.cs,v
retrieving revision 1.37
diff -u -r1.37 browser.cs
--- browser.cs	11 Jul 2003 00:13:10 -0000	1.37
+++ browser.cs	12 Jul 2003 20:51:20 -0000
@@ -529,10 +529,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);
 		}
 	}
 
@@ -554,23 +560,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
 			//
Index: ecma-provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/ecma-provider.cs,v
retrieving revision 1.51
diff -u -r1.51 ecma-provider.cs
--- ecma-provider.cs	10 Jul 2003 16:34:32 -0000	1.51
+++ ecma-provider.cs	12 Jul 2003 20:51:20 -0000
@@ -384,6 +384,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: provider.cs
===================================================================
RCS file: /cvs/public/monodoc/browser/provider.cs,v
retrieving revision 1.34
diff -u -r1.34 provider.cs
--- provider.cs	11 Jul 2003 00:13:10 -0000	1.34
+++ provider.cs	12 Jul 2003 20:51:20 -0000
@@ -641,6 +641,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){
@@ -661,6 +662,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)
 	{
@@ -678,7 +680,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");
@@ -812,7 +814,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 (":");

--=-cPKQHxsTLwZfpiMG8VKK--