Quellcode durchsuchen

Finished Subdomain url generation using routes.

tags/2.0.3
Teknikode vor 5 Jahren
Ursprung
Commit
d6a9579778
37 geänderte Dateien mit 248 neuen und 250 gelöschten Zeilen
  1. 7
    16
      Teknik/App_Start/SubdomainRoute.cs
  2. 20
    10
      Teknik/App_Start/SubdomainRouteExtension.cs
  3. 4
    4
      Teknik/Areas/About/AboutAreaRegistration.cs
  4. 12
    12
      Teknik/Areas/About/Views/About/Index.cshtml
  5. 6
    6
      Teknik/Areas/Blog/BlogAreaRegistration.cs
  6. 14
    14
      Teknik/Areas/Blog/Views/Blog/Blog.cshtml
  7. 1
    1
      Teknik/Areas/Blog/Views/Blog/Comment.cshtml
  8. 2
    2
      Teknik/Areas/Blog/Views/Blog/Post.cshtml
  9. 14
    14
      Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml
  10. 18
    4
      Teknik/Areas/Contact/ContactAreaRegistration.cs
  11. 1
    1
      Teknik/Areas/Contact/Views/Contact/Index.cshtml
  12. 1
    1
      Teknik/Areas/Dev/DevAreaRegistration.cs
  13. 1
    4
      Teknik/Areas/Dev/Views/Dev/Index.cshtml
  14. 1
    1
      Teknik/Areas/Error/ErrorAreaRegistration.cs
  15. 2
    2
      Teknik/Areas/Error/Views/Error/Exception.cshtml
  16. 2
    2
      Teknik/Areas/Error/Views/Error/General.cshtml
  17. 2
    2
      Teknik/Areas/Error/Views/Error/Http404.cshtml
  18. 2
    2
      Teknik/Areas/Error/Views/Error/Http500.cshtml
  19. 4
    4
      Teknik/Areas/Home/HomeAreaRegistration.cs
  20. 13
    13
      Teknik/Areas/Home/Views/Home/Index.cshtml
  21. 2
    2
      Teknik/Areas/Privacy/PrivacyAreaRegistration.cs
  22. 4
    3
      Teknik/Areas/Profile/Controllers/ProfileController.cs
  23. 11
    11
      Teknik/Areas/Profile/ProfileAreaRegistration.cs
  24. 2
    0
      Teknik/Areas/Profile/ViewModels/RegisterViewModel.cs
  25. 2
    6
      Teknik/Areas/Profile/Views/Profile/Login.cshtml
  26. 2
    1
      Teknik/Areas/Profile/Views/Profile/Register.cshtml
  27. 4
    11
      Teknik/Areas/Profile/Views/Profile/ViewLogin.cshtml
  28. 15
    1
      Teknik/Areas/Profile/Views/Profile/ViewRegistration.cshtml
  29. 17
    17
      Teknik/Areas/Upload/UploadAreaRegistration.cs
  30. 3
    3
      Teknik/Areas/Upload/Views/Upload/Index.cshtml
  31. 42
    34
      Teknik/Helpers/UrlExtensions.cs
  32. 0
    2
      Teknik/Teknik.csproj
  33. 0
    17
      Teknik/Views/Shared/Error.cshtml
  34. 0
    10
      Teknik/Views/Shared/Lockout.cshtml
  35. 1
    1
      Teknik/Views/Shared/_Footer.cshtml
  36. 4
    4
      Teknik/Views/Shared/_LoginPartial.cshtml
  37. 12
    12
      Teknik/Views/Shared/_Navbar.cshtml

+ 7
- 16
Teknik/App_Start/SubdomainRoute.cs Datei anzeigen

@@ -8,29 +8,29 @@ namespace Teknik
{
public class SubdomainRoute : Route
{
public string subDomain { get; set; }
public string Subdomain { get; set; }

public SubdomainRoute(string subdomain, string url, IRouteHandler handler)
: base(url, handler)
{
this.subDomain = subdomain;
this.Subdomain = subdomain;
}
public SubdomainRoute(string subdomain, string url, RouteValueDictionary defaults, IRouteHandler handler)
: base(url, defaults, handler)
{
this.subDomain = subdomain;
this.Subdomain = subdomain;
}

public SubdomainRoute(string subdomain, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, IRouteHandler handler)
: base(url, defaults, constraints, handler)
{
this.subDomain = subdomain;
this.Subdomain = subdomain;
}

public SubdomainRoute(string subdomain, string url, RouteValueDictionary defaults, RouteValueDictionary constraints, RouteValueDictionary dataTokens, IRouteHandler handler)
: base(url, defaults, constraints, dataTokens, handler)
{
this.subDomain = subdomain;
this.Subdomain = subdomain;
}

public override RouteData GetRouteData(HttpContextBase httpContext)
@@ -41,16 +41,7 @@ namespace Teknik
if (subdomain == null)
{
string host = httpContext.Request.Headers["Host"];
if (host.Split('.').Count() > 2)
{
int index = host.IndexOf('.');
if (index >= 0)
subdomain = host.Substring(0, index);
}
else
{
subdomain = string.Empty;
}
subdomain = host.GetSubdomain();
}
else
{
@@ -65,7 +56,7 @@ namespace Teknik
}

//routeData.Values["sub"] = subdomain;
if (subDomain == "*" || subDomain == subdomain)
if (Subdomain == "*" || Subdomain == subdomain)
{
return routeData;
}

+ 20
- 10
Teknik/App_Start/SubdomainRouteExtension.cs Datei anzeigen

@@ -7,13 +7,12 @@ namespace Teknik
{
public static SubdomainRoute MapSubdomainRoute(this RouteCollection routes, string name, string subDomain, string url, object defaults)
{

SubdomainRoute route = new SubdomainRoute(
subDomain,
url,
new RouteValueDictionary(defaults),
new MvcRouteHandler());
routes.Add(name, route);
routes.Add(AddSubToName(subDomain, name), route);

return route;
}
@@ -26,7 +25,7 @@ namespace Teknik
new RouteValueDictionary(defaults),
new RouteValueDictionary(constraints),
new MvcRouteHandler());
routes.Add(name, route);
routes.Add(AddSubToName(subDomain, name), route);
return route;
}

@@ -39,7 +38,7 @@ namespace Teknik
new RouteValueDictionary(new { }),
new RouteValueDictionary(new { Area = area, Namespaces = namespaces }),
new MvcRouteHandler());
routes.Add(name, route);
routes.Add(AddSubToName(subDomain, name), route);
return route;
}

@@ -53,7 +52,7 @@ namespace Teknik
new RouteValueDictionary(new {Area = context.AreaName}),
new MvcRouteHandler());

context.Routes.Add(name, route);
context.Routes.Add(AddSubToName(subDomain, name), route);
return route;
}

@@ -67,7 +66,7 @@ namespace Teknik
new RouteValueDictionary(new {Area = context.AreaName}),
new MvcRouteHandler());

