Explorar el Código

added support for use of absolute links with content files

git-svn-id: trunk@2311 -
Vincent Snijders hace 19 años
padre
commit
8a02b500ed
Se han modificado 2 ficheros con 20 adiciones y 2 borrados
  1. 19 1
      utils/fpdoc/dglobals.pp
  2. 1 1
      utils/fpdoc/dw_html.pp

+ 19 - 1
utils/fpdoc/dglobals.pp

@@ -279,12 +279,16 @@ procedure TranslateDocStrings(const Lang: String);
 Function IsLinkNode(Node : TDomNode) : Boolean;
 Function IsExampleNode(Example : TDomNode) : Boolean;
 
-
+// returns true is link is an absolute URI
+Function IsLinkAbsolute(ALink: String): boolean;
 
 implementation
 
 uses SysUtils, Gettext, XMLRead;
 
+const
+  AbsoluteLinkPrefixes : array[0..2] of string = ('/', 'http://', 'ms-its:');
+
 
 { TObjectList }
 
@@ -697,6 +701,8 @@ var
 var
   s: String;
 begin
+  if not FileExists(AFileName) then
+    raise EInOutError.Create('File not found: ' + AFileName);
   Assign(f, AFilename);
   Reset(f);
   while not EOF(f) do
@@ -1216,6 +1222,18 @@ begin
   Result:=Assigned(Example) and (Example.NodeType = ELEMENT_NODE) and (Example.NodeName = 'example')
 end;
 
+function IsLinkAbsolute(ALink: String): boolean;
+var
+  i: integer;
+begin
+  Result := false;
+  for i := low(AbsoluteLinkPrefixes) to high(AbsoluteLinkPrefixes) do
+    if CompareText(AbsoluteLinkPrefixes[i], copy(ALink,1,length(AbsoluteLinkPrefixes[i])))=0 then begin
+      Result := true;
+      break;
+    end;
+end;
+
 initialization
   LEOL:=Length(LineEnding);
 end.

+ 1 - 1
utils/fpdoc/dw_html.pp

@@ -768,7 +768,7 @@ begin
   if Length(Result) > 0 then
     if Copy(Result, 1, Length(CurDirectory) + 1) = CurDirectory + '/' then
       Result := Copy(Result, Length(CurDirectory) + 2, Length(Result))
-    else
+    else if not IsLinkAbsolute(Result) then
       Result := BaseDirectory + Result;
 end;