mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Updated Routing to allow defining the Area.
Modified loading of scripts to move some to end of body.
This commit is contained in:
parent
6fd2360cf7
commit
89434ea16e
@ -83,5 +83,47 @@ namespace Teknik
|
||||
context.Routes.Add(name, route);
|
||||
return route;
|
||||
}
|
||||
|
||||
public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, string area, object defaults)
|
||||
{
|
||||
SubdomainRoute route = new SubdomainRoute(
|
||||
subDomain,
|
||||
url,
|
||||
new RouteValueDictionary(defaults),
|
||||
new RouteValueDictionary(new { }),
|
||||
new RouteValueDictionary(new { Area = area }),
|
||||
new MvcRouteHandler());
|
||||
|
||||
context.Routes.Add(name, route);
|
||||
return route;
|
||||
}
|
||||
|
||||
public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, string area, object defaults, object constraints)
|
||||
{
|
||||
SubdomainRoute route = new SubdomainRoute(
|
||||
subDomain,
|
||||
url,
|
||||
new RouteValueDictionary(defaults),
|
||||
new RouteValueDictionary(constraints),
|
||||
new RouteValueDictionary(new { Area = area }),
|
||||
new MvcRouteHandler());
|
||||
|
||||
context.Routes.Add(name, route);
|
||||
return route;
|
||||
}
|
||||
|
||||
public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, string area, object defaults, string[] namespaces)
|
||||
{
|
||||
SubdomainRoute route = new SubdomainRoute(
|
||||
subDomain,
|
||||
url,
|
||||
new RouteValueDictionary(defaults),
|
||||
new RouteValueDictionary(new { }),
|
||||
new RouteValueDictionary(new { Area = area, Namespaces = namespaces }),
|
||||
new MvcRouteHandler());
|
||||
|
||||
context.Routes.Add(name, route);
|
||||
return route;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,14 +18,14 @@ namespace Teknik.Areas.About
|
||||
"About_dev", // Route name
|
||||
"dev",
|
||||
"About/{controller}/{action}", // URL with parameters
|
||||
new { area = "About", controller = "About", action = "Index" }, // Parameter defaults
|
||||
new { controller = "About", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.AboutController).Namespace }
|
||||
);
|
||||
context.MapSubdomainRoute(
|
||||
"About_default", // Route name
|
||||
"about",
|
||||
"{controller}/{action}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "About", action = "Index", username = UrlParameter.Optional, page = UrlParameter.Optional }, // Parameter defaults
|
||||
new { controller = "About", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.AboutController).Namespace }
|
||||
);
|
||||
}
|
||||
|
@ -14,37 +14,18 @@ namespace Teknik.Areas.Blog
|
||||
|
||||
public override void RegisterArea(AreaRegistrationContext context)
|
||||
{
|
||||
//context.MapSubdomainRoute(
|
||||
// "Blog_dev", // Route name
|
||||
// "dev",
|
||||
// "blog/{controller}/{action}/{username}/{page}", // URL with parameters
|
||||
// new { subdomain = "blog", area = this.AreaName, controller = "Blog", action = "Index", username = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults
|
||||
// );
|
||||
context.MapSubdomainRoute(
|
||||
"Blog_dev", // Route name
|
||||
"dev",
|
||||
"Blog/{controller}/{action}", // URL with parameters
|
||||
new { area = "Blog", controller = "Blog", action = "Index" } // Parameter defaults
|
||||
new { controller = "Blog", action = "Index" } // Parameter defaults
|
||||
);
|
||||
context.MapSubdomainRoute(
|
||||
"Blog_default", // Route name
|
||||
"blog",
|
||||
"{controller}/{action}/{username}/{page}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "Blog", action = "Index", username = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults
|
||||
new { controller = "Blog", action = "Index", username = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults
|
||||
);
|
||||
//context.Routes.MapSubDomainRoute(
|
||||
// "Blog_default", // Route name
|
||||
// "blog", // Domain with parameters
|
||||
// "{controller}/{action}", // URL with parameters
|
||||
// new { controller = "Blog", action = "Index" }, // Parameter defaults
|
||||
// new[] { typeof(Controllers.BlogController).Namespace }
|
||||
// );
|
||||
//context.MapRoute(
|
||||
// "Blog_default",
|
||||
// "{subdomain}/{controller}/{action}/{username}/{page}",
|
||||
// new { subdomain = "blog", controller = "Blog", action = "Index", username = UrlParameter.Optional, page = UrlParameter.Optional },
|
||||
// namespaces: new[] { "Teknik.Areas.Blog.Controllers" }
|
||||
//);
|
||||
}
|
||||
}
|
||||
}
|
@ -18,14 +18,14 @@ namespace Teknik.Areas.Contact
|
||||
"Contact_dev", // Route name
|
||||
"dev",
|
||||
"Contact/{controller}/{action}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "Contact", action = "Index" }, // Parameter defaults
|
||||
new { controller = "Contact", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.ContactController).Namespace }
|
||||
);
|
||||
context.MapSubdomainRoute(
|
||||
"Contact_default", // Route name
|
||||
"contact",
|
||||
"{controller}/{action}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "Contact", action = "Index" }, // Parameter defaults
|
||||
new { controller = "Contact", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.ContactController).Namespace }
|
||||
);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Web.Mvc;
|
||||
using Teknik.Areas.Home.Controllers;
|
||||
|
||||
namespace Teknik.Areas.Dev
|
||||
{
|
||||
@ -14,25 +15,21 @@ namespace Teknik.Areas.Dev
|
||||
|
||||
public override void RegisterArea(AreaRegistrationContext context)
|
||||
{
|
||||
//Config config = Config.Load();
|
||||
context.MapSubdomainRoute(
|
||||
"Dev_subdomain", // Route name
|
||||
"dev",
|
||||
"Dev/{controller}/{action}", // URL with parameters
|
||||
new { area = "Dev", controller = "Dev", action = "Index" } // Parameter defaults
|
||||
new { controller = "Dev", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.DevController).Namespace }
|
||||
);
|
||||
context.MapSubdomainRoute(
|
||||
"Dev_default", // Route name
|
||||
"dev",
|
||||
"", // URL with parameters
|
||||
new { area = "Home", controller = "Home", action = "Index" } // Parameter defaults
|
||||
"Home",
|
||||
new { controller = "Home", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(HomeController).Namespace }
|
||||
);
|
||||
//context.MapRoute(
|
||||
// "Dev_default",
|
||||
// "Dev/{controller}/{action}",
|
||||
// new { controller = "Dev", action = "Index" },
|
||||
// namespaces: new[] { "Teknik.Areas.Dev.Controllers" }
|
||||
//);
|
||||
}
|
||||
}
|
||||
}
|
@ -19,29 +19,23 @@ namespace Teknik.Areas.Home
|
||||
"Home_dev", // Route name
|
||||
"dev",
|
||||
"Home/{controller}/{action}", // URL with parameters
|
||||
new { area = "Home", controller = "Home", action = "Index" }, // Parameter defaults
|
||||
new { controller = "Home", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.HomeController).Namespace }
|
||||
);
|
||||
context.MapSubdomainRoute(
|
||||
"Home_subdomain", // Route name
|
||||
"www",
|
||||
"{controller}/{action}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "Home", action = "Index" }, // Parameter defaults
|
||||
new { controller = "Home", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.HomeController).Namespace }
|
||||
);
|
||||
context.MapSubdomainRoute(
|
||||
"Home_default", // Route name
|
||||
null,
|
||||
"{controller}/{action}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "Home", action = "Index" }, // Parameter defaults
|
||||
new { controller = "Home", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.HomeController).Namespace }
|
||||
);
|
||||
//context.MapRoute(
|
||||
// "Home_default",
|
||||
// "{controller}/{action}",
|
||||
// new { area = "Home", controller = "Home", action = "Index" },
|
||||
// namespaces: new[] { "Teknik.Areas.Home.Controllers" }
|
||||
//);
|
||||
}
|
||||
}
|
||||
}
|
1
Teknik/Areas/Home/Scripts/Home.js
Normal file
1
Teknik/Areas/Home/Scripts/Home.js
Normal file
@ -0,0 +1 @@
|
||||
|
@ -126,7 +126,6 @@
|
||||
<ul class="list-group">
|
||||
@foreach (Post post in Model)
|
||||
{
|
||||
|
||||
<script>
|
||||
var converter = new Markdown.getSanitizingConverter();
|
||||
// Title Conversion
|
||||
|
@ -18,14 +18,14 @@ namespace Teknik.Areas.Privacy
|
||||
"Privacy_dev", // Route name
|
||||
"dev",
|
||||
"Privacy/{controller}/{action}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "Privacy", action = "Index" }, // Parameter defaults
|
||||
new { controller = "Privacy", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.PrivacyController).Namespace }
|
||||
);
|
||||
context.MapSubdomainRoute(
|
||||
"Privacy_default", // Route name
|
||||
"privacy",
|
||||
"{controller}/{action}", // URL with parameters
|
||||
new { area = this.AreaName, controller = "Privacy", action = "Index" }, // Parameter defaults
|
||||
new { controller = "Privacy", action = "Index" }, // Parameter defaults
|
||||
new[] { typeof(Controllers.PrivacyController).Namespace }
|
||||
);
|
||||
}
|
||||
|
@ -166,6 +166,7 @@
|
||||
<Compile Include="App_Start\SubdomainRouteExtension.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Areas\Home\Scripts\Home.js" />
|
||||
<Content Include="Content\CSS\bootstrap-theme.css" />
|
||||
<Content Include="Content\CSS\bootstrap-theme.min.css" />
|
||||
<Content Include="Content\CSS\bootstrap.css" />
|
||||
|
@ -10,13 +10,8 @@
|
||||
<link rel="shortcut icon" href="/Content/Images/favicon.ico" type="image/x-icon" />
|
||||
@Styles.Render("~/Content/css")
|
||||
@Scripts.Render("~/bundles/modernizr")
|
||||
|
||||
@Scripts.Render("~/bundles/jquery")
|
||||
@Scripts.Render("~/bundles/bootstrap")
|
||||
@Scripts.Render("~/bundles/markdown")
|
||||
@Scripts.Render("~/bundles/common")
|
||||
@RenderSection("scripts", required: false)
|
||||
|
||||
</head>
|
||||
<body data-twttr-rendered="true">
|
||||
<div id="wrap">
|
||||
@ -63,5 +58,10 @@
|
||||
</script>
|
||||
<noscript><p><img src="//stats.teknik.io/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
|
||||
<!-- End Piwik Code -->
|
||||
|
||||
<!-- Load Scripts -->
|
||||
@Scripts.Render("~/bundles/bootstrap")
|
||||
@Scripts.Render("~/bundles/common")
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user