OSDN Git Service

1.57.2.749
[gikonavigoeson/gikonavi.git] / HTMLCreate.pas
index 8212920..8ba7bec 100644 (file)
@@ -15,7 +15,7 @@ uses
        {HttpApp,} YofUtils, {URLMon,} BoardGroup, {gzip,} {Dolib,}
        {bmRegExp,} AbonUnit,   MojuUtils, Setting,
        ExternalBoardManager, ExternalBoardPlugInMain{,}
-       {Sort,} ,GikoBayesian, HintWindow, ActiveX;
+       {Sort,} ,GikoBayesian, {HintWindow,} ActiveX, ResPopupBrowser;
 
 type
 
@@ -67,7 +67,9 @@ type
              dat : boolean;    var s : String) : string;
         function getNumberString(const str: String;var index :Integer; var dbCharlen: Boolean;
              sLen :Integer): String;
-
+        function isOutsideRange(item: TThreadItem; index: Integer ): Boolean;
+        function getKeywordLink(item: TThreadItem): String;
+        function GetResString(index: Integer; const Line: String; PResLink : PResLinkRec): String;
        public
                { Public \90é\8c¾ }
                procedure AddAnchorTag(PRes: PResRec);
@@ -77,7 +79,7 @@ type
                procedure CreateHTML2(Browser: TWebBrowser; ThreadItem: TThreadItem; var sTitle: string);
                procedure CreateHTML3(var html: TStringList; ThreadItem: TThreadItem; var sTitle: string);
                //\83\8c\83X\83|\83b\83v\83A\83b\83v\82Ì\8dì\90¬
-               procedure SetResPopupText(Hint :TResPopup; threadItem: TThreadItem; StNum, ToNum: Integer; Title, First: Boolean);
+               procedure SetResPopupText(Hint :TResPopupBrowser; threadItem: TThreadItem; StNum, ToNum: Integer; Title, First: Boolean);
                //\83\8a\83\93\83N\82Ì\95\8e\9a\97ñ\82©\82ç\83\8c\83X\83|\83b\83v\83A\83b\83v\97p\82ÌURL\82É\95Ï\8a·\82·\82é
                class function GetRespopupURL(AText, AThreadURL : string): string;
                //\8ew\92è\82µ\82½\83p\83X\82É\83X\83L\83\93\82à\82µ\82­\82ÍCSS\82Ì\83t\83@\83C\83\8b\82Ì\83R\83s\81[\82ð\8dì\82é
@@ -86,6 +88,11 @@ type
                class procedure DivideStrLine(Line: string; PRes: PResRec);
         //HTML\82©\82ç\83\8a\83\93\83N\83^\83O\82ð\8dí\8f\9c\82·\82é
                class function DeleteLink(const s: string): string;
+        //HTML\82Ì\83{\83f\83B\82É\8b\96\82³\82ê\82é\95\8e\9a\97ñ\82É\92u\8a·\82·\82é
+        class function RepHtml(const s: string): string;
+        //\83\8c\83X\83G\83f\83B\83^\82Ì\83v\83\8c\83r\83\85\81[\97pHTML\82ð\8dì\90¬\82·\82é
+        class function CreatePreviewHTML(const Title: string; const No: string;
+               const Mail: string; const Namae: string; const Body: string ) : string;
        end;
 
 var
@@ -93,6 +100,9 @@ var
 
 implementation
 
+uses
+    Trip;
+
 const
        URL_CHAR: string = '0123456789'
                                                                         + 'abcdefghijklmnopqrstuvwxyz'
@@ -629,7 +639,6 @@ begin
        PRes.FBody := PRes.FBody + res;
 
 end;
-
 //Plugin\82ð\97\98\97p\82·\82éBoard\82Ì\83X\83\8c\83b\83h\82ÌHTML\82ð\8dì\90¬\82µ\82Ädoc\82É\8f\91\82«\8d\9e\82Þ
 procedure THTMLCreate.CreateUsePluginHTML(html:TBufferedWebBrowser; ThreadItem: TThreadItem; var sTitle: string);
 var
@@ -652,17 +661,9 @@ begin
                // 1 \82Í\95K\82¸\95\\8e¦
                if i <> 0 then begin
                        // \95\\8e¦\94Í\88Í\82ð\8cÀ\92è
