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);
|
context.Routes.Add(name, route);
|
||||||
return 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
|
"About_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"About/{controller}/{action}", // URL with parameters
|
"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 }
|
new[] { typeof(Controllers.AboutController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"About_default", // Route name
|
"About_default", // Route name
|
||||||
"about",
|
"about",
|
||||||
"{controller}/{action}", // URL with parameters
|
"{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 }
|
new[] { typeof(Controllers.AboutController).Namespace }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,37 +14,18 @@ namespace Teknik.Areas.Blog
|
|||||||
|
|
||||||
public override void RegisterArea(AreaRegistrationContext context)
|
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(
|
context.MapSubdomainRoute(
|
||||||
"Blog_dev", // Route name
|
"Blog_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Blog/{controller}/{action}", // URL with parameters
|
"Blog/{controller}/{action}", // URL with parameters
|
||||||
new { area = "Blog", controller = "Blog", action = "Index" } // Parameter defaults
|
new { controller = "Blog", action = "Index" } // Parameter defaults
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Blog_default", // Route name
|
"Blog_default", // Route name
|
||||||
"blog",
|
"blog",
|
||||||
"{controller}/{action}/{username}/{page}", // URL with parameters
|
"{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
|
"Contact_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Contact/{controller}/{action}", // URL with parameters
|
"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 }
|
new[] { typeof(Controllers.ContactController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Contact_default", // Route name
|
"Contact_default", // Route name
|
||||||
"contact",
|
"contact",
|
||||||
"{controller}/{action}", // URL with parameters
|
"{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 }
|
new[] { typeof(Controllers.ContactController).Namespace }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using Teknik.Areas.Home.Controllers;
|
||||||
|
|
||||||
namespace Teknik.Areas.Dev
|
namespace Teknik.Areas.Dev
|
||||||
{
|
{
|
||||||
@ -14,25 +15,21 @@ namespace Teknik.Areas.Dev
|
|||||||
|
|
||||||
public override void RegisterArea(AreaRegistrationContext context)
|
public override void RegisterArea(AreaRegistrationContext context)
|
||||||
{
|
{
|
||||||
//Config config = Config.Load();
|
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Dev_subdomain", // Route name
|
"Dev_subdomain", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Dev/{controller}/{action}", // URL with parameters
|
"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(
|
context.MapSubdomainRoute(
|
||||||
"Dev_default", // Route name
|
"Dev_default", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"", // URL with parameters
|
"", // 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
|
"Home_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Home/{controller}/{action}", // URL with parameters
|
"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 }
|
new[] { typeof(Controllers.HomeController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Home_subdomain", // Route name
|
"Home_subdomain", // Route name
|
||||||
"www",
|
"www",
|
||||||
"{controller}/{action}", // URL with parameters
|
"{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 }
|
new[] { typeof(Controllers.HomeController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Home_default", // Route name
|
"Home_default", // Route name
|
||||||
null,
|
null,
|
||||||
"{controller}/{action}", // URL with parameters
|
"{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 }
|
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">
|
<ul class="list-group">
|
||||||
@foreach (Post post in Model)
|
@foreach (Post post in Model)
|
||||||
{
|
{
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var converter = new Markdown.getSanitizingConverter();
|
var converter = new Markdown.getSanitizingConverter();
|
||||||
// Title Conversion
|
// Title Conversion
|
||||||
|
@ -18,14 +18,14 @@ namespace Teknik.Areas.Privacy
|
|||||||
"Privacy_dev", // Route name
|
"Privacy_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Privacy/{controller}/{action}", // URL with parameters
|
"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 }
|
new[] { typeof(Controllers.PrivacyController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Privacy_default", // Route name
|
"Privacy_default", // Route name
|
||||||
"privacy",
|
"privacy",
|
||||||
"{controller}/{action}", // URL with parameters
|
"{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 }
|
new[] { typeof(Controllers.PrivacyController).Namespace }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,7 @@
|
|||||||
<Compile Include="App_Start\SubdomainRouteExtension.cs" />
|
<Compile Include="App_Start\SubdomainRouteExtension.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Areas\Home\Scripts\Home.js" />
|
||||||
<Content Include="Content\CSS\bootstrap-theme.css" />
|
<Content Include="Content\CSS\bootstrap-theme.css" />
|
||||||
<Content Include="Content\CSS\bootstrap-theme.min.css" />
|
<Content Include="Content\CSS\bootstrap-theme.min.css" />
|
||||||
<Content Include="Content\CSS\bootstrap.css" />
|
<Content Include="Content\CSS\bootstrap.css" />
|
||||||
|
@ -10,13 +10,8 @@
|
|||||||
<link rel="shortcut icon" href="/Content/Images/favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="/Content/Images/favicon.ico" type="image/x-icon" />
|
||||||
@Styles.Render("~/Content/css")
|
@Styles.Render("~/Content/css")
|
||||||
@Scripts.Render("~/bundles/modernizr")
|
@Scripts.Render("~/bundles/modernizr")
|
||||||
|
|
||||||
@Scripts.Render("~/bundles/jquery")
|
@Scripts.Render("~/bundles/jquery")
|
||||||
@Scripts.Render("~/bundles/bootstrap")
|
|
||||||
@Scripts.Render("~/bundles/markdown")
|
@Scripts.Render("~/bundles/markdown")
|
||||||
@Scripts.Render("~/bundles/common")
|
|
||||||
@RenderSection("scripts", required: false)
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body data-twttr-rendered="true">
|
<body data-twttr-rendered="true">
|
||||||
<div id="wrap">
|
<div id="wrap">
|
||||||
@ -63,5 +58,10 @@
|
|||||||
</script>
|
</script>
|
||||||
<noscript><p><img src="//stats.teknik.io/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
|
<noscript><p><img src="//stats.teknik.io/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
|
||||||
<!-- End Piwik Code -->
|
<!-- End Piwik Code -->
|
||||||
|
|
||||||
|
<!-- Load Scripts -->
|
||||||
|
@Scripts.Render("~/bundles/bootstrap")
|
||||||
|
@Scripts.Render("~/bundles/common")
|
||||||
|
@RenderSection("scripts", required: false)
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user