context.Routes.Add(name, route);
context.Routes.Add(AddSubToName(subDomain, name), route);
return route;
}

@@ -81,7 +80,7 @@ namespace Teknik
new RouteValueDictionary(new { Area = context.AreaName, Namespaces = namespaces }),
new MvcRouteHandler());

context.Routes.Add(name, route);
context.Routes.Add(AddSubToName(subDomain, name), route);
return route;
}

@@ -95,7 +94,7 @@ namespace Teknik
new RouteValueDictionary(new { Area = area }),
new MvcRouteHandler());

context.Routes.Add(name, route);
context.Routes.Add(AddSubToName(subDomain, name), route);
return route;
}

@@ -109,7 +108,7 @@ namespace Teknik
new RouteValueDictionary(new { Area = area }),
new MvcRouteHandler());

context.Routes.Add(name, route);
context.Routes.Add(AddSubToName(subDomain, name), route);
return route;
}

@@ -123,8 +122,19 @@ namespace Teknik
new RouteValueDictionary(new { Area = area, Namespaces = namespaces }),
new MvcRouteHandler());

context.Routes.Add(name, route);
context.Routes.Add(AddSubToName(subDomain, name), route);
return route;
}

private static string AddSubToName(string sub, string name)
{
string newName = name;
if (!string.IsNullOrEmpty(sub))
{
newName = sub + "." + name;
}

return newName;
}
}
}

+ 4
- 4
Teknik/Areas/About/AboutAreaRegistration.cs Datei anzeigen

@@ -15,16 +15,16 @@ namespace Teknik.Areas.About
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"About_dev", // Route name
"About.Index", // Route name
"dev",
"About/{controller}/{action}", // URL with parameters
"About", // URL with parameters
new { controller = "About", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.AboutController).Namespace }
);
context.MapSubdomainRoute(
"About_default", // Route name
"About.Index", // Route name
"about",
"{controller}/{action}", // URL with parameters
"", // URL with parameters
new { controller = "About", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.AboutController).Namespace }
);

+ 12
- 12
Teknik/Areas/About/Views/About/Index.cshtml Datei anzeigen

@@ -9,24 +9,24 @@
Teknik was created to provide our users free services that they can trust. All of our services are treated with the utmost care to provide you with the best experience possible, and the best security with your data that we can give.
</p>
<p>
You can view our complete activity and statistics by visiting the <a href="@Url.SubAction("transparency", "Index", "Transparency", new { area = "Transparency" })">Transparency</a> page.
You can view our complete activity and statistics by visiting the <a href="@Url.SubRouteUrl("transparency", "Transparency.Index")">Transparency</a> page.
</p>
<h2 class="text-center">What we Offer</h2>
<hr>
<div class="row">
<div class="col-sm-4 col-sm-offset-2 text-center">
<h4><a href="@Url.SubAction("paste", "Index", "Paste", new { area = "Paste" })">Fast and Secure Pastebin</a></h4>
<h4><a href="@Url.SubAction("upload", "Index", "Upload", new { area = "Upload" })">Encrypted File Uploads</a></h4>
<h4><a href="@Url.SubAction("help", "Index", "Help", new { area = "Help", section = "Mail" })">Free Email Address</a></h4>
<h4><a href="@Url.SubAction("help", "Index", "Help", new { area = "Help", section = "Api" })">Easy to Use API</a></h4>
<h4><a href="@Url.SubAction("git", "Index", "Git", new { area = "Git" })">Personal Git Repositories</a></h4>
<h4><a href="@Url.SubRouteUrl("paste", "Paste.Index")">Fast and Secure Pastebin</a></h4>
<h4><a href="@Url.SubRouteUrl("upload", "Upload.Index")">Encrypted File Uploads</a></h4>
<h4><a href="@Url.SubRouteUrl("help", "Help.Index", new { section = "Mail" })">Free Email Address</a></h4>
<h4><a href="@Url.SubRouteUrl("help", "Help.Index", new { section = "Api" })">Easy to Use API</a></h4>
<h4><a href="@Url.SubRouteUrl("git", "Git.Index")">Personal Git Repositories</a></h4>
</div>
<div class="col-sm-4 text-center">
<h4><a href="@Url.SubAction("blog", "Blog", "Blog", new { area = "Blog" })">Personal Blog</a></h4>
<h4><a href="@Url.SubAction("podcast", "Index", "Podcast", new { area = "Podcast" })">Entertaining Podcasts</a></h4>
<h4><a href="@Url.SubAction("help", "Index", "Help", new { area = "Help", section = "Mumble" })">Mumble Server</a></h4>
<h4><a href="@Url.SubAction("transparency", "Index", "Transparency", new { area = "Transparency" })">Full Transparency</a></h4>
<h4><a href="@Url.SubAction("git", "Index", "Git", new { area = "Git" })">Completely Open Source</a></h4>
<h4><a href="@Url.SubRouteUrl("blog", "Blog.Blog")">Personal Blog</a></h4>
<h4><a href="@Url.SubRouteUrl("podcast", "Podcast.Index")">Entertaining Podcasts</a></h4>
<h4><a href="@Url.SubRouteUrl("help", "Help.Index", new { section = "Mumble" })">Mumble Server</a></h4>
<h4><a href="@Url.SubRouteUrl("transparency", "Transparency.Index")">Full Transparency</a></h4>
<h4><a href="@Url.SubRouteUrl("git", "Git.Index", new { username = "Teknikode", repository = "Teknik" })">Completely Open Source</a></h4>
</div>
</div>

@@ -36,7 +36,7 @@
Teknik's source code can be located on our <a href="http://git.teknik.io/Teknikode/">Git Repository</a> as well as all our internal tools and projects.
<br />
<br />
Have a cool suggestion for the site? Just submit it using the <a href="@Url.SubAction("contact", "Index", "Contact", new { area = "Contact" })">Feedback Form</a>!
Have a cool suggestion for the site? Just submit it using the <a href="@Url.SubRouteUrl("contact", "Contact.Index")">Feedback Form</a>!
</p>
<div class="alert alert-info">
<div class="text-center">

+ 6
- 6
Teknik/Areas/Blog/BlogAreaRegistration.cs Datei anzeigen

