|
|
@ -65,8 +65,9 @@ namespace Volo.Docs.Documents |
|
|
{ |
|
|
{ |
|
|
var project = await _projectRepository.GetAsync(input.ProjectId); |
|
|
var project = await _projectRepository.GetAsync(input.ProjectId); |
|
|
|
|
|
|
|
|
input.Version = GetProjectVersionPrefixIfExist(project) + input.Version; |
|
|
var inputVersionStringBuilder = new StringBuilder(); |
|
|
|
|
|
input.Version = inputVersionStringBuilder.Append(GetProjectVersionPrefixIfExist(project)).Append(input.Version).ToString(); |
|
|
|
|
|
|
|
|
return await GetDocumentWithDetailsDtoAsync( |
|
|
return await GetDocumentWithDetailsDtoAsync( |
|
|
project, |
|
|
project, |
|
|
input.Name, |
|
|
input.Name, |
|
|
@ -79,11 +80,14 @@ namespace Volo.Docs.Documents |
|
|
{ |
|
|
{ |
|
|
var project = await _projectRepository.GetAsync(input.ProjectId); |
|
|
var project = await _projectRepository.GetAsync(input.ProjectId); |
|
|
|
|
|
|
|
|
input.Version = GetProjectVersionPrefixIfExist(project) + input.Version; |
|
|
var sb = new StringBuilder(); |
|
|
|
|
|
input.Version = sb.Append(GetProjectVersionPrefixIfExist(project)).Append(input.Version).ToString(); |
|
|
|
|
|
|
|
|
|
|
|
sb.Clear(); |
|
|
|
|
|
|
|
|
return await GetDocumentWithDetailsDtoAsync( |
|
|
return await GetDocumentWithDetailsDtoAsync( |
|
|
project, |
|
|
project, |
|
|
project.DefaultDocumentName + "." + project.Format, |
|
|
sb.Append(project.DefaultDocumentName).Append(".").Append(project.Format).ToString(), |
|
|
input.LanguageCode, |
|
|
input.LanguageCode, |
|
|
input.Version |
|
|
input.Version |
|
|
); |
|
|
); |
|
|
@ -226,7 +230,7 @@ namespace Volo.Docs.Documents |
|
|
private async Task AddDocumentToUrls(string prefix, Project project, DocumentWithoutDetails document, |
|
|
private async Task AddDocumentToUrls(string prefix, Project project, DocumentWithoutDetails document, |
|
|
List<string> documentUrls) |
|
|
List<string> documentUrls) |
|
|
{ |
|
|
{ |
|
|
var navigationNodes = await GetNavigationNodesAsync(prefix, project, document); |
|
|
var navigationNodes = await GetNavigationNodesAsync(project, document); |
|
|
AddDocumentUrls(prefix, navigationNodes, documentUrls, project, document); |
|
|
AddDocumentUrls(prefix, navigationNodes, documentUrls, project, document); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -244,7 +248,7 @@ namespace Volo.Docs.Documents |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task<List<NavigationNode>> GetNavigationNodesAsync(string prefix, Project project, |
|
|
private async Task<List<NavigationNode>> GetNavigationNodesAsync(Project project, |
|
|
DocumentWithoutDetails document) |
|
|
DocumentWithoutDetails document) |
|
|
{ |
|
|
{ |
|
|
var version = GetProjectVersionPrefixIfExist(project) + document.Version; |
|
|
var version = GetProjectVersionPrefixIfExist(project) + document.Version; |
|
|
@ -286,10 +290,12 @@ namespace Volo.Docs.Documents |
|
|
private string NormalizePath(string prefix, string path, string shortName, DocumentWithoutDetails document) |
|
|
private string NormalizePath(string prefix, string path, string shortName, DocumentWithoutDetails document) |
|
|
{ |
|
|
{ |
|
|
var pathWithoutFileExtension = RemoveFileExtensionFromPath(path, document.Format); |
|
|
var pathWithoutFileExtension = RemoveFileExtensionFromPath(path, document.Format); |
|
|
var normalizedPath = prefix + document.LanguageCode + "/" + shortName + "/" + document.Version + "/" + |
|
|
|
|
|
pathWithoutFileExtension; |
|
|
var normalizedPathStringBuilder = new StringBuilder(); |
|
|
|
|
|
normalizedPathStringBuilder.Append(prefix).Append(document.LanguageCode).Append("/").Append(shortName) |
|
|
|
|
|
.Append("/").Append(document.Version).Append("/").Append(pathWithoutFileExtension); |
|
|
|
|
|
|
|
|
return normalizedPath; |
|
|
return normalizedPathStringBuilder.ToString(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private string RemoveFileExtensionFromPath(string path, string format) |
|
|
private string RemoveFileExtensionFromPath(string path, string format) |
|
|
@ -375,21 +381,6 @@ namespace Volo.Docs.Documents |
|
|
return await GetDocumentAsync(documentName, project, languageCode, version, document); |
|
|
return await GetDocumentAsync(documentName, project, languageCode, version, document); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var cacheKey = CacheKeyGenerator.GenerateDocumentUpdateInfoCacheKey( |
|
|
|
|
|
project, |
|
|
|
|
|
document.Name, |
|
|
|
|
|
document.LanguageCode, |
|
|
|
|
|
document.Version |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
await DocumentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo |
|
|
|
|
|
{ |
|
|
|
|
|
Name = document.Name, |
|
|
|
|
|
CreationTime = document.CreationTime, |
|
|
|
|
|
LastUpdatedTime = document.LastUpdatedTime, |
|
|
|
|
|
LastSignificantUpdateTime = document.LastSignificantUpdateTime |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return CreateDocumentWithDetailsDto(project, document); |
|
|
return CreateDocumentWithDetailsDto(project, document); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|