bishop335 / subtext

Automatically exported from code.google.com/p/subtext
0 stars 0 forks source link

ActiveCssClass is not rendered for default.aspx #287

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add / Change the following entry to MyLinks.ascx of your current skin:
<st:NavigationLink Runat="server" 
NavigateUrl="~/Default.aspx" Text="Home" ID="HomeLink" 
ActiveCssClass="current" />
2. Save the changes and navigate to the homepage of your installattion
3.

What is the expected output? What do you see instead?
The "Home Link" should have the css class "current" assigned. Instead it has no 
css class assigned. 

What version of the product are you using? On what operating system?
Subtext 2.5 running on my Windows 7 dev machine in cassini

Please provide any additional information below.
This problem only exists for the default.aspx. All other pages, like 
archives.aspx or contact.aspx work fine. You can see the issue live at 
http://haacked.com/Default.aspx :-) 

Original issue reported on code.google.com by codemu...@googlemail.com on 28 Dec 2010 at 4:05

GoogleCodeExporter commented 8 years ago
I've created a patch for the issue.

Original comment by codemu...@googlemail.com on 28 Dec 2010 at 4:21

Attachments:

GoogleCodeExporter commented 8 years ago
I took a look at the patch and there's one part I didn't understand and think 
might be incorrect.

+            if(navigateUrl.EndsWith("default.aspx", 
StringComparison.OrdinalIgnoreCase) 
+                && Page.Request.Url.AbsolutePath == "/")
+            {
+                navigateUrl = "/";
+            }

What if the navigateUrl was set to "/foo/bar/default.aspx". It would be 
highlighted when the root is highlighted according to this logic.

Original comment by haac...@gmail.com on 29 Dec 2010 at 6:25

GoogleCodeExporter commented 8 years ago
Also, we got rid of the Default.aspx file in the root. So you'll need to double 
check this logic against the latest trunk. We're going to be moving towards 
extensionless URLs.

Original comment by haac...@gmail.com on 29 Dec 2010 at 6:28

GoogleCodeExporter commented 8 years ago
Yes you're right. I didn't think of sub folders. Attached there's a new patch 
that takes sub folders in account. In addition I've cleaned the if statement a 
bit and moved the logic to two boolean functions.
I already thought of moving those new functions from the controls codebehind to 
a helper class so that I could easily unit test them. In addition they could be 
useful in other places, too. However I wasn't sure in wich helper to put them. 
Maybe UrlHelper or HttpHelper?

Original comment by codemu...@googlemail.com on 29 Dec 2010 at 10:57

Attachments:

GoogleCodeExporter commented 8 years ago
Fixed in r4172.

Note that this code works now, but it may break when we move to extensionless 
URLs. For example, IsDirectory assumes ending in slash means directory. But 
/foo/bar is also a "directory" request.

To test out the extensionless pattern, change the following route in Routes.cs:

routes.MapControls("archives", "archives.aspx", null, new[] { "ArchivesPage" });

to

routes.MapControls("archives", "archives", null, new[] { "ArchivesPage" });

And you'll see the navigation link for Archives doesn't work in all skins.

Original comment by haac...@gmail.com on 31 Dec 2010 at 6:26