From d9017851becc6e589c5d35201e45c86e11b2b489 Mon Sep 17 00:00:00 2001 From: rxtur Date: Sun, 6 Mar 2016 21:05:58 -0600 Subject: [PATCH 001/145] Blogroll widget added (3.2.1.4) --- BlogEngine/BlogEngine.Core/BlogSettings.cs | 3 +- .../Data/SettingsRepository.cs | 4 +- .../Properties/AssemblyInfo.cs | 2 +- .../_new/datastore/widgets/be_WIDGET_ZONE.xml | 7 +- .../BlogEngine.NET/BlogEngine.NET.csproj | 3 + .../Custom/Widgets/BlogRoll/BlogRoll.cs | 238 ++++++++++++++++++ .../Custom/Widgets/BlogRoll/edit.cshtml | 206 +++++++++++++++ .../Custom/Widgets/BlogRoll/widget.cshtml | 43 ++++ .../admin/app/content/blogs/blogView.html | 6 +- .../admin/themes/standard/sidebar.cshtml | 2 +- .../BlogEngine.NET/setup/SQLServer/Setup.sql | Bin 235876 -> 235866 bytes 11 files changed, 502 insertions(+), 12 deletions(-) create mode 100644 BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/BlogRoll.cs create mode 100644 BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/edit.cshtml create mode 100644 BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/widget.cshtml diff --git a/BlogEngine/BlogEngine.Core/BlogSettings.cs b/BlogEngine/BlogEngine.Core/BlogSettings.cs index 5cc37f184..f888698dc 100644 --- a/BlogEngine/BlogEngine.Core/BlogSettings.cs +++ b/BlogEngine/BlogEngine.Core/BlogSettings.cs @@ -1101,9 +1101,10 @@ public DateTime FromUtc(DateTime ? serverTime = null) /// /// Gets or sets a value indicating if extensions (.aspx) should be removed from URLs + /// -- always returns true to prepare for transition to MVC style routing /// /// true if should be removed, otherwise returns false. - public bool RemoveExtensionsFromUrls { get; set; } + public bool RemoveExtensionsFromUrls { get { return true; } } #endregion diff --git a/BlogEngine/BlogEngine.Core/Data/SettingsRepository.cs b/BlogEngine/BlogEngine.Core/Data/SettingsRepository.cs index 516e0d35c..b23ea5ea0 100644 --- a/BlogEngine/BlogEngine.Core/Data/SettingsRepository.cs +++ b/BlogEngine/BlogEngine.Core/Data/SettingsRepository.cs @@ -52,7 +52,7 @@ public bool Update(Settings ns) bs.ShowPostNavigation = ns.ShowPostNavigation; bs.Culture = ns.Culture; bs.TimeZoneId = ns.TimeZoneId; - bs.RemoveExtensionsFromUrls = ns.RemoveExtensionsFromUrls; + //bs.RemoveExtensionsFromUrls = ns.RemoveExtensionsFromUrls; bs.RedirectToRemoveFileExtension = ns.RedirectToRemoveFileExtension; bs.Theme = ns.DesktopTheme; @@ -163,7 +163,7 @@ private Settings GetSettings() ns.ShowPostNavigation = bs.ShowPostNavigation; ns.Culture = bs.Culture; ns.TimeZoneId = string.IsNullOrEmpty(bs.TimeZoneId) ? "UTC" : bs.TimeZoneId; - ns.RemoveExtensionsFromUrls = bs.RemoveExtensionsFromUrls; + //ns.RemoveExtensionsFromUrls = bs.RemoveExtensionsFromUrls; ns.RedirectToRemoveFileExtension = bs.RedirectToRemoveFileExtension; ns.DesktopTheme = bs.Theme; diff --git a/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs b/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs index 4175cd91c..60a2173a2 100644 --- a/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs +++ b/BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs @@ -19,5 +19,5 @@ [assembly: CLSCompliant(false)] [assembly: ComVisible(false)] [assembly: AllowPartiallyTrustedCallers] -[assembly: AssemblyVersion("3.2.1.3")] +[assembly: AssemblyVersion("3.2.1.4")] [assembly: SecurityRules(SecurityRuleSet.Level1)] diff --git a/BlogEngine/BlogEngine.NET/App_Data/blogs/_new/datastore/widgets/be_WIDGET_ZONE.xml b/BlogEngine/BlogEngine.NET/App_Data/blogs/_new/datastore/widgets/be_WIDGET_ZONE.xml index 3c78a28b6..60c281b9e 100644 --- a/BlogEngine/BlogEngine.NET/App_Data/blogs/_new/datastore/widgets/be_WIDGET_ZONE.xml +++ b/BlogEngine/BlogEngine.NET/App_Data/blogs/_new/datastore/widgets/be_WIDGET_ZONE.xml @@ -2,8 +2,7 @@ Administration Search - Blog List - Calendar - Category list - Tag cloud + BlogList + CategoryList + TagCloud \ No newline at end of file diff --git a/BlogEngine/BlogEngine.NET/BlogEngine.NET.csproj b/BlogEngine/BlogEngine.NET/BlogEngine.NET.csproj index 63a4cbd2f..ad26ca261 100644 --- a/BlogEngine/BlogEngine.NET/BlogEngine.NET.csproj +++ b/BlogEngine/BlogEngine.NET/BlogEngine.NET.csproj @@ -725,6 +725,8 @@ + + @@ -2118,6 +2120,7 @@ site.master + diff --git a/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/BlogRoll.cs b/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/BlogRoll.cs new file mode 100644 index 000000000..9fe635235 --- /dev/null +++ b/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/BlogRoll.cs @@ -0,0 +1,238 @@ +using BlogEngine.Core; +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Linq; +using System.ServiceModel.Syndication; +using System.Web; +using System.Xml; + +namespace BlogEngine.NET.Custom.Widgets +{ + public class BlogRoll + { + public BlogRoll() + { + Xfn = new XfnList(); + } + + public BlogRoll(string id) + { + var gId = Guid.Parse(id); + var rolls = BlogRollItem.BlogRolls; + var broll = rolls.Where(r => r.Id == gId).FirstOrDefault(); + + Title = broll.Title; + Description = broll.Description; + WebSite = broll.BlogUrl.ToString(); + FeedUrl = broll.FeedUrl.ToString(); + + var x = broll.Xfn.Split(' ').ToList(); + Xfn = new XfnList(); + + if (x.Contains("contact")) { Xfn.contact = true; } + if (x.Contains("acquaintance")) { Xfn.acquaintance = true; } + if (x.Contains("friend")) { Xfn.friend = true; } + if (x.Contains("met")) { Xfn.met = true; } + if (x.Contains("coworker")) { Xfn.coworker = true; } + if (x.Contains("colleague")) { Xfn.colleague = true; } + + if (x.Contains("coresident")) { Xfn.coresident = true; } + if (x.Contains("neighbor")) { Xfn.neighbor = true; } + if (x.Contains("child")) { Xfn.child = true; } + if (x.Contains("parent")) { Xfn.parent = true; } + if (x.Contains("sibling")) { Xfn.sibling = true; } + if (x.Contains("spouse")) { Xfn.spouse = true; } + + if (x.Contains("kin")) { Xfn.kin = true; } + if (x.Contains("muse")) { Xfn.muse = true; } + if (x.Contains("crush")) { Xfn.crush = true; } + if (x.Contains("date")) { Xfn.date = true; } + if (x.Contains("sweetheart")) { Xfn.sweetheart = true; } + if (x.Contains("me")) { Xfn.me = true; } + } + + #region Puplic properties + + public string Title { get; set; } + public string Description { get; set; } + public string WebSite { get; set; } + public string FeedUrl { get; set; } + public XfnList Xfn { get; set; } + + #endregion + + public void SaveForm(NameValueCollection form) + { + Title = form["txtTitle"]; + Description = form["txtDesc"]; + WebSite = form["txtWebsite"]; + FeedUrl = form["txtUrl"]; + + Xfn.contact = form["cblXfn_0"] == "on" ? true : false; + Xfn.acquaintance = form["cblXfn_1"] == "on" ? true : false; + Xfn.friend = form["cblXfn_2"] == "on" ? true : false; + Xfn.met = form["cblXfn_3"] == "on" ? true : false; + Xfn.coworker = form["cblXfn_4"] == "on" ? true : false; + Xfn.colleague = form["cblXfn_5"] == "on" ? true : false; + Xfn.coresident = form["cblXfn_6"] == "on" ? true : false; + Xfn.neighbor = form["cblXfn_7"] == "on" ? true : false; + Xfn.child = form["cblXfn_8"] == "on" ? true : false; + Xfn.parent = form["cblXfn_9"] == "on" ? true : false; + Xfn.sibling = form["cblXfn_10"] == "on" ? true : false; + Xfn.spouse = form["cblXfn_11"] == "on" ? true : false; + Xfn.kin = form["cblXfn_12"] == "on" ? true : false; + Xfn.muse = form["cblXfn_13"] == "on" ? true : false; + Xfn.crush = form["cblXfn_14"] == "on" ? true : false; + Xfn.date = form["cblXfn_15"] == "on" ? true : false; + Xfn.sweetheart = form["cblXfn_16"] == "on" ? true : false; + Xfn.me = form["cblXfn_17"] == "on" ? true : false; + } + + public string GetXfnString(NameValueCollection form) + { + var s = ""; + + if (form["cblXfn_0"] == "on") { s += "contact "; } + if (form["cblXfn_1"] == "on") { s += "acquaintance "; } + if (form["cblXfn_2"] == "on") { s += "friend "; } + if (form["cblXfn_3"] == "on") { s += "met "; } + if (form["cblXfn_4"] == "on") { s += "coworker "; } + if (form["cblXfn_5"] == "on") { s += "colleague "; } + + if (form["cblXfn_6"] == "on") { s += "coresident "; } + if (form["cblXfn_7"] == "on") { s += "neighbor "; } + if (form["cblXfn_8"] == "on") { s += "child "; } + if (form["cblXfn_9"] == "on") { s += "parent "; } + if (form["cblXfn_10"] == "on") { s += "sibling "; } + if (form["cblXfn_11"] == "on") { s += "spouse "; } + + if (form["cblXfn_12"] == "on") { s += "kin "; } + if (form["cblXfn_13"] == "on") { s += "muse "; } + if (form["cblXfn_14"] == "on") { s += "crush "; } + if (form["cblXfn_15"] == "on") { s += "date "; } + if (form["cblXfn_16"] == "on") { s += "sweetheart "; } + if (form["cblXfn_17"] == "on") { s += "me "; } + + return s.Trim(); + } + + public void Add(NameValueCollection form) + { + BlogRollItem br = new BlogRollItem(); + br.Title = form["txtTitle"].Replace(@"\", "'"); + br.Description = form["txtDesc"]; + br.BlogUrl = new Uri(form["txtWebsite"]); + br.FeedUrl = new Uri(form["txtUrl"]); + + br.Xfn = GetXfnString(form); + + int largestSortIndex = -1; + foreach (BlogRollItem brExisting in BlogRollItem.BlogRolls) + { + if (brExisting.SortIndex > largestSortIndex) + { + largestSortIndex = brExisting.SortIndex; + } + } + br.SortIndex = largestSortIndex + 1; + br.Save(); + } + + public void Update(NameValueCollection form, string id) + { + try + { + var br = BlogRollItem.GetBlogRollItem(Guid.Parse(id)); + if (br != null) + { + br.Title = form["txtTitle"].Replace(@"\", "'"); + br.Description = form["txtDesc"]; + br.BlogUrl = new Uri(form["txtWebsite"]); + br.FeedUrl = new Uri(form["txtUrl"]); + br.Xfn = GetXfnString(form); + br.Save(); + } + } + catch (Exception ex) + { + Utils.Log("Custom.Widgets.BlogRoll.Update", ex); + } + } + + public void Delete(string id) + { + try + { + var br = BlogRollItem.GetBlogRollItem(Guid.Parse(id)); + br.Delete(); + br.Save(); + } + catch (Exception ex) + { + Utils.Log("Custom.Widgets.BlogRoll.Delete", ex); + } + + } + + + public List GetFeeds(string feedUrl) + { + var lastNews = new List(); + + try + { + lastNews.AddRange(GetItemsFromUrl(feedUrl)); + lastNews.Sort(delegate (SyndicationItem x, SyndicationItem y) { return y.PublishDate.CompareTo(x.PublishDate); }); + } + catch (Exception) { } + + return lastNews; + } + private List GetItemsFromUrl(string url) + { + var lst = new List(); + var reader = XmlReader.Create(url); + var feed = SyndicationFeed.Load(reader); + var cnt = 0; + foreach (SyndicationItem item in feed.Items) + { + lst.Add(item); + cnt++; + if(cnt > 2) + { + break; + } + } + return lst; + } + public string Shorten(string textToShorten) + { + return HttpUtility.HtmlEncode(textToShorten.Length > BlogSettings.Instance.BlogrollMaxLength + ? string.Format("{0}...", textToShorten.Substring(0, BlogSettings.Instance.BlogrollMaxLength).Trim()) + : textToShorten); + } + + } + public class XfnList + { + public bool contact { get; set; } + public bool acquaintance { get; set; } + public bool friend { get; set; } + public bool met { get; set; } + public bool coworker { get; set; } + public bool colleague { get; set; } + public bool coresident { get; set; } + public bool neighbor { get; set; } + public bool child { get; set; } + public bool parent { get; set; } + public bool sibling { get; set; } + public bool spouse { get; set; } + public bool kin { get; set; } + public bool muse { get; set; } + public bool crush { get; set; } + public bool date { get; set; } + public bool sweetheart { get; set; } + public bool me { get; set; } + } +} \ No newline at end of file diff --git a/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/edit.cshtml b/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/edit.cshtml new file mode 100644 index 000000000..e66e39163 --- /dev/null +++ b/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/edit.cshtml @@ -0,0 +1,206 @@ +@using BlogEngine.NET.Custom.Widgets +@using BlogEngine.Core +@{ + // check if edit exists, no need to process + if (Request.HttpMethod == "HEAD") { return; } + var br = new BlogRoll(); + + if (Request.Form["btnAdd"] != null || Request.Form["btnUpdate"] != null) + { + Validation.Add("txtTitle", Validator.Required("Field is required")); + Validation.Add("txtDesc", Validator.Required("Field is required")); + Validation.Add("txtWebsite", Validator.Required("Field is required"), Validator.Url("Field is URL")); + Validation.Add("txtUrl", Validator.Required("Field is required"), Validator.Url("Field is URL")); + } + var id = Request.Form["hdnId"]; + + if (IsPost) + { + if (Request.Form["btnAdd"] != null) + { + if (Validation.IsValid()) + { + br.Add(Request.Form); + @: + } + else + { + br.SaveForm(Request.Form); + } + } + else if (Request.Form["btnUpdate"] != null) + { + if (Validation.IsValid()) + { + br.Update(Request.Form, id); + @: + } + else + { + br.SaveForm(Request.Form); + } + } + else if (Request.Form["btnDelete"] != null) + { + br.Delete(id); + @: + } + else + { + // load form for update + if (!string.IsNullOrEmpty(id)) + { + br = new BlogRoll(id); + } + } + } + var rolls = BlogRollItem.BlogRolls; +} + + + + + + + + + + +
+
+ +
+ + + + + + + + + + + @foreach (var roll in rolls) + { + + + + + + } + @if (rolls == null || rolls.Count == 0) + { + + } + +
@Resources.labels.title@Resources.labels.descriptionXFN
+ @roll.Title + + @roll.Description@roll.Xfn
@Resources.labels.empty
+ +
+ + + \ No newline at end of file diff --git a/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/widget.cshtml b/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/widget.cshtml new file mode 100644 index 000000000..6a239af5b --- /dev/null +++ b/BlogEngine/BlogEngine.NET/Custom/Widgets/BlogRoll/widget.cshtml @@ -0,0 +1,43 @@ +@using BlogEngine.NET.Custom.Widgets +@using BlogEngine.Core +@{ + var title = Model.Title; + var rolls = BlogRollItem.BlogRolls; + var br = new BlogRoll(); + var imgPath = Utils.ApplicationRelativeWebRoot + "Content/images/blog"; + var opmlPath = Utils.ApplicationRelativeWebRoot + "opml.axd"; +} +
+

