wiki test: opening external links

git-svn-id: trunk@35856 -
This commit is contained in:
mattias 2012-03-09 22:21:51 +00:00
parent f11f069e84
commit 4945f1f1fe
2 changed files with 28 additions and 2 deletions

View File

@ -335,6 +335,7 @@ var
// normalize link to get the page, e.g. convert spaces to underscores
function WikiInternalLinkToPage(Link: string): string;
function WikiIsExternalLink(Link: string): boolean;
function GetWikiPageID(doc: TDOMNode): string;
function GetWikiPageID(s: TStream): string;
@ -1560,6 +1561,25 @@ begin
end;
end;
function WikiIsExternalLink(Link: string): boolean;
// check if Link starts with a scheme http://
var
p: PChar;
begin
Result:=false;
if Link='' then exit;
p:=PChar(Link);
while p^ in ['a'..'z','A'..'Z'] do inc(p);
if p=PChar(Link) then exit;
if p^<>':' then exit;
inc(p);
if p^<>'/' then exit;
inc(p);
if p^<>'/' then exit;
inc(p);
Result:=true;
end;
function GetWikiPageID(doc: TDOMNode): string;
var
Node: TDOMNode;

View File

@ -26,10 +26,10 @@ interface
uses
Classes, SysUtils, math, FileUtil, LazLogger, LazUTF8, LazFileUtils, laz2_DOM,
Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, ComCtrls, LCLIntf,
IpHtml, Ipfilebroker, IpMsg,
CodeToolManager, CodeCache,
WikiHelpManager, WikiSearchOptions;
WikiHelpManager, WikiSearchOptions, WikiParser;
type
@ -258,6 +258,12 @@ begin
//Target := TIpHtmlNodeAREA(HotNode).Target;
end;
debugln(['TWikiSearchDemoForm.ResultsIpHtmlPanelHotClick href=',href]);
if WikiIsExternalLink(HRef) then begin
// open external page
OpenURL(HRef);
exit;
end;
// open page in PageIpHtmlPanel
ms:=TMemoryStream.Create;
try