Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for multilingual in version 8.2 update 5 #12

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1,023 changes: 1,023 additions & 0 deletions .vs/Sitemap.XML/config/applicationhost.config

Large diffs are not rendered by default.

26 changes: 5 additions & 21 deletions Sitemap.XML.sln
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,24 +17,12 @@ 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
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
91 changes: 48 additions & 43 deletions Sitemap.XML/App_Config/Include/SitemapXML.config
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<!--
<sitecore>
<!--
STATIC FILE GENERATOR

The following section is responsible for generating a static robots.txt and site map XML files per website
defined below. To disable the static file generator, comment out the <sitemapVariables> and <events> sections below.
-->

<sitemapVariables>
<sitemapVariable name="xmlnsTpl" value="http://www.sitemaps.org/schemas/sitemap/0.9" />
<sitemapVariable name="database" value="master" />
<sitemapVariable name="sitemapConfigurationItemPath" value="/sitecore/system/Modules/Sitemap XML/" />
<sitemapVariable name="productionEnvironment" value="false" />
<sitemapVariable name="generateRobotsFile" value="true" />
</sitemapVariables>
<events timingLevel="custom">
<event name="publish:end">
<handler type="Sitemap.XML.Models.SitemapHandler, Sitemap.XML" method="RefreshSitemap" />
</event>
</events>

<!--

<sitemapVariables>
<sitemapVariable name="xmlnsTpl" value="http://www.sitemaps.org/schemas/sitemap/0.9" />
<sitemapVariable name="xmlnsXhtmlTpl" value="http://www.w3.org/TR/xhtml11/xhtml11_schema.html" />
<sitemapVariable name="database" value="master" />
<sitemapVariable name="sitemapConfigurationItemPath" value="/sitecore/system/Modules/Sitemap XML/" />
<sitemapVariable name="productionEnvironment" value="false" />
<sitemapVariable name="generateRobotsFile" value="true" />
<sitemapVariable name="sitesMultilingual" value="seiumb|seiumbV2" />
</sitemapVariables>
<events timingLevel="custom">
<event name="publish:end">
<handler type="Sitemap.XML.Models.SitemapHandler, Sitemap.XML" method="RefreshSitemap" />
</event>
</events>

<!--
SITEMAP HANDLER

The following section is responsible for adding a handler for generating a sitemap "on the fly".
To disable the handler, comment out the <pipelines> section below.
-->

<pipelines>
<httpRequestBegin>
<processor type="Sitemap.XML.Configuration.SitemapHandler, Sitemap.XML"
patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.CustomHandlers, Sitecore.Kernel']">
<!--
<pipelines>
<httpRequestBegin>
<processor type="Sitemap.XML.Configuration.SitemapHandler, Sitemap.XML"
patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.CustomHandlers, Sitecore.Kernel']">
<!--
cacheTime:
Cache time in seconds.

Expand All @@ -40,25 +42,28 @@
The pipeline will exclude all items with this string as part of the path.
You can add more that one, separating them with a pipe
-->
<cacheTime>1</cacheTime>
<excludedPaths>/My Account/|/Customer/</excludedPaths>
</processor>
</httpRequestBegin>

<!--Adding a .xml extension to the list of allowed extensions to avoid sitecore pipelines ignoring
requests with that extension-->
<preprocessRequest>
<processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, xml</param>
</processor>
</preprocessRequest>
</pipelines>
<settings>
<setting name="Sitemap.XML.Fields.ExcludeItemFromSitemap" value="Exclude From Sitemap" />
<setting name="Sitemap.XML.Fields.Title" value="Sitemap Title" />
<setting name="Sitemap.XML.Fields.Priority" value="Priority" />
<setting name="Sitemap.XML.Fields.ChangeFrequency" value="Change Frequency" />
<setting name="Sitemap.XML.UrlLimit" value="1000" />
</settings>
</sitecore>
<cacheTime>1</cacheTime>
<excludedPaths>/My Account/|/Customer/</excludedPaths>
</processor>
<processor type="Sitemap.XML.Configuration.RobotHandler, Sitemap.XML"
patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.CustomHandlers, Sitecore.Kernel']">
</processor>
</httpRequestBegin>

<!--Adding a .xml extension to the list of allowed extensions to avoid sitecore pipelines ignoring
requests with that extension-->
<preprocessRequest>
<processor type="Sitecore.Pipelines.PreprocessRequest.FilterUrlExtensions, Sitecore.Kernel">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx, xml, txt</param>
</processor>
</preprocessRequest>
</pipelines>
<settings>
<setting name="Sitemap.XML.Fields.ExcludeItemFromSitemap" value="Exclude From Sitemap" />
<setting name="Sitemap.XML.Fields.Title" value="Sitemap Title" />
<setting name="Sitemap.XML.Fields.Priority" value="Priority" />
<setting name="Sitemap.XML.Fields.ChangeFrequency" value="Change Frequency" />
<setting name="Sitemap.XML.UrlLimit" value="1000" />
</settings>
</sitecore>
</configuration>
49 changes: 49 additions & 0 deletions Sitemap.XML/Configuration/RobotHandler.cs
Original file line number Diff line number Diff line change
@@ -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.HttpContext.Response.ClearHeaders();
args.HttpContext.Response.ClearContent();
args.HttpContext.Response.ContentType = "text/plain";

var content = string.Empty;
try
{
var config = new SitemapManagerConfiguration(site.Name);
var sitemapManager = new SitemapManager(config);

content = sitemapManager.GetRobotSite();
args.HttpContext.Response.Write(content);
}
catch (Exception e)
{
Log.Error("Error Robots", e, this);
}
finally
{

args.HttpContext.Response.Flush();
args.HttpContext.Response.End();
}
}
}
}
81 changes: 43 additions & 38 deletions Sitemap.XML/Configuration/SitemapHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region

using System;
using Sitecore;
using Sitecore.Caching;
using Sitecore.Diagnostics;
Expand All @@ -10,60 +11,64 @@

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)
{
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;
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;

// 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.HttpContext.Response.ClearHeaders();
args.HttpContext.Response.ClearContent();
args.HttpContext.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);
if (!string.IsNullOrWhiteSpace(cache))
{
args.Context.Response.Write(cache);
args.Context.Response.End();
args.HttpContext.Response.Write(cache);
args.HttpContext.Response.End();
return;
}
#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);
}
finally
{
content = sitemapManager.BuildSiteMapForHandler();
args.HttpContext.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.HttpContext.Response.Flush();
args.HttpContext.Response.End();
}
}
}
}
3 changes: 2 additions & 1 deletion Sitemap.XML/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
28 changes: 18 additions & 10 deletions Sitemap.XML/Models/SitemapHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,31 @@
* *********************************************************************** */

using System;
using Sitecore.Diagnostics;

namespace Sitemap.XML.Models
{
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();

if (!config.GenerateRobotsFile) continue;
sitemapManager.RegisterSitemapToRobotsFile();
}
try
{
var sites = SitemapManagerConfiguration.GetSiteNames();
foreach (var site in sites)
{
var config = new SitemapManagerConfiguration(site);
var sitemapManager = new SitemapManager(config);
sitemapManager.SubmitSitemapToSearchenginesByHttp();
//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)
{
Log.Error("Error Sitemap",e,this);
}
}
}
}
Loading