OSDN Git Service

極力レスポップできるようにしたけど、差し戻しになるかも。
authorh677 <h677>
Mon, 1 Dec 2003 14:32:40 +0000 (14:32 +0000)
committerh677 <h677>
Mon, 1 Dec 2003 14:32:40 +0000 (14:32 +0000)
掲示板の方でリンク張られている以外のレスアンカーにURLを付加しました。

ExternalThreadItem.pas
Giko.pas
GikoSystem.pas

index 09e266f..a3212b2 100644 (file)
@@ -287,8 +287,9 @@ begin
        // \88ø\90\94\82ð\95ª\89ð
        res                                     := GikoSys.DivideStrLine( string( inDatRes ) );
     if AnsiCompareStr( string( inDatRes ) , '' ) <> 0 then begin
-        res.FBody              := GikoSys.ConvRes( res.FBody, threadItem.ParentBoard.BBSID, ChangeFileExt( threadItem.FileName, '' ), 'bbs', 'key', 'st', 'to', 'nofirst', 'true' );
         res.FBody              := GikoSys.AddAnchorTag( res.FBody );
+        res.FBody              := GikoSys.ConvRes( res.FBody, threadItem.ParentBoard.BBSID, ChangeFileExt( threadItem.FileName, '' ), 'bbs', 'key', 'st', 'to', 'nofirst', 'true',threadItem.URL );
+
         no                                     := IntToStr( inResNo );
 
         try
index 31ab157..bc52f8e 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -2485,18 +2485,29 @@ begin
                end else begin
                        URL := Text;
 
-                       if Pos('about:blank..', URL) = 1 then
+                       if Pos('about:blank..', URL) = 1 then begin
                                URL := StringReplace( URL, 'about:blank..', 'http://www.2ch.net', [] );
+                PathRec := Gikosys.Parse2chURL2(URL);
+            end else begin
+                PathRec := Gikosys.Parse2chURL2(URL);
+                if (AnsiPos('=st=', Text ) <> 0) and ( AnsiPos( '=to=',Text) <> 0 ) then begin
+                       try
+                       PathRec.FSt := StrToInt( Copy( Text, AnsiPos('=st=', Text ) + 4, AnsiPos( '=to=',Text) - AnsiPos('=st=', Text ) - 4 ) );
+                        PathRec.FTo := StrToInt( Copy( Text, AnsiPos('=to=', Text ) + 4, AnsiPos( '=nofirst=',Text) - AnsiPos('=to=', Text ) - 4) );
+                    except
+                       PathRec.FSt := 0;
+                        PathRec.FTo := 0;
+                    end;
+                end;
+            end;
 
-                       PathRec := Gikosys.Parse2chURL2(URL);
                        GikoSys.ParseURI( URL, Protocol, Host, Path, Document, Port, Bookmark );
 
-                       if PathRec.FDone or (not GikoSys.Is2chHost( Host )) then begin
+                       //if PathRec.FDone or (not GikoSys.Is2chHost( Host )) then begin
 
                                URL := GikoSys.GetBrowsableThreadURL( URL );
-
-                               wkIntSt := PathRec.FSt;
-                               wkIntTo := PathRec.FTo;
+                wkIntSt := PathRec.FSt;
+                wkIntTo := PathRec.FTo;
 
                                if (wkIntSt = 0) and (wkIntTo = 0) then begin
                                        wkIntSt := 1;
@@ -2536,7 +2547,7 @@ begin
                                        SetResPopupText( threadItem, wkIntSt, wkIntTo, ATitle, PathRec.FFirst );
                                end;
                        end;
-               end;
+               //end;
 
                //if s <> '' then
                //      ShowTextPopup(s);
index b3bfeed..aa11018 100644 (file)
@@ -165,7 +165,8 @@ type
                function DeleteLink(const s: string): string;
 
                function GetShortName(const LongName: string; ALength: integer): string;
