@ -29,8 +29,6 @@ namespace Volo.Docs.Pages.Documents.Project
public DocumentWithDetailsDto Document { get ; private set ; }
public DocumentWithDetailsDto Document { get ; private set ; }
public List < VersionInfoViewModel > Versions { get ; private set ; }
public List < SelectListItem > VersionSelectItems { get ; private set ; }
public List < SelectListItem > VersionSelectItems { get ; private set ; }
public NavigationWithDetailsDto Navigation { get ; private set ; }
public NavigationWithDetailsDto Navigation { get ; private set ; }
@ -58,6 +56,7 @@ namespace Volo.Docs.Pages.Documents.Project
SetDocumentNames ( ) ;
SetDocumentNames ( ) ;
await SetVersionAsync ( ) ;
await SetVersionAsync ( ) ;
await SetDocumentAsync ( ) ;
await SetDocumentAsync ( ) ;
ConvertDocumentContentToHtml ( ) ;
await SetNavigationAsync ( ) ;
await SetNavigationAsync ( ) ;
}
}
@ -73,13 +72,14 @@ namespace Volo.Docs.Pages.Documents.Project
private async Task SetVersionAsync ( )
private async Task SetVersionAsync ( )
{
{
var output = await _ projectAppService . GetVersionsAsync ( Project . Id ) ;
//TODO: Needs refactoring
Versions = output . Items
var output = await _ projectAppService . GetVersionsAsync ( Project . Id ) ;
var versions = output . Items
. Select ( v = > new VersionInfoViewModel ( v . DisplayName , v . Name ) )
. Select ( v = > new VersionInfoViewModel ( v . DisplayName , v . Name ) )
. ToList ( ) ;
. ToList ( ) ;
LatestVersionInfo = V ersions. First ( ) ;
LatestVersionInfo = v ersions. First ( ) ;
LatestVersionInfo . DisplayText = $"{LatestVersionInfo.DisplayText} ({DocsAppConsts.Latest})" ;
LatestVersionInfo . DisplayText = $"{LatestVersionInfo.DisplayText} ({DocsAppConsts.Latest})" ;
LatestVersionInfo . Version = LatestVersionInfo . Version ;
LatestVersionInfo . Version = LatestVersionInfo . Version ;
@ -90,7 +90,7 @@ namespace Volo.Docs.Pages.Documents.Project
}
}
else
else
{
{
var versionFromUrl = V ersions. FirstOrDefault ( v = > v . Version = = Version ) ;
var versionFromUrl = v ersions. FirstOrDefault ( v = > v . Version = = Version ) ;
if ( versionFromUrl ! = null )
if ( versionFromUrl ! = null )
{
{
versionFromUrl . IsSelected = true ;
versionFromUrl . IsSelected = true ;
@ -98,12 +98,12 @@ namespace Volo.Docs.Pages.Documents.Project
}
}
else
else
{
{
V ersions. First ( ) . IsSelected = true ;
v ersions. First ( ) . IsSelected = true ;
Version = V ersions. First ( ) . Version ;
Version = v ersions. First ( ) . Version ;
}
}
}
}
VersionSelectItems = V ersions. Select ( v = > new SelectListItem
VersionSelectItems = v ersions. Select ( v = > new SelectListItem
{
{
Text = v . DisplayText ,
Text = v . DisplayText ,
Value = CreateLink ( LatestVersionInfo , v . Version , DocumentName ) ,
Value = CreateLink ( LatestVersionInfo , v . Version , DocumentName ) ,
@ -191,16 +191,27 @@ namespace Volo.Docs.Pages.Documents.Project
catch ( DocumentNotFoundException )
catch ( DocumentNotFoundException )
{
{
//TODO: Handle it!
//TODO: Handle it!
return ;
throw ;
}
}
}
var converter = _d ocumentToHtmlConverterFactory . Create ( Document . Format ? ? Project . Format ) ;
var content = converter . NormalizeLinks ( Document . Content , Document . Project . ShortName , GetSpecificVersionOrLatest ( ) , Document . LocalDirectory ) ;
content = converter . Convert ( content ) ;
content = HtmlNormalizer . ReplaceImageSources ( content , Document . RawRootUrl , Document . LocalDirectory ) ;
private void ConvertDocumentContentToHtml ( )
content = HtmlNormalizer . ReplaceCodeBlocksLanguage ( content , "language-C#" , "language-csharp" ) ; //todo find a way to make it on client in prismJS configuration (eg: map C# => csharp)
{
var converter = _d ocumentToHtmlConverterFactory . Create ( Document . Format ? ? Project . Format ) ;
var content = converter . Convert ( Project , Document , GetSpecificVersionOrLatest ( ) ) ;
content = HtmlNormalizer . ReplaceImageSources (
content ,
Document . RawRootUrl ,
Document . LocalDirectory
) ;
//todo find a way to make it on client in prismJS configuration (eg: map C# => csharp)
content = HtmlNormalizer . ReplaceCodeBlocksLanguage (
content ,
"language-C#" ,
"language-csharp"
) ;
Document . Content = content ;
Document . Content = content ;
}
}