-                       case GikoSys.ResRange of
-                       Ord( grrKoko ):
-                               if ThreadItem.Kokomade > (i + 1) then
-                                       Continue;
-                       Ord( grrNew ):
-                               if NewReceiveNo > (i + 1) then
-                                       Continue;
-                       10..65535:
-                               if (threadItem.Count - i) > GikoSys.ResRange then
-                                       Continue;
-                       end;
+            if (isOutsideRange(ThreadItem, i)) then begin
+                Continue;
+            end;
                end;
 
                // \90V\92\85\83}\81[\83N
@@ -757,17 +758,9 @@ begin
                // 1 \82Í\95K\82¸\95\\8e¦
                if i <> 0 then begin
                        // \95\\8e¦\94Í\88Í\82ð\8cÀ\92è
-                       case GikoSys.ResRange of
-                       Ord( grrKoko ):
-                               if ThreadItem.Kokomade > (i + 1) then
-                                       Continue;
-                       Ord( grrNew ):
-                               if NewReceiveNo > (i + 1) then
-                                       Continue;
-                       10..65535:
-                               if (threadItem.Count - i) > GikoSys.ResRange then
-                                       Continue;
-                       end;
+            if (isOutsideRange(ThreadItem, i)) then begin
+                Continue;
+            end;
                end;
 
                // \90V\92\85\83}\81[\83N
@@ -780,16 +773,16 @@ begin
 
                if (Trim(ReadList[i]) <> '') then begin
                        DivideStrLine(ReadList[i], @Res);
-                       AddAnchorTag(@Res);
-                       ConvRes(@Res, @ResLink);
-                       Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
-
-                       if NewReceiveNo <= (i + 1) then
-                               // \90V\92\85\83\8c\83X
-                               html.Add(SkinedRes(SkinNewRes, @Res, IntToStr(i + 1)))
-                       else
-                               // \92Ê\8fí\82Ì\83\8c\83X
-                               html.Add(SkinedRes(SkinRes, @Res, IntToStr(i + 1)));
+            AddAnchorTag(@Res);
+            ConvRes(@Res, @ResLink);
+            Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
+
+            if NewReceiveNo <= (i + 1) then
+                // \90V\92\85\83\8c\83X
+                html.Add(SkinedRes(SkinNewRes, @Res, IntToStr(i + 1)))
+            else
+                // \92Ê\8fí\82Ì\83\8c\83X
+                html.Add(SkinedRes(SkinRes, @Res, IntToStr(i + 1)));
                end;
 
                if ThreadItem.Kokomade = (i + 1) then begin
@@ -800,7 +793,7 @@ begin
                                html.Add( KOKO_TAG );
                end;
        end;
-
+    html.Add(getKeywordLink(ThreadItem));
        html.Add('<a name="bottom"></a>');
        // \83X\83L\83\93(\83t\83b\83^)
        html.Add( LoadFromSkin( GikoSys.GetSkinFooterFileName, ThreadItem, ThreadItem.Size ) );
@@ -854,18 +847,10 @@ begin
                for i := 0 to ReadList.Count - 1 do begin
                        // 1 \82Í\95K\82¸\95\\8e¦
                        if i <> 0 then begin
-                               // \95\\8e¦\94Í\88Í\82ð\8cÀ\92è
-                               case GikoSys.ResRange of
-                               Ord( grrKoko ):
-                                       if ThreadItem.Kokomade > (i + 1) then
-                                               Continue;
-                               Ord( grrNew ):
-                                       if NewReceiveNo > (i + 1) then
-                                               Continue;
-                               10..65535:
-                                       if (threadItem.Count - i) > GikoSys.ResRange then
-                                               Continue;
-                               end;
+                       // \95\\8e¦\94Í\88Í\82ð\8cÀ\92è
+                if (isOutsideRange(ThreadItem, i)) then begin
+                    Continue;
+                end;
                        end;
 
                        if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
@@ -875,23 +860,22 @@ begin
                        if (Trim(ReadList[i]) <> '') then begin
                                No := IntToStr(i + 1);
                                DivideStrLine(ReadList[i], @Res);