-               function ConvRes(const Body, Bbs, Key,  ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string;
+               function ConvRes(const Body, Bbs, Key,  ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string): string; overload;
+        function ConvRes(const Body, Bbs, Key, ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue, FullURL : string): string; overload;
 
                function ZenToHan(const s: string): string;
                function VaguePos(const Substr, S: string): Integer;
@@ -268,8 +269,8 @@ begin
        FAWKStr.Free;
        FSetting.Free;
        FDolib.Free;
-               FAbon.Free;
-               FSelectResFilter.Free;
+       FAbon.Free;
+       FSelectResFilter.Free;
        //\83e\83\93\83|\83\89\83\8aHTML\82ð\8dí\8f\9c
        FileList := TStringList.Create;
        try
@@ -1192,8 +1193,6 @@ begin
                                                No := IntToStr(i + 1);
 
                                                Res := DivideStrLine(ReadList[i]);
-                                               Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
-
                                                if Res.FType = glt2chOld then begin
                                                        Res.FMailTo := CustomStringReplace(Res.FMailTo, '\81\97\81M', ',');
                                                        Res.FName := CustomStringReplace(Res.FName, '\81\97\81M', ',');
@@ -1201,6 +1200,8 @@ begin
                                                end;
 
                                                Res.FBody := AddAnchorTag(Res.FBody);
+                                               Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true',ThreadItem.URL);
+
                                                if Res.FName = '' then
                                                        Res.FName := '&nbsp;';
 
@@ -1276,8 +1277,9 @@ begin
                                                        SaveList.Add('<a name="new"></a><div class="new">\90V\92\85\83\8c\83X <span class="newdate">' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</span></div>');
                                                end;
                                                Res := DivideStrLine(ReadList[i]);
-                                               Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
-                                               Res.FBody := AddAnchorTag(Res.FBody);
+                        Res.FBody := AddAnchorTag(Res.FBody);
+                                               Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true',ThreadItem.URL);
+
                                                if Res.FName = '' then
                                                        Res.FName := '&nbsp;';
                                                if Res.FMailTo = '' then
@@ -1348,13 +1350,13 @@ begin
                                                        SaveList.Add('<dl>');
                                                end;
                                                Res := DivideStrLine(ReadList[i]);
-                                               Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true');
                                                if Res.FType = glt2chOld then begin
                                                        Res.FMailTo := CustomStringReplace(Res.FMailTo, '\81\97\81M', ',');
                                                        Res.FName := CustomStringReplace(Res.FName, '\81\97\81M', ',');
                                                        Res.FBody := CustomStringReplace(Res.FBody, '\81\97\81M', ',');
                                                end;
                                                Res.FBody := AddAnchorTag(Res.FBody);
+                                               Res.FBody := ConvRes(Res.FBody, ThreadItem.ParentBoard.BBSID, ChangeFileExt(ThreadItem.FileName, ''), 'bbs', 'key', 'st', 'to', 'nofirst', 'true',ThreadItem.URL);
                                                if Res.FMailTo = '' then
                                                        SaveList.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> \96¼\91O\81F<font color="forestgreen"><b> ' + Res.FName + ' </b></font> \93\8a\8de\93ú\81F ' + Res.FDateTime+ '<br><dd>' + Res.Fbody + ' <br><br><br>')
                                                else if GikoSys.Setting.ShowMail then
@@ -2053,6 +2055,195 @@ begin
        Result  :=      r;
 end;
 
+function TGikoSys.ConvRes(
+       const Body, Bbs, Key, ParamBBS, ParamKey,
+    ParamStart, ParamTo, ParamNoFirst,
+    ParamTrue, FullURL : string
+): string;
+type
+       PIndex = ^TIndex;
+       TIndex = record
+               FIndexFrom      : integer;
+               FIndexTo                : integer;
+               FNo                              : string;
+       end;
+const
+       GT      = '&gt;';
+       SN      = '0123456789-';
+       ZN      = '\82O\82P\82Q\82R\82S\82T\82U\82V\82W\82X\81|';
+var
+       i : integer;
+       s,r : string;
+       b : TMbcsByteType;
+       sw: boolean;
+       sp: integer;
+       No: string;
+       sx: string;
+       List: TList;
+       oc      : string;
+       st, et: string;
+       chk : boolean;
+       al : boolean;
+       procedure Add(IndexFrom, IndexTo: integer; const No: string);
+       var
+               FIndex : PIndex;
+       begin
+               New(FIndex);
+               FIndex.FIndexFrom       := IndexFrom;
+               FIndex.FIndexTo         := IndexTo;
+               FIndex.FNo                               := No;
+               List.Add(FIndex);
+       end;
+       function ChooseString(const Text, Separator: string; Index: integer): string;
+       var
+               S : string;
+               i, p : integer;
+       begin
+               S :=    Text;
+               for i :=        0 to    Index - 1 do    begin
+                       if      (AnsiPos(Separator, S) = 0) then        S :=    ''
+                       else    S :=    Copy(S, AnsiPos(Separator, S) + Length(Separator), Length(S));
+               end;
+               p :=    AnsiPos(Separator, S);
+               if      (p > 0) then    Result  :=      Copy(S, 1, p - 1) else Result :=        S;
+       end;
+begin
+       { v1.0 b2 - 03 }
+       s        :=     Body;
+       r        :=     Body;
+       i        :=     1;
+       sw      :=      False;
+       No      :=      '';
+       List:=  TList.Create;
+       oc      :=      '';
+       sp      :=      0;
+       chk :=  False;
+       al      :=      False;
+       while true      do      begin
+               b :=    ByteType(s, i);
+               case    b of
+                       mbSingleByte    : begin
+                               if      (not sw) and (Copy(s,i,8) = GT + GT) then       begin
+                                       if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then        begin
+                                               sw      :=      True;
+                                               sp      :=      i;
+                                               i :=    i + 7;
+                                               oc:='';
+                                               chk :=  True;
+                                       end;
+                               end else
+                               if      (not sw) and (Copy(s,i,8) = GT + GT) then       begin
+                                       if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 1) then        begin
+                                               i :=    i + 7;
+                                               oc:='';
+                                               chk :=  True;
+                                       end;
+                               end else
+                               if      (not sw) and (Copy(s,i,4) = GT) then    begin
+                                       if      (AnsiPos('<A HREF', AnsiUpperCase(oc)) = 0) then        begin
+                                               sw      :=      True;
+                                               sp      :=      i;
+                                               i :=    i + 3;
+                                               oc:='';
+                                               chk :=  True;
+                                       end;
+                               end else
+                               if      ((not sw) and (Copy(s,i,1) = ',')) or
+                                               ((not sw) and (Copy(s,i,1) = '=')) then begin
+                                       if      ((not Chk) and (AnsiLowerCase(oc) = '</a>')) or
+                                                       ((Chk) and      (oc = '')) or
+                                                       ((not Chk) and (al)) then
+                                       begin
+                                               sw      :=      True;
+                                               sp      :=      i;
+                                               //i :=  i + 1;
+                                               oc:='';
+                                       end;
+                               end else
+                               if      (sw) then begin
+                                       sx      :=      Copy(s,i,1);
+                                       if      (AnsiPos(sx, SN) > 0)   then    begin
+                                               No      :=      No      + sx;
+                                       end else begin
+                                               if      (No <> '') and (No <> '-')       then   begin
+                                                       Add(sp, i, No);
+                                                       al := True;
+                                               end;
+                                               sw      :=      False;
+                                               //
+                                               i := i - 1;
+                                               //
+                                               No      := '';
+                                               oc:='';
+                                               //chk :=        False;
+                                       end;
+                               end else begin
+                                       if      Copy(s,i,1) = '<' then  oc      :=      '';
+                                       oc      :=      oc + Copy(s,i,1);
+                                       chk :=  False;
+                                       al      :=      False;
+                               end;
+                       end;
+                       mbLeadByte      : begin
+                               if      (not sw) and (Copy(s,i,4) = '\81\84\81\84') then        begin
+                                       sw      :=      True;
+                                       sp      :=      i;
+                                       i :=    i + 3;
+                                       chk :=  True;
+                               end else
+                               if      (not sw) and (Copy(s,i,2) = '\81\84') then  begin
+                                       sw      :=      True;
+                                       sp      :=      i;
+                                       i :=    i + 1;
+                                       chk :=  True;
+                               end else
+                               if      (sw) then begin
+                                       sx      :=      Copy(s,i,2);
+                                       if      (AnsiPos(sx, ZN) > 0)   then    begin
+                                               No      :=      No      + ZenToHan(sx);
+                                       end else begin
+                                               if      (No <> '') and (No <> '-')      and (No <> '\81|') then   begin
+                                                       Add(sp, i, No);
+                                               end;
+                                               sw      :=      False;
+                                               i := i - 1;
+                                               No      :=      '';
+                                       end;
+                               end else begin
+                                       oc      :=      '';
+                                       chk :=  False;
+                               end;
+                               al      :=      False;
+                       end;
+               end;
+               inc(i);
+               if      (i > Length(Body))      then    begin
+                       if      (sw)    then    begin
+                               if      (No <> '')      then    Add(sp, i, No);
+                       end;
+                       Break;
+               end;
+       end;
+       for i :=        List.Count - 1  downto  0 do    begin
+        //plName := Copy(PluginName, LastDelimiter('\',PluginName) + 1, Length(PluginName) - LastDelimiter('/',PluginName) -1 );
+               if      (AnsiPos('-', PIndex(List[i]).FNo) > 0) then    begin
+                       st      :=      ChooseString(PIndex(List[i]).FNo, '-', 0);
+                       et      :=      ChooseString(PIndex(List[i]).FNo, '-', 1);
+               end else begin
+                       st      :=      PIndex(List[i]).FNo;
+                       et      :=      PIndex(List[i]).FNo;
+               end;
+               r :=    Copy(r,0, PIndex(List[i]).FIndexFrom - 1) +
+                                       Format('<a href="%s=%s=%s=%s=%s=%s=%s" target="_blank">',
+                                                               [FullURL, ParamStart, st, ParamTo, et, ParamNoFirst, ParamTrue]) +
+                                       Copy(r,PIndex(List[i]).FIndexFrom, PIndex(List[i]).FIndexTo - PIndex(List[i]).FIndexFrom) + '</A>' +
+                                       Copy(r,PIndex(List[i]).FIndexTo,Length(r));
+               Dispose(PIndex(List[i]));
+       end;
+       List.Free;
+       Result  :=      r;
+end;
+
 (*************************************************************************
  * \91S\8ap\81¨\94¼\8ap
  * from HotZonu