@@ -45,9 +45,7 @@ namespace Docnet | |||||
return 1; | return 1; | ||||
} | } | ||||
var navigationContext = new NavigationContext(_loadedConfig.PathSpecification, _loadedConfig.UrlFormatting, | |||||
_loadedConfig.MaxLevelInToC, _loadedConfig.StripIndexHtm); | |||||
var navigationContext = new NavigationContext(_loadedConfig.PathSpecification, _loadedConfig.UrlFormatting, _loadedConfig.MaxLevelInToC, _loadedConfig.StripIndexHtm); | |||||
GeneratePages(navigationContext); | GeneratePages(navigationContext); | ||||
return 0; | return 0; | ||||
} | } | ||||
@@ -75,8 +73,7 @@ namespace Docnet | |||||
return null; | return null; | ||||
} | } | ||||
var navigationContext = new NavigationContext(config.PathSpecification, config.UrlFormatting, | |||||
config.MaxLevelInToC, config.StripIndexHtm); | |||||
var navigationContext = new NavigationContext(config.PathSpecification, config.UrlFormatting, config.MaxLevelInToC, config.StripIndexHtm); | |||||
var indexElement = config.Pages.GetIndexElement(navigationContext); | var indexElement = config.Pages.GetIndexElement(navigationContext); | ||||
if(indexElement == null) | if(indexElement == null) | ||||
@@ -4,7 +4,7 @@ | |||||
{ | { | ||||
public NavigationContext() | public NavigationContext() | ||||
{ | { | ||||
MaxLevel = 2; | |||||
this.MaxLevel = 2; | |||||
} | } | ||||
public NavigationContext(PathSpecification pathSpecification, UrlFormatting urlFormatting, int maxLevel, bool stripIndexHtm) | public NavigationContext(PathSpecification pathSpecification, UrlFormatting urlFormatting, int maxLevel, bool stripIndexHtm) | ||||
@@ -17,11 +17,8 @@ | |||||
} | } | ||||
public PathSpecification PathSpecification { get; set; } | public PathSpecification PathSpecification { get; set; } | ||||
public UrlFormatting UrlFormatting { get; set; } | public UrlFormatting UrlFormatting { get; set; } | ||||
public int MaxLevel { get; set; } | public int MaxLevel { get; set; } | ||||
public bool StripIndexHtm { get; set; } | public bool StripIndexHtm { get; set; } | ||||
} | } | ||||
} | } |
@@ -28,17 +28,15 @@ namespace Docnet | |||||
throw new ArgumentOutOfRangeException(nameof(urlFormatting), urlFormatting, null); | throw new ArgumentOutOfRangeException(nameof(urlFormatting), urlFormatting, null); | ||||
} | } | ||||
var splitted = value.Split(new[] { "/", "\\" }, StringSplitOptions.RemoveEmptyEntries); | |||||
if (replacementValue != null) | if (replacementValue != null) | ||||
{ | { | ||||
var doubleReplacementValue = replacementValue + replacementValue; | var doubleReplacementValue = replacementValue + replacementValue; | ||||
var regEx = new Regex("[^a-zA-Z0-9 -]"); | var regEx = new Regex("[^a-zA-Z0-9 -]"); | ||||
for (var i = 0; i < splitted.Length; i++) | |||||
var splitted = value.Split(new[] { "/", "\\" }, StringSplitOptions.RemoveEmptyEntries); | |||||
for(var i = 0; i < splitted.Length; i++) | |||||
{ | { | ||||
var splittedValue = splitted[i]; | var splittedValue = splitted[i]; | ||||
splittedValue = regEx.Replace(splittedValue, replacementValue).Replace(" ", replacementValue); | splittedValue = regEx.Replace(splittedValue, replacementValue).Replace(" ", replacementValue); | ||||
if (!string.IsNullOrEmpty(replacementValue)) | if (!string.IsNullOrEmpty(replacementValue)) | ||||
@@ -48,13 +46,11 @@ namespace Docnet | |||||
splittedValue = splittedValue.Replace(doubleReplacementValue, replacementValue); | splittedValue = splittedValue.Replace(doubleReplacementValue, replacementValue); | ||||
} | } | ||||
} | } | ||||
splitted[i] = splittedValue.ToLower(); | splitted[i] = splittedValue.ToLower(); | ||||
} | } | ||||
finalValue = string.Join("/", splitted); | finalValue = string.Join("/", splitted); | ||||
} | } | ||||
return finalValue; | return finalValue; | ||||
} | } | ||||
} | } |
@@ -3,9 +3,7 @@ | |||||
public enum UrlFormatting | public enum UrlFormatting | ||||
{ | { | ||||
None, | None, | ||||
Strip, | Strip, | ||||
Dashes | Dashes | ||||
} | } | ||||
} | } |