-                               AddAnchorTag(@Res);
-                               ConvRes(@Res, @ResLink);
-                               Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
-                               if Res.FMailTo = '' then
-                                       html.Add(Format(FORMAT_NOMAIL, [No, No, No, Res.FName, Res.FDateTime, Res.FBody]))
-                               else if GikoSys.Setting.ShowMail then
-                                       html.Add(Format(FORMAT_SHOWMAIL, [No, No, No, Res.FMailTo, Res.FName, Res.FMailTo, Res.FDateTime, Res.FBody]))
-                               else
-                                       html.Add(Format(FORMAT_NOSHOW, [No, No, No, Res.FMailTo, Res.FName, Res.FDateTime, Res.FBody]));
-                       end;
-
+                AddAnchorTag(@Res);
+                ConvRes(@Res, @ResLink);
+                Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
+                if Res.FMailTo = '' then
+                    html.Add(Format(FORMAT_NOMAIL, [No, No, No, Res.FName, Res.FDateTime, Res.FBody]))
+                else if GikoSys.Setting.ShowMail then
+                    html.Add(Format(FORMAT_SHOWMAIL, [No, No, No, Res.FMailTo, Res.FName, Res.FMailTo, Res.FDateTime, Res.FBody]))
+                else
+                    html.Add(Format(FORMAT_NOSHOW, [No, No, No, Res.FMailTo, Res.FName, Res.FDateTime, Res.FBody]));
+            end;
                        if ThreadItem.Kokomade = (i + 1) then begin
                                html.Add('<a name="koko"></a><div class="koko">\83R\83R\82Ü\82Å\93Ç\82ñ\82¾</div>');
                        end;
 
                end;
-
+        html.Add(getKeywordLink(ThreadItem));
                html.Add('<a name="bottom"></a>');
                html.Add('<a name="last"></a>');
                html.Add('</body></html>');
@@ -901,9 +885,7 @@ end;
 procedure THTMLCreate.CreateDefaultHTML (html:TBufferedWebBrowser; ThreadItem: TThreadItem; ReadList: TStringList; sTitle: string );
 var
        i: integer;
-       No: string;
        NewReceiveNo: Integer;
-       Res: TResRec;
        ThreadName: String;
        ResLink : TResLinkRec;
 begin
@@ -924,17 +906,9 @@ begin
                // 1 \82Í\95K\82¸\95\\8e¦
                if i <> 0 then begin
                        // \95\\8e¦\94Í\88Í\82ð\8cÀ\92è
-                       case GikoSys.ResRange of
-                       Ord( grrKoko ):
-                               if ThreadItem.Kokomade > (i + 1) then
-                                       Continue;
-                       Ord( grrNew ):
-                               if NewReceiveNo > (i + 1) then
-                                       Continue;
-                       10..65535:
-                               if (threadItem.Count - i) > GikoSys.ResRange then
-                                       Continue;
-                       end;
+            if (isOutsideRange(ThreadItem, i)) then begin
+                Continue;
+            end;
                end;
 
                if (NewReceiveNo = (i + 1)) or ((NewReceiveNo = 0) and (i = 0)) then begin
@@ -945,27 +919,34 @@ begin
                end;
 
                if (Trim(ReadList[i]) <> '') then begin
-                       No := IntToStr(i + 1);
-                       DivideStrLine(ReadList[i], @Res);
-                       AddAnchorTag(@Res);
-                       ConvRes(@Res, @ResLink);
-                       Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
-                       if Res.FMailTo = '' then
-                               html.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 <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10)
-                       else if GikoSys.Setting.ShowMail then
-                               html.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> \96¼\91O\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] \93\8a\8de\93ú\81F <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10)
-                       else
-                               html.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> \96¼\91O\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> \93\8a\8de\93ú\81F <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10);
-               end;
+            html.Add(GetResString(i, ReadList[i], @ResLink));
+        end;
                if ThreadItem.Kokomade = (i + 1) then begin
                        html.Add('</dl>');
                        html.Add('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>\83R\83R\82Ü\82Å\93Ç\82ñ\82¾</b></font></td></tr></table>');
                        html.Add('<dl>');
                end;
        end;