@@ -16,42 +16,42 @@ namespace Teknik.Areas.Blog
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Blog_dev_blog", // Route name
"Blog.Blog", // Route name
"dev",
"Blog/{username}", // URL with parameters
new { controller = "Blog", action = "Blog", username = string.Empty }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog_dev_post", // Route name
"Blog.Post", // Route name
"dev",
"Blog/{username}/{id}", // URL with parameters
new { controller = "Blog", action = "Post", username = "", id = 0 }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog_dev_post_unique", // Route name
"Blog.Action", // Route name
"dev",
"Blog/Action/{controller}/{action}", // URL with parameters
new { controller = "Blog", action = "Blog" }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog_default_blog", // Route name
"Blog.Blog", // Route name
"blog",
"{username}", // URL with parameters
new { controller = "Blog", action = "Blog", username = string.Empty }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog_default_post", // Route name
"Blog.Post", // Route name
"blog",
"{username}/{id}", // URL with parameters
new { controller = "Blog", action = "Post", username = "", id = 0 }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
context.MapSubdomainRoute(
"Blog_default_post_unique", // Route name
"Blog.Action", // Route name
"blog",
"Action/{controller}/{action}", // URL with parameters
new { controller = "Blog", action = "Blog" }, // Parameter defaults

+ 14
- 14
Teknik/Areas/Blog/Views/Blog/Blog.cshtml Datei anzeigen

@@ -5,21 +5,21 @@
<script>
// We need to define the action URLs for the script

var uploadURL = '@Url.Action("Upload", "Upload", new { area = "Upload" })';
var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Upload")';

var getPostsURL = '@Url.Action("GetPosts", "Blog", new { area = "Blog" })';
var getPostTitleURL = '@Url.Action("GetPostTitle", "Blog", new { area = "Blog" })';
var getPostArticleURL = '@Url.Action("GetPostArticle", "Blog", new { area = "Blog" })';
var publishPostURL = '@Url.Action("PublishPost", "Blog", new { area = "Blog" })';
var addPostURL = '@Url.Action("CreatePost", "Blog", new { area = "Blog" })';
var editPostURL = '@Url.Action("EditPost", "Blog", new { area = "Blog" })';
var deletePostURL = '@Url.Action("DeletePost", "Blog", new { area = "Blog" })';
var getPostsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPosts" })';
var getPostTitleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostTitle" })';
var getPostArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostArticle" })';
var publishPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "PublishPost" })';
var addPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreatePost" })';
var editPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditPost" })';
var deletePostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeletePost" })';

var getCommentsURL = '@Url.Action("GetComments", "Blog", new { area = "Blog" })';
var getCommentArticleURL = '@Url.Action("GetCommentArticle", "Blog", new { area = "Blog" })';
var addCommentURL = '@Url.Action("CreateComment", "Blog", new { area = "Blog" })';
var editCommentURL = '@Url.Action("EditComment", "Blog", new { area = "Blog" })';
var deleteCommentURL = '@Url.Action("DeleteComment", "Blog", new { area = "Blog" })';
var getCommentsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetComments" })';
var getCommentArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetCommentArticle" })';
var addCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreateComment" })';
var editCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditComment" })';
var deleteCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeleteComment" })';
</script>

@Styles.Render("~/Content/blog")
@@ -37,7 +37,7 @@
<div class="row">
<div class="col-sm-12 text-center">
<p>
<a href="@Url.SubAction("rss", "Blog", "RSS", new { area = "RSS", username = (Model.BlogId == Constants.SERVERBLOGID) ? string.Empty : Model.User.Username })"><i class="fa fa-rss fa-2x fa-border"></i></a>
<a href="@Url.SubRouteUrl("rss", "RSS.Blog", new { username = (Model.BlogId == Constants.SERVERBLOGID) ? string.Empty : Model.User.Username })"><i class="fa fa-rss fa-2x fa-border"></i></a>
</p>
</div>
</div>

+ 1
- 1
Teknik/Areas/Blog/Views/Blog/Comment.cshtml Datei anzeigen

@@ -16,7 +16,7 @@
<div class="col-sm-8 col-sm-offset-2">
<div class="post-comment">
<p class="post-comment-meta text-muted">
<a href="@Url.SubAction("profile", "Index", "Profile", new { area = "Profile", username = Model.Post.Blog.User.Username })">@Model.Post.Blog.User.Username</a> replied at @Model.DatePosted.ToString("HH:mm:ss tt") on @Model.DatePosted.ToString("MMMM dd, yyyy")
<a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = Model.Post.Blog.User.Username })">@Model.Post.Blog.User.Username</a> replied at @Model.DatePosted.ToString("HH:mm:ss tt") on @Model.DatePosted.ToString("MMMM dd, yyyy")
@if (Model.Post.Blog.User.Username == User.Identity.Name || User.IsInRole("Admin"))
{
<br />

+ 2
- 2
Teknik/Areas/Blog/Views/Blog/Post.cshtml Datei anzeigen

@@ -14,9 +14,9 @@
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="blog-post">
<h2 class="blog-post-title text-center"><a href="@Url.SubAction("blog", "Post", "Blog", new { area = "Blog", username = Model.Blog.User.Username, id = Model.PostId })" id="title_@Model.PostId">@Model.Title</a></h2>
<h2 class="blog-post-title text-center"><a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = Model.Blog.User.Username, id = Model.PostId })" id="title_@Model.PostId">@Model.Title</a></h2>
<p class="blog-post-meta text-center text-muted">
Posted on @Model.DatePublished.ToString("MMMM dd, yyyy") by <a href="@Url.SubAction("profile", "Index", "Profile", new { area = "Profile", username = Model.Blog.User.Username })">@Model.Blog.User.Username</a>
Posted on @Model.DatePublished.ToString("MMMM dd, yyyy") by <a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = Model.Blog.User.Username })">@Model.Blog.User.Username</a>
@if (Model.Blog.User.Username == User.Identity.Name || User.IsInRole("Admin"))
{
<br />

+ 14
- 14
Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml Datei anzeigen

@@ -5,21 +5,21 @@
<script>
// We need to define the action URLs for the script

var uploadURL = '@Url.Action("UploadFile", "Upload", new { area = "Upload" })';
var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Upload")';

var getPostsURL = '@Url.Action("GetPosts", "Blog", new { area = "Blog" })';
var getPostTitleURL = '@Url.Action("GetPostTitle", "Blog", new { area = "Blog" })';
var getPostArticleURL = '@Url.Action("GetPostArticle", "Blog", new { area = "Blog" })';
var publishPostURL = '@Url.Action("PublishPost", "Blog", new { area = "Blog" })';
var addPostURL = '@Url.Action("CreatePost", "Blog", new { area = "Blog" })';
var editPostURL = '@Url.Action("EditPost", "Blog", new { area = "Blog" })';
var deletePostURL = '@Url.Action("DeletePost", "Blog", new { area = "Blog" })';
var getPostsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPosts" })';
var getPostTitleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostTitle" })';
var getPostArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetPostArticle" })';
var publishPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "PublishPost" })';
var addPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreatePost" })';
var editPostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditPost" })';
var deletePostURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeletePost" })';

var getCommentsURL = '@Url.Action("GetComments", "Blog", new { area = "Blog" })';
var getCommentArticleURL = '@Url.Action("GetCommentArticle", "Blog", new { area = "Blog" })';
var addCommentURL = '@Url.Action("CreateComment", "Blog", new { area = "Blog" })';
var editCommentURL = '@Url.Action("EditComment", "Blog", new { area = "Blog" })';
var deleteCommentURL = '@Url.Action("DeleteComment", "Blog", new { area = "Blog" })';
var getCommentsURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetComments" })';
var getCommentArticleURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "GetCommentArticle" })';
var addCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "CreateComment" })';
var editCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "EditComment" })';
var deleteCommentURL = '@Url.SubRouteUrl("blog", "Blog.Action", new { action = "DeleteComment" })';
</script>

