From 3d35266e339638a9457abf86924a4b5360603928 Mon Sep 17 00:00:00 2001 From: mpancho Date: Tue, 14 May 2019 15:29:54 -0500 Subject: [PATCH 01/11] Changes for multilingual in version 8.2 update 5 --- .gitignore | 3 ++ Sitemap.XML.sln | 25 ++---------- .../App_Config/Include/SitemapXML.config | 4 +- Sitemap.XML/Configuration/SitemapHandler.cs | 9 ++++- Sitemap.XML/Models/SitemapHandler.cs | 26 ++++++++----- Sitemap.XML/Models/SitemapItem.cs | 38 ++++++++++++++++--- Sitemap.XML/Models/SitemapItemHrefLang.cs | 13 +++++++ Sitemap.XML/Models/SitemapManager.cs | 38 +++++++++++++++++-- .../Models/SitemapManagerConfiguration.cs | 24 ++++++++++-- Sitemap.XML/Sitemap.XML.csproj | 36 +++++++++++------- Sitemap.XML/packages.config | 7 ++++ Sitemap.XML/web.Debug.config | 30 +++++++++++++++ Sitemap.XML/web.Release.config | 31 +++++++++++++++ Sitemap.XML/web.config | 15 ++++++++ 14 files changed, 238 insertions(+), 61 deletions(-) create mode 100644 Sitemap.XML/Models/SitemapItemHrefLang.cs create mode 100644 Sitemap.XML/packages.config create mode 100644 Sitemap.XML/web.Debug.config create mode 100644 Sitemap.XML/web.Release.config create mode 100644 Sitemap.XML/web.config diff --git a/.gitignore b/.gitignore index 1595434..fb9ae66 100644 --- a/.gitignore +++ b/.gitignore @@ -174,3 +174,6 @@ $RECYCLE.BIN/ thejames.sublime-workspace thejames.sublime-project /.vs/config +/.vs/slnx.sqlite +/.vs/VSWorkspaceState.json +/.vs/Sitemap.XML/v15/Server/sqlite3 diff --git a/Sitemap.XML.sln b/Sitemap.XML.sln index 87cbcbc..82979fe 100644 --- a/Sitemap.XML.sln +++ b/Sitemap.XML.sln @@ -1,16 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2024 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitemap.XML", "Sitemap.XML\Sitemap.XML.csproj", "{B626A91F-590A-49D3-AE5C-798B2F05FDE1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Content", "Content", "{E3A0F2D9-8A00-400D-BC40-4981F55ACBB5}" EndProject -Project("{CAA73BB0-EF22-4D79-A57E-DF67B3BA9C80}") = "Sitemap.XML.Core", "Sitemap.XML.Core\Sitemap.XML.Core.scproj", "{11A7F075-CEC0-44EB-830D-DE1EDAF54499}" -EndProject -Project("{CAA73BB0-EF22-4D79-A57E-DF67B3BA9C80}") = "Sitemap.XML.Master", "Sitemap.XML.Master\Sitemap.XML.Master.scproj", "{2739FEAB-9692-462F-82B5-4DC2C241C3CE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,24 +17,11 @@ Global {B626A91F-590A-49D3-AE5C-798B2F05FDE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {B626A91F-590A-49D3-AE5C-798B2F05FDE1}.Release|Any CPU.ActiveCfg = Release|Any CPU {B626A91F-590A-49D3-AE5C-798B2F05FDE1}.Release|Any CPU.Build.0 = Release|Any CPU - {11A7F075-CEC0-44EB-830D-DE1EDAF54499}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {11A7F075-CEC0-44EB-830D-DE1EDAF54499}.Debug|Any CPU.Build.0 = Debug|Any CPU - {11A7F075-CEC0-44EB-830D-DE1EDAF54499}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {11A7F075-CEC0-44EB-830D-DE1EDAF54499}.Release|Any CPU.ActiveCfg = Release|Any CPU - {11A7F075-CEC0-44EB-830D-DE1EDAF54499}.Release|Any CPU.Build.0 = Release|Any CPU - {11A7F075-CEC0-44EB-830D-DE1EDAF54499}.Release|Any CPU.Deploy.0 = Release|Any CPU - {2739FEAB-9692-462F-82B5-4DC2C241C3CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2739FEAB-9692-462F-82B5-4DC2C241C3CE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2739FEAB-9692-462F-82B5-4DC2C241C3CE}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {2739FEAB-9692-462F-82B5-4DC2C241C3CE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2739FEAB-9692-462F-82B5-4DC2C241C3CE}.Release|Any CPU.Build.0 = Release|Any CPU - {2739FEAB-9692-462F-82B5-4DC2C241C3CE}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {11A7F075-CEC0-44EB-830D-DE1EDAF54499} = {E3A0F2D9-8A00-400D-BC40-4981F55ACBB5} - {2739FEAB-9692-462F-82B5-4DC2C241C3CE} = {E3A0F2D9-8A00-400D-BC40-4981F55ACBB5} + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {354BB054-3BDB-4B02-8661-9592CCB79295} EndGlobalSection EndGlobal diff --git a/Sitemap.XML/App_Config/Include/SitemapXML.config b/Sitemap.XML/App_Config/Include/SitemapXML.config index ec8c235..a5c8c99 100644 --- a/Sitemap.XML/App_Config/Include/SitemapXML.config +++ b/Sitemap.XML/App_Config/Include/SitemapXML.config @@ -9,10 +9,12 @@ - + + + diff --git a/Sitemap.XML/Configuration/SitemapHandler.cs b/Sitemap.XML/Configuration/SitemapHandler.cs index 930e721..d89d72e 100644 --- a/Sitemap.XML/Configuration/SitemapHandler.cs +++ b/Sitemap.XML/Configuration/SitemapHandler.cs @@ -1,5 +1,6 @@ #region +using System; using Sitecore; using Sitecore.Caching; using Sitecore.Diagnostics; @@ -21,7 +22,7 @@ public class SitemapHandler : HttpRequestProcessor public override void Process(HttpRequestArgs args) { - Assert.ArgumentNotNull(args, "args"); + Assert.ArgumentNotNull(args, "args"); if (Context.Site == null || string.IsNullOrEmpty(Context.Site.RootPath.Trim())) return; if (Context.Page.FilePath.Length > 0) return; var sitemapHandler = string.IsNullOrWhiteSpace(Context.Site.Properties["sitemapHandler"]) @@ -56,7 +57,11 @@ public override void Process(HttpRequestArgs args) content = sitemapManager.BuildSiteMapForHandler(); args.Context.Response.Write(content); } - finally + catch (Exception e) + { + Log.Error("Error Sitemap", e, this); + } + finally { #if !DEBUG CacheManager.GetHtmlCache(site).SetHtml(cacheKey, content); diff --git a/Sitemap.XML/Models/SitemapHandler.cs b/Sitemap.XML/Models/SitemapHandler.cs index 2fc7b65..cb99280 100644 --- a/Sitemap.XML/Models/SitemapHandler.cs +++ b/Sitemap.XML/Models/SitemapHandler.cs @@ -20,6 +20,7 @@ * *********************************************************************** */ using System; +using Sitecore.Diagnostics; namespace Sitemap.XML.Models { @@ -27,16 +28,23 @@ public class SitemapHandler { public void RefreshSitemap(object sender, EventArgs args) { - var sites = SitemapManagerConfiguration.GetSiteNames(); - foreach (var site in sites) - { - var config = new SitemapManagerConfiguration(site); - var sitemapManager = new SitemapManager(config); - sitemapManager.SubmitSitemapToSearchenginesByHttp(); + try + { + var sites = SitemapManagerConfiguration.GetSiteNames(); + foreach (var site in sites) + { + var config = new SitemapManagerConfiguration(site); + var sitemapManager = new SitemapManager(config); + sitemapManager.SubmitSitemapToSearchenginesByHttp(); - if (!config.GenerateRobotsFile) continue; - sitemapManager.RegisterSitemapToRobotsFile(); - } + if (!config.GenerateRobotsFile) continue; + sitemapManager.RegisterSitemapToRobotsFile(); + } + } + catch (Exception e) + { + Log.Error("Error Sitemap",e,this); + } } } } diff --git a/Sitemap.XML/Models/SitemapItem.cs b/Sitemap.XML/Models/SitemapItem.cs index 63d62f8..44d4e3f 100644 --- a/Sitemap.XML/Models/SitemapItem.cs +++ b/Sitemap.XML/Models/SitemapItem.cs @@ -1,8 +1,11 @@ using Sitecore.Data.Items; using Sitecore.Sites; using System; +using System.Collections.Generic; using System.Text; using System.Web; +using Sitecore.Globalization; +using Sitecore.Links; namespace Sitemap.XML.Models { @@ -26,7 +29,24 @@ public SitemapItem(Item item, SiteContext site, Item parentItem) { Location = GetSharedItemUrl(item, site, parentItem); } - } + Language[] languages = item.Languages; + HrefLangs = new List(); + Language[] languageArray = languages; + for (int i = 0; i < (int)languageArray.Length; i++) + { + Language language = languageArray[i]; + string sharedItemUrl = SitemapItem.HtmlEncode(SitemapItem.GetItemUrl(item, site, language)); + if (parentItem != null) + { + sharedItemUrl = SitemapItem.GetSharedItemUrl(item, site, parentItem); + } + this.HrefLangs.Add(new SitemapItemHrefLang() + { + Href = sharedItemUrl, + HrefLang = language.CultureInfo.TwoLetterISOLanguageName + }); + } + } #endregion @@ -38,12 +58,13 @@ public SitemapItem(Item item, SiteContext site, Item parentItem) public string Priority { get; set; } public Guid Id { get; set; } public string Title { get; set; } + public List HrefLangs { get; set; } - #endregion + #endregion - #region Private Methods + #region Private Methods - private static string GetSharedItemUrl(Item item, SiteContext site, Item parentItem) + private static string GetSharedItemUrl(Item item, SiteContext site, Item parentItem) { var itemUrl = HtmlEncode(GetItemUrl(item, site)); var parentUrl = HtmlEncode(GetItemUrl(parentItem, site)); @@ -87,15 +108,20 @@ public static string HtmlEncode(string text) return result; } - public static string GetItemUrl(Item item, SiteContext site) + public static string GetItemUrl(Item item, SiteContext site, Language language = null) { Sitecore.Links.UrlOptions options = Sitecore.Links.UrlOptions.DefaultOptions; options.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving; options.Site = SiteContext.GetSite(site.Name); options.AlwaysIncludeServerUrl = false; + if (language != null) + { + options.LanguageEmbedding = LanguageEmbedding.Always; + options.Language = language; + } - string url = Sitecore.Links.LinkManager.GetItemUrl(item, options); + string url = Sitecore.Links.LinkManager.GetItemUrl(item, options); var serverUrl = (new SitemapManagerConfiguration(site.Name)).ServerUrl; diff --git a/Sitemap.XML/Models/SitemapItemHrefLang.cs b/Sitemap.XML/Models/SitemapItemHrefLang.cs new file mode 100644 index 0000000..6235d0e --- /dev/null +++ b/Sitemap.XML/Models/SitemapItemHrefLang.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace Sitemap.XML.Models +{ + public class SitemapItemHrefLang + { + public string Href { get; set; } + public string HrefLang { get; set; } + } +} \ No newline at end of file diff --git a/Sitemap.XML/Models/SitemapManager.cs b/Sitemap.XML/Models/SitemapManager.cs index bf399ea..c2a4f29 100644 --- a/Sitemap.XML/Models/SitemapManager.cs +++ b/Sitemap.XML/Models/SitemapManager.cs @@ -108,7 +108,11 @@ private string BuildSitemapXML(List items, Site site) xmlnsAttr.Value = SitemapManagerConfiguration.XmlnsTpl; urlsetNode.Attributes.Append(xmlnsAttr); - doc.AppendChild(urlsetNode); + XmlAttribute xmlnsXhtmlTpl = doc.CreateAttribute("xmlns:xhtml"); + xmlnsXhtmlTpl.Value = SitemapManagerConfiguration.XmlnsXhtmlTpl; + urlsetNode.Attributes.Append(xmlnsXhtmlTpl); + + doc.AppendChild(urlsetNode); foreach (var itm in items) @@ -121,7 +125,11 @@ private string BuildSitemapXML(List items, Site site) private XmlDocument BuildSitemapItem(XmlDocument doc, SitemapItem item, Site site) { - XmlNode urlsetNode = doc.LastChild; + string sitesMultilingual = SitemapManagerConfiguration.SitesMultilingual; + + var sitesMultilingualList= sitesMultilingual.Split('|').ToList(); + + XmlNode urlsetNode = doc.LastChild; XmlNode urlNode = doc.CreateElement("url"); urlsetNode.AppendChild(urlNode); @@ -134,7 +142,30 @@ private XmlDocument BuildSitemapItem(XmlDocument doc, SitemapItem item, Site sit urlNode.AppendChild(lastmodNode); lastmodNode.AppendChild(doc.CreateTextNode(item.LastModified)); - if (!string.IsNullOrWhiteSpace(item.ChangeFrequency)) + var siteIsMultilingual= sitesMultilingualList.FirstOrDefault(x => x.Equals(site.Name)); + + if (siteIsMultilingual != null) + { + if ((item.HrefLangs == null ? false : item.HrefLangs.Count > 0)) + { + foreach (SitemapItemHrefLang hrefLang in item.HrefLangs) + { + XmlElement xmlElement = doc.CreateElement("xhtml", "link", SitemapManagerConfiguration.XmlnsXhtmlTpl); + XmlAttribute xmlAttribute = doc.CreateAttribute("rel"); + xmlAttribute.Value = "alternate"; + xmlElement.Attributes.Append(xmlAttribute); + xmlAttribute = doc.CreateAttribute("hreflang"); + xmlAttribute.Value = hrefLang.HrefLang; + xmlElement.Attributes.Append(xmlAttribute); + xmlAttribute = doc.CreateAttribute("href"); + xmlAttribute.Value = hrefLang.Href; + xmlElement.Attributes.Append(xmlAttribute); + urlNode.AppendChild(xmlElement); + } + } + } + + if (!string.IsNullOrWhiteSpace(item.ChangeFrequency)) { XmlNode changeFrequencyNode = doc.CreateElement("changefreq"); urlNode.AppendChild(changeFrequencyNode); @@ -191,7 +222,6 @@ private void BuildSiteMap() StreamWriter strWriter = new StreamWriter(fullPath, false); strWriter.Write(xmlContent); strWriter.Close(); - } private List GetSitemapItems(string rootPath) diff --git a/Sitemap.XML/Models/SitemapManagerConfiguration.cs b/Sitemap.XML/Models/SitemapManagerConfiguration.cs index ee0a923..d5325a6 100644 --- a/Sitemap.XML/Models/SitemapManagerConfiguration.cs +++ b/Sitemap.XML/Models/SitemapManagerConfiguration.cs @@ -49,11 +49,19 @@ public SitemapManagerConfiguration(string siteName) SiteName = siteName; } - #endregion + #endregion + + #region Properties - #region Properties + public static string SitesMultilingual + { + get + { + return GetValueByName("sitesMultilingual"); + } + } - public static string XmlnsTpl + public static string XmlnsTpl { get { @@ -61,7 +69,15 @@ public static string XmlnsTpl } } - public static string WorkingDatabase + public static string XmlnsXhtmlTpl + { + get + { + return GetValueByName("xmlnsXhtmlTpl"); + } + } + + public static string WorkingDatabase { get { diff --git a/Sitemap.XML/Sitemap.XML.csproj b/Sitemap.XML/Sitemap.XML.csproj index b5a8e08..a8076cf 100644 --- a/Sitemap.XML/Sitemap.XML.csproj +++ b/Sitemap.XML/Sitemap.XML.csproj @@ -1,5 +1,5 @@  - + Debug @@ -12,7 +12,7 @@ Properties Sitemap.XML Sitemap.XML - v4.5 + v4.6.1 4.0 @@ -25,6 +25,7 @@ + true @@ -48,24 +49,21 @@ false - - ..\..\..\..\..\inetpub\wwwroot\test\Website\bin\Sitecore.Buckets.dll - False + + ..\packages\Sitecore.Buckets.NoReferences.8.2.170728\lib\NET452\Sitecore.Buckets.dll - - ..\..\..\..\..\inetpub\wwwroot\test\Website\bin\Sitecore.ContentSearch.dll - False + + ..\packages\Sitecore.ContentSearch.NoReferences.8.2.170728\lib\NET452\Sitecore.ContentSearch.dll - - ..\..\..\..\..\inetpub\wwwroot\test\Website\bin\Sitecore.ContentSearch.Linq.dll - False + + ..\packages\Sitecore.ContentSearch.Linq.NoReferences.8.2.170728\lib\NET452\Sitecore.ContentSearch.Linq.dll - - ..\..\..\..\..\inetpub\wwwroot\test\Website\bin\Sitecore.Kernel.dll - False + + ..\packages\Sitecore.Kernel.NoReferences.8.2.170728\lib\NET452\Sitecore.Kernel.dll + @@ -77,12 +75,14 @@ + + @@ -95,9 +95,17 @@ + + + + web.config + + + web.config + 10.0 diff --git a/Sitemap.XML/packages.config b/Sitemap.XML/packages.config new file mode 100644 index 0000000..0d23b1f --- /dev/null +++ b/Sitemap.XML/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Sitemap.XML/web.Debug.config b/Sitemap.XML/web.Debug.config new file mode 100644 index 0000000..fae9cfe --- /dev/null +++ b/Sitemap.XML/web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Sitemap.XML/web.Release.config b/Sitemap.XML/web.Release.config new file mode 100644 index 0000000..da6e960 --- /dev/null +++ b/Sitemap.XML/web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Sitemap.XML/web.config b/Sitemap.XML/web.config new file mode 100644 index 0000000..66015b1 --- /dev/null +++ b/Sitemap.XML/web.config @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file From 16238ef37be398c9cc0ce48c8437c0eb6633c47d Mon Sep 17 00:00:00 2001 From: mpancho Date: Thu, 4 Jul 2019 17:24:52 -0500 Subject: [PATCH 02/11] Implement functionality Exclude Items --- Sitemap.XML/Models/SitemapItem.cs | 17 ++++++++--------- Sitemap.XML/Models/SitemapManager.cs | 11 ++++++++--- .../Models/SitemapManagerConfiguration.cs | 1 + 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Sitemap.XML/Models/SitemapItem.cs b/Sitemap.XML/Models/SitemapItem.cs index 44d4e3f..8777e7f 100644 --- a/Sitemap.XML/Models/SitemapItem.cs +++ b/Sitemap.XML/Models/SitemapItem.cs @@ -90,7 +90,7 @@ private static string GetSharedItemUrl(Item item, SiteContext site, Item parentI public static string GetSharedItemUrl(Item item, SiteContext site) { var parentItem = SitemapManager.GetSharedLocationParent(item); - var itemUrl = HtmlEncode(GetItemUrl(item, site)); + var itemUrl = HtmlEncode(GetItemUrl(item, site)); var parentUrl = HtmlEncode(GetItemUrl(parentItem, site)); parentUrl = parentUrl.EndsWith("/") ? parentUrl : parentUrl + "/"; var pos = itemUrl.LastIndexOf("/") + 1; @@ -127,11 +127,11 @@ public static string GetItemUrl(Item item, SiteContext site, Language language = if (serverUrl.Contains("http://")) { - serverUrl = serverUrl.Substring("http://".Length); + serverUrl = serverUrl.Substring("http://".Length); } else if (serverUrl.Contains("https://")) { - serverUrl = serverUrl.Substring("https://".Length); + serverUrl = serverUrl.Substring("https://".Length); } StringBuilder sb = new StringBuilder(); @@ -140,27 +140,27 @@ public static string GetItemUrl(Item item, SiteContext site, Language language = { if (url.Contains("://") && !url.Contains("http")) { - sb.Append("http://"); + sb.Append("http://"); sb.Append(serverUrl); if (url.IndexOf("/", 3) > 0) sb.Append(url.Substring(url.IndexOf("/", 3))); } else { - sb.Append("http://"); + sb.Append("http://"); sb.Append(serverUrl); sb.Append(url); } } else if (!string.IsNullOrEmpty(site.Properties["hostname"])) { - sb.Append("http://"); + sb.Append("http://"); sb.Append(site.Properties["hostname"]); sb.Append(url); } else { - if (url.Contains("://") && !url.Contains("http")) + if (url.Contains("://") && !url.Contains("http")) { sb.Append("http://"); sb.Append(url); @@ -170,8 +170,7 @@ public static string GetItemUrl(Item item, SiteContext site, Language language = sb.Append(Sitecore.Web.WebUtil.GetFullUrl(url)); } } - - return sb.ToString(); + return sb.ToString(); } diff --git a/Sitemap.XML/Models/SitemapManager.cs b/Sitemap.XML/Models/SitemapManager.cs index c2a4f29..e43d109 100644 --- a/Sitemap.XML/Models/SitemapManager.cs +++ b/Sitemap.XML/Models/SitemapManager.cs @@ -227,6 +227,7 @@ private void BuildSiteMap() private List GetSitemapItems(string rootPath) { string disTpls = _config.EnabledTemplates; + string excludeItemsField = _config.ExcludedItems; Database database = Factory.GetDatabase(SitemapManagerConfiguration.WorkingDatabase); @@ -245,6 +246,7 @@ private List GetSitemapItems(string rootPath) var sharedDefinitions = Db.SelectItems(string.Format("fast:{0}/*", _config.SitemapConfigurationItemPath)); var site = Factory.GetSite(_config.SiteName); var enabledTemplates = BuildListFromString(disTpls, '|'); + var excludeItems = BuildListFromString(excludeItemsField, '|'); foreach (var sharedDefinition in sharedDefinitions) { if (string.IsNullOrWhiteSpace(sharedDefinition[Constants.SharedContent.ContentLocationFieldName]) || @@ -272,6 +274,7 @@ private List GetSitemapItems(string rootPath) var cleanedSharedItems = from itm in sharedItems where itm.Template != null && enabledTemplates.Select(t => t.ToLower()).Contains(itm.Template.ID.ToString().ToLower()) + && !excludeItems.Contains(itm.ID.ToString()) select itm; var sharedSitemapItems = cleanedSharedItems.Select(i => new SitemapItem(i, site, parentItem)); sharedModels.AddRange(sharedSitemapItems); @@ -282,6 +285,7 @@ private List GetSitemapItems(string rootPath) var selected = from itm in sitemapItems where itm.Template != null && enabledTemplates.Contains(itm.Template.ID.ToString()) + && !excludeItems.Contains(itm.ID.ToString()) select itm; var selectedModels = selected.Select(i => new SitemapItem(i, site, null)).ToList(); @@ -292,8 +296,8 @@ private List GetSitemapItems(string rootPath) private static List BuildListFromString(string str, char separator) { - var enabledTemplates = str.Split(separator); - var selected = from dtp in enabledTemplates + var separatedValues = str.Split(separator); + var selected = from dtp in separatedValues where !string.IsNullOrEmpty(dtp) select dtp; @@ -363,7 +367,8 @@ public static bool IsEnabledTemplate(Item item) public static bool IsExcludedItem(Item item) { - return item[Settings.GetSetting("Sitemap.XML.Fields.ExcludeItemFromSitemap", "Exclude From Sitemap")] == "1"; + var config = new SitemapManagerConfiguration(Context.GetSiteName()); + return config.ExcludedItems.ToLower().Contains(item.ID.ToGuid().ToString()); } public static bool ContainsItemsToShow(IEnumerable items) diff --git a/Sitemap.XML/Models/SitemapManagerConfiguration.cs b/Sitemap.XML/Models/SitemapManagerConfiguration.cs index d5325a6..9d73cdd 100644 --- a/Sitemap.XML/Models/SitemapManagerConfiguration.cs +++ b/Sitemap.XML/Models/SitemapManagerConfiguration.cs @@ -112,6 +112,7 @@ public bool GenerateRobotsFile } public string EnabledTemplates => GetValueByNameFromDatabase(Constants.WebsiteDefinition.EnabledTemplatesFieldName); + public string ExcludedItems => GetValueByNameFromDatabase(Constants.WebsiteDefinition.ExcludedItemsFieldName); public bool CleanupBucketPath => GetValueByNameFromDatabase(Constants.WebsiteDefinition.CleanupBucketPath) == "1"; From 0c3c22617ad61a09aa3c6c9bf7b4a6e7a8b0d7d8 Mon Sep 17 00:00:00 2001 From: Mario Guillen Date: Mon, 8 Jul 2019 03:25:41 -0500 Subject: [PATCH 03/11] MBREQ-297: Added fix for robots.txt with format --- Sitemap.XML/Models/SitemapManager.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Sitemap.XML/Models/SitemapManager.cs b/Sitemap.XML/Models/SitemapManager.cs index e43d109..793ddef 100644 --- a/Sitemap.XML/Models/SitemapManager.cs +++ b/Sitemap.XML/Models/SitemapManager.cs @@ -431,15 +431,12 @@ public void RegisterSitemapToRobotsFile() if (string.IsNullOrWhiteSpace(_config.FileName)) return; string robotsPath = MainUtil.MapPath(string.Concat("/", Constants.RobotsFileName)); StringBuilder sitemapContent = new StringBuilder(string.Empty); - if (File.Exists(robotsPath)) - { - StreamReader sr = new StreamReader(robotsPath); - sitemapContent.Append(sr.ReadToEnd()); - sr.Close(); - } + sitemapContent.AppendLine("User-agent: *"); + sitemapContent.AppendLine("Disallow:"); StreamWriter sw = new StreamWriter(robotsPath, false); - string sitemapLine = string.Concat("Sitemap: ", _config.FileName); + string sitemapUrl = _config.ServerUrl + "/" + _config.FileName; + string sitemapLine = string.Concat("Sitemap: ", sitemapUrl); if (!sitemapContent.ToString().Contains(sitemapLine)) { sitemapContent.AppendLine(sitemapLine); From 026d2527674cce6b8fee75ad2ff96870088922d0 Mon Sep 17 00:00:00 2001 From: Mario Guillen Date: Mon, 30 Sep 2019 14:46:40 -0500 Subject: [PATCH 04/11] Commit for ticket MBREQ-297 --- Sitemap.XML/Models/SitemapItem.cs | 34 ++++++++++++++++++++-------- Sitemap.XML/Models/SitemapManager.cs | 17 +++++++++++--- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Sitemap.XML/Models/SitemapItem.cs b/Sitemap.XML/Models/SitemapItem.cs index 8777e7f..f658d78 100644 --- a/Sitemap.XML/Models/SitemapItem.cs +++ b/Sitemap.XML/Models/SitemapItem.cs @@ -124,15 +124,19 @@ public static string GetItemUrl(Item item, SiteContext site, Language language = string url = Sitecore.Links.LinkManager.GetItemUrl(item, options); var serverUrl = (new SitemapManagerConfiguration(site.Name)).ServerUrl; + + var isHttps = false; if (serverUrl.Contains("http://")) { serverUrl = serverUrl.Substring("http://".Length); + isHttps = false; } else if (serverUrl.Contains("https://")) { serverUrl = serverUrl.Substring("https://".Length); - } + isHttps = true; + } StringBuilder sb = new StringBuilder(); @@ -140,30 +144,42 @@ public static string GetItemUrl(Item item, SiteContext site, Language language = { if (url.Contains("://") && !url.Contains("http")) { - sb.Append("http://"); - sb.Append(serverUrl); + if (isHttps) + sb.Append("https://"); + else + sb.Append("http://"); + sb.Append(serverUrl); if (url.IndexOf("/", 3) > 0) sb.Append(url.Substring(url.IndexOf("/", 3))); } else { - sb.Append("http://"); - sb.Append(serverUrl); + if (isHttps) + sb.Append("https://"); + else + sb.Append("http://"); + sb.Append(serverUrl); sb.Append(url); } } else if (!string.IsNullOrEmpty(site.Properties["hostname"])) { - sb.Append("http://"); - sb.Append(site.Properties["hostname"]); + if (isHttps) + sb.Append("https://"); + else + sb.Append("http://"); + sb.Append(site.Properties["hostname"]); sb.Append(url); } else { if (url.Contains("://") && !url.Contains("http")) { - sb.Append("http://"); - sb.Append(url); + if (isHttps) + sb.Append("https://"); + else + sb.Append("http://"); + sb.Append(url); } else { diff --git a/Sitemap.XML/Models/SitemapManager.cs b/Sitemap.XML/Models/SitemapManager.cs index 793ddef..0892390 100644 --- a/Sitemap.XML/Models/SitemapManager.cs +++ b/Sitemap.XML/Models/SitemapManager.cs @@ -431,10 +431,21 @@ public void RegisterSitemapToRobotsFile() if (string.IsNullOrWhiteSpace(_config.FileName)) return; string robotsPath = MainUtil.MapPath(string.Concat("/", Constants.RobotsFileName)); StringBuilder sitemapContent = new StringBuilder(string.Empty); - sitemapContent.AppendLine("User-agent: *"); - sitemapContent.AppendLine("Disallow:"); + - StreamWriter sw = new StreamWriter(robotsPath, false); + if (File.Exists(robotsPath)) + { + StreamReader sr = new StreamReader(robotsPath); + sitemapContent.Append(sr.ReadToEnd()); + sr.Close(); + } + else + { + sitemapContent.AppendLine("User-agent: *"); + sitemapContent.AppendLine("Disallow:"); + } + + StreamWriter sw = new StreamWriter(robotsPath, false); string sitemapUrl = _config.ServerUrl + "/" + _config.FileName; string sitemapLine = string.Concat("Sitemap: ", sitemapUrl); if (!sitemapContent.ToString().Contains(sitemapLine)) From 094cc0fbf7d1c0944f1cca0609438eb1df4d46ad Mon Sep 17 00:00:00 2001 From: mpancho Date: Tue, 1 Oct 2019 16:03:09 -0500 Subject: [PATCH 05/11] Task 440. Robots txt file is generated with the link to sitemap of a specific site --- .../App_Config/Include/SitemapXML.config | 19 ++++++- Sitemap.XML/Configuration/RobotHandler.cs | 49 +++++++++++++++++++ Sitemap.XML/Constants.cs | 3 +- Sitemap.XML/Models/SitemapHandler.cs | 6 +-- Sitemap.XML/Models/SitemapManager.cs | 16 +++++- .../Models/SitemapManagerConfiguration.cs | 7 +-- Sitemap.XML/Sitemap.XML.csproj | 1 + 7 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 Sitemap.XML/Configuration/RobotHandler.cs diff --git a/Sitemap.XML/App_Config/Include/SitemapXML.config b/Sitemap.XML/App_Config/Include/SitemapXML.config index a5c8c99..a21f0f4 100644 --- a/Sitemap.XML/App_Config/Include/SitemapXML.config +++ b/Sitemap.XML/App_Config/Include/SitemapXML.config @@ -45,13 +45,30 @@ 1 /My Account/|/Customer/ + + + 1 + /My Account/|/Customer/ + + + - aspx, ashx, asmx, xml + aspx, ashx, asmx, xml, txt diff --git a/Sitemap.XML/Configuration/RobotHandler.cs b/Sitemap.XML/Configuration/RobotHandler.cs new file mode 100644 index 0000000..290c13a --- /dev/null +++ b/Sitemap.XML/Configuration/RobotHandler.cs @@ -0,0 +1,49 @@ +#region + +using System; +using Sitecore; +using Sitecore.Caching; +using Sitecore.Diagnostics; +using Sitecore.Pipelines.HttpRequest; +using Sitemap.XML.Models; + +#endregion + +namespace Sitemap.XML.Configuration +{ + public class RobotHandler : HttpRequestProcessor + { + public override void Process(HttpRequestArgs args) + { + Assert.ArgumentNotNull(args, "args"); + if (Context.Site == null || string.IsNullOrEmpty(Context.Site.RootPath.Trim())) return; + if (Context.Page.FilePath.Length > 0) return; + var site = Context.Site; + if (!args.Url.FilePath.Contains(Constants.RobotsFileName)) return; + + args.Context.Response.ClearHeaders(); + args.Context.Response.ClearContent(); + args.Context.Response.ContentType = "text/plain"; + + var content = string.Empty; + try + { + var config = new SitemapManagerConfiguration(site.Name); + var sitemapManager = new SitemapManager(config); + + content = sitemapManager.GetRobotSite(); + args.Context.Response.Write(content); + } + catch (Exception e) + { + Log.Error("Error Robots", e, this); + } + finally + { + + args.Context.Response.Flush(); + args.Context.Response.End(); + } + } + } +} \ No newline at end of file diff --git a/Sitemap.XML/Constants.cs b/Sitemap.XML/Constants.cs index 8b71512..a7629a3 100644 --- a/Sitemap.XML/Constants.cs +++ b/Sitemap.XML/Constants.cs @@ -34,9 +34,10 @@ public struct WebsiteDefinition public static string FileNameFieldName = "File Name"; public static string ServerUrlFieldName = "Server Url"; public static string CleanupBucketPath = "Cleanup Bucket Path"; + public static string SitemapNameForRobots = "Sitemap name for Robots"; } - public static string SitemapParserUser = @"extranet\Anonymous"; + public static string SitemapParserUser = @"extranet\Anonymous"; public static string SitemapModuleSettingsRootItemId = "{6003D67E-0000-4A4D-BFB1-11408B9ADCFD}"; public static string RobotsFileName = "robots.txt"; public static string SitemapSubmissionUriFieldName = "Sitemap Submission Uri"; diff --git a/Sitemap.XML/Models/SitemapHandler.cs b/Sitemap.XML/Models/SitemapHandler.cs index cb99280..7ab7fdc 100644 --- a/Sitemap.XML/Models/SitemapHandler.cs +++ b/Sitemap.XML/Models/SitemapHandler.cs @@ -36,9 +36,9 @@ public void RefreshSitemap(object sender, EventArgs args) var config = new SitemapManagerConfiguration(site); var sitemapManager = new SitemapManager(config); sitemapManager.SubmitSitemapToSearchenginesByHttp(); - - if (!config.GenerateRobotsFile) continue; - sitemapManager.RegisterSitemapToRobotsFile(); + //removed because now the robots is generated when it is invoked the url with robots.txt at the end + //if (!config.GenerateRobotsFile) continue; + //sitemapManager.RegisterSitemapToRobotsFile(); } } catch (Exception e) diff --git a/Sitemap.XML/Models/SitemapManager.cs b/Sitemap.XML/Models/SitemapManager.cs index 0892390..a278494 100644 --- a/Sitemap.XML/Models/SitemapManager.cs +++ b/Sitemap.XML/Models/SitemapManager.cs @@ -456,6 +456,20 @@ public void RegisterSitemapToRobotsFile() sw.Close(); } - #endregion + public string GetRobotSite() + { + StringBuilder sitemapContent = new StringBuilder(string.Empty); + sitemapContent.AppendLine("User-agent: *"); + sitemapContent.AppendLine("Disallow:"); + string sitemapUrl = _config.ServerUrl + "/" + _config.SitemapNameForRobots; + string sitemapLine = string.Concat("Sitemap: ", sitemapUrl); + if (!sitemapContent.ToString().Contains(sitemapLine)) + { + sitemapContent.AppendLine(sitemapLine); + } + return sitemapContent.ToString(); + } + + #endregion } } \ No newline at end of file diff --git a/Sitemap.XML/Models/SitemapManagerConfiguration.cs b/Sitemap.XML/Models/SitemapManagerConfiguration.cs index 9d73cdd..9059301 100644 --- a/Sitemap.XML/Models/SitemapManagerConfiguration.cs +++ b/Sitemap.XML/Models/SitemapManagerConfiguration.cs @@ -138,12 +138,13 @@ public static bool IsProductionEnvironment public string SiteName { get; } = string.Empty; public string FileName => GetValueByNameFromDatabase(Constants.WebsiteDefinition.FileNameFieldName); + public string SitemapNameForRobots => GetValueByNameFromDatabase(Constants.WebsiteDefinition.SitemapNameForRobots); - #endregion properties + #endregion properties - #region Private Methods + #region Private Methods - private static string GetValueByName(string name) + private static string GetValueByName(string name) { var result = string.Empty; diff --git a/Sitemap.XML/Sitemap.XML.csproj b/Sitemap.XML/Sitemap.XML.csproj index a8076cf..3183038 100644 --- a/Sitemap.XML/Sitemap.XML.csproj +++ b/Sitemap.XML/Sitemap.XML.csproj @@ -78,6 +78,7 @@ + From 44c98e529fcd481a1079aa403d68464c7cd6976d Mon Sep 17 00:00:00 2001 From: mpancho Date: Tue, 18 Feb 2020 11:43:11 -0500 Subject: [PATCH 06/11] Update Sitecore version to 9.1.1 --- Sitemap.XML.sln | 1 + .../App_Config/Include/SitemapXML.config | 110 ++++++------- Sitemap.XML/Configuration/SitemapHandler.cs | 76 ++++----- Sitemap.XML/Sitemap.XML.csproj | 149 ++++++++++++++++-- Sitemap.XML/packages.config | 43 ++++- Sitemap.XML/web.config | 14 +- 6 files changed, 276 insertions(+), 117 deletions(-) diff --git a/Sitemap.XML.sln b/Sitemap.XML.sln index 82979fe..6e83175 100644 --- a/Sitemap.XML.sln +++ b/Sitemap.XML.sln @@ -22,6 +22,7 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution + EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.Common.6.0.1304.0\lib\NET45;packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8;packages\EnterpriseLibrary.TransientFaultHandling.Caching.6.0.1304.0\lib\NET45;packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45;packages\EnterpriseLibrary.TransientFaultHandling.ServiceBus.6.0.1304.0\lib\NET45;packages\EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage.6.0.1304.0\lib\NET45;packages\EnterpriseLibrary.TransientFaultHandling.Configuration.6.0.1304.0\lib\NET45 SolutionGuid = {354BB054-3BDB-4B02-8661-9592CCB79295} EndGlobalSection EndGlobal diff --git a/Sitemap.XML/App_Config/Include/SitemapXML.config b/Sitemap.XML/App_Config/Include/SitemapXML.config index a21f0f4..5daeb34 100644 --- a/Sitemap.XML/App_Config/Include/SitemapXML.config +++ b/Sitemap.XML/App_Config/Include/SitemapXML.config @@ -1,53 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - 1 - /My Account/|/Customer/ - - - - 1 - /My Account/|/Customer/ - - - - - - - - - aspx, ashx, asmx, xml, txt - - - - - - - - - - - + 1 + /My Account/|/Customer/ + + + + + + + + + aspx, ashx, asmx, xml, txt + + + + + + + + + + + \ No newline at end of file diff --git a/Sitemap.XML/Configuration/SitemapHandler.cs b/Sitemap.XML/Configuration/SitemapHandler.cs index d89d72e..50dc825 100644 --- a/Sitemap.XML/Configuration/SitemapHandler.cs +++ b/Sitemap.XML/Configuration/SitemapHandler.cs @@ -11,32 +11,32 @@ namespace Sitemap.XML.Configuration { - public class SitemapHandler : HttpRequestProcessor - { - #region Properties + public class SitemapHandler : HttpRequestProcessor + { + #region Properties - public string ExcludedPaths { get; set; } - public string CacheTime { get; set; } + public string ExcludedPaths { get; set; } + public string CacheTime { get; set; } - #endregion + #endregion - public override void Process(HttpRequestArgs args) - { + public override void Process(HttpRequestArgs args) + { Assert.ArgumentNotNull(args, "args"); - if (Context.Site == null || string.IsNullOrEmpty(Context.Site.RootPath.Trim())) return; - if (Context.Page.FilePath.Length > 0) return; - var sitemapHandler = string.IsNullOrWhiteSpace(Context.Site.Properties["sitemapHandler"]) - ? "sitemap.xml" - : Context.Site.Properties["sitemapHandler"]; - if (!args.Url.FilePath.Contains(sitemapHandler)) return; + if (Context.Site == null || string.IsNullOrEmpty(Context.Site.RootPath.Trim())) return; + if (Context.Page.FilePath.Length > 0) return; + var sitemapHandler = string.IsNullOrWhiteSpace(Context.Site.Properties["sitemapHandler"]) + ? "sitemap.xml" + : Context.Site.Properties["sitemapHandler"]; + if (!args.Url.FilePath.Contains(sitemapHandler)) return; - // Important to return qualified XML (text/xml) for sitemaps - args.Context.Response.ClearHeaders(); - args.Context.Response.ClearContent(); - args.Context.Response.ContentType = "text/xml"; + // Important to return qualified XML (text/xml) for sitemaps + args.Context.Response.ClearHeaders(); + args.Context.Response.ClearContent(); + args.Context.Response.ContentType = "text/xml"; - // Checking the HTML cache first - var site = Context.Site; + // Checking the HTML cache first + var site = Context.Site; #if !DEBUG var cacheKey = "UltimateSitemapXML_" + site.Name; var cache = CacheManager.GetHtmlCache(site).GetHtml(cacheKey); @@ -48,27 +48,27 @@ public override void Process(HttpRequestArgs args) } #endif - var content = string.Empty; - try - { - var config = new SitemapManagerConfiguration(site.Name); - var sitemapManager = new SitemapManager(config); + var content = string.Empty; + try + { + var config = new SitemapManagerConfiguration(site.Name); + var sitemapManager = new SitemapManager(config); - content = sitemapManager.BuildSiteMapForHandler(); - args.Context.Response.Write(content); - } - catch (Exception e) - { - Log.Error("Error Sitemap", e, this); - } + content = sitemapManager.BuildSiteMapForHandler(); + args.Context.Response.Write(content); + } + catch (Exception e) + { + Log.Error("Error Sitemap", e, this); + } finally - { + { #if !DEBUG CacheManager.GetHtmlCache(site).SetHtml(cacheKey, content); #endif - args.Context.Response.Flush(); - args.Context.Response.End(); - } - } - } + args.Context.Response.Flush(); + args.Context.Response.End(); + } + } + } } \ No newline at end of file diff --git a/Sitemap.XML/Sitemap.XML.csproj b/Sitemap.XML/Sitemap.XML.csproj index 3183038..0bacb0d 100644 --- a/Sitemap.XML/Sitemap.XML.csproj +++ b/Sitemap.XML/Sitemap.XML.csproj @@ -12,7 +12,7 @@ Properties Sitemap.XML Sitemap.XML - v4.6.1 + v4.7.1 4.0 @@ -49,33 +49,160 @@ false - - ..\packages\Sitecore.Buckets.NoReferences.8.2.170728\lib\NET452\Sitecore.Buckets.dll + + ..\packages\DocumentFormat.OpenXml.2.7.2\lib\net46\DocumentFormat.OpenXml.dll - - ..\packages\Sitecore.ContentSearch.NoReferences.8.2.170728\lib\NET452\Sitecore.ContentSearch.dll + + ..\packages\HtmlAgilityPack.1.4.9.5\lib\Net45\HtmlAgilityPack.dll - - ..\packages\Sitecore.ContentSearch.Linq.NoReferences.8.2.170728\lib\NET452\Sitecore.ContentSearch.Linq.dll + + ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll - - ..\packages\Sitecore.Kernel.NoReferences.8.2.170728\lib\NET452\Sitecore.Kernel.dll + + ..\packages\Lucene.Net.3.0.3\lib\NET40\Lucene.Net.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.2.1.1\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\EnterpriseLibrary.Common.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.Common.dll + + + ..\packages\EnterpriseLibrary.TransientFaultHandling.6.0.1304.0\lib\portable-net45+win+wp8\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll + + + ..\packages\EnterpriseLibrary.TransientFaultHandling.Caching.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Caching.dll + + + ..\packages\EnterpriseLibrary.TransientFaultHandling.Configuration.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Configuration.dll + + + ..\packages\EnterpriseLibrary.TransientFaultHandling.Data.6.0.1304.1\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll + + + ..\packages\EnterpriseLibrary.TransientFaultHandling.ServiceBus.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.ServiceBus.dll + + + ..\packages\EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage.dll + + + ..\packages\Mvp.Xml.2.3.0\lib\net20\Mvp.Xml.dll + + + ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll + + + ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll + + + ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.Charting.dll + + + ..\packages\Sitecore.Abstractions.9.1.1\lib\net471\Sitecore.Abstractions.dll + + + ..\packages\Sitecore.Buckets.9.1.1\lib\net471\Sitecore.Buckets.dll + + + ..\packages\Sitecore.Client.9.1.1\lib\net471\Sitecore.Client.dll + + + ..\packages\Sitecore.ContentSearch.9.1.1\lib\net471\Sitecore.ContentSearch.dll + + + ..\packages\Sitecore.ContentSearch.Client.9.1.1\lib\net471\Sitecore.ContentSearch.Client.dll + + + ..\packages\Sitecore.ContentSearch.ContentExtraction.9.1.1\lib\net471\Sitecore.ContentSearch.ContentExtraction.dll + + + ..\packages\Sitecore.ContentSearch.Data.9.1.1\lib\net471\Sitecore.ContentSearch.Data.dll + + + ..\packages\Sitecore.ContentSearch.Linq.9.1.1\lib\net471\Sitecore.ContentSearch.Linq.dll + + + ..\packages\Sitecore.Kernel.9.1.1\lib\net471\Sitecore.Kernel.dll + + + ..\packages\Sitecore.Logging.9.1.1\lib\net471\Sitecore.Logging.dll + + + ..\packages\Sitecore.Logging.Client.9.1.1\lib\net471\Sitecore.Logging.Client.dll + + + ..\packages\Sitecore.Nexus.9.1.1\lib\net471\Sitecore.Nexus.dll + + + ..\packages\Sitecore.Nexus.Consumption.1.0.0\lib\netstandard2.0\Sitecore.Nexus.Consumption.dll + + + ..\packages\Sitecore.Nexus.Licensing.2.0.5\lib\netstandard2.0\Sitecore.Nexus.Licensing.dll + + + ..\packages\Sitecore.NVelocity.9.1.1\lib\net471\Sitecore.NVelocity.dll + + + ..\packages\Sitecore.Publishing.WebDeploy.9.1.1\lib\net471\Sitecore.Publishing.WebDeploy.dll + + + ..\packages\Sitecore.Zip.9.1.1\lib\net471\Sitecore.Zip.dll + + + + + + + + + ..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll + True + + + ..\packages\System.IO.Packaging.4.0.0\lib\net46\System.IO.Packaging.dll + + + + + + + ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll + + + ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll + + + ..\packages\System.Security.Permissions.4.5.0\lib\net461\System.Security.Permissions.dll + + + ..\packages\System.Security.Principal.Windows.4.5.0\lib\net461\System.Security.Principal.Windows.dll + + + + + + + + @@ -100,7 +227,9 @@ - + + Designer + web.config diff --git a/Sitemap.XML/packages.config b/Sitemap.XML/packages.config index 0d23b1f..1d313e8 100644 --- a/Sitemap.XML/packages.config +++ b/Sitemap.XML/packages.config @@ -1,7 +1,42 @@  - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sitemap.XML/web.config b/Sitemap.XML/web.config index 66015b1..e950d98 100644 --- a/Sitemap.XML/web.config +++ b/Sitemap.XML/web.config @@ -1,4 +1,4 @@ - + - - + + + + + + + + + + \ No newline at end of file From 691669f087dda42989807a0268b712e3371aa2d3 Mon Sep 17 00:00:00 2001 From: Yamilet Contreras Date: Wed, 6 Oct 2021 15:20:16 -0500 Subject: [PATCH 07/11] Update for Sitecore 10 --- Sitemap.XML/Configuration/RobotHandler.cs | 12 ++++++------ Sitemap.XML/Configuration/SitemapHandler.cs | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Sitemap.XML/Configuration/RobotHandler.cs b/Sitemap.XML/Configuration/RobotHandler.cs index 290c13a..a29db17 100644 --- a/Sitemap.XML/Configuration/RobotHandler.cs +++ b/Sitemap.XML/Configuration/RobotHandler.cs @@ -21,9 +21,9 @@ public override void Process(HttpRequestArgs args) var site = Context.Site; if (!args.Url.FilePath.Contains(Constants.RobotsFileName)) return; - args.Context.Response.ClearHeaders(); - args.Context.Response.ClearContent(); - args.Context.Response.ContentType = "text/plain"; + args.HttpContext.Response.ClearHeaders(); + args.HttpContext.Response.ClearContent(); + args.HttpContext.Response.ContentType = "text/plain"; var content = string.Empty; try @@ -32,7 +32,7 @@ public override void Process(HttpRequestArgs args) var sitemapManager = new SitemapManager(config); content = sitemapManager.GetRobotSite(); - args.Context.Response.Write(content); + args.HttpContext.Response.Write(content); } catch (Exception e) { @@ -41,8 +41,8 @@ public override void Process(HttpRequestArgs args) finally { - args.Context.Response.Flush(); - args.Context.Response.End(); + args.HttpContext.Response.Flush(); + args.HttpContext.Response.End(); } } } diff --git a/Sitemap.XML/Configuration/SitemapHandler.cs b/Sitemap.XML/Configuration/SitemapHandler.cs index 50dc825..a429d28 100644 --- a/Sitemap.XML/Configuration/SitemapHandler.cs +++ b/Sitemap.XML/Configuration/SitemapHandler.cs @@ -31,9 +31,9 @@ public override void Process(HttpRequestArgs args) if (!args.Url.FilePath.Contains(sitemapHandler)) return; // Important to return qualified XML (text/xml) for sitemaps - args.Context.Response.ClearHeaders(); - args.Context.Response.ClearContent(); - args.Context.Response.ContentType = "text/xml"; + args.HttpContext.Response.ClearHeaders(); + args.HttpContext.Response.ClearContent(); + args.HttpContext.Response.ContentType = "text/xml"; // Checking the HTML cache first var site = Context.Site; @@ -42,8 +42,8 @@ public override void Process(HttpRequestArgs args) var cache = CacheManager.GetHtmlCache(site).GetHtml(cacheKey); if (!string.IsNullOrWhiteSpace(cache)) { - args.Context.Response.Write(cache); - args.Context.Response.End(); + args.HttpContext.Response.Write(cache); + args.HttpContext.Response.End(); return; } #endif @@ -55,7 +55,7 @@ public override void Process(HttpRequestArgs args) var sitemapManager = new SitemapManager(config); content = sitemapManager.BuildSiteMapForHandler(); - args.Context.Response.Write(content); + args.HttpContext.Response.Write(content); } catch (Exception e) { @@ -66,8 +66,8 @@ public override void Process(HttpRequestArgs args) #if !DEBUG CacheManager.GetHtmlCache(site).SetHtml(cacheKey, content); #endif - args.Context.Response.Flush(); - args.Context.Response.End(); + args.HttpContext.Response.Flush(); + args.HttpContext.Response.End(); } } } From 6493df569c6cdadc1eecbfdd54ca3e419d3fff26 Mon Sep 17 00:00:00 2001 From: mpancho Date: Mon, 24 Jul 2023 13:07:58 -0400 Subject: [PATCH 08/11] Update to framework 4.8. Update Sitecore libraries with the version 10.1.1. Use LanguageSwitcher with the Item language. --- .../App_Config/Include/SitemapXML.config | 2 +- Sitemap.XML/Models/SitemapItem.cs | 21 ++- Sitemap.XML/Sitemap.XML.csproj | 171 ++++++++++++++---- Sitemap.XML/packages.config | 67 +++++-- Sitemap.XML/web.config | 58 +++++- 5 files changed, 251 insertions(+), 68 deletions(-) diff --git a/Sitemap.XML/App_Config/Include/SitemapXML.config b/Sitemap.XML/App_Config/Include/SitemapXML.config index 5daeb34..3bc3d4f 100644 --- a/Sitemap.XML/App_Config/Include/SitemapXML.config +++ b/Sitemap.XML/App_Config/Include/SitemapXML.config @@ -14,7 +14,7 @@ - + diff --git a/Sitemap.XML/Models/SitemapItem.cs b/Sitemap.XML/Models/SitemapItem.cs index f658d78..59a59b3 100644 --- a/Sitemap.XML/Models/SitemapItem.cs +++ b/Sitemap.XML/Models/SitemapItem.cs @@ -115,13 +115,22 @@ public static string GetItemUrl(Item item, SiteContext site, Language language = options.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving; options.Site = SiteContext.GetSite(site.Name); options.AlwaysIncludeServerUrl = false; - if (language != null) - { - options.LanguageEmbedding = LanguageEmbedding.Always; - options.Language = language; - } + string url = ""; + + if (language != null) + { + options.LanguageEmbedding = LanguageEmbedding.Always; + options.Language = language; + using (new LanguageSwitcher(language)) + { + url = Sitecore.Links.LinkManager.GetItemUrl(item, options); + } + } + else + { + url = Sitecore.Links.LinkManager.GetItemUrl(item, options); + } - string url = Sitecore.Links.LinkManager.GetItemUrl(item, options); var serverUrl = (new SitemapManagerConfiguration(site.Name)).ServerUrl; diff --git a/Sitemap.XML/Sitemap.XML.csproj b/Sitemap.XML/Sitemap.XML.csproj index 0bacb0d..89899e8 100644 --- a/Sitemap.XML/Sitemap.XML.csproj +++ b/Sitemap.XML/Sitemap.XML.csproj @@ -12,7 +12,7 @@ Properties Sitemap.XML Sitemap.XML - v4.7.1 + v4.8 4.0 @@ -55,18 +55,51 @@ ..\packages\HtmlAgilityPack.1.4.9.5\lib\Net45\HtmlAgilityPack.dll - - ..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + + ..\packages\SharpZipLib.1.3.0\lib\net45\ICSharpCode.SharpZipLib.dll ..\packages\Lucene.Net.3.0.3\lib\NET40\Lucene.Net.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.1\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Configuration.ConfigurationBuilders.Base.1.0.2\lib\Net471\Microsoft.Configuration.ConfigurationBuilders.Base.dll + + + ..\packages\Microsoft.Configuration.ConfigurationBuilders.Environment.1.0.2\lib\Net471\Microsoft.Configuration.ConfigurationBuilders.Environment.dll + - - ..\packages\Microsoft.Extensions.DependencyInjection.2.1.1\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + ..\packages\Microsoft.Extensions.Configuration.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll + + + ..\packages\Microsoft.Extensions.Configuration.Abstractions.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.3.1.5\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.5\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + ..\packages\Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll ..\packages\EnterpriseLibrary.Common.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.Common.dll @@ -89,6 +122,15 @@ ..\packages\EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.WindowsAzure.Storage.dll + + ..\packages\Microsoft.Web.Deployment.3.5.0\lib\Net40\Microsoft.Web.Delegation.dll + + + ..\packages\Microsoft.Web.Deployment.3.5.0\lib\Net40\Microsoft.Web.Deployment.dll + + + ..\packages\Microsoft.Web.Deployment.3.5.0\lib\Net40\Microsoft.Web.Deployment.Tracing.dll + ..\packages\Mvp.Xml.2.3.0\lib\net20\Mvp.Xml.dll @@ -101,65 +143,88 @@ ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.Charting.dll - - ..\packages\Sitecore.Abstractions.9.1.1\lib\net471\Sitecore.Abstractions.dll + + ..\packages\protobuf-net.2.0.0.668\lib\net40\protobuf-net.dll - - ..\packages\Sitecore.Buckets.9.1.1\lib\net471\Sitecore.Buckets.dll + + ..\packages\Sitecore.Abstractions.9.2.0\lib\net471\Sitecore.Abstractions.dll - - ..\packages\Sitecore.Client.9.1.1\lib\net471\Sitecore.Client.dll + + ..\packages\Sitecore.Annotations.10.1.1\lib\net471\Sitecore.Annotations.dll - - ..\packages\Sitecore.ContentSearch.9.1.1\lib\net471\Sitecore.ContentSearch.dll + + ..\packages\Sitecore.Buckets.10.1.1\lib\net48\Sitecore.Buckets.dll - - ..\packages\Sitecore.ContentSearch.Client.9.1.1\lib\net471\Sitecore.ContentSearch.Client.dll + + ..\packages\Sitecore.Client.10.1.1\lib\net48\Sitecore.Client.dll - - ..\packages\Sitecore.ContentSearch.ContentExtraction.9.1.1\lib\net471\Sitecore.ContentSearch.ContentExtraction.dll + + ..\packages\Sitecore.ContentSearch.10.1.1\lib\net48\Sitecore.ContentSearch.dll - - ..\packages\Sitecore.ContentSearch.Data.9.1.1\lib\net471\Sitecore.ContentSearch.Data.dll + + ..\packages\Sitecore.ContentSearch.Client.10.1.1\lib\net48\Sitecore.ContentSearch.Client.dll - - ..\packages\Sitecore.ContentSearch.Linq.9.1.1\lib\net471\Sitecore.ContentSearch.Linq.dll + + ..\packages\Sitecore.ContentSearch.ContentExtraction.10.1.1\lib\net48\Sitecore.ContentSearch.ContentExtraction.dll - - ..\packages\Sitecore.Kernel.9.1.1\lib\net471\Sitecore.Kernel.dll + + ..\packages\Sitecore.ContentSearch.Data.10.1.1\lib\net48\Sitecore.ContentSearch.Data.dll - - ..\packages\Sitecore.Logging.9.1.1\lib\net471\Sitecore.Logging.dll + + ..\packages\Sitecore.ContentSearch.Linq.10.1.1\lib\net48\Sitecore.ContentSearch.Linq.dll - - ..\packages\Sitecore.Logging.Client.9.1.1\lib\net471\Sitecore.Logging.Client.dll + + ..\packages\Sitecore.Framework.Conditions.5.0.0\lib\netstandard2.0\Sitecore.Framework.Conditions.dll - - ..\packages\Sitecore.Nexus.9.1.1\lib\net471\Sitecore.Nexus.dll + + ..\packages\Sitecore.Framework.Data.Blobs.2.0.0\lib\netstandard2.0\Sitecore.Framework.Data.Blobs.dll + + + ..\packages\Sitecore.Framework.Data.Blobs.Abstractions.2.0.0\lib\netstandard2.0\Sitecore.Framework.Data.Blobs.Abstractions.dll + + + ..\packages\Sitecore.Kernel.10.1.1\lib\net48\Sitecore.Kernel.dll + + + ..\packages\Sitecore.Logging.10.1.1\lib\net48\Sitecore.Logging.dll + + + ..\packages\Sitecore.Logging.Client.10.1.1\lib\net48\Sitecore.Logging.Client.dll + + + ..\packages\Sitecore.Nexus.10.1.1\lib\net48\Sitecore.Nexus.dll - ..\packages\Sitecore.Nexus.Consumption.1.0.0\lib\netstandard2.0\Sitecore.Nexus.Consumption.dll + ..\packages\Sitecore.Nexus.Consumption.1.3.1\lib\netstandard2.0\Sitecore.Nexus.Consumption.dll - ..\packages\Sitecore.Nexus.Licensing.2.0.5\lib\netstandard2.0\Sitecore.Nexus.Licensing.dll + ..\packages\Sitecore.Nexus.Licensing.2.0.6\lib\netstandard2.0\Sitecore.Nexus.Licensing.dll - - ..\packages\Sitecore.NVelocity.9.1.1\lib\net471\Sitecore.NVelocity.dll + + ..\packages\Sitecore.NVelocity.9.2.0\lib\net471\Sitecore.NVelocity.dll - - ..\packages\Sitecore.Publishing.WebDeploy.9.1.1\lib\net471\Sitecore.Publishing.WebDeploy.dll + + ..\packages\Sitecore.Publishing.WebDeploy.9.2.0\lib\net471\Sitecore.Publishing.WebDeploy.dll - - ..\packages\Sitecore.Zip.9.1.1\lib\net471\Sitecore.Zip.dll + + ..\packages\Sitecore.Zip.10.1.1\lib\net48\Sitecore.Zip.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.ComponentModel.Annotations.4.7.0\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll @@ -168,8 +233,26 @@ ..\packages\System.IO.Packaging.4.0.0\lib\net46\System.IO.Packaging.dll + + + ..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll + + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.6\lib\net45\System.Net.Http.Formatting.dll + + + + ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + @@ -187,6 +270,10 @@ + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + @@ -195,6 +282,12 @@ + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.6\lib\net45\System.Web.Http.dll + + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.6\lib\net45\System.Web.Http.WebHost.dll + diff --git a/Sitemap.XML/packages.config b/Sitemap.XML/packages.config index 1d313e8..adae386 100644 --- a/Sitemap.XML/packages.config +++ b/Sitemap.XML/packages.config @@ -10,33 +10,60 @@ - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sitemap.XML/web.config b/Sitemap.XML/web.config index e950d98..dd4a835 100644 --- a/Sitemap.XML/web.config +++ b/Sitemap.XML/web.config @@ -8,8 +8,15 @@ --> + +
+ + + + + - + @@ -18,6 +25,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + + + + + + + + \ No newline at end of file From 39e1b69a6cc8c15cbe8a6fd16c9d7031062ff2ee Mon Sep 17 00:00:00 2001 From: Andres Mino Date: Wed, 8 Nov 2023 18:14:41 -0500 Subject: [PATCH 09/11] As an editor I would like change couple of behavioral properties of the "qa-do-not-delete" folder (MBREQ-4740) (feature) --- Sitemap.XML/Models/SitemapManager.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sitemap.XML/Models/SitemapManager.cs b/Sitemap.XML/Models/SitemapManager.cs index a278494..d27f223 100644 --- a/Sitemap.XML/Models/SitemapManager.cs +++ b/Sitemap.XML/Models/SitemapManager.cs @@ -460,8 +460,10 @@ public string GetRobotSite() { StringBuilder sitemapContent = new StringBuilder(string.Empty); sitemapContent.AppendLine("User-agent: *"); - sitemapContent.AppendLine("Disallow:"); - string sitemapUrl = _config.ServerUrl + "/" + _config.SitemapNameForRobots; + sitemapContent.AppendLine("Disallow: /ns/"); + sitemapContent.AppendLine("Disallow: /QA/"); + sitemapContent.AppendLine("Disallow: /UITest/"); + string sitemapUrl = _config.ServerUrl + "/" + _config.SitemapNameForRobots; string sitemapLine = string.Concat("Sitemap: ", sitemapUrl); if (!sitemapContent.ToString().Contains(sitemapLine)) { From 3510ded50749c5bf2ca293d2c13159436fa4d562 Mon Sep 17 00:00:00 2001 From: Andres Mino Date: Fri, 10 Nov 2023 10:09:23 -0500 Subject: [PATCH 10/11] As an editor I would like change couple of behavioral properties of the "qa-do-not-delete" folder (MBREQ-4740) (bug) --- Sitemap.XML/Models/SitemapManager.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sitemap.XML/Models/SitemapManager.cs b/Sitemap.XML/Models/SitemapManager.cs index d27f223..1001c7e 100644 --- a/Sitemap.XML/Models/SitemapManager.cs +++ b/Sitemap.XML/Models/SitemapManager.cs @@ -460,10 +460,20 @@ public string GetRobotSite() { StringBuilder sitemapContent = new StringBuilder(string.Empty); sitemapContent.AppendLine("User-agent: *"); - sitemapContent.AppendLine("Disallow: /ns/"); - sitemapContent.AppendLine("Disallow: /QA/"); + sitemapContent.AppendLine("Disallow: /ns/*"); + sitemapContent.AppendLine("Disallow: /QA/*"); sitemapContent.AppendLine("Disallow: /UITest/"); string sitemapUrl = _config.ServerUrl + "/" + _config.SitemapNameForRobots; + if (sitemapUrl.Contains("seiumb")){ + sitemapContent.AppendLine("Disallow: /*/ns/*"); + sitemapContent.AppendLine("Disallow: /*/QA/*"); + sitemapContent.AppendLine("Disallow: /*/UITest/*"); + } + else + { + sitemapContent.AppendLine("Disallow: /QA%20do%20not%20delete/*"); + sitemapContent.AppendLine("Disallow: /Migration/*"); + } string sitemapLine = string.Concat("Sitemap: ", sitemapUrl); if (!sitemapContent.ToString().Contains(sitemapLine)) { From e276542c583525c1f0151ec0ef11af40ba4d7535 Mon Sep 17 00:00:00 2001 From: mpancho Date: Fri, 5 Jan 2024 22:43:32 +0000 Subject: [PATCH 11/11] Upgraded to SC 10.3.1 --- .vs/Sitemap.XML/config/applicationhost.config | 1023 +++++++++++++++++ Sitemap.XML/Models/SitemapItem.cs | 11 +- Sitemap.XML/Sitemap.XML.csproj | 152 ++- Sitemap.XML/packages.config | 63 +- Sitemap.XML/web.config | 24 +- 5 files changed, 1179 insertions(+), 94 deletions(-) create mode 100644 .vs/Sitemap.XML/config/applicationhost.config diff --git a/.vs/Sitemap.XML/config/applicationhost.config b/.vs/Sitemap.XML/config/applicationhost.config new file mode 100644 index 0000000..a9d1b10 --- /dev/null +++ b/.vs/Sitemap.XML/config/applicationhost.config @@ -0,0 +1,1023 @@ + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sitemap.XML/Models/SitemapItem.cs b/Sitemap.XML/Models/SitemapItem.cs index 59a59b3..10fc8c4 100644 --- a/Sitemap.XML/Models/SitemapItem.cs +++ b/Sitemap.XML/Models/SitemapItem.cs @@ -6,6 +6,7 @@ using System.Web; using Sitecore.Globalization; using Sitecore.Links; +using Sitecore.Links.UrlBuilders; namespace Sitemap.XML.Models { @@ -110,11 +111,13 @@ public static string HtmlEncode(string text) public static string GetItemUrl(Item item, SiteContext site, Language language = null) { - Sitecore.Links.UrlOptions options = Sitecore.Links.UrlOptions.DefaultOptions; + ItemUrlBuilderOptions options = new ItemUrlBuilderOptions + { + SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving, + Site = SiteContext.GetSite(site.Name), + AlwaysIncludeServerUrl = false + }; - options.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving; - options.Site = SiteContext.GetSite(site.Name); - options.AlwaysIncludeServerUrl = false; string url = ""; if (language != null) diff --git a/Sitemap.XML/Sitemap.XML.csproj b/Sitemap.XML/Sitemap.XML.csproj index 89899e8..cb3fa15 100644 --- a/Sitemap.XML/Sitemap.XML.csproj +++ b/Sitemap.XML/Sitemap.XML.csproj @@ -26,6 +26,8 @@ + + true @@ -55,14 +57,14 @@ ..\packages\HtmlAgilityPack.1.4.9.5\lib\Net45\HtmlAgilityPack.dll - - ..\packages\SharpZipLib.1.3.0\lib\net45\ICSharpCode.SharpZipLib.dll + + ..\packages\SharpZipLib.1.3.2\lib\net45\ICSharpCode.SharpZipLib.dll ..\packages\Lucene.Net.3.0.3\lib\NET40\Lucene.Net.dll - - ..\packages\Microsoft.Bcl.AsyncInterfaces.1.1.1\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll ..\packages\Microsoft.Configuration.ConfigurationBuilders.Base.1.0.2\lib\Net471\Microsoft.Configuration.ConfigurationBuilders.Base.dll @@ -80,26 +82,26 @@ ..\packages\Microsoft.Extensions.Configuration.Binder.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll - - ..\packages\Microsoft.Extensions.DependencyInjection.3.1.5\lib\net461\Microsoft.Extensions.DependencyInjection.dll + + ..\packages\Microsoft.Extensions.DependencyInjection.6.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll - - ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.3.1.5\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.Abstractions.dll - - ..\packages\Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.dll + + ..\packages\Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions.dll - - ..\packages\Microsoft.Extensions.Logging.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Logging.dll + + ..\packages\Microsoft.Extensions.Logging.6.0.0\lib\net461\Microsoft.Extensions.Logging.dll - - ..\packages\Microsoft.Extensions.Logging.Abstractions.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll + + ..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.1\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll - - ..\packages\Microsoft.Extensions.Options.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Options.dll + + ..\packages\Microsoft.Extensions.Options.6.0.0\lib\net461\Microsoft.Extensions.Options.dll - - ..\packages\Microsoft.Extensions.Primitives.3.1.5\lib\netstandard2.0\Microsoft.Extensions.Primitives.dll + + ..\packages\Microsoft.Extensions.Primitives.6.0.0\lib\net461\Microsoft.Extensions.Primitives.dll ..\packages\EnterpriseLibrary.Common.6.0.1304.0\lib\NET45\Microsoft.Practices.EnterpriseLibrary.Common.dll @@ -131,11 +133,12 @@ ..\packages\Microsoft.Web.Deployment.3.5.0\lib\Net40\Microsoft.Web.Deployment.Tracing.dll + ..\packages\Mvp.Xml.2.3.0\lib\net20\Mvp.Xml.dll - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll @@ -150,52 +153,61 @@ ..\packages\Sitecore.Abstractions.9.2.0\lib\net471\Sitecore.Abstractions.dll - ..\packages\Sitecore.Annotations.10.1.1\lib\net471\Sitecore.Annotations.dll + ..\packages\Sitecore.Annotations.10.3.1\lib\net471\Sitecore.Annotations.dll - - ..\packages\Sitecore.Buckets.10.1.1\lib\net48\Sitecore.Buckets.dll + + ..\packages\Sitecore.Buckets.10.3.1\lib\net48\Sitecore.Buckets.dll - - ..\packages\Sitecore.Client.10.1.1\lib\net48\Sitecore.Client.dll + + ..\packages\Sitecore.Client.10.3.1\lib\net48\Sitecore.Client.dll - - ..\packages\Sitecore.ContentSearch.10.1.1\lib\net48\Sitecore.ContentSearch.dll + + ..\packages\Sitecore.ContentSearch.10.3.1\lib\net48\Sitecore.ContentSearch.dll - - ..\packages\Sitecore.ContentSearch.Client.10.1.1\lib\net48\Sitecore.ContentSearch.Client.dll + + ..\packages\Sitecore.ContentSearch.Client.10.3.1\lib\net48\Sitecore.ContentSearch.Client.dll - - ..\packages\Sitecore.ContentSearch.ContentExtraction.10.1.1\lib\net48\Sitecore.ContentSearch.ContentExtraction.dll + + ..\packages\Sitecore.ContentSearch.ContentExtraction.10.3.1\lib\net48\Sitecore.ContentSearch.ContentExtraction.dll - - ..\packages\Sitecore.ContentSearch.Data.10.1.1\lib\net48\Sitecore.ContentSearch.Data.dll + + ..\packages\Sitecore.ContentSearch.Data.10.3.1\lib\net48\Sitecore.ContentSearch.Data.dll - - ..\packages\Sitecore.ContentSearch.Linq.10.1.1\lib\net48\Sitecore.ContentSearch.Linq.dll + + ..\packages\Sitecore.ContentSearch.Linq.10.3.1\lib\net48\Sitecore.ContentSearch.Linq.dll - - ..\packages\Sitecore.Framework.Conditions.5.0.0\lib\netstandard2.0\Sitecore.Framework.Conditions.dll + + ..\packages\Sitecore.Data.ResourceItems.Abstractions.10.3.1\lib\netstandard2.0\Sitecore.Data.ResourceItems.Abstractions.dll - - ..\packages\Sitecore.Framework.Data.Blobs.2.0.0\lib\netstandard2.0\Sitecore.Framework.Data.Blobs.dll + + ..\packages\Sitecore.Data.ResourceItems.ProtobufNet.10.3.1\lib\netstandard2.0\Sitecore.Data.ResourceItems.ProtobufNet.dll - - ..\packages\Sitecore.Framework.Data.Blobs.Abstractions.2.0.0\lib\netstandard2.0\Sitecore.Framework.Data.Blobs.Abstractions.dll + + ..\packages\Sitecore.Framework.Conditions.6.0.0\lib\netstandard2.0\Sitecore.Framework.Conditions.dll - - ..\packages\Sitecore.Kernel.10.1.1\lib\net48\Sitecore.Kernel.dll + + ..\packages\Sitecore.Framework.Data.Blobs.3.0.1\lib\netstandard2.0\Sitecore.Framework.Data.Blobs.dll - - ..\packages\Sitecore.Logging.10.1.1\lib\net48\Sitecore.Logging.dll + + ..\packages\Sitecore.Framework.Data.Blobs.Abstractions.3.0.1\lib\netstandard2.0\Sitecore.Framework.Data.Blobs.Abstractions.dll - - ..\packages\Sitecore.Logging.Client.10.1.1\lib\net48\Sitecore.Logging.Client.dll + + ..\packages\Sitecore.Kernel.10.3.1\lib\net48\Sitecore.Kernel.dll + + + ..\packages\Sitecore.Kernel.Portable.10.3.1\lib\netstandard2.0\Sitecore.Kernel.Portable.dll + + + ..\packages\Sitecore.Logging.10.3.1\lib\net48\Sitecore.Logging.dll + + + ..\packages\Sitecore.Logging.Client.10.3.1\lib\net48\Sitecore.Logging.Client.dll ..\packages\Sitecore.Nexus.10.1.1\lib\net48\Sitecore.Nexus.dll - ..\packages\Sitecore.Nexus.Consumption.1.3.1\lib\netstandard2.0\Sitecore.Nexus.Consumption.dll + ..\packages\Sitecore.Nexus.Consumption.1.5.0\lib\netstandard2.0\Sitecore.Nexus.Consumption.dll ..\packages\Sitecore.Nexus.Licensing.2.0.6\lib\netstandard2.0\Sitecore.Nexus.Licensing.dll @@ -207,10 +219,11 @@ ..\packages\Sitecore.Publishing.WebDeploy.9.2.0\lib\net471\Sitecore.Publishing.WebDeploy.dll - ..\packages\Sitecore.Zip.10.1.1\lib\net48\Sitecore.Zip.dll + ..\packages\Sitecore.Zip.10.1.3\lib\net48\Sitecore.Zip.dll + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll @@ -218,14 +231,23 @@ ..\packages\System.ComponentModel.Annotations.4.7.0\lib\net461\System.ComponentModel.Annotations.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.6.0.0\lib\net461\System.Diagnostics.DiagnosticSource.dll + + + + + + ..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll True @@ -234,23 +256,27 @@ ..\packages\System.IO.Packaging.4.0.0\lib\net46\System.IO.Packaging.dll - - ..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll ..\packages\Microsoft.AspNet.WebApi.Client.5.2.6\lib\net45\System.Net.Http.Formatting.dll + - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.7.1\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + @@ -258,6 +284,10 @@ ..\packages\System.Security.AccessControl.4.5.0\lib\net461\System.Security.AccessControl.dll + + + + ..\packages\System.Security.Cryptography.Xml.4.5.0\lib\net461\System.Security.Cryptography.Xml.dll @@ -270,11 +300,15 @@ + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + @@ -295,6 +329,7 @@ + @@ -363,4 +398,11 @@ + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + \ No newline at end of file diff --git a/Sitemap.XML/packages.config b/Sitemap.XML/packages.config index adae386..db7f70a 100644 --- a/Sitemap.XML/packages.config +++ b/Sitemap.XML/packages.config @@ -14,56 +14,61 @@ - + - - - - - - - + + + + + + + - + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - + + - - - + + + + \ No newline at end of file diff --git a/Sitemap.XML/web.config b/Sitemap.XML/web.config index dd4a835..b13eeef 100644 --- a/Sitemap.XML/web.config +++ b/Sitemap.XML/web.config @@ -27,15 +27,15 @@ - + - + - + @@ -43,7 +43,7 @@ - + @@ -55,14 +55,26 @@ - + - + + + + + + + + + + + + +