erichexter / twitter.bootstrap.mvc

nuget package to make bootstrap easy with mvc4
Apache License 2.0
248 stars 134 forks source link

issue #46: support for areas #56

Closed erroric closed 11 years ago

erroric commented 11 years ago

It is working good for me. Also some little code refactoring :)

Usage example:


using System.Web.Mvc;
using NavigationRoutes;

namespace MyProject.Areas.Admin
{
    using Controllers;
    using System.Web.Routing;

    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {

            context.Routes.MapNavigationRoute("Admin_root", "TestLayout1", this.AreaName, new { controller = "ExampleLayouts", action = "Starter" }, context: context);
            context.Routes.MapNavigationRoute("Admin_foo", "TestLayout2", "{area}/fuuu", new { area = this.AreaName, controller = "ExampleLayouts", action = "Marketing" }, context: context);
            context.Routes.MapNavigationRoute<ExampleLayoutsController>("TestLayout3 with inners", c => c.Narrow(), context, urlPrefix: this.AreaName)
                .AddChildRoute<ExampleLayoutsController>("Marketing", c => c.Marketing(), context, urlPrefix: this.AreaName)
                .AddChildRoute<ExampleLayoutsController>("Fluid", c => c.Fluid(), context, urlPrefix: this.AreaName)
                .AddChildRoute<ExampleLayoutsController>("Sign In", c => c.SignIn(), context, urlPrefix: this.AreaName);
        }
    }
}
erichexter commented 11 years ago

I added area support in a separate commit a566487b15ad31899170241f8252c328f13d08a6

erroric commented 11 years ago

Actually, not. Your commit only adds support for abstract prefixes in route url, not Area itself. Without my suggested code with DataTokens.Add("area", AreaName) or implementing IRouteWithArea inside NavigationRoute MVC don't knows nothing about Area linked to the current Route. An example, Controller inside Area will not find its Views inside Area, because it will search in ~Views/ instead of ~AreaName/Views

And what about other overloaded versions of MapNavigationRoute(...) ?

erichexter commented 11 years ago

I noticed that.. I will add that to the code. Thanks for following up .

Eric Hexter

blog | http://Hex.LosTechies.com info | http://www.linkedin.com/in/erichexter

On Wed, Jan 30, 2013 at 9:04 AM, Локтионов Алексей <notifications@github.com

wrote:

Actually, not. Your commit only adds support for abstract prefixes in route url, not Area itself. Without my suggested code with DataTokens.Add("area", AreaName) or implementing IRouteWithArea inside NavigationRoute MVC don't knows nothing about Area linked to the current Route. An example, Controller inside Area will not find its Views inside Area, because it will search in ~Views/ instead of ~AreaName/Views

— Reply to this email directly or view it on GitHubhttps://github.com/erichexter/twitter.bootstrap.mvc/pull/56#issuecomment-12893470.

erichexter commented 11 years ago

I added this will push it shortly.

Eric Hexter

blog | http://Hex.LosTechies.com info | http://www.linkedin.com/in/erichexter

On Wed, Jan 30, 2013 at 9:59 AM, Eric Hexter eric.hexter@gmail.com wrote:

I noticed that.. I will add that to the code. Thanks for following up .

Eric Hexter

blog | http://Hex.LosTechies.com info | http://www.linkedin.com/in/erichexter

On Wed, Jan 30, 2013 at 9:04 AM, Локтионов Алексей < notifications@github.com> wrote:

Actually, not. Your commit only adds support for abstract prefixes in route url, not Area itself. Without my suggested code with DataTokens.Add("area", AreaName) or implementing IRouteWithArea inside NavigationRoute MVC don't knows nothing about Area linked to the current Route. An example, Controller inside Area will not find its Views inside Area, because it will search in ~Views/ instead of ~AreaName/Views

— Reply to this email directly or view it on GitHubhttps://github.com/erichexter/twitter.bootstrap.mvc/pull/56#issuecomment-12893470.

erroric commented 11 years ago

Thanks! And what about DataToken["area"] for other overloaded versions of MapNavigationRoute(...) ?

erichexter commented 11 years ago

I need to do some refactoring of the internals to remove the duplicate code paths for the various overloads.

Eric Hexter

blog | http://Hex.LosTechies.com info | http://www.linkedin.com/in/erichexter

On Thu, Jan 31, 2013 at 5:44 AM, Локтионов Алексей <notifications@github.com

wrote:

Thanks! And what about DataToken["area"] for other overloaded versions of MapNavigationRoute(...) ?

— Reply to this email directly or view it on GitHubhttps://github.com/erichexter/twitter.bootstrap.mvc/pull/56#issuecomment-12938893.