@title

+
+ @if (rolls != null) + { +
    + @foreach (var roll in rolls) + { +
  • + + @roll.Description + + @roll.Title + @if (br.GetFeeds(roll.FeedUrl.ToString()).Count > 0) + { + + } +
  • + } +
+ } + + @Resources.labels.downloadOPML + OPML + +
+
\ No newline at end of file diff --git a/BlogEngine/BlogEngine.NET/admin/app/content/blogs/blogView.html b/BlogEngine/BlogEngine.NET/admin/app/content/blogs/blogView.html index b587db510..eee9f54e0 100644 --- a/BlogEngine/BlogEngine.NET/admin/app/content/blogs/blogView.html +++ b/BlogEngine/BlogEngine.NET/admin/app/content/blogs/blogView.html @@ -109,9 +109,9 @@

{{lbl.blogs}}

- -
- +
+ +
diff --git a/BlogEngine/BlogEngine.NET/admin/app/settings/settingController.js b/BlogEngine/BlogEngine.NET/admin/app/settings/settingController.js index 2ee198ef1..3f659c93d 100644 --- a/BlogEngine/BlogEngine.NET/admin/app/settings/settingController.js +++ b/BlogEngine/BlogEngine.NET/admin/app/settings/settingController.js @@ -105,6 +105,19 @@ .error(function () { toastr.error($rootScope.lbl.failed); }); } + $scope.clearCache = function () { + dataService.updateItem("/api/settings?action=clearCache", $scope.settings) + .success(function (data) { + if (data) { + toastr.error(data); + } + else { + toastr.success($rootScope.lbl.completed); + } + }) + .error(function () { toastr.error($rootScope.lbl.failed); }); + } + $scope.loadTheme = function () { var theme = $("#selDesktopTheme option:selected").text(); window.location.assign("#/shared/package?id=" + theme); From d37be24ab87096173d2018ebdadc24e8560d4f53 Mon Sep 17 00:00:00 2001 From: Farzin Seyfolahi Date: Mon, 14 Mar 2016 18:37:37 -0700 Subject: [PATCH 006/145] Toggle arrow in sidebar removed and toolbar is open by default and Widgets improved. --- .../admin/app/custom/widgets/widgetView.html | 207 ++++++++---------- .../admin/themes/standard/css/styles.css | 2 +- .../admin/themes/standard/css/styles.css.map | 4 +- .../themes/standard/sass/layout/_header.scss | 16 +- .../themes/standard/sass/layout/_sidebar.scss | 25 --- .../standard/sass/pages/custom/_widgets.scss | 71 ++++++ .../admin/themes/standard/sass/styles.scss | 5 +- .../admin/themes/standard/sidebar.cshtml | 3 +- 8 files changed, 181 insertions(+), 152 deletions(-) create mode 100644 BlogEngine/BlogEngine.NET/admin/themes/standard/sass/pages/custom/_widgets.scss diff --git a/BlogEngine/BlogEngine.NET/admin/app/custom/widgets/widgetView.html b/BlogEngine/BlogEngine.NET/admin/app/custom/widgets/widgetView.html index c76dac93e..fbb6346a1 100644 --- a/BlogEngine/BlogEngine.NET/admin/app/custom/widgets/widgetView.html +++ b/BlogEngine/BlogEngine.NET/admin/app/custom/widgets/widgetView.html @@ -1,151 +1,134 @@ -
- +
+

{{lbl.widgets}}

- +
- -