From d97e89d9d3bd64aa5c680a43bfd281ee08b8fe44 Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Mon, 23 Nov 2015 11:17:57 -0800 Subject: [PATCH] Fixed URL Routing generation for Links. Added Namespace routing extension. --- Teknik/App_Start/SubdomainRouteExtension.cs | 32 +++++++++++++++++-- Teknik/Areas/About/AboutAreaRegistration.cs | 6 ++-- .../About/Controllers/AboutController.cs | 2 +- Teknik/Areas/About/Views/About/Index.cshtml | 2 +- Teknik/Areas/Home/HomeAreaRegistration.cs | 9 ++++-- Teknik/Areas/Home/Views/Home/Index.cshtml | 16 +++++----- Teknik/Configuration/Config.cs | 8 +++-- Teknik/Content/Images/logo-black-io.svg | 30 +++++++++++++++++ Teknik/Content/Images/logo-black.svg | 23 +++++++++++++ Teknik/Content/Images/logo-blue-io.svg | 30 +++++++++++++++++ Teknik/Teknik.csproj | 3 ++ Teknik/Views/Profile/Login.cshtml | 2 +- Teknik/Views/Profile/Register.cshtml | 2 +- Teknik/Views/Shared/_LoginPartial.cshtml | 8 ++--- Teknik/Views/Shared/_Navbar.cshtml | 24 +++++++------- 15 files changed, 159 insertions(+), 38 deletions(-) create mode 100644 Teknik/Content/Images/logo-black-io.svg create mode 100644 Teknik/Content/Images/logo-black.svg create mode 100644 Teknik/Content/Images/logo-blue-io.svg diff --git a/Teknik/App_Start/SubdomainRouteExtension.cs b/Teknik/App_Start/SubdomainRouteExtension.cs index da6ace8..f66ddd8 100644 --- a/Teknik/App_Start/SubdomainRouteExtension.cs +++ b/Teknik/App_Start/SubdomainRouteExtension.cs @@ -18,6 +18,30 @@ namespace Teknik return route; } + public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, string subDomain, string url, object defaults, object constraints) + { + SubdomainRoute route = new SubdomainRoute( + subDomain, + url, + new RouteValueDictionary(defaults), + new RouteValueDictionary(constraints), + new MvcRouteHandler()); + routes.Add(name, route); + return route; + } + + public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, string subDomain, string url, object defaults, string[] namespaces) + { + SubdomainRoute route = new SubdomainRoute( + subDomain, + url, + new RouteValueDictionary(defaults), + new RouteValueDictionary(namespaces), + new MvcRouteHandler()); + routes.Add(name, route); + return route; + } + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, object defaults) { SubdomainRoute route = new SubdomainRoute( @@ -46,15 +70,17 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, string subDomain, string url, object defaults, object constraints) + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, string subDomain, string url, object defaults, string[] namespaces) { SubdomainRoute route = new SubdomainRoute( subDomain, url, new RouteValueDictionary(defaults), - new RouteValueDictionary(constraints), + new RouteValueDictionary(new {}), + new RouteValueDictionary(new { Area = context.AreaName, Namespaces = namespaces }), new MvcRouteHandler()); - routes.Add(name, route); + + context.Routes.Add(name, route); return route; } } diff --git a/Teknik/Areas/About/AboutAreaRegistration.cs b/Teknik/Areas/About/AboutAreaRegistration.cs index 29c26e6..feae6a9 100644 --- a/Teknik/Areas/About/AboutAreaRegistration.cs +++ b/Teknik/Areas/About/AboutAreaRegistration.cs @@ -18,13 +18,15 @@ 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 { area = "About", 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 { area = this.AreaName, controller = "About", action = "Index", username = UrlParameter.Optional, page = UrlParameter.Optional }, // Parameter defaults + new[] { typeof(Controllers.AboutController).Namespace } ); } } diff --git a/Teknik/Areas/About/Controllers/AboutController.cs b/Teknik/Areas/About/Controllers/AboutController.cs index dec97a1..6eb089e 100644 --- a/Teknik/Areas/About/Controllers/AboutController.cs +++ b/Teknik/Areas/About/Controllers/AboutController.cs @@ -16,7 +16,7 @@ namespace Teknik.Areas.About.Controllers ViewBag.Title = Config.Title + " - About"; ViewBag.Message = "Your application description page."; - return View(Config); + return View(); } } } \ No newline at end of file diff --git a/Teknik/Areas/About/Views/About/Index.cshtml b/Teknik/Areas/About/Views/About/Index.cshtml index 5d96546..ab382f1 100644 --- a/Teknik/Areas/About/Views/About/Index.cshtml +++ b/Teknik/Areas/About/Views/About/Index.cshtml @@ -45,7 +45,7 @@

Bitcoin Address - +

diff --git a/Teknik/Areas/Home/HomeAreaRegistration.cs b/Teknik/Areas/Home/HomeAreaRegistration.cs index d90c2a8..d5e119c 100644 --- a/Teknik/Areas/Home/HomeAreaRegistration.cs +++ b/Teknik/Areas/Home/HomeAreaRegistration.cs @@ -19,19 +19,22 @@ 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 { area = "Home", 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 { area = this.AreaName, 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 { area = this.AreaName, controller = "Home", action = "Index" }, // Parameter defaults + new[] { typeof(Controllers.HomeController).Namespace } ); //context.MapRoute( // "Home_default", diff --git a/Teknik/Areas/Home/Views/Home/Index.cshtml b/Teknik/Areas/Home/Views/Home/Index.cshtml index ce64fa1..fca3501 100644 --- a/Teknik/Areas/Home/Views/Home/Index.cshtml +++ b/Teknik/Areas/Home/Views/Home/Index.cshtml @@ -15,7 +15,7 @@
- +

@@ -26,7 +26,7 @@
- +

@@ -37,7 +37,7 @@
- +

@@ -48,7 +48,7 @@
- +

@@ -68,7 +68,7 @@

- +

@@ -79,7 +79,7 @@
- +

@@ -90,7 +90,7 @@
- +

@@ -101,7 +101,7 @@
- +

diff --git a/Teknik/Configuration/Config.cs b/Teknik/Configuration/Config.cs index d63aa0c..e4e4bfe 100644 --- a/Teknik/Configuration/Config.cs +++ b/Teknik/Configuration/Config.cs @@ -58,8 +58,12 @@ namespace Teknik public static Config Load() { - string configContents = File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Data/Config.json")); - Config config = Config.Deserialize(configContents); + Config config = new Config(); + if (File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/Config.json"))) + { + string configContents = File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Data/Config.json")); + config = Config.Deserialize(configContents); + } return config; } } diff --git a/Teknik/Content/Images/logo-black-io.svg b/Teknik/Content/Images/logo-black-io.svg new file mode 100644 index 0000000..3c6eb48 --- /dev/null +++ b/Teknik/Content/Images/logo-black-io.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/Teknik/Content/Images/logo-black.svg b/Teknik/Content/Images/logo-black.svg new file mode 100644 index 0000000..2a5a4dc --- /dev/null +++ b/Teknik/Content/Images/logo-black.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + diff --git a/Teknik/Content/Images/logo-blue-io.svg b/Teknik/Content/Images/logo-blue-io.svg new file mode 100644 index 0000000..6638a60 --- /dev/null +++ b/Teknik/Content/Images/logo-blue-io.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + diff --git a/Teknik/Teknik.csproj b/Teknik/Teknik.csproj index 716dcd0..eb62e07 100644 --- a/Teknik/Teknik.csproj +++ b/Teknik/Teknik.csproj @@ -169,6 +169,9 @@ + + + diff --git a/Teknik/Views/Profile/Login.cshtml b/Teknik/Views/Profile/Login.cshtml index 087a256..634ab2a 100644 --- a/Teknik/Views/Profile/Login.cshtml +++ b/Teknik/Views/Profile/Login.cshtml @@ -1,6 +1,6 @@ @model Teknik.ViewModels.LoginViewModel -
+ @Html.ValidationSummary(true, "Login failed. Check your login details.")