From 401a23b5dfaf01f91abd53810b9205c1add359eb Mon Sep 17 00:00:00 2001 From: Leandro Adolfo Date: Mon, 17 Oct 2016 15:02:31 -0200 Subject: [PATCH] Add Date and Time Formats in Configuration File --- Website/Web.config | 180 ++++++++++------------- Website/app_code/code/Blog.cs | 15 ++ Website/themes/OffCanvas/Comment.cshtml | 4 +- Website/themes/OffCanvas/Post.cshtml | 2 +- Website/themes/OneColumn/Comment.cshtml | 4 +- Website/themes/OneColumn/Post.cshtml | 2 +- Website/themes/TwoColumns/Comment.cshtml | 4 +- Website/themes/TwoColumns/Post.cshtml | 2 +- 8 files changed, 105 insertions(+), 108 deletions(-) diff --git a/Website/Web.config b/Website/Web.config index b649c397..1ebe30f4 100644 --- a/Website/Web.config +++ b/Website/Web.config @@ -1,180 +1,162 @@ - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - + + + - + - - + - - + - - + - - - - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + - - - - - + + + - - - + + - - - - + + + - - - + + - - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + - - + + - - - + + - - - + + - - + + - + \ No newline at end of file diff --git a/Website/app_code/code/Blog.cs b/Website/app_code/code/Blog.cs index 9b171b22..84b3ae70 100644 --- a/Website/app_code/code/Blog.cs +++ b/Website/app_code/code/Blog.cs @@ -21,6 +21,10 @@ static Blog() Image = ConfigurationManager.AppSettings.Get("blog:image"); ModerateComments = bool.Parse(ConfigurationManager.AppSettings.Get("blog:moderateComments")); BlogPath = ConfigurationManager.AppSettings.Get("blog:path"); + + DateFormat = GetStringAppSetting("blog:dateFormat", "MMMM d. yyyy"); + DateTimeFormat = GetStringAppSetting("blog:dateTimeFormat", "MMMM d. yyyy HH:mm"); + DateTimeFormatTitle = GetStringAppSetting("blog:dateTimeFormatTitle", "yyyy-MM-ddTHH:mm"); } public static string Title { get; private set; } @@ -31,7 +35,18 @@ static Blog() public static int DaysToComment { get; private set; } public static bool ModerateComments { get; private set; } public static string BlogPath { get; private set; } + public static string DateFormat { get; private set; } + public static string DateTimeFormat { get; private set; } + public static string DateTimeFormatTitle { get; private set; } + + private static string GetStringAppSetting(string setting, string defaultValue){ + var value = ConfigurationManager.AppSettings.Get(setting); + value = value == null ? defaultValue : value; + + return value; + } + public static string CurrentSlug { get { return (HttpContext.Current.Request.QueryString["slug"] ?? string.Empty).Trim().ToLowerInvariant(); } diff --git a/Website/themes/OffCanvas/Comment.cshtml b/Website/themes/OffCanvas/Comment.cshtml index b2679d10..0339fba3 100644 --- a/Website/themes/OffCanvas/Comment.cshtml +++ b/Website/themes/OffCanvas/Comment.cshtml @@ -11,8 +11,8 @@ @helper Date() { - var title = Model.PubDate.ToString("yyyy-MM-ddTHH:mm"); - var display = Model.PubDate.ToString("MMMM d. yyyy HH:mm"); + var title = Model.PubDate.ToString(Blog.DateTimeFormatTitle); + var display = Model.PubDate.ToString(Blog.DateTimeFormat); } @helper Author() diff --git a/Website/themes/OffCanvas/Post.cshtml b/Website/themes/OffCanvas/Post.cshtml index 6e81f402..4c069beb 100644 --- a/Website/themes/OffCanvas/Post.cshtml +++ b/Website/themes/OffCanvas/Post.cshtml @@ -14,7 +14,7 @@ else
- + @Model.CountApprovedComments(Context) Comments diff --git a/Website/themes/OneColumn/Comment.cshtml b/Website/themes/OneColumn/Comment.cshtml index b2679d10..0339fba3 100644 --- a/Website/themes/OneColumn/Comment.cshtml +++ b/Website/themes/OneColumn/Comment.cshtml @@ -11,8 +11,8 @@ @helper Date() { - var title = Model.PubDate.ToString("yyyy-MM-ddTHH:mm"); - var display = Model.PubDate.ToString("MMMM d. yyyy HH:mm"); + var title = Model.PubDate.ToString(Blog.DateTimeFormatTitle); + var display = Model.PubDate.ToString(Blog.DateTimeFormat); } @helper Author() diff --git a/Website/themes/OneColumn/Post.cshtml b/Website/themes/OneColumn/Post.cshtml index 4b79593c..9a39cc28 100644 --- a/Website/themes/OneColumn/Post.cshtml +++ b/Website/themes/OneColumn/Post.cshtml @@ -4,7 +4,7 @@
- + @Model.CountApprovedComments(Context) Comments diff --git a/Website/themes/TwoColumns/Comment.cshtml b/Website/themes/TwoColumns/Comment.cshtml index b2679d10..0339fba3 100644 --- a/Website/themes/TwoColumns/Comment.cshtml +++ b/Website/themes/TwoColumns/Comment.cshtml @@ -11,8 +11,8 @@ @helper Date() { - var title = Model.PubDate.ToString("yyyy-MM-ddTHH:mm"); - var display = Model.PubDate.ToString("MMMM d. yyyy HH:mm"); + var title = Model.PubDate.ToString(Blog.DateTimeFormatTitle); + var display = Model.PubDate.ToString(Blog.DateTimeFormat); } @helper Author() diff --git a/Website/themes/TwoColumns/Post.cshtml b/Website/themes/TwoColumns/Post.cshtml index c30848ec..71db88da 100644 --- a/Website/themes/TwoColumns/Post.cshtml +++ b/Website/themes/TwoColumns/Post.cshtml @@ -4,7 +4,7 @@
- + @Model.CountApprovedComments(Context) Comments