@Styles.Render("~/Content/blog")
@@ -65,7 +65,7 @@
}

<ol class="breadcrumb">
<li><a href="@Url.SubAction("blog", "Blog", "Blog", new { area = "Blog", username = (Model.BlogId == Constants.SERVERBLOGID) ? string.Empty : Model.Blog.User.Username })">@((Model.BlogId == Constants.SERVERBLOGID) ? Model.Config.BlogConfig.Title : Model.Blog.Title)</a></li>
<li><a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = (Model.BlogId == Constants.SERVERBLOGID) ? string.Empty : Model.Blog.User.Username })">@((Model.BlogId == Constants.SERVERBLOGID) ? Model.Config.BlogConfig.Title : Model.Blog.Title)</a></li>
<li class="active"><a href="#">@Model.Title</a></li>
</ol>


+ 18
- 4
Teknik/Areas/Contact/ContactAreaRegistration.cs Datei anzeigen

@@ -16,16 +16,30 @@ namespace Teknik.Areas.Contact
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Contact_dev", // Route name
"Contact.Index", // Route name
"dev",
"Contact/{controller}/{action}", // URL with parameters
"Contact/", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ContactController).Namespace }
);
context.MapSubdomainRoute(
"Contact_default", // Route name
"Contact.Action", // Route name
"dev",
"Contact/{action}", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ContactController).Namespace }
);
context.MapSubdomainRoute(
"Contact.Index", // Route name
"contact",
"", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ContactController).Namespace }
);
context.MapSubdomainRoute(
"Contact.Action", // Route name
"contact",
"{controller}/{action}", // URL with parameters
"{action}", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ContactController).Namespace }
);

+ 1
- 1
Teknik/Areas/Contact/Views/Contact/Index.cshtml Datei anzeigen

@@ -14,7 +14,7 @@
<div class="row">
<div class="col-md-8">
<div class="well well-sm">
<form role="form" id="contactForm" action="@Url.Action("Submit", "Contact", new { area = "Contact" })" method="post" accept-charset="UTF-8">
<form role="form" id="contactForm" action="@Url.SubRouteUrl("contact", "Contact.Action", new { action = "Submit" })" method="post" accept-charset="UTF-8">
@Html.ValidationSummary(true, "Message send failed.")
<div class="row">
<div class="col-md-6">

+ 1
- 1
Teknik/Areas/Dev/DevAreaRegistration.cs Datei anzeigen

@@ -16,7 +16,7 @@ namespace Teknik.Areas.Dev
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Dev_subdomain", // Route name
"Dev.Index", // Route name
"dev",
"Dev/{controller}/{action}", // URL with parameters
new { controller = "Dev", action = "Index" }, // Parameter defaults

+ 1
- 4
Teknik/Areas/Dev/Views/Dev/Index.cshtml Datei anzeigen

@@ -1,4 +1 @@

Testing Dev

@Html.ActionLink("Main Area", "Index", "Blog", new { area = "Blog" }, null)


+ 1
- 1
Teknik/Areas/Error/ErrorAreaRegistration.cs Datei anzeigen

@@ -15,7 +15,7 @@ namespace Teknik.Areas.Error
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Error_404", // Route name
"Error.Http404", // Route name
"*",
"Error/404", // URL with parameters
new { controller = "Error", action = "Http404" }, // Parameter defaults

+ 2
- 2
Teknik/Areas/Error/Views/Error/Exception.cshtml Datei anzeigen

@@ -24,11 +24,11 @@
</div>
<br />
<div class="error-actions">
<a href="@Url.SubAction("www", "Index", "Home", new { area = "Home"})" class="btn btn-primary btn-lg">
<a href="@Url.SubRouteUrl("www", "Home.Index")" class="btn btn-primary btn-lg">
<span class="glyphicon glyphicon-home"></span>
Take Me Home
</a>
<a href="@Url.SubAction("contact", "Index", "Contact", new { area = "Contact"})" class="btn btn-default btn-lg">
<a href="@Url.SubRouteUrl("contact", "Contact.Index")" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-envelope"></span>
Contact Support
</a>

+ 2
- 2
Teknik/Areas/Error/Views/Error/General.cshtml Datei anzeigen

@@ -10,10 +10,10 @@
Sorry, an error has occured: @Model.Description
</div>
<div class="error-actions">
<a href="@Url.SubAction("www", "Index", "Home", new { area = "Home"})" class="btn btn-primary btn-lg">
<a href="@Url.SubRouteUrl("www", "Home.Index")" class="btn btn-primary btn-lg">
<span class="glyphicon glyphicon-home"></span>
Take Me Home
</a><a href="@Url.SubAction("contact", "Index", "Contact", new { area = "Contact"})" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-envelope"></span> Contact Support </a>
</a><a href="@Url.SubRouteUrl("contact", "Contact.Index")" class="btn btn-default btn-lg"><span class="glyphicon glyphicon-envelope"></span> Contact Support </a>
</div>
</div>
</div>

+ 2
- 2
Teknik/Areas/Error/Views/Error/Http404.cshtml Datei anzeigen

@@ -11,11 +11,11 @@
</div>
<br />
<div class="error-actions">
<a href="@Url.SubAction("www", "Index", "Home", new { area = "Home"})" class="btn btn-primary btn-lg">
<a href="@Url.SubRouteUrl("www", "Home.Index")" class="btn btn-primary btn-lg">
<span class="glyphicon glyphicon-home"></span>
Take Me Home
</a>
<a href="@Url.SubAction("contact", "Index", "Contact", new { area = "Contact"})" class="btn btn-default btn-lg">
<a href="@Url.SubRouteUrl("contact", "Contact.Index")" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-envelope"></span>
Contact Support
</a>

+ 2
- 2
Teknik/Areas/Error/Views/Error/Http500.cshtml Datei anzeigen

@@ -25,11 +25,11 @@
</div>
<br />
<div class="error-actions">
<a href="@Url.SubAction("www", "Index", "Home", new { area = "Home"})" class="btn btn-primary btn-lg">
<a href="@Url.SubRouteUrl("www", "Home.Index")" class="btn btn-primary btn-lg">
<span class="glyphicon glyphicon-home"></span>
Take Me Home
</a>
<a href="@Url.SubAction("contact", "Index", "Contact", new { area = "Contact"})" class="btn btn-default btn-lg">
<a href="@Url.SubRouteUrl("contact", "Contact.Index")" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-envelope"></span>
Contact Support
</a>

+ 4
- 4
Teknik/Areas/Home/HomeAreaRegistration.cs Datei anzeigen

@@ -17,28 +17,28 @@ namespace Teknik.Areas.Home
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Home_dev", // Route name
"Home.Index", // Route name
"dev",
"Home", // URL with parameters
new { controller = "Home", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.HomeController).Namespace }
);
context.MapSubdomainRoute(
"Home_dev_blank", // Route name
"Home.Default", // Route name
"dev",
"", // URL with parameters
new { controller = "Home", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.HomeController).Namespace }
);
context.MapSubdomainRoute(
"Home_subdomain", // Route name
"Home.Index", // Route name
"www",
"", // URL with parameters
new { controller = "Home", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.HomeController).Namespace }
);
context.MapSubdomainRoute(
"Home_default", // Route name
"Home.Index", // Route name
string.Empty,
"", // URL with parameters
new { controller = "Home", action = "Index" }, // Parameter defaults

+ 13
- 13
Teknik/Areas/Home/Views/Home/Index.cshtml Datei anzeigen

@@ -20,7 +20,7 @@
<br />
<div class="container">
<div class="row">
<a href="@Url.SubAction("upload", "Index", "Upload", new { area = "Upload"})">
<a href="@Url.SubRouteUrl("upload", "Upload.Index")">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br />
@@ -31,7 +31,7 @@
</div>
</div>
</a>
<a href="@Url.SubAction("paste", "Index", "Paste", new { area = "Paste"})">
<a href="@Url.SubRouteUrl("paste", "Paste.Index")">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br />
@@ -42,7 +42,7 @@
</div>
</div>
</a>
<a href="@Url.SubAction("podcast", "Index", "Podcast", new { area = "Podcast"})">
<a href="@Url.SubRouteUrl("podcast", "Podcast.Index")">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br />
@@ -53,7 +53,7 @@
</div>
</div>
</a>
<a href="@Url.SubAction("help", "Index", "Help", new { area = "Help", section = "Mumble"})">
<a href="@Url.SubRouteUrl("help", "Help.Index", new { section = "Mumble"})">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br />
@@ -73,7 +73,7 @@
</div>
<br/>
<div class="row">
<a href="@Url.SubAction("help", "Index", "Help", new { area = "Help", section = "Mail"})">
<a href="@Url.SubRouteUrl("help", "Help.Index", new { section = "Mail"})">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br/>
@@ -84,7 +84,7 @@
</div>
</div>
</a>
<a href="@Url.SubAction("git", "Index", "Git", new { area = "Git"})">
<a href="@Url.SubRouteUrl("git", "Git.Index")">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br/>
@@ -95,7 +95,7 @@
</div>
</div>
</a>
<a href="@Url.SubAction("blog", "blog", "Blog", new { area = "Blog"})">
<a href="@Url.SubRouteUrl("blog", "Blog.Index")">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br/>
@@ -106,7 +106,7 @@
</div>
</div>
</a>
<a href="@Url.SubAction("help", "Index", "Help", new { area = "Help", section = "Irc"})">
<a href="@Url.SubRouteUrl("help", "Help.Index", new { section = "Irc"})">
<div class="col-md-3 text-center">
<div class="thumbnail">
<br/>
@@ -146,10 +146,10 @@
<div class="col-sm-12">
<div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left">
<a href="@Url.SubAction("blog", "Post", "Blog", new { area = "Blog", username = post.Blog.User.Username, id = post.PostId })" id="title_@post.PostId">@post.Title</a>
<a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = post.Blog.User.Username, id = post.PostId })" id="title_@post.PostId">@post.Title</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on @post.DatePosted.ToString("MMMM dd, yyyy") by <a href="@Url.SubAction("profile", "Index", "Profile", new { area = "Profile", username = post.Blog.User.Username })">@post.Blog.User.Username</a>
Posted on @post.DatePosted.ToString("MMMM dd, yyyy") by <a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = post.Blog.User.Username })">@post.Blog.User.Username</a>
</p>
</div>
</div>
@@ -197,7 +197,7 @@
<div class="col-sm-12">
<div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left">
<a href="@Url.SubAction("podcast", "View", "Podcast", new { area = "Podcast", username = post.Blog.User.Username, id = post.PostId })" id="title_@post.PostId">@post.Title</a>
<a href="@Url.SubRouteUrl("podcast", "Podcast.View", new { username = post.Blog.User.Username, id = post.PostId })" id="title_@post.PostId">@post.Title</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on @post.DatePosted.ToString("MMMM dd, yyyy")
@@ -247,10 +247,10 @@
<div class="row">
<div class="col-sm-12">
<div class="blog-post-sm">
<h2 class="blog-post-title-sm text-left"><a href="@Url.SubAction("blog", "Post", "Blog", new { area = "Blog", username = post.Blog.User.Username, id = post.PostId })" id="title_@post.PostId">@post.Title</a>
<h2 class="blog-post-title-sm text-left"><a href="@Url.SubRouteUrl("blog", "Blog.Post", new { username = post.Blog.User.Username, id = post.PostId })" id="title_@post.PostId">@post.Title</a>
</h2>
<p class="blog-post-meta-sm text-left text-muted">
Posted on @post.DatePosted.ToString("MMMM dd, yyyy") by <a href="@Url.SubAction("profile", "Index", "Profile", new { area = "Profile", username = post.Blog.User.Username })">@post.Blog.User.Username</a>
Posted on @post.DatePosted.ToString("MMMM dd, yyyy") by <a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = post.Blog.User.Username })">@post.Blog.User.Username</a>
</p>
</div>
</div>

+ 2
- 2
Teknik/Areas/Privacy/PrivacyAreaRegistration.cs Datei anzeigen

@@ -15,14 +15,14 @@ namespace Teknik.Areas.Privacy
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Privacy_dev", // Route name
"Privacy.Index", // Route name
"dev",
"Privacy/{controller}/{action}", // URL with parameters
new { controller = "Privacy", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.PrivacyController).Namespace }
);
context.MapSubdomainRoute(
"Privacy_default", // Route name
"Privacy.Index", // Route name
"privacy",
"{controller}/{action}", // URL with parameters
new { controller = "Privacy", action = "Index" }, // Parameter defaults

+ 4
- 3
Teknik/Areas/Profile/Controllers/ProfileController.cs Datei anzeigen

@@ -67,15 +67,16 @@ namespace Teknik.Areas.Profile.Controllers
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Home", new { Area = "Home" });
return Redirect(Url.SubRouteUrl("www", "Home.Index"));
}

[HttpGet]
[AllowAnonymous]
// GET: Profile
public ActionResult Register()
public ActionResult Register(string ReturnUrl)
{
RegisterViewModel model = new RegisterViewModel();
model.ReturnUrl = ReturnUrl;

return View("/Areas/Profile/Views/Profile/ViewRegistration.cshtml", model);
}
@@ -114,7 +115,7 @@ namespace Teknik.Areas.Profile.Controllers
{
return Json(new { error = "Unable to create the user." });
}
return Login(new LoginViewModel { Username = model.Username, Password = model.Password, RememberMe = false });
return Login(new LoginViewModel { Username = model.Username, Password = model.Password, RememberMe = false, ReturnUrl = model.ReturnUrl });
}
return Json(new { error = "You must include all fields." });
}

