From 2a0abb0f9828249f9e7a064a2d48da1f0d9abc11 Mon Sep 17 00:00:00 2001 From: wp Date: Wed, 17 Jun 2015 10:26:43 +0000 Subject: [PATCH] wiki: Fix internal links within chm files if filename contains illegal characters; fix icon of wiki template in chm file. git-svn-id: trunk@49359 - --- components/wiki/lazwiki/wiki2chmconvert.pas | 9 ++++++++- components/wiki/lazwiki/wiki2xhtmlconvert.pas | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/wiki/lazwiki/wiki2chmconvert.pas b/components/wiki/lazwiki/wiki2chmconvert.pas index 2ce7ff9977..e49c428097 100644 --- a/components/wiki/lazwiki/wiki2chmconvert.pas +++ b/components/wiki/lazwiki/wiki2chmconvert.pas @@ -70,6 +70,7 @@ type procedure WriteIndexToStream(aStream: TStream); procedure OnWriterLastFileAdded(Sender: TObject); function GetImageLink(ImgFilename: string): string; override; + function GetInternalImageLink(ImgFilename: String): String; override; function GetPageLink(Page: TW2XHTMLPage): string; override; procedure SaveAllPages; override; public @@ -206,9 +207,15 @@ begin Result:=CHMImagesDir+ExtractFileName(ImgFilename); end; +function TWiki2CHMConverter.GetInternalImageLink(ImgFilename: String): String; +begin + Result := CHMImagesDir + 'internal/' + ExtractFilename(ImgFilename); +end; + function TWiki2CHMConverter.GetPageLink(Page: TW2XHTMLPage): string; begin - Result:=Page.WikiDocumentName+'.html'; +// Result:=Page.WikiDocumentName+'.html'; + Result :=Page.Filename; end; procedure TWiki2CHMConverter.SetCHMFile(AValue: string); diff --git a/components/wiki/lazwiki/wiki2xhtmlconvert.pas b/components/wiki/lazwiki/wiki2xhtmlconvert.pas index 9771b4f164..ea983769c7 100644 --- a/components/wiki/lazwiki/wiki2xhtmlconvert.pas +++ b/components/wiki/lazwiki/wiki2xhtmlconvert.pas @@ -81,6 +81,7 @@ type procedure OnWikiToken(Token: TWPToken); virtual; procedure RaiseNodeNotOpen(Token: TWPToken); function GetImageLink(ImgFilename: string): string; virtual; + function GetInternalImageLink(ImgFilename: string): string; virtual; function FindImage(const ImgFilename: string): string; virtual; procedure MarkImageAsUsed(const ImgFilename: string; Page: TW2XHTMLPage); virtual; function GetPageLink(Page: TW2XHTMLPage): string; virtual; @@ -845,9 +846,9 @@ begin Node.AppendChild(childnode1); childnode1.SetAttribute('class', 'icon'); if FUseTemplateIcons then begin - fn := FindImage('internal\'+iconfile); + fn := FindImage('internal/'+iconfile); if fn <> '' then - fn := GetImageLink(fn); + fn := GetInternalImageLink(fn); MarkImageAsUsed(fn, Page); childnode2 := doc.CreateElement('img'); childnode2.SetAttribute('src', fn); @@ -922,6 +923,11 @@ begin Result:=CreateRelativePath(ImgFilename,OutputDir); end; +function TWiki2XHTMLConverter.GetInternalImagelink(ImgFilename: String): string; +begin + Result := CreateRelativepath(ImgFilename,OutputDir); +end; + function TWiki2XHTMLConverter.FindImage(const ImgFilename: string): string; begin if ImagesDir='' then exit('');