+    html.Add(getKeywordLink(ThreadItem));
        html.Add('</dl>'#13#10'<a name="bottom"></a>'#13#10'</body></html>');
 end;
-
+function THTMLCreate.GetResString(index: Integer; const Line: String; PResLink : PResLinkRec): String;
+var
+    No : String;
+    Res: TResRec;
+begin
+    No := IntToStr(index + 1);
+    DivideStrLine(Line, @Res);
+    AddAnchorTag(@Res);
+    ConvRes(@Res, PResLink);
+    Res.FDateTime := AddBeProfileLink(Res.FDateTime, index + 1);
+    if Res.FMailTo = '' then
+        Result := '<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 <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10
+    else if GikoSys.Setting.ShowMail then
+        Result := '<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> \96¼\91O\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] \93\8a\8de\93ú\81F <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10
+    else
+        Result := '<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> \96¼\91O\81F<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> \93\8a\8de\93ú\81F <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10;
+end;
 procedure THTMLCreate.CreateHTML2(Browser: TWebBrowser; ThreadItem: TThreadItem; var sTitle: string);
 var
        ReadList: TStringList;
@@ -1273,7 +1254,7 @@ begin
        end;
 end;
 
-procedure THTMLCreate.SetResPopupText(Hint : TResPopup; threadItem: TThreadItem; StNum, ToNum: Integer; Title, First: Boolean);
+procedure THTMLCreate.SetResPopupText(Hint : TResPopupBrowser; threadItem: TThreadItem; StNum, ToNum: Integer; Title, First: Boolean);
 var
        i: Integer;
        tmp: string;
@@ -1282,11 +1263,12 @@ var
 
        wkInt: Integer;
 
-       Res: TResRec;
-       Header: string;
-       Body: string;
     boardPlugIn : TBoardPlugIn;
+    Html: TStringList;
+       ResLink : TResLinkRec;
 begin
+
+    Html := TStringList.Create;
        try
                if StNum > ToNum then begin
                        wkInt := StNum;
@@ -1298,12 +1280,19 @@ begin
                if StNum + MAX_POPUP_RES < ToNum then
                        ToNum := StNum + MAX_POPUP_RES;
 
+        Hint.Title := '';
+        Hint.RawDocument := '';
+        Hint.Thread := nil;
+        
                //\83^\83C\83g\83\8b\95\\8e¦
                if Title then
                                if ThreadItem <> nil then
                                        Hint.Title := ThreadItem.Title;
 
         if ThreadItem <> nil then begin
+            Hint.Thread := ThreadItem;
+            ResLink.FBbs := ThreadItem.ParentBoard.BBSID;
+            ResLink.FKey := ChangeFileExt(ThreadItem.FileName, '');
             //if ThreadItem.IsBoardPlugInAvailable then begin
             if ThreadItem.ParentBoard.IsBoardPlugInAvailable then begin
                 //===== \83v\83\89\83O\83C\83\93\82É\82æ\82é\95\\8e¦
@@ -1317,25 +1306,7 @@ begin
                                        //\82±\82±\82Å\82Q\82¿\82á\82ñ\82Ë\82é\82Ìdat\82Ì\8c`\8e®\82Å\82P\8ds\93Ç\82Ý\8d\9e\82ß\82ê\82Î¥¥¥\81B\81«\93Ç\82ß\82é\82æ\82¤\82É\82È\82Á\82½
                                        tmp := boardPlugIn.GetDat( DWORD( threadItem ), i );
                     if (tmp <> '') And ( not GikoSys.FAbon.CheckAbonPopupRes(tmp) And( not GikoSys.FAbon.CheckIndividualAbonList(line))) then begin
-                                               DivideStrLine(tmp, @Res);
-                        if (GikoSys.Setting.ShowMail = false) or (Length(res.FMailTo) = 0) then
-                               Header := IntToStr(Line) + ' \96¼\91O\81F ' + Res.FName + ' \93\8a\8de\93ú\81F ' + Res.FDateTime
-                        else
-                               Header := IntToStr(Line) + ' \96¼\91O\81F ' + Res.FName + ' [' + res.FMailTo + '] \93\8a\8de\93ú\81F ' + Res.FDateTime;
-                                               Header := DeleteFontTag(Header);
-                                               Header := CustomStringReplace(Header, '<br>', '',true);
-
-                                               Body := CustomStringReplace(Res.FBody, '<br> ', #10,true);
-                                               Body := CustomStringReplace(Body, '<br>', #10,true);
-                        Body := CustomStringReplace(Body, '</a>', '',true);
-                                               Body := THTMLCreate.DeleteLink(Body);
-                        Body := CustomStringReplace(Body, '&lt;', '<');
-                        Body := CustomStringReplace(Body, '&gt;', '>');
-                        Body := CustomStringReplace(Body, '&quot;', '"');
-                        Body := CustomStringReplace(Body, '&amp;', '&');
-                        Body := CustomStringReplace(Body, '&nbsp;', ' ');
-
-                                               Hint.Add(Header, Body);
+                        Html.Add(GetResString(Line-1, tmp, @ResLink));
                                        end;
                                end;
                        end else begin
@@ -1344,28 +1315,16 @@ begin
                                        FileName := ThreadItem.FilePath;
                                        tmp := GikoSys.ReadThreadFile(FileName, Line);
                                        if (tmp <> '') And ( not GikoSys.FAbon.CheckAbonPopupRes(tmp) And( not GikoSys.FAbon.CheckIndividualAbonList(line))) then begin
-                                               DivideStrLine(tmp, @Res);
-                                               if (GikoSys.Setting.ShowMail = false) or (Length(res.FMailTo) = 0) then
-                                                       Header := IntToStr(Line) + ' \96¼\91O\81F ' + Res.FName + ' \93\8a\8de\93ú\81F ' + Res.FDateTime
-                                               else
-                                                       Header := IntToStr(Line) + ' \96¼\91O\81F ' + Res.FName + ' [' + res.FMailTo + '] \93\8a\8de\93ú\81F ' + Res.FDateTime;
-
-                                               Body := DeleteFontTag(Res.FBody);
-                                               Body := CustomStringReplace(Body, '<br> ', #10,true);
-                                               Body := CustomStringReplace(Body, '<br>', #10,true);
-                                               Body := CustomStringReplace(Body, '</a>', '',true);
-                                               Body := THTMLCreate.DeleteLink(Body);
-                                               Body := CustomStringReplace(Body, '&lt;', '<');
-                                               Body := CustomStringReplace(Body, '&gt;', '>');
-                                               Body := CustomStringReplace(Body, '&quot;', '"');
-                                               Body := CustomStringReplace(Body, '&amp;', '&');
-                                                Body := CustomStringReplace(Body, '&nbsp;', ' ');
-                                               Hint.Add(Header, Body);
+                                               Html.Add(GetResString(Line-1, tmp, @ResLink));
                                        end;
                                end;
                        end;
+            if (Html.Count > 0) then begin
+                Hint.RawDocument := '<DL>' + Html.Text + '</DL>';
+            end;
                end;
        finally
+        Html.Free;
        end;
 end;
 
@@ -1426,7 +1385,9 @@ begin
        end else if GikoSys.Setting.UseCSS then begin
                current := ExtractFilePath(GikoSys.GetStyleSheetDir);
                tmp := ExtractFilePath(GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName);
-       end;
+       end else begin
+        Exit;
+    end;
        dirs := TStringList.Create;
        try
                dirs.Add(tmp);
@@ -1544,7 +1505,94 @@ begin
                inc(i, 2);
        end;
 end;
+{
+\brief  HTML\89»\82Ì\82½\82ß\82Ì\92u\8a·
+\param  s   \8c³\82É\82È\82é\95\8e\9a\97ñ
+\return HTML\82ÌinnerText\82Æ\82µ\82Ä\82ä\82é\82³\82ê\82é\95\8e\9a\97ñ
+}
+class function THTMLCreate.RepHtml(const s: string): string;
+begin
+//     s := StringReplace(s, '&', '&amp;', [rfReplaceAll]);
+    Result := s;
+       Result := CustomStringReplace(Result, '<', '&lt;');
+       Result := CustomStringReplace(Result, '>', '&gt;');
+//     s := StringReplace(s, ' ', '&nbsp;', [rfReplaceAll]);   //\8ed\97l\95Ï\8dX\82É\82æ\82è&nbsp;\8eg\97p\95s\89Â
+       Result := CustomStringReplace(Result, '"', '&quot;');
+end;
+{
+\brief  \83\8c\83X\83G\83f\83B\83^\82Å\82Ì\83v\83\8c\83r\83\85\81[\97pHTML\8dì\90¬
+\param  Title   \83X\83\8c\83b\83h\83^\83C\83g\83\8b
+\param  No  \83\8c\83X\94Ô\8d\86
+\param  Mail    \83\81\81[\83\8b\97\93
+\param  Name    \96¼\91O\97\93
+\param  Body    \96{\95
+\return \83v\83\8c\83r\83\85\81[\97pHTML
+}
+class function THTMLCreate.CreatePreviewHTML(
+       const Title: string;
+       const No: string;
+       const Mail: string;
+       const Namae: string;
+       const Body: string
+) : string;
+var
+    posTrip : Integer;
+    tripOrigin : string;
+    NameWithTrip: string;
+    DateTime: string;
+begin
+       Result := '<HTML><HEAD>'#13#10
+                       + '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">'#13#10
+                       + '<TITLE>' + title + '</TITLE>'#13#10
+                       + '</HEAD>'#13#10
+                       + '<BODY text="#000000" bgcolor="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">'#13#10
+                       + '<FONT COLOR="#FF0000">' + title + '</FONT>'#13#10
+                       + '<DL>'#13#10;
+
+       DateTime := FormatDateTime('yyyy/mm/dd(aaa) hh:nn', Now());
+
+    NameWithTrip := Namae;
+    posTrip := AnsiPos( '#', Namae );
+    if posTrip > 0 then begin
+        tripOrigin := Copy( Namae, posTrip + 1, Length( Namae ) );
+        NameWithTrip := Copy( Namae, 1, posTrip - 1 ) + '</B> \81\9f' +
+                    get_2ch_trip( PChar( tripOrigin ) ) + '<B>';
+    end;
+    if Mail = '' then begin
+        Result := Result + '<DT>' + No + ' \81F <FONT color="forestgreen"><B>' + NameWithTrip
+                 + '</B></FONT> \81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10
+    end else begin
+               Result := Result + '<DT>' + No + ' \81F <A href="mailto:' + Mail + '"><B>' + NameWithTrip
+                 + '</B></A> [' + Mail + ']\81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10;
+    end;
+       Result := Result + '</BODY></HTML>';
 
+end;
+{
+\brief  \95\\8e¦\94Í\88Í\8aO\83\8c\83X\94Ô\8d\86\94»\92è\8f\88\97\9d
+\param  item    \95\\8e¦\83X\83\8c\83b\83h
+\param  index   \83\8c\83X\94Ô\8d\86
+\return ture:\95\\8e¦\94Í\88Í\8aO false:\95\\8e¦\94Í\88Í\93à
+}
+function THTMLCreate.isOutsideRange( item: TThreadItem; index: Integer ): Boolean;
+begin
+    Result := False;
+    // \95\\8e¦\94Í\88Í\82ð\8cÀ\92è
+    case GikoSys.ResRange of
+    Ord( grrKoko ):
+        if item.Kokomade > (index + 1) then
+            Result := True;
+    Ord( grrNew ):
+        if item.NewReceive > (index + 1) then
+            Result := True;
+    10..65535:
+        if (GikoSys.Setting.HeadResCount) < (index + 1)  then begin
+            if (item.Count - index) > GikoSys.ResRange then begin
+                Result := True;
+            end;
+        end;
+    end;
+end;
 constructor TBufferedWebBrowser.Create(Browser: TWebBrowser; BuffSize: Integer);
 begin
        inherited Create;
@@ -1602,14 +1650,23 @@ begin
        end;
        inherited;
 end;
-
+//! \8aÖ\98A\83L\81[\83\8f\81[\83h\83\8a\83\93\83N\8fo\97Í
+function THTMLCreate.getKeywordLink(item: TThreadItem): String;
+const
+    PARA_URL = 'http://p2.2ch.io/getf.cgi?';
+begin
+    Result := '';
+    if (GikoSys.Setting.AddKeywordLink) and (item.ParentBoard.Is2ch) then begin
+        Result := '<p><span id="keyword"><a href="' + PARA_URL
+            + item.URL + '" target="_blank">\8aÖ\98A\83L\81[\83\8f\81[\83h</a></span></p>';
+    end;
+end;
 initialization
         HTMLCreater := THTMLCreate.Create;
 
 finalization
        if HTMLCreater <> nil then begin
-               HTMLCreater.Free;
-               HTMLCreater := nil;
+               FreeAndNil(HTMLCreater);
        end;
 
 end.