+ 11
- 11
Teknik/Areas/Profile/ProfileAreaRegistration.cs Datei anzeigen

@@ -15,70 +15,70 @@ namespace Teknik.Areas.Profile
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Profile_dev_login", // Route name
"Profile.Login", // Route name
"dev",
"Profile/Login", // URL with parameters
new { controller = "Profile", action = "Login" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_dev_logout", // Route name
"Profile.Logout", // Route name
"dev",
"Profile/Logout", // URL with parameters
new { controller = "Profile", action = "Logout" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_dev_Register", // Route name
"Profile.Register", // Route name
"dev",
"Profile/Login", // URL with parameters
new { controller = "Profile", action = "Register" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_dev", // Route name
"Profile.Index", // Route name
"dev",
"Profile/{username}", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults
new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_dev_unique", // Route name
"Profile.Action", // Route name
"dev",
"Profile/{controller}/{action}", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default_login", // Route name
"Profile.Login", // Route name
"profile",
"Login", // URL with parameters
new { controller = "Profile", action = "Login" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default_logout", // Route name
"Profile.Logout", // Route name
"profile",
"Logout", // URL with parameters
new { controller = "Profile", action = "Logout" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default_register", // Route name
"Profile.Register", // Route name
"profile",
"Register", // URL with parameters
new { controller = "Profile", action = "Register" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default", // Route name
"Profile.Index", // Route name
"profile",
"{username}", // URL with parameters
new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default_unique", // Route name
"Profile.Action", // Route name
"profile",
"{controller}/{action}", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults

+ 2
- 0
Teknik/Areas/Profile/ViewModels/RegisterViewModel.cs Datei anzeigen

@@ -24,5 +24,7 @@ namespace Teknik.Areas.Profile.ViewModels
[Display(Name = "Confirm Password")]
[DataType(DataType.Password)]
public string ConfirmPassword { get; set; }

public string ReturnUrl { get; set; }
}
}

+ 2
- 6
Teknik/Areas/Profile/Views/Profile/Login.cshtml Datei anzeigen

@@ -1,16 +1,12 @@
@model Teknik.Areas.Profile.ViewModels.LoginViewModel

@using (Html.BeginForm("Login", "Profile", new { area = "Profile" }, FormMethod.Post, new { id = "loginForm" }))
{
@Html.ValidationMessage("Unable to login.")
<form role="form" id="loginForm" action="@Url.SubRouteUrl("profile", "Profile.Login")" method="post" accept-charset="UTF-8">
<input name="ReturnUrl" id="ReturnUrl" type="hidden" value="@Model.ReturnUrl" />
<div class="form-group">
<input type="text" class="form-control" id="Username" value="" placeholder="Username" name="Username" data-val-required="The Username field is required." data-val="true" />
@Html.ValidationMessageFor(u => u.Username)
</div>
<div class="form-group">
<input type="password" class="form-control" id="Password" value="" placeholder="Password" name="Password" data-val-required="The Password field is required." data-val="true" />
@Html.ValidationMessageFor(u => u.Password)
</div>
<div class="checkbox">
<label>
@@ -20,4 +16,4 @@
<div class="form-group text-center">
<button class="btn btn-primary" id="login_submit" type="submit" name="submit">Sign In</button>
</div>
}
</form>

+ 2
- 1
Teknik/Areas/Profile/Views/Profile/Register.cshtml Datei anzeigen

@@ -1,6 +1,7 @@
@model Teknik.Areas.Profile.ViewModels.RegisterViewModel

<form role="form" id="registrationForm" action="@Url.Action("Register", "Profile", new { area = "Profile" })" method="post" accept-charset="UTF-8">
<form role="form" id="registrationForm" action="@Url.Action("profile", "Profile.Register")" method="post" accept-charset="UTF-8">
<input name="ReturnUrl" id="ReturnUrl" type="hidden" value="@Model.ReturnUrl" />
<div class="form-group">
<input type="text" class="form-control" id="Username" value="" placeholder="Username" name="Username" data-val-required="The Username field is required." data-val="true"/>
</div>

+ 4
- 11
Teknik/Areas/Profile/Views/Profile/ViewLogin.cshtml Datei anzeigen

@@ -3,17 +3,10 @@
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="error-template text-center">
<h1>No Access</h1>
<h2>403 Access Denied</h2>
<div class="error-details">
You aren't allowed to see this! If you think you are, then please login below.
</div>
<br />
<div class="error-actions">
<div class="col-md-4 col-md-offset-4">
@Html.Partial("../../Areas/Profile/Views/Profile/Login", Model)
</div>
<div class="text-center">
<h1>Teknik Login</h1>
<div class="col-md-4 col-md-offset-4">
@Html.Partial("../../Areas/Profile/Views/Profile/Login", Model)
</div>
</div>
</div>

+ 15
- 1
Teknik/Areas/Profile/Views/Profile/ViewRegistration.cshtml Datei anzeigen

@@ -1 +1,15 @@

@model Teknik.Areas.Profile.ViewModels.RegisterViewModel

<div class="container">
<div class="row">
<div class="col-md-12">
<div class="text-center">
<h1>Teknik Registration</h1>
<h3>By regsitering, you agree to Teknik's <a href="@Url.SubRouteUrl("tos", "Terms")">Terms of Service</a></h3>
<div class="col-md-4 col-md-offset-4">
@Html.Partial("../../Areas/Profile/Views/Profile/Register", Model)
</div>
</div>
</div>
</div>
</div>

+ 17
- 17
Teknik/Areas/Upload/UploadAreaRegistration.cs Datei anzeigen

@@ -16,84 +16,84 @@ namespace Teknik.Areas.Upload
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Upload_dev",
"Upload.Index",
"dev",
"Upload",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_dev_download",
"Upload.Download",
"dev",
"Upload/{url}",
new { controller = "Upload", action = "Download", url = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_dev_delete",
"Upload.Delete",
"dev",
"Upload/{url}/{deleteKey}",
new { controller = "Upload", action = "Download", url = string.Empty, deleteKey = string.Empty },
new { controller = "Upload", action = "Delete", url = string.Empty, deleteKey = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_dev_action",
"Upload.Action",
"dev",
"Upload/Action/{controller}/{action}",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_short",
"Upload.Index",
"u",
"",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_short_download",
"Upload.Download",
"u",
"{url}",
new { controller = "Upload", action = "Download", url = "" },
new { controller = "Upload", action = "Download", url = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_short_delete",
"Upload.Delete",
"u",
"{url}/{deleteKey}",
new { controller = "Upload", action = "Download", url = string.Empty, deleteKey = string.Empty },
new { controller = "Upload", action = "Delete", url = string.Empty, deleteKey = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_short_action",
"Upload.Action",
"u",
"Action/{controller}/{action}",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_long",
"Upload.Index",
"upload",
"",
new { controller = "Upload", action = "Index" },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_long_download",
"Upload.Download",
"upload",
"{url}",
new { controller = "Upload", action = "Index" },
new { controller = "Upload", action = "Download", url = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_long_delete",
"Upload.Delete",
"upload",
"{url}/{deleteKey}",
new { controller = "Upload", action = "Index", url = string.Empty, deleteKey = string.Empty },
new { controller = "Upload", action = "Delete", url = string.Empty, deleteKey = string.Empty },
new[] { typeof(Controllers.UploadController).Namespace }
);
context.MapSubdomainRoute(
"Upload_default_long_action",
"Upload.Action",
"upload",
"Action/{controller}/{action}",
new { controller = "Upload", action = "Index" },

+ 3
- 3
Teknik/Areas/Upload/Views/Upload/Index.cshtml Datei anzeigen

@@ -1,8 +1,8 @@
@model Teknik.Areas.Upload.ViewModels.UploadViewModel

<script>
var generateDeleteKeyURL = '@Url.Action("GenerateDeleteKey", "Upload", new { area = "Upload" })';
var uploadURL = '@Url.Action("Download", "Upload", new { area = "Upload", url = string.Empty })';
var generateDeleteKeyURL = '@Url.SubRouteUrl("upload", "Upload.Action", new { action= "GenerateDeleteKey" })';
var uploadURL = '@Url.SubRouteUrl("upload", "Upload.Download")';
var maxUploadSize = @(Model.Config.UploadConfig.MaxUploadSize / 100000);
</script>

@@ -10,7 +10,7 @@

<div class="container">
<div class="row text-center">
<form action="@Url.Action("Upload", "Upload", new { area = "Upload" })" class="dropzone" id="TeknikUpload" name="TeknikUpload">
<form action="@Url.SubRouteUrl("upload", "Upload.Upload")" class="dropzone" id="TeknikUpload" name="TeknikUpload">
@Html.AntiForgeryToken()
<div class="dz-message text-center" id="upload_message">
<div class="row">

+ 42
- 34
Teknik/Helpers/UrlExtensions.cs Datei anzeigen

@@ -2,39 +2,41 @@
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.UI;

namespace Teknik
{
public static class UrlExtensions
{
public static string SubRouteUrl(this UrlHelper url, string sub, string routeName)
{
return url.SubRouteUrl(sub, routeName, null);
}

/// <summary>
/// Generates a full URL given the specified sub domain.
/// If the subdomain is not 'dev', the Controller will be removed
/// Generates a full URL given the specified sub domain and route name
/// </summary>
/// <param name="url"></param>
/// <param name="sub"></param>
/// <param name="action"></param>
/// <param name="controller"></param>
/// <param name="routeName"></param>
/// <param name="routeValues"></param>
/// <returns></returns>
public static string SubAction(this UrlHelper url, string sub, string action, string controller, object routeValues)
public static string SubRouteUrl(this UrlHelper url, string sub, string routeName, object routeValues)
{
Uri requestUrl = url.RequestContext.HttpContext.Request.Url;
string host = url.RequestContext.HttpContext.Request.Url.Authority;
string paramSub = string.Empty;
string domain = host;
string rightUrl = string.Empty;

// get current subdomain
string curSub = string.Empty;
string curSub = host.GetSubdomain();
var split = host.Split('.'); // split the host by '.'
if (split.Count() > 2)
{
curSub = split[0];
int index = host.IndexOf('.') + 1;
if (index >= 0 && index < host.Length)
domain = host.Substring(index, (host.Length - index));
@@ -42,42 +44,33 @@ namespace Teknik

// Grab the sub from parameters if it exists
string subParam = url.RequestContext.HttpContext.Request.QueryString["sub"]; // A subdomain specified as a query parameter takes precedence over the hostname.
string fullHost = url.RequestContext.HttpContext.Request.Headers["Host"];

// If the param is not being used, we will use the curSub
if (string.IsNullOrEmpty(subParam))
{
// If we are in dev, we need to keep it in dev
string firstSub = (curSub == "dev") ? "dev" : sub;
rightUrl = url.Action(action, controller, Utility.Merge(new { sub = sub }, routeValues));

domain = (string.IsNullOrEmpty(firstSub)) ? domain : firstSub + "." + domain;
if (!string.IsNullOrEmpty(firstSub))
{
routeName = firstSub + "." + routeName;
domain = firstSub + "." + domain;
}
}
else
{
//
if (subParam != "dev")
{
// replace the host and sub param in the context in order to generate the correct URLs
string newUrl = url.RequestContext.HttpContext.Request.Url.AbsoluteUri.SetUrlParameter("sub", sub);
url.RequestContext.HttpContext.RewritePath(url.RequestContext.HttpContext.Request.Path, url.RequestContext.HttpContext.Request.PathInfo, newUrl.GetUrlParameters());
// get the url for the new sub
rightUrl = url.Action(action, controller, routeValues);
var page = url.RequestContext.HttpContext.Handler as Page;
rightUrl = page.GetRouteUrl(new { sub = sub });
// Reset the url
string oldUrl = url.RequestContext.HttpContext.Request.Url.AbsoluteUri.SetUrlParameter("sub", subParam);
url.RequestContext.HttpContext.RewritePath(url.RequestContext.HttpContext.Request.Path, url.RequestContext.HttpContext.Request.PathInfo, newUrl.GetUrlParameters());
}
else // 'dev' is in the param, so we need to generate the action based on
{
rightUrl = url.Action(action, controller, routeValues);
}

// if using sub param, keep domain as is
string desiredSub = (subParam == "dev") ? "dev" : sub;
routeName = desiredSub + "." + routeName;
domain = host;
}

try
{
rightUrl = url.RouteUrl(routeName, routeValues);
}
catch (ArgumentException)
{

}

string absoluteAction = string.Format("{0}://{1}{2}", url.RequestContext.HttpContext.Request.Url.Scheme, domain, rightUrl);

if (!string.IsNullOrEmpty(subParam) && subParam != "dev")
@@ -110,5 +103,20 @@ namespace Teknik
{
return url.AbsoluteUri.Split('?').FirstOrDefault() ?? String.Empty;
}
public static string GetSubdomain(this string host)
{
if (host.IndexOf(":") >= 0)
host = host.Substring(0, host.IndexOf(":"));

Regex tldRegex = new Regex(@"\.[a-z]{2,3}\.[a-z]{2}$");
host = tldRegex.Replace(host, "");
tldRegex = new Regex(@"\.[a-z]{2,4}$");
host = tldRegex.Replace(host, "");

if (host.Split('.').Length > 1)
return host.Substring(0, host.IndexOf("."));
else
return string.Empty;
}
}
}

+ 0
- 2
Teknik/Teknik.csproj Datei anzeigen

@@ -317,9 +317,7 @@
</Content>
<Content Include="Views\Web.config" />
<Content Include="Views\_ViewStart.cshtml" />
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\Shared\Lockout.cshtml" />
<Content Include="Views\Shared\_LoginPartial.cshtml" />
<Content Include="Views\Shared\_Navbar.cshtml" />
<Content Include="Views\Shared\_Footer.cshtml" />

+ 0
- 17
Teknik/Views/Shared/Error.cshtml Datei anzeigen

@@ -1,17 +0,0 @@
{
Layout = null;
}

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Error</title>
</head>
<body>
<hgroup>
<h1>Error.</h1>
<h2>An error occurred while processing your request.</h2>
</hgroup>
</body>
</html>

+ 0
- 10
Teknik/Views/Shared/Lockout.cshtml Datei anzeigen

@@ -1,10 +0,0 @@
@model System.Web.Mvc.HandleErrorInfo

@{
ViewBag.Title = "Locked Out";
}

<hgroup>
<h1 class="text-danger">Locked out.</h1>
<h2 class="text-danger">This account has been locked out, please try again later.</h2>
</hgroup>

+ 1
- 1
Teknik/Views/Shared/_Footer.cshtml Datei anzeigen

@@ -9,7 +9,7 @@
string version = fileVersionInfo.ProductVersion;
}
<p class="text-muted">
&copy; Teknik 2013-2015 | <a href="@Url.SubAction("privacy", "Index", "Privacy", new { area = "Privacy"})">Privacy</a> | <a href="@Url.SubAction("transparency", "Index", "Transparency", new { area = "Transparency" })">Transparency</a> | <a href="@Url.SubAction("server", "Index", "Server", new { area = "Server" })">Server</a>
&copy; Teknik 2013-2015 | <a href="@Url.SubRouteUrl("privacy", "Privacy.Index")">Privacy</a> | <a href="@Url.SubRouteUrl("transparency", "Transparency.Index")">Transparency</a> | <a href="@Url.SubRouteUrl("server", "Server.Index")">Server</a>
<br />
@string.Format("{0}", version)
</p>

+ 4
- 4
Teknik/Views/Shared/_LoginPartial.cshtml Datei anzeigen

@@ -7,19 +7,19 @@
<a href="#" id="user_menu" class="dropdown-toggle" data-toggle="dropdown">@User.Identity.Name <strong class="caret"></strong></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="user_menu">
<li>
<a href="@Url.SubAction("profile", "Index", "Profile", new { area = "Profile", username = User.Identity.Name })">Profile</a>
<a href="@Url.SubRouteUrl("profile", "Profile.Index", new { username = User.Identity.Name })">Profile</a>
</li>
<li>
<a href="@Url.SubAction("blog", "Blog", "Blog", new { area = "Blog", username = User.Identity.Name })">Blog</a>
<a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = User.Identity.Name })">Blog</a>
</li>
@if (User.IsInRole("Admin"))
{
<li>
<a href="@Url.SubAction("admin", "Index", "Admin", new { area = "Admin" })">Administration</a>
<a href="@Url.SubRouteUrl("admin", "Admin.Index")">Administration</a>
</li>
}
<li>
<a href="@Url.SubAction("profile", "Logout", "Profile", new { area = "Profile" })">Sign Out</a>
<a href="@Url.SubRouteUrl("profile", "Profile.Logout")">Sign Out</a>
</li>
</ul>
</li>

+ 12
- 12
Teknik/Views/Shared/_Navbar.cshtml Datei anzeigen

@@ -8,50 +8,50 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="@Url.SubAction("www", "Index", "Home", new { area = "Home" })"><img src="/Images/logo-black.svg" height="20" alt="Teknik"></a>
<a class="navbar-brand" href="@Url.SubRouteUrl("www", "Home.Index")"><img src="/Images/logo-black.svg" height="20" alt="Teknik"></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="@Url.SubAction("www", "Index", "Home", new { area = "Home" })">Home</a></li>
<li><a href="@Url.SubAction("about", "Index", "About", new { area = "About" })">About</a></li>
<li><a href="@Url.SubRouteUrl("www", "Home.Index")">Home</a></li>
<li><a href="@Url.SubRouteUrl("about", "About.Index")">About</a></li>
<li class="divider-vertical"></li>

<li class="dropdown">
<a href="#" id="services_menu" class="dropdown-toggle" data-toggle="dropdown">Services <strong class="caret"></strong></a>
<ul class="dropdown-menu" role="menu" aria-labelledby="services_menu">
<li>
<a href="@Url.SubAction("blog", "Blog", "Blog", new { area = "Blog", username = string.Empty })">Blog</a>
<a href="@Url.SubRouteUrl("blog", "Blog.Blog", new { username = string.Empty })">Blog</a>
</li>
<li>
<a href="@Url.SubAction("podcast", "Index", "Podcast", new { area = "Podcast" })">Podcast</a>
<a href="@Url.SubRouteUrl("podcast", "Podcast.Index")">Podcast</a>
</li>
<li class="divider"></li>
<li>
<a href="@Url.SubAction("upload", "Index", "Upload", new { area = "Upload" })">Upload</a>
<a href="@Url.SubRouteUrl("upload", "Upload.Index")">Upload</a>
</li>
<li>
<a href="@Url.SubAction("paste", "Index", "Paste", new { area = "Paste" })">Paste</a>
<a href="@Url.SubRouteUrl("paste", "Paste.Index")">Paste</a>
</li>
<li>
<a href="@Url.SubAction("git", "Index", "Git", new { area = "Git" })">Git</a>
<a href="@Url.SubRouteUrl("git", "Git.Index")">Git</a>
</li>
<li>
<a href="@Url.SubAction("mail", "Index", "Mail", new { area = "Mail" })" target="_blank">Mail</a>
<a href="@Url.SubRouteUrl("mail", "Mail.Index")" target="_blank">Mail</a>
</li>
<li>
<a href="mumble://mumble.@(Model.Config.Host):64738/?version=1.2.5" target="_blank">Mumble</a>
</li>
<li class="divider"></li>
<li>
<a href="@Url.SubAction("ricehalla", "Index", "Ricehalla", new { area = "Ricehalla" })">Ricehalla</a>
<a href="@Url.SubRouteUrl("ricehalla", "Ricehalla.Index")">Ricehalla</a>
</li>
</ul>
</li>
<li>
<a href="@Url.SubAction("contact", "Index", "Contact", new { area = "Contact" })">Contact</a>
<a href="@Url.SubRouteUrl("contact", "Contact.Index")">Contact</a>
</li>
<li>
<a href="@Url.SubAction("help", "Index", "Help", new { area = "Help" })">Help</a>
<a href="@Url.SubRouteUrl("help", "Help.Index")">Help</a>
</li>
</ul>
@Html.Partial("_LoginPartial")

Laden…
Abbrechen
Speichern