| @@ -64,34 +64,33 @@ namespace Docnet | |||||
| if (childValue.EndsWith("**")) | if (childValue.EndsWith("**")) | ||||
| { | { | ||||
| var path = childValue.Replace("**", string.Empty) | var path = childValue.Replace("**", string.Empty) | ||||
| .Replace('\\', Path.DirectorySeparatorChar) | |||||
| .Replace('/', Path.DirectorySeparatorChar); | |||||
| .Replace('\\', Path.DirectorySeparatorChar) | |||||
| .Replace('/', Path.DirectorySeparatorChar); | |||||
| if (!Path.IsPathRooted(path)) | if (!Path.IsPathRooted(path)) | ||||
| { | { | ||||
| path = Path.Combine(_rootDirectory, path); | path = Path.Combine(_rootDirectory, path); | ||||
| } | } | ||||
| toAdd = CreateGeneratedLevel(path); | toAdd = CreateGeneratedLevel(path); | ||||
| toAdd.Name = nameToUse; | toAdd.Name = nameToUse; | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| toAdd = new SimpleNavigationElement | toAdd = new SimpleNavigationElement | ||||
| { | |||||
| Name = nameToUse, | |||||
| Value = childValue, | |||||
| IsIndexElement = isIndexElement | |||||
| }; | |||||
| { | |||||
| Name = nameToUse, | |||||
| Value = childValue, | |||||
| IsIndexElement = isIndexElement | |||||
| }; | |||||
| } | } | ||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| var subLevel = new NavigationLevel(_rootDirectory) | var subLevel = new NavigationLevel(_rootDirectory) | ||||
| { | |||||
| Name = child.Key, | |||||
| IsRoot = false | |||||
| }; | |||||
| { | |||||
| Name = child.Key, | |||||
| IsRoot = false | |||||
| }; | |||||
| subLevel.Load((JObject)child.Value); | subLevel.Load((JObject)child.Value); | ||||
| toAdd = subLevel; | toAdd = subLevel; | ||||
| } | } | ||||
| @@ -201,12 +200,13 @@ namespace Docnet | |||||
| return string.Join(Environment.NewLine, fragments.ToArray()); | return string.Join(Environment.NewLine, fragments.ToArray()); | ||||
| } | } | ||||
| private NavigationLevel CreateGeneratedLevel(string path) | private NavigationLevel CreateGeneratedLevel(string path) | ||||
| { | { | ||||
| var root = new NavigationLevel(_rootDirectory) | var root = new NavigationLevel(_rootDirectory) | ||||
| { | |||||
| ParentContainer = this | |||||
| }; | |||||
| { | |||||
| ParentContainer = this | |||||
| }; | |||||
| foreach (var mdFile in Directory.GetFiles(path, "*.md", SearchOption.TopDirectoryOnly)) | foreach (var mdFile in Directory.GetFiles(path, "*.md", SearchOption.TopDirectoryOnly)) | ||||
| { | { | ||||
| @@ -216,33 +216,28 @@ namespace Docnet | |||||
| continue; | continue; | ||||
| } | } | ||||
| var relativeFilePath = Utils.MakeRelativePath(mdFile, _rootDirectory); | |||||
| var item = new SimpleNavigationElement | var item = new SimpleNavigationElement | ||||
| { | |||||
| Name = name, | |||||
| Value = relativeFilePath, | |||||
| ParentContainer = root | |||||
| }; | |||||
| { | |||||
| Name = name, | |||||
| Value = Utils.MakeRelativePath(mdFile, _rootDirectory), | |||||
| ParentContainer = root | |||||
| }; | |||||
| root.Value.Add(item); | root.Value.Add(item); | ||||
| } | } | ||||
| foreach (var directory in Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly)) | foreach (var directory in Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly)) | ||||
| { | { | ||||
| var directoryInfo = new DirectoryInfo(directory); | |||||
| var subDirectoryNavigationElement = CreateGeneratedLevel(directory); | var subDirectoryNavigationElement = CreateGeneratedLevel(directory); | ||||
| subDirectoryNavigationElement.Name = directoryInfo.Name; | |||||
| subDirectoryNavigationElement.Name = new DirectoryInfo(directory).Name; | |||||
| subDirectoryNavigationElement.ParentContainer = root; | subDirectoryNavigationElement.ParentContainer = root; | ||||
| root.Value.Add(subDirectoryNavigationElement); | root.Value.Add(subDirectoryNavigationElement); | ||||
| } | } | ||||
| return root; | return root; | ||||
| } | } | ||||
| private string FindTitleInMdFile(string path) | private string FindTitleInMdFile(string path) | ||||
| { | { | ||||
| var title = string.Empty; | var title = string.Empty; | ||||
| @@ -252,20 +247,16 @@ namespace Docnet | |||||
| using (var streamReader = new StreamReader(fileStream)) | using (var streamReader = new StreamReader(fileStream)) | ||||
| { | { | ||||
| var line = string.Empty; | var line = string.Empty; | ||||
| while (string.IsNullOrWhiteSpace(line)) | while (string.IsNullOrWhiteSpace(line)) | ||||
| { | { | ||||
| line = streamReader.ReadLine(); | line = streamReader.ReadLine(); | ||||
| if (!string.IsNullOrWhiteSpace(line)) | if (!string.IsNullOrWhiteSpace(line)) | ||||
| { | { | ||||
| line = line.Trim(); | line = line.Trim(); | ||||
| while (line.StartsWith("#")) | while (line.StartsWith("#")) | ||||
| { | { | ||||
| line = line.Substring(1).Trim(); | line = line.Substring(1).Trim(); | ||||
| } | } | ||||
| if (!string.IsNullOrWhiteSpace(line)) | if (!string.IsNullOrWhiteSpace(line)) | ||||
| { | { | ||||
| title = line; | title = line; | ||||