diff --git a/Teknik/Areas/Podcast/PodcastAreaRegistration.cs b/Teknik/Areas/Podcast/PodcastAreaRegistration.cs index c556905..c945e4f 100644 --- a/Teknik/Areas/Podcast/PodcastAreaRegistration.cs +++ b/Teknik/Areas/Podcast/PodcastAreaRegistration.cs @@ -31,7 +31,7 @@ namespace Teknik.Areas.Podcast "Podcast.View", // Route name new List() { "podcast" }, // Subdomains new List() { config.Host }, // domains - "{episode}", // URL with parameters + "ep/{episode}", // URL with parameters new { controller = "Podcast", action = "View" }, // Parameter defaults new[] { typeof(Controllers.PodcastController).Namespace } ); diff --git a/Utilities/Uploader/Properties/AssemblyInfo.cs b/Utilities/Uploader/Properties/AssemblyInfo.cs deleted file mode 100644 index 4953536..0000000 --- a/Utilities/Uploader/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Uploader")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Uploader")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f9db28e9-efa1-4d0f-a7b3-c8f491306ce3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Utilities/Uploader/Uploader.cs b/Utilities/Uploader/Uploader.cs deleted file mode 100644 index 06314b7..0000000 --- a/Utilities/Uploader/Uploader.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Teknik.Utilities -{ - public class Uploader - { - public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength) - { - return SaveFile(db, config, file, contentType, contentLength, string.Empty, null, null, 256, 128); - } - public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension) - { - return SaveFile(db, config, file, contentType, contentLength, defaultExtension, null, null, 256, 128); - } - - public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv) - { - return SaveFile(db, config, file, contentType, contentLength, defaultExtension, iv, null, 256, 128); - } - - public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key) - { - return SaveFile(db, config, file, contentType, contentLength, defaultExtension, iv, key, 256, 128); - } - - public static Models.Upload SaveFile(TeknikEntities db, Config config, byte[] file, string contentType, int contentLength, string defaultExtension, string iv, string key, int keySize, int blockSize) - { - if (!Directory.Exists(config.UploadConfig.UploadDirectory)) - { - Directory.CreateDirectory(config.UploadConfig.UploadDirectory); - } - - // Generate a unique file name that does not currently exist - string filePath = Utility.GenerateUniqueFileName(config.UploadConfig.UploadDirectory, config.UploadConfig.FileExtension, 10); - string fileName = Path.GetFileName(filePath); - - // once we have the filename, lets save the file - File.WriteAllBytes(filePath, file); - - // Generate a unique url - string extension = (config.UploadConfig.IncludeExtension) ? Utility.GetDefaultExtension(contentType, defaultExtension) : string.Empty; - string url = Utility.RandomString(config.UploadConfig.UrlLength) + extension; - while (db.Uploads.Where(u => u.Url == url).FirstOrDefault() != null) - { - url = Utility.RandomString(config.UploadConfig.UrlLength) + extension; - } - - // Now we need to update the database with the new upload information - Models.Upload upload = db.Uploads.Create(); - upload.DateUploaded = DateTime.Now; - upload.Url = url; - upload.FileName = fileName; - upload.ContentType = (!string.IsNullOrEmpty(contentType)) ? contentType : "application/octet-stream"; - upload.ContentLength = contentLength; - upload.Key = key; - upload.IV = iv; - upload.KeySize = keySize; - upload.BlockSize = blockSize; - - db.Uploads.Add(upload); - db.SaveChanges(); - - return upload; - } - } -} diff --git a/Utilities/Uploader/Uploader.csproj b/Utilities/Uploader/Uploader.csproj deleted file mode 100644 index 763d5ec..0000000 --- a/Utilities/Uploader/Uploader.csproj +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Debug - AnyCPU - {F9DB28E9-EFA1-4D0F-A7B3-C8F491306CE3} - Library - Properties - Uploader - Uploader - v4.6.2 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Utilities/Utilities/StringExtensions.cs b/Utilities/Utilities/StringExtensions.cs new file mode 100644 index 0000000..07629d1 --- /dev/null +++ b/Utilities/Utilities/StringExtensions.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; + +namespace Teknik.Utilities +{ + public static class StringExtensions + { + public static string Truncate(this string value, int maxLength) + { + if (string.IsNullOrEmpty(value)) return value; + return value.Length <= maxLength ? value : value.Substring(0, maxLength); + } + + public static string AddStringAtInterval(this string value, int interval, string insertStr) + { + if (interval <= 0 || value.Length < interval) + return value; + + StringBuilder sb = new StringBuilder(); + + int finalIndex = 0; + for (int i = 0; i < value.Length; i = i + interval) + { + sb.Append(value.Substring(i, interval)); + sb.Append(insertStr); + finalIndex = i; + } + + if (finalIndex + interval != value.Length) + { + sb.Append(value.Substring(finalIndex, value.Length - finalIndex)); + } + + return sb.ToString(); + } + } +} \ No newline at end of file diff --git a/Utilities/Utilities/Utilities.csproj b/Utilities/Utilities/Utilities.csproj index 155155c..2c74a94 100644 --- a/Utilities/Utilities/Utilities.csproj +++ b/Utilities/Utilities/Utilities.csproj @@ -42,6 +42,7 @@ +