Browse Source

- Removed uneeded 'dev' subdomains from routes.

- Made url shortening require absolute url
tags/2.0.3
Teknikode 4 years ago
parent
commit
f848ff9f42

+ 4
- 4
Teknik/Areas/API/APIAreaRegistration.cs View File

@@ -21,7 +21,7 @@ namespace Teknik.Areas.API
// Base Routing
context.MapSubdomainRoute(
"API.v1.Index", // Route name
new List<string>() { "dev", "api" },
new List<string>() { "api" },
new List<string>() { config.Host },
"v1", // URL with parameters
new { controller = "APIv1", action = "Index" }, // Parameter defaults
@@ -30,7 +30,7 @@ namespace Teknik.Areas.API
// Uploads
context.MapSubdomainRoute(
"API.v1.Upload", // Route name
new List<string>() { "dev", "api" },
new List<string>() { "api" },
new List<string>() { config.Host },
"v1/Upload", // URL with parameters
new { controller = "APIv1", action = "Upload" }, // Parameter defaults
@@ -38,7 +38,7 @@ namespace Teknik.Areas.API
);
context.MapSubdomainRoute(
"API.v1.Paste", // Route name
new List<string>() { "dev", "api" },
new List<string>() { "api" },
new List<string>() { config.Host },
"v1/Paste", // URL with parameters
new { controller = "APIv1", action = "Paste" }, // Parameter defaults
@@ -49,7 +49,7 @@ namespace Teknik.Areas.API
// Default Routing
context.MapSubdomainRoute(
"API.Index", // Route name
new List<string>() { "dev", "" },
new List<string>() { "api" },
new List<string>() { config.Host },
"", // URL with parameters
new { controller = "API", action = "Index" }, // Parameter defaults

+ 1
- 1
Teknik/Areas/About/AboutAreaRegistration.cs View File

@@ -19,7 +19,7 @@ namespace Teknik.Areas.About
Config config = Config.Load();
context.MapSubdomainRoute(
"About.Index", // Route name
new List<string>() { "dev", "about" },
new List<string>() { "about" },
new List<string>() { config.Host },
"", // URL with parameters
new { controller = "About", action = "Index" }, // Parameter defaults

+ 3
- 3
Teknik/Areas/Blog/BlogAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Blog
Config config = Config.Load();
context.MapSubdomainRoute(
"Blog.Blog", // Route name
new List<string>() { "dev", "blog" }, // Subdomains
new List<string>() { "blog" }, // Subdomains
new List<string>() { config.Host },
"{username}", // URL with parameters
new { controller = "Blog", action = "Blog", username = string.Empty }, // Parameter defaults
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Blog
);
context.MapSubdomainRoute(
"Blog.Post", // Route name
new List<string>() { "dev", "blog" }, // Subdomains
new List<string>() { "blog" }, // Subdomains
new List<string>() { config.Host },
"{username}/{id}", // URL with parameters
new { controller = "Blog", action = "Post", username = "", id = 0 }, // Parameter defaults
@@ -36,7 +36,7 @@ namespace Teknik.Areas.Blog
);
context.MapSubdomainRoute(
"Blog.Action", // Route name
new List<string>() { "dev", "blog" }, // Subdomains
new List<string>() { "blog" }, // Subdomains
new List<string>() { config.Host },
"Action/{controller}/{action}", // URL with parameters
new { controller = "Blog", action = "Blog" }, // Parameter defaults

+ 2
- 2
Teknik/Areas/Contact/ContactAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Contact
Config config = Config.Load();
context.MapSubdomainRoute(
"Contact.Index", // Route name
new List<string>() { "dev", "contact" }, // Subdomains
new List<string>() { "contact" }, // Subdomains
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Contact
);
context.MapSubdomainRoute(
"Contact.Action", // Route name
new List<string>() { "dev", "contact" }, // Subdomains
new List<string>() { "contact" }, // Subdomains
new List<string>() { config.Host }, // domains
"{action}", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults

+ 9
- 9
Teknik/Areas/Help/HelpAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Help
Config config = Config.Load();
context.MapSubdomainRoute(
"Help.Index", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Help", action = "Index" }, // Parameter defaults
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.API", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"API/{version}/{service}", // URL with parameters
new { controller = "Help", action = "API", version = UrlParameter.Optional, service = UrlParameter.Optional }, // Parameter defaults
@@ -36,7 +36,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.Blog", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"Blog", // URL with parameters
new { controller = "Help", action = "Blog" }, // Parameter defaults
@@ -44,7 +44,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.Git", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"Git", // URL with parameters
new { controller = "Help", action = "Git" }, // Parameter defaults
@@ -52,7 +52,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.IRC", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"IRC", // URL with parameters
new { controller = "Help", action = "IRC" }, // Parameter defaults
@@ -60,7 +60,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.Mail", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"Mail", // URL with parameters
new { controller = "Help", action = "Mail" }, // Parameter defaults
@@ -68,7 +68,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.Mumble", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"Mumble", // URL with parameters
new { controller = "Help", action = "Mumble" }, // Parameter defaults
@@ -76,7 +76,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.RSS", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"RSS", // URL with parameters
new { controller = "Help", action = "RSS" }, // Parameter defaults
@@ -84,7 +84,7 @@ namespace Teknik.Areas.Help
);
context.MapSubdomainRoute(
"Help.Upload", // Route name
new List<string>() { "dev", "help" }, // Subdomains
new List<string>() { "help" }, // Subdomains
new List<string>() { config.Host }, // domains
"Upload", // URL with parameters
new { controller = "Help", action = "Upload" }, // Parameter defaults

+ 1
- 1
Teknik/Areas/Home/HomeAreaRegistration.cs View File

@@ -21,7 +21,7 @@ namespace Teknik.Areas.Home
Config config = Config.Load();
context.MapSubdomainRoute(
"Home.Index", // Route name
new List<string>() { "dev", "www", string.Empty }, // Subdomains
new List<string>() { "www", string.Empty }, // Subdomains
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Home", action = "Index" }, // Parameter defaults

+ 6
- 6
Teknik/Areas/Paste/PasteAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Paste
Config config = Config.Load();
context.MapSubdomainRoute(
"Paste.Index", // Route name
new List<string>() { "dev", "paste", "p" },
new List<string>() { "paste", "p" },
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Paste", action = "Index" }, // Parameter defaults
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Paste
);
context.MapSubdomainRoute(
"Paste.Simple", // Route name
new List<string>() { "dev", "paste", "p" },
new List<string>() { "paste", "p" },
new List<string>() { config.Host }, // domains
"Simple/{url}/{password}", // URL with parameters
new { controller = "Paste", action = "ViewPaste", type = "Simple", password = UrlParameter.Optional }, // Parameter defaults
@@ -36,7 +36,7 @@ namespace Teknik.Areas.Paste
);
context.MapSubdomainRoute(
"Paste.Raw", // Route name
new List<string>() { "dev", "paste", "p" },
new List<string>() { "paste", "p" },
new List<string>() { config.Host }, // domains
"Raw/{url}/{password}", // URL with parameters
new { controller = "Paste", action = "ViewPaste", type = "Raw", password = UrlParameter.Optional }, // Parameter defaults
@@ -44,7 +44,7 @@ namespace Teknik.Areas.Paste
);
context.MapSubdomainRoute(
"Paste.Download", // Route name
new List<string>() { "dev", "paste", "p" },
new List<string>() { "paste", "p" },
new List<string>() { config.Host }, // domains
"Download/{url}/{password}", // URL with parameters
new { controller = "Paste", action = "ViewPaste", type = "Download", password = UrlParameter.Optional }, // Parameter defaults
@@ -52,7 +52,7 @@ namespace Teknik.Areas.Paste
);
context.MapSubdomainRoute(
"Paste.Action", // Route name
new List<string>() { "dev", "paste", "p" },
new List<string>() { "paste", "p" },
new List<string>() { config.Host }, // domains
"Action/{action}", // URL with parameters
new { controller = "Paste", action = "Index" }, // Parameter defaults
@@ -60,7 +60,7 @@ namespace Teknik.Areas.Paste
);
context.MapSubdomainRoute(
"Paste.View", // Route name
new List<string>() { "dev", "paste", "p" },
new List<string>() { "paste", "p" },
new List<string>() { config.Host }, // domains
"{url}/{password}", // URL with parameters
new { controller = "Paste", action = "ViewPaste", type = "Full", password = UrlParameter.Optional }, // Parameter defaults

+ 4
- 4
Teknik/Areas/Podcast/PodcastAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Podcast
Config config = Config.Load();
context.MapSubdomainRoute(
"Podcast.Index", // Route name
new List<string>() { "dev", "podcast" }, // Subdomains
new List<string>() { "podcast" }, // Subdomains
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Podcast", action = "Index" }, // Parameter defaults
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Podcast
);
context.MapSubdomainRoute(
"Podcast.View", // Route name
new List<string>() { "dev", "podcast" }, // Subdomains
new List<string>() { "podcast" }, // Subdomains
new List<string>() { config.Host }, // domains
"{episode}", // URL with parameters
new { controller = "Podcast", action = "View" }, // Parameter defaults
@@ -36,7 +36,7 @@ namespace Teknik.Areas.Podcast
);
context.MapSubdomainRoute(
"Podcast.Download", // Route name
new List<string>() { "dev", "podcast" }, // Subdomains
new List<string>() { "podcast" }, // Subdomains
new List<string>() { config.Host }, // domains
"File/{episode}/{fileName}", // URL with parameters
new { controller = "Podcast", action = "Download" }, // Parameter defaults
@@ -44,7 +44,7 @@ namespace Teknik.Areas.Podcast
);
context.MapSubdomainRoute(
"Podcast.Action", // Route name
new List<string>() { "dev", "podcast" }, // Subdomains
new List<string>() { "podcast" }, // Subdomains
new List<string>() { config.Host }, // domains
"Action/{controller}/{action}", // URL with parameters
new { controller = "Podcast", action = "Index" }, // Parameter defaults

+ 1
- 1
Teknik/Areas/Privacy/PrivacyAreaRegistration.cs View File

@@ -19,7 +19,7 @@ namespace Teknik.Areas.Privacy
Config config = Config.Load();
context.MapSubdomainRoute(
"Privacy.Index", // Route name
new List<string>() { "dev", "privacy" }, // Subdomains
new List<string>() { "privacy" }, // Subdomains
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Privacy", action = "Index" }, // Parameter defaults

+ 6
- 6
Teknik/Areas/Profile/ProfileAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Profile
Config config = Config.Load();
context.MapSubdomainRoute(
"Profile.Login", // Route name
new List<string>() { "dev", "profile", "www", string.Empty }, // Subdomains
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Login", // URL with parameters
new { controller = "Profile", action = "Login" }, // Parameter defaults
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Profile
);
context.MapSubdomainRoute(
"Profile.Logout", // Route name
new List<string>() { "dev", "profile", "www", string.Empty }, // Subdomains
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Logout", // URL with parameters
new { controller = "Profile", action = "Logout" }, // Parameter defaults
@@ -36,7 +36,7 @@ namespace Teknik.Areas.Profile
);
context.MapSubdomainRoute(
"Profile.Register", // Route name
new List<string>() { "dev", "profile", "www", string.Empty }, // Subdomains
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Register", // URL with parameters
new { controller = "Profile", action = "Register" }, // Parameter defaults
@@ -44,7 +44,7 @@ namespace Teknik.Areas.Profile
);
context.MapSubdomainRoute(
"Profile.Settings", // Route name
new List<string>() { "dev", "profile" }, // Subdomains
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Settings", // URL with parameters
new { controller = "Profile", action = "Settings" }, // Parameter defaults
@@ -52,7 +52,7 @@ namespace Teknik.Areas.Profile
);
context.MapSubdomainRoute(
"Profile.Index", // Route name
new List<string>() { "dev", "profile" }, // Subdomains
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"{username}", // URL with parameters
new { controller = "Profile", action = "Index", username = UrlParameter.Optional }, // Parameter defaults
@@ -60,7 +60,7 @@ namespace Teknik.Areas.Profile
);
context.MapSubdomainRoute(
"Profile.Action", // Route name
new List<string>() { "dev", "profile" }, // Subdomains
new List<string>() { "profile" }, // Subdomains
new List<string>() { config.Host }, // domains
"Action/{action}", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults

+ 3
- 3
Teknik/Areas/RSS/RSSAreaRegistration.cs View File

@@ -19,7 +19,7 @@ namespace Teknik.Areas.RSS
Config config = Config.Load();
context.MapSubdomainRoute(
"RSS.Index", // Route name
new List<string>() { "dev", "rss" },
new List<string>() { "rss" },
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "RSS", action = "Index" }, // Parameter defaults
@@ -27,7 +27,7 @@ namespace Teknik.Areas.RSS
);
context.MapSubdomainRoute(
"RSS.Blog", // Route name
new List<string>() { "dev", "rss" },
new List<string>() { "rss" },
new List<string>() { config.Host }, // domains
"Blog/{username}", // URL with parameters
new { controller = "RSS", action = "Blog", username = UrlParameter.Optional }, // Parameter defaults
@@ -35,7 +35,7 @@ namespace Teknik.Areas.RSS
);
context.MapSubdomainRoute(
"RSS.Podcast", // Route name
new List<string>() { "dev", "rss" },
new List<string>() { "rss" },
new List<string>() { config.Host }, // domains
"Podcast", // URL with parameters
new { controller = "RSS", action = "Podcast" }, // Parameter defaults

+ 9
- 3
Teknik/Areas/Shortener/Controllers/ShortenerController.cs View File

@@ -31,7 +31,7 @@ namespace Teknik.Areas.Shortener.Controllers
shortUrl.Views += 1;
db.Entry(shortUrl).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
return RedirectToUrl(shortUrl.OriginalUrl);
return Redirect(shortUrl.OriginalUrl);
}
return Redirect(Url.SubRouteUrl("error", "Error.Http404"));
}
@@ -56,11 +56,17 @@ namespace Teknik.Areas.Shortener.Controllers
db.ShortenedUrls.Add(newUrl);
db.SaveChanges();

return Json(new { result = new { shortUrl = string.Format("http://{0}/{1}", Config.ShortenerConfig.ShortenerHost, newUrl.ShortUrl), originalUrl = url } });
string shortUrl = Url.SubRouteUrl(string.Empty, "Shortener.View", new { url = newUrl.ShortUrl });
if (Config.DevEnvironment)
{
shortUrl = Url.SubRouteUrl("shortened", "Shortener.View", new { url = newUrl.ShortUrl });
}

return Json(new { result = new { shortUrl = shortUrl, originalUrl = url } });
}
else
{
return Json(new { error = "Must be a valid HTTP or HTTPS Url" });
return Json(new { error = "Must be a valid Url" });
}
}
}

+ 3
- 3
Teknik/Areas/Shortener/ShortenerAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Shortener
Config config = Config.Load();
context.MapSubdomainRoute(
"Shortener.Index", // Route name
new List<string>() { "dev", "shorten", "s" }, // Subdomains
new List<string>() { "shorten", "s" }, // Subdomains
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Shortener", action = "Index" }, // Parameter defaults
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Shortener
);
context.MapSubdomainRoute(
"Shortener.Action", // Route name
new List<string>() { "dev", "shorten", "s" }, // Subdomains
new List<string>() { "shorten", "s" }, // Subdomains
new List<string>() { config.Host }, // domains
"Action/{action}", // URL with parameters
new { controller = "Shortener", action = "Index" }, // Parameter defaults
@@ -36,7 +36,7 @@ namespace Teknik.Areas.Shortener
);
context.MapSubdomainRoute(
"Shortener.View", // Route name
new List<string>() { "dev", "*" }, // Subdomains
new List<string>() { string.Empty, "shortened" }, // Subdomains
new List<string>() { config.ShortenerConfig.ShortenerHost }, // domains
"{url}", // URL with parameters
new { controller = "Shortener", action = "RedirectToUrl" }, // Parameter defaults

+ 1
- 2
Teknik/Areas/Shortener/Views/Shortener/Index.cshtml View File

@@ -5,11 +5,10 @@
<div class="container">
<div class="row">
<div class="col-sm-12 text-center">
<h1>Shorten a Url</h1>
<h1>Url Shortener</h1>
</div>
</div>
<br />
<br />
<div class="row">
<div class="col-sm-12 text-center">
<form class="form-horizontal" name="shortenerForm" id="shortenerForm" method="post" action="@Url.SubRouteUrl("shorten", "Shortener.Action", new { action = "ShortenUrl" })">

+ 1
- 1
Teknik/Areas/Stream/StreamAreaRegistration.cs View File

@@ -19,7 +19,7 @@ namespace Teknik.Areas.Stream
Config config = Config.Load();
context.MapSubdomainRoute(
"Stream.Index", // Route name
new List<string>() { "dev", "stream" }, // Subdomains
new List<string>() { "stream" }, // Subdomains
new List<string>() { config.Host }, // domains
"", // URL with parameters
new { controller = "Stream", action = "Index" }, // Parameter defaults

+ 1
- 1
Teknik/Areas/Transparency/TransparencyAreaRegistration.cs View File

@@ -19,7 +19,7 @@ namespace Teknik.Areas.Transparency
Config config = Config.Load();
context.MapSubdomainRoute(
"Transparency.Index",
new List<string>() { "dev", "transparency" }, // Subdomains
new List<string>() { "transparency" }, // Subdomains
new List<string>() { config.Host }, // domains
"",
new { controller = "Transparency", action = "Index" },

+ 4
- 4
Teknik/Areas/Upload/UploadAreaRegistration.cs View File

@@ -20,7 +20,7 @@ namespace Teknik.Areas.Upload
Config config = Config.Load();
context.MapSubdomainRoute(
"Upload.Index",
new List<string>() { "dev", "upload", "u" }, // Subdomains
new List<string>() { "upload", "u" }, // Subdomains
new List<string>() { config.Host }, // domains
"",
new { controller = "Upload", action = "Index" },
@@ -28,7 +28,7 @@ namespace Teknik.Areas.Upload
);
context.MapSubdomainRoute(
"Upload.Download",
new List<string>() { "dev", "upload", "u" }, // Subdomains
new List<string>() { "upload", "u" }, // Subdomains
new List<string>() { config.Host }, // domains
"{file}",
new { controller = "Upload", action = "Download", file = string.Empty },
@@ -36,7 +36,7 @@ namespace Teknik.Areas.Upload
);
context.MapSubdomainRoute(
"Upload.Delete",
new List<string>() { "dev", "upload", "u" }, // Subdomains
new List<string>() { "upload", "u" }, // Subdomains
new List<string>() { config.Host }, // domains
"{file}/{key}",
new { controller = "Upload", action = "Delete", file = string.Empty, key = string.Empty },
@@ -44,7 +44,7 @@ namespace Teknik.Areas.Upload
);
context.MapSubdomainRoute(
"Upload.Action",
new List<string>() { "dev", "upload", "u" }, // Subdomains
new List<string>() { "upload", "u" }, // Subdomains
new List<string>() { config.Host }, // domains
"Action/{controller}/{action}",
new { controller = "Upload", action = "Index" },

+ 1
- 1
Teknik/Helpers/UrlExtensions.cs View File

@@ -174,7 +174,7 @@ namespace Teknik
public static bool IsValidUrl(this string url)
{
Uri uriResult;
bool result = Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uriResult);
bool result = Uri.TryCreate(url, UriKind.Absolute, out uriResult);
if (result)
{
result = uriResult.IsWellFormedOriginalString();

Loading…
Cancel
Save