diff --git a/Teknik/App_Start/SubdomainRoute.cs b/Teknik/App_Start/SubdomainRoute.cs index c641248..348248d 100644 --- a/Teknik/App_Start/SubdomainRoute.cs +++ b/Teknik/App_Start/SubdomainRoute.cs @@ -11,27 +11,33 @@ namespace Teknik { public List Subdomains { get; set; } - public SubdomainRoute(List subdomains, string url, IRouteHandler handler) + public List Domains { get; set; } + + public SubdomainRoute(List subdomains, List domains, string url, IRouteHandler handler) : base(url, handler) { this.Subdomains = subdomains; + this.Domains = domains; } - public SubdomainRoute(List subdomains, string url, RouteValueDictionary defaults, IRouteHandler handler) + public SubdomainRoute(List subdomains, List domains, string url, RouteValueDictionary defaults, IRouteHandler handler) : base(url, defaults, handler) { this.Subdomains = subdomains; + this.Domains = domains; } - public SubdomainRoute(List subdomains, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler handler) + public SubdomainRoute(List subdomains, List domains, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler handler) : base(url, defaults, constraints, handler) { this.Subdomains = subdomains; + this.Domains = domains; } - public SubdomainRoute(List subdomains, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler handler) + public SubdomainRoute(List subdomains, List domains, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler handler) : base(url, defaults, constraints, dataTokens, handler) { this.Subdomains = subdomains; + this.Domains = domains; } public override RouteData GetRouteData(HttpContextBase httpContext) @@ -41,6 +47,7 @@ namespace Teknik string subdomain = httpContext.Request.QueryString["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname. string host = httpContext.Request.Headers["Host"]; string curSub = host.GetSubdomain(); + string domain = host.GetDomain(); // special consideration for 'dev' subdomain if (subdomain == null || subdomain == "dev") @@ -68,10 +75,14 @@ namespace Teknik } } - //routeData.Values["sub"] = subdomain; - if (Subdomains.Contains("*") || Subdomains.Contains(subdomain)) + // Check if this route is valid for the current domain + if (httpContext.Request.IsLocal || Domains.Contains(domain)) { - return routeData; + // Check if this route is valid for the current subdomain ('*' means any subdomain is valid) + if (Subdomains.Contains("*") || Subdomains.Contains(subdomain)) + { + return routeData; + } } return null; } diff --git a/Teknik/App_Start/SubdomainRouteExtension.cs b/Teknik/App_Start/SubdomainRouteExtension.cs index 80a5555..c3764ce 100644 --- a/Teknik/App_Start/SubdomainRouteExtension.cs +++ b/Teknik/App_Start/SubdomainRouteExtension.cs @@ -6,10 +6,11 @@ namespace Teknik { public static class SubdomainRouteExtension { - public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List subDomains, string url, object defaults) + public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List subDomains, List domains, string url, object defaults) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new MvcRouteHandler()); @@ -18,10 +19,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List subDomains, string url, object defaults, object constraints) + public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List subDomains, List domains, string url, object defaults, object constraints) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(constraints), @@ -30,10 +32,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List subDomains, string area, string url, object defaults, string[] namespaces) + public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, List subDomains, List domains, string area, string url, object defaults, string[] namespaces) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(new { }), @@ -43,10 +46,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, string url, object defaults) + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, List domains, string url, object defaults) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(new {}), @@ -57,10 +61,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, string url, object defaults, object constraints) + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, List domains, string url, object defaults, object constraints) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(constraints), @@ -71,10 +76,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, string url, object defaults, string[] namespaces) + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, List domains, string url, object defaults, string[] namespaces) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(new {}), @@ -85,10 +91,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, string url, string area, object defaults) + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, List domains, string url, string area, object defaults) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(new { }), @@ -99,10 +106,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, string url, string area, object defaults, object constraints) + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, List domains, string url, string area, object defaults, object constraints) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(constraints), @@ -113,10 +121,11 @@ namespace Teknik return route; } - public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, string url, string area, object defaults, string[] namespaces) + public static SubdomainRoute MapSubdomainRoute(this AreaRegistrationContext context, string name, List subDomains, List domains, string url, string area, object defaults, string[] namespaces) { SubdomainRoute route = new SubdomainRoute( subDomains, + domains, url, new RouteValueDictionary(defaults), new RouteValueDictionary(new { }), diff --git a/Teknik/Areas/API/APIAreaRegistration.cs b/Teknik/Areas/API/APIAreaRegistration.cs index 9ad56de..5fea74f 100644 --- a/Teknik/Areas/API/APIAreaRegistration.cs +++ b/Teknik/Areas/API/APIAreaRegistration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Web.Mvc; +using Teknik.Configuration; namespace Teknik.Areas.API { @@ -15,11 +16,13 @@ namespace Teknik.Areas.API public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); #region API v1 // Base Routing context.MapSubdomainRoute( "API.v1.Index", // Route name new List() { "dev", "api" }, + new List() { config.Host }, "v1", // URL with parameters new { controller = "APIv1", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.APIv1Controller).Namespace } @@ -28,6 +31,7 @@ namespace Teknik.Areas.API context.MapSubdomainRoute( "API.v1.Upload", // Route name new List() { "dev", "api" }, + new List() { config.Host }, "v1/Upload", // URL with parameters new { controller = "APIv1", action = "Upload" }, // Parameter defaults new[] { typeof(Controllers.APIv1Controller).Namespace } @@ -35,6 +39,7 @@ namespace Teknik.Areas.API context.MapSubdomainRoute( "API.v1.Paste", // Route name new List() { "dev", "api" }, + new List() { config.Host }, "v1/Paste", // URL with parameters new { controller = "APIv1", action = "Paste" }, // Parameter defaults new[] { typeof(Controllers.APIv1Controller).Namespace } @@ -45,6 +50,7 @@ namespace Teknik.Areas.API context.MapSubdomainRoute( "API.Index", // Route name new List() { "dev", "" }, + new List() { config.Host }, "", // URL with parameters new { controller = "API", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.APIController).Namespace } diff --git a/Teknik/Areas/About/AboutAreaRegistration.cs b/Teknik/Areas/About/AboutAreaRegistration.cs index 18a1810..0a33bb9 100644 --- a/Teknik/Areas/About/AboutAreaRegistration.cs +++ b/Teknik/Areas/About/AboutAreaRegistration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Web.Mvc; +using Teknik.Configuration; namespace Teknik.Areas.About { @@ -15,9 +16,11 @@ namespace Teknik.Areas.About public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "About.Index", // Route name new List() { "dev", "about" }, + new List() { config.Host }, "", // URL with parameters new { controller = "About", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.AboutController).Namespace } diff --git a/Teknik/Areas/Blog/BlogAreaRegistration.cs b/Teknik/Areas/Blog/BlogAreaRegistration.cs index 451b905..bf6cd93 100644 --- a/Teknik/Areas/Blog/BlogAreaRegistration.cs +++ b/Teknik/Areas/Blog/BlogAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using System.Web.Optimization; +using Teknik.Configuration; namespace Teknik.Areas.Blog { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Blog public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Blog.Blog", // Route name new List() { "dev", "blog" }, // Subdomains + new List() { config.Host }, "{username}", // URL with parameters new { controller = "Blog", action = "Blog", username = string.Empty }, // Parameter defaults new[] { typeof(Controllers.BlogController).Namespace } @@ -26,6 +29,7 @@ namespace Teknik.Areas.Blog context.MapSubdomainRoute( "Blog.Post", // Route name new List() { "dev", "blog" }, // Subdomains + new List() { config.Host }, "{username}/{id}", // URL with parameters new { controller = "Blog", action = "Post", username = "", id = 0 }, // Parameter defaults new[] { typeof(Controllers.BlogController).Namespace } @@ -33,6 +37,7 @@ namespace Teknik.Areas.Blog context.MapSubdomainRoute( "Blog.Action", // Route name new List() { "dev", "blog" }, // Subdomains + new List() { config.Host }, "Action/{controller}/{action}", // URL with parameters new { controller = "Blog", action = "Blog" }, // Parameter defaults new[] { typeof(Controllers.BlogController).Namespace } diff --git a/Teknik/Areas/Contact/ContactAreaRegistration.cs b/Teknik/Areas/Contact/ContactAreaRegistration.cs index ad4f6e1..0f876ff 100644 --- a/Teknik/Areas/Contact/ContactAreaRegistration.cs +++ b/Teknik/Areas/Contact/ContactAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using System.Web.Optimization; +using Teknik.Configuration; namespace Teknik.Areas.Contact { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Contact public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Contact.Index", // Route name new List() { "dev", "contact" }, // Subdomains + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Contact", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.ContactController).Namespace } @@ -26,6 +29,7 @@ namespace Teknik.Areas.Contact context.MapSubdomainRoute( "Contact.Action", // Route name new List() { "dev", "contact" }, // Subdomains + new List() { config.Host }, // domains "{action}", // URL with parameters new { controller = "Contact", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.ContactController).Namespace } diff --git a/Teknik/Areas/Dev/DevAreaRegistration.cs b/Teknik/Areas/Dev/DevAreaRegistration.cs index e13a218..e5fc0f3 100644 --- a/Teknik/Areas/Dev/DevAreaRegistration.cs +++ b/Teknik/Areas/Dev/DevAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using Teknik.Areas.Home.Controllers; +using Teknik.Configuration; namespace Teknik.Areas.Dev { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Dev public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Dev.Index", // Route name new List() { "dev" }, // Subdomains + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Dev", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.DevController).Namespace } diff --git a/Teknik/Areas/Error/ErrorAreaRegistration.cs b/Teknik/Areas/Error/ErrorAreaRegistration.cs index b539904..eccaf2b 100644 --- a/Teknik/Areas/Error/ErrorAreaRegistration.cs +++ b/Teknik/Areas/Error/ErrorAreaRegistration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Web.Mvc; +using Teknik.Configuration; namespace Teknik.Areas.Error { @@ -15,9 +16,11 @@ namespace Teknik.Areas.Error public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Error.Http404", // Route name new List() { "*", "error" }, // Subdomains + new List() { config.Host }, // domains "404", // URL with parameters new { controller = "Error", action = "Http404" }, // Parameter defaults new[] { typeof(Controllers.ErrorController).Namespace } @@ -25,6 +28,7 @@ namespace Teknik.Areas.Error context.MapSubdomainRoute( "Error.Http403", // Route name new List() { "*", "error" }, // Subdomains + new List() { config.Host }, // domains "403", // URL with parameters new { controller = "Error", action = "Http403" }, // Parameter defaults new[] { typeof(Controllers.ErrorController).Namespace } @@ -32,6 +36,7 @@ namespace Teknik.Areas.Error context.MapSubdomainRoute( "Error.Http500", // Route name new List() { "*", "error" }, // Subdomains + new List() { config.Host }, // domains "500", // URL with parameters new { controller = "Error", action = "Http500" }, // Parameter defaults new[] { typeof(Controllers.ErrorController).Namespace } diff --git a/Teknik/Areas/Help/HelpAreaRegistration.cs b/Teknik/Areas/Help/HelpAreaRegistration.cs index 4fdfd83..55fef60 100644 --- a/Teknik/Areas/Help/HelpAreaRegistration.cs +++ b/Teknik/Areas/Help/HelpAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using System.Web.Optimization; +using Teknik.Configuration; namespace Teknik.Areas.Help { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Help public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Help.Index", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Help", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -26,6 +29,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.API", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "API/{version}/{service}", // URL with parameters new { controller = "Help", action = "API", version = UrlParameter.Optional, service = UrlParameter.Optional }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -33,6 +37,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.Blog", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "Blog", // URL with parameters new { controller = "Help", action = "Blog" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -40,6 +45,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.Git", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "Git", // URL with parameters new { controller = "Help", action = "Git" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -47,6 +53,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.IRC", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "IRC", // URL with parameters new { controller = "Help", action = "IRC" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -54,6 +61,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.Mail", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "Mail", // URL with parameters new { controller = "Help", action = "Mail" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -61,6 +69,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.Mumble", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "Mumble", // URL with parameters new { controller = "Help", action = "Mumble" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -68,6 +77,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.RSS", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "RSS", // URL with parameters new { controller = "Help", action = "RSS" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } @@ -75,6 +85,7 @@ namespace Teknik.Areas.Help context.MapSubdomainRoute( "Help.Upload", // Route name new List() { "dev", "help" }, // Subdomains + new List() { config.Host }, // domains "Upload", // URL with parameters new { controller = "Help", action = "Upload" }, // Parameter defaults new[] { typeof(Controllers.HelpController).Namespace } diff --git a/Teknik/Areas/Home/HomeAreaRegistration.cs b/Teknik/Areas/Home/HomeAreaRegistration.cs index 50b76bd..0683692 100644 --- a/Teknik/Areas/Home/HomeAreaRegistration.cs +++ b/Teknik/Areas/Home/HomeAreaRegistration.cs @@ -2,6 +2,7 @@ using System.Web.Mvc; using System.Web.Optimization; using Teknik; +using Teknik.Configuration; namespace Teknik.Areas.Home { @@ -17,9 +18,11 @@ namespace Teknik.Areas.Home public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Home.Index", // Route name new List() { "dev", "www", string.Empty }, // Subdomains + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Home", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.HomeController).Namespace } diff --git a/Teknik/Areas/Paste/PasteAreaRegistration.cs b/Teknik/Areas/Paste/PasteAreaRegistration.cs index b31f889..25bb2b9 100644 --- a/Teknik/Areas/Paste/PasteAreaRegistration.cs +++ b/Teknik/Areas/Paste/PasteAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using System.Web.Optimization; +using Teknik.Configuration; namespace Teknik.Areas.Paste { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Paste public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Paste.Index", // Route name new List() { "dev", "paste", "p" }, + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Paste", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.PasteController).Namespace } @@ -26,6 +29,7 @@ namespace Teknik.Areas.Paste context.MapSubdomainRoute( "Paste.Simple", // Route name new List() { "dev", "paste", "p" }, + new List() { config.Host }, // domains "Simple/{url}/{password}", // URL with parameters new { controller = "Paste", action = "ViewPaste", type = "Simple", password = UrlParameter.Optional }, // Parameter defaults new[] { typeof(Controllers.PasteController).Namespace } @@ -33,6 +37,7 @@ namespace Teknik.Areas.Paste context.MapSubdomainRoute( "Paste.Raw", // Route name new List() { "dev", "paste", "p" }, + new List() { config.Host }, // domains "Raw/{url}/{password}", // URL with parameters new { controller = "Paste", action = "ViewPaste", type = "Raw", password = UrlParameter.Optional }, // Parameter defaults new[] { typeof(Controllers.PasteController).Namespace } @@ -40,6 +45,7 @@ namespace Teknik.Areas.Paste context.MapSubdomainRoute( "Paste.Download", // Route name new List() { "dev", "paste", "p" }, + new List() { config.Host }, // domains "Download/{url}/{password}", // URL with parameters new { controller = "Paste", action = "ViewPaste", type = "Download", password = UrlParameter.Optional }, // Parameter defaults new[] { typeof(Controllers.PasteController).Namespace } @@ -47,6 +53,7 @@ namespace Teknik.Areas.Paste context.MapSubdomainRoute( "Paste.Action", // Route name new List() { "dev", "paste", "p" }, + new List() { config.Host }, // domains "Action/{action}", // URL with parameters new { controller = "Paste", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.PasteController).Namespace } @@ -54,6 +61,7 @@ namespace Teknik.Areas.Paste context.MapSubdomainRoute( "Paste.View", // Route name new List() { "dev", "paste", "p" }, + new List() { config.Host }, // domains "{url}/{password}", // URL with parameters new { controller = "Paste", action = "ViewPaste", type = "Full", password = UrlParameter.Optional }, // Parameter defaults new[] { typeof(Controllers.PasteController).Namespace } diff --git a/Teknik/Areas/Podcast/PodcastAreaRegistration.cs b/Teknik/Areas/Podcast/PodcastAreaRegistration.cs index e945cc7..6fd2711 100644 --- a/Teknik/Areas/Podcast/PodcastAreaRegistration.cs +++ b/Teknik/Areas/Podcast/PodcastAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using System.Web.Optimization; +using Teknik.Configuration; namespace Teknik.Areas.Podcast { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Podcast public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Podcast.Index", // Route name new List() { "dev", "podcast" }, // Subdomains + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Podcast", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.PodcastController).Namespace } @@ -26,6 +29,7 @@ namespace Teknik.Areas.Podcast context.MapSubdomainRoute( "Podcast.View", // Route name new List() { "dev", "podcast" }, // Subdomains + new List() { config.Host }, // domains "{episode}", // URL with parameters new { controller = "Podcast", action = "View" }, // Parameter defaults new[] { typeof(Controllers.PodcastController).Namespace } @@ -33,6 +37,7 @@ namespace Teknik.Areas.Podcast context.MapSubdomainRoute( "Podcast.Download", // Route name new List() { "dev", "podcast" }, // Subdomains + new List() { config.Host }, // domains "File/{episode}/{fileName}", // URL with parameters new { controller = "Podcast", action = "Download" }, // Parameter defaults new[] { typeof(Controllers.PodcastController).Namespace } @@ -40,6 +45,7 @@ namespace Teknik.Areas.Podcast context.MapSubdomainRoute( "Podcast.Action", // Route name new List() { "dev", "podcast" }, // Subdomains + new List() { config.Host }, // domains "Action/{controller}/{action}", // URL with parameters new { controller = "Podcast", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.PodcastController).Namespace } diff --git a/Teknik/Areas/Privacy/PrivacyAreaRegistration.cs b/Teknik/Areas/Privacy/PrivacyAreaRegistration.cs index 00f757a..d6dc295 100644 --- a/Teknik/Areas/Privacy/PrivacyAreaRegistration.cs +++ b/Teknik/Areas/Privacy/PrivacyAreaRegistration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Web.Mvc; +using Teknik.Configuration; namespace Teknik.Areas.Privacy { @@ -15,9 +16,11 @@ namespace Teknik.Areas.Privacy public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Privacy.Index", // Route name new List() { "dev", "privacy" }, // Subdomains + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Privacy", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.PrivacyController).Namespace } diff --git a/Teknik/Areas/Profile/ProfileAreaRegistration.cs b/Teknik/Areas/Profile/ProfileAreaRegistration.cs index 714d738..c34f4f6 100644 --- a/Teknik/Areas/Profile/ProfileAreaRegistration.cs +++ b/Teknik/Areas/Profile/ProfileAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using System.Web.Optimization; +using Teknik.Configuration; namespace Teknik.Areas.Profile { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Profile public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Profile.Login", // Route name new List() { "dev", "profile", "www", string.Empty }, // Subdomains + new List() { config.Host }, // domains "Login", // URL with parameters new { controller = "Profile", action = "Login" }, // Parameter defaults new[] { typeof(Controllers.ProfileController).Namespace } @@ -26,6 +29,7 @@ namespace Teknik.Areas.Profile context.MapSubdomainRoute( "Profile.Logout", // Route name new List() { "dev", "profile", "www", string.Empty }, // Subdomains + new List() { config.Host }, // domains "Logout", // URL with parameters new { controller = "Profile", action = "Logout" }, // Parameter defaults new[] { typeof(Controllers.ProfileController).Namespace } @@ -33,6 +37,7 @@ namespace Teknik.Areas.Profile context.MapSubdomainRoute( "Profile.Register", // Route name new List() { "dev", "profile", "www", string.Empty }, // Subdomains + new List() { config.Host }, // domains "Register", // URL with parameters new { controller = "Profile", action = "Register" }, // Parameter defaults new[] { typeof(Controllers.ProfileController).Namespace } @@ -40,6 +45,7 @@ namespace Teknik.Areas.Profile context.MapSubdomainRoute( "Profile.Settings", // Route name new List() { "dev", "profile" }, // Subdomains + new List() { config.Host }, // domains "Settings", // URL with parameters new { controller = "Profile", action = "Settings" }, // Parameter defaults new[] { typeof(Controllers.ProfileController).Namespace } @@ -47,6 +53,7 @@ namespace Teknik.Areas.Profile context.MapSubdomainRoute( "Profile.Index", // Route name new List() { "dev", "profile" }, // Subdomains + new List() { config.Host }, // domains "{username}", // URL with parameters new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults new[] { typeof(Controllers.ProfileController).Namespace } @@ -54,6 +61,7 @@ namespace Teknik.Areas.Profile context.MapSubdomainRoute( "Profile.Action", // Route name new List() { "dev", "profile" }, // Subdomains + new List() { config.Host }, // domains "Action/{action}", // URL with parameters new { controller = "Profile", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.ProfileController).Namespace } diff --git a/Teknik/Areas/RSS/RSSAreaRegistration.cs b/Teknik/Areas/RSS/RSSAreaRegistration.cs index c1196dd..3ea3aa8 100644 --- a/Teknik/Areas/RSS/RSSAreaRegistration.cs +++ b/Teknik/Areas/RSS/RSSAreaRegistration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Web.Mvc; +using Teknik.Configuration; namespace Teknik.Areas.RSS { @@ -15,9 +16,11 @@ namespace Teknik.Areas.RSS public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "RSS.Index", // Route name new List() { "dev", "rss" }, + new List() { config.Host }, // domains "", // URL with parameters new { controller = "RSS", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.RSSController).Namespace } @@ -25,6 +28,7 @@ namespace Teknik.Areas.RSS context.MapSubdomainRoute( "RSS.Blog", // Route name new List() { "dev", "rss" }, + new List() { config.Host }, // domains "Blog/{username}", // URL with parameters new { controller = "RSS", action = "Blog", username = UrlParameter.Optional }, // Parameter defaults new[] { typeof(Controllers.RSSController).Namespace } @@ -32,6 +36,7 @@ namespace Teknik.Areas.RSS context.MapSubdomainRoute( "RSS.Podcast", // Route name new List() { "dev", "rss" }, + new List() { config.Host }, // domains "Podcast", // URL with parameters new { controller = "RSS", action = "Podcast" }, // Parameter defaults new[] { typeof(Controllers.RSSController).Namespace } diff --git a/Teknik/Areas/Shortener/Controllers/ShortenerController.cs b/Teknik/Areas/Shortener/Controllers/ShortenerController.cs new file mode 100644 index 0000000..88e8b64 --- /dev/null +++ b/Teknik/Areas/Shortener/Controllers/ShortenerController.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Teknik.Controllers; + +namespace Teknik.Areas.Shortener.Controllers +{ + public class ShortenerController : DefaultController + { + // GET: Shortener/Shortener + public ActionResult Index() + { + return View(); + } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Shortener/ShortenerAreaRegistration.cs b/Teknik/Areas/Shortener/ShortenerAreaRegistration.cs new file mode 100644 index 0000000..7f9329c --- /dev/null +++ b/Teknik/Areas/Shortener/ShortenerAreaRegistration.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; +using System.Web.Mvc; +using Teknik.Configuration; + +namespace Teknik.Areas.Shortener +{ + public class ShortenerAreaRegistration : AreaRegistration + { + public override string AreaName + { + get + { + return "Shortener"; + } + } + + public override void RegisterArea(AreaRegistrationContext context) + { + Config config = Config.Load(); + context.MapSubdomainRoute( + "Stream.Index", // Route name + new List() { "dev", "shorten", "s" }, // Subdomains + new List() { config.Host }, // domains + "", // URL with parameters + new { controller = "Shortener", action = "Index" }, // Parameter defaults + new[] { typeof(Controllers.ShortenerController).Namespace } + ); + } + } +} \ No newline at end of file diff --git a/Teknik/Areas/Shortener/Views/web.config b/Teknik/Areas/Shortener/Views/web.config new file mode 100644 index 0000000..ada5aaf --- /dev/null +++ b/Teknik/Areas/Shortener/Views/web.config @@ -0,0 +1,36 @@ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Teknik/Areas/Stream/StreamAreaRegistration.cs b/Teknik/Areas/Stream/StreamAreaRegistration.cs index 0add339..cbe7781 100644 --- a/Teknik/Areas/Stream/StreamAreaRegistration.cs +++ b/Teknik/Areas/Stream/StreamAreaRegistration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Web.Mvc; +using Teknik.Configuration; namespace Teknik.Areas.Stream { @@ -15,9 +16,11 @@ namespace Teknik.Areas.Stream public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Stream.Index", // Route name new List() { "dev", "stream" }, // Subdomains + new List() { config.Host }, // domains "", // URL with parameters new { controller = "Stream", action = "Index" }, // Parameter defaults new[] { typeof(Controllers.StreamController).Namespace } diff --git a/Teknik/Areas/Transparency/TransparencyAreaRegistration.cs b/Teknik/Areas/Transparency/TransparencyAreaRegistration.cs index d472190..4d6a10e 100644 --- a/Teknik/Areas/Transparency/TransparencyAreaRegistration.cs +++ b/Teknik/Areas/Transparency/TransparencyAreaRegistration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Web.Mvc; +using Teknik.Configuration; namespace Teknik.Areas.Transparency { @@ -15,9 +16,11 @@ namespace Teknik.Areas.Transparency public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Transparency.Index", new List() { "dev", "transparency" }, // Subdomains + new List() { config.Host }, // domains "", new { controller = "Transparency", action = "Index" }, new[] { typeof(Controllers.TransparencyController).Namespace } diff --git a/Teknik/Areas/Upload/UploadAreaRegistration.cs b/Teknik/Areas/Upload/UploadAreaRegistration.cs index 007cabe..7c4b3c7 100644 --- a/Teknik/Areas/Upload/UploadAreaRegistration.cs +++ b/Teknik/Areas/Upload/UploadAreaRegistration.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Web.Mvc; using System.Web.Optimization; +using Teknik.Configuration; namespace Teknik.Areas.Upload { @@ -16,9 +17,11 @@ namespace Teknik.Areas.Upload public override void RegisterArea(AreaRegistrationContext context) { + Config config = Config.Load(); context.MapSubdomainRoute( "Upload.Index", new List() { "dev", "upload", "u" }, // Subdomains + new List() { config.Host }, // domains "", new { controller = "Upload", action = "Index" }, new[] { typeof(Controllers.UploadController).Namespace } @@ -26,6 +29,7 @@ namespace Teknik.Areas.Upload context.MapSubdomainRoute( "Upload.Download", new List() { "dev", "upload", "u" }, // Subdomains + new List() { config.Host }, // domains "{file}", new { controller = "Upload", action = "Download", file = string.Empty }, new[] { typeof(Controllers.UploadController).Namespace } @@ -33,6 +37,7 @@ namespace Teknik.Areas.Upload context.MapSubdomainRoute( "Upload.Delete", new List() { "dev", "upload", "u" }, // Subdomains + new List() { config.Host }, // domains "{file}/{key}", new { controller = "Upload", action = "Delete", file = string.Empty, key = string.Empty }, new[] { typeof(Controllers.UploadController).Namespace } @@ -40,6 +45,7 @@ namespace Teknik.Areas.Upload context.MapSubdomainRoute( "Upload.Action", new List() { "dev", "upload", "u" }, // Subdomains + new List() { config.Host }, // domains "Action/{controller}/{action}", new { controller = "Upload", action = "Index" }, new[] { typeof(Controllers.UploadController).Namespace } diff --git a/Teknik/Teknik.csproj b/Teknik/Teknik.csproj index b071f2e..23b037e 100644 --- a/Teknik/Teknik.csproj +++ b/Teknik/Teknik.csproj @@ -207,6 +207,8 @@ + + @@ -475,6 +477,7 @@ + @@ -565,6 +568,9 @@ + + +