OSDN Git Service

スキン利用のスレの表示の高速化
authorh677 <h677>
Mon, 5 Dec 2005 16:07:01 +0000 (16:07 +0000)
committerh677 <h677>
Mon, 5 Dec 2005 16:07:01 +0000 (16:07 +0000)
HTMLCreate.pas

index 61b0c3e..e1752e7 100644 (file)
@@ -41,7 +41,7 @@ type
                { Public \90é\8c¾ }
                function AddAnchorTag(s: string): string;
                function LoadFromSkin(fileName: string; ThreadItem: TThreadItem; SizeByte: Integer): string;
-               function SkinedRes(skin: string; Res: TResRec; No: string): string;
+               function SkinedRes(const skin: string; Res: TResRec; const No: string): string;
                function ConvRes(const Body, Bbs, Key,  ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue : string; DatToHTML: boolean = false): string; overload;
 //             function ConvRes(const Body, Bbs, Key,  ParamBBS, ParamKey, ParamStart, ParamTo, ParamNoFirst, ParamTrue, FullURL : string): string; overload;
                procedure CreateHTML2(doc: Variant; ThreadItem: TThreadItem; var sTitle: string);
@@ -156,52 +156,60 @@ end;
 
 // \83\8c\83X\82Ì\92l\82ð\92u\8a·\82·\82é
 function THTMLCreate.SkinedRes(
-       skin: string;
+       const skin: string;
        Res: TResRec;
-       No: string
+       const No: string
 ): string;
+const
+       FORMT_NAME = '<b>%s</b>';
+       FORMT_NUM  = '<a href="menu:%s" name="%s">%s</a>';
+       FORMT_MAILNAME  = '<a href="mailto:%s"><b>%s</b></a>';
 var
        spamminess      : Extended;
+{$IFDEF SPAM_FILTER_ENABLED}
        wordCount               : TWordCount;
+{$ENDIF}
 begin
-
+{$IFDEF SPAM_FILTER_ENABLED}
        wordCount := TWordCount.Create;
        try
                spamminess := Floor( GikoSys.SpamParse(
                        Res.FName + '<>' + Res.FMailTo + '<>' + Res.FBody, wordCount ) * 100 );
-
-               Skin := CustomStringReplace( Skin, '<NUMBER/>',
-                       Format('<a href="menu:%s" name="%s">%s</a>', [No, No, No]));
-               Skin := CustomStringReplace( Skin, '<PLAINNUMBER/>', No);
-               Skin := CustomStringReplace( Skin, '<NAME/>', '<b>' + Res.FName + '</b>');
-               Skin := CustomStringReplace( Skin, '<MAILNAME/>',
-                       Format('<a href="mailto:%s"><b>%s</b></a>',[Res.FMailTo, Res.FName]));
-               Skin := CustomStringReplace( Skin, '<MAIL/>', Res.FMailTo);
-               Skin := CustomStringReplace( Skin, '<DATE/>', Res.FDateTime);
-               Skin := CustomStringReplace( Skin, '<MESSAGE/>', Res.FBody);
-               Skin := CustomStringReplace( Skin, '<SPAMMINESS/>', FloatToStr( spamminess ) );
-               Skin := CustomStringReplace( Skin, '<NONSPAMMINESS/>', FloatToStr( 100 - spamminess ) );
-
+{$ELSE}
+       spamminess := 0;
+{$ENDIF}
+               Result := CustomStringReplace( Skin, '<SPAMMINESS/>', FloatToStr( spamminess ) );
+               Result := CustomStringReplace( Result, '<NONSPAMMINESS/>', FloatToStr( 100 - spamminess ) );
+               Result := CustomStringReplace( Result, '<MAIL/>', Res.FMailTo);
+               Result := CustomStringReplace( Result, '<DATE/>', Res.FDateTime);
+               Result := CustomStringReplace( Result, '<PLAINNUMBER/>', No);
+               Result := CustomStringReplace( Result, '<NAME/>',
+                       Format(FORMT_NAME, [Res.FName]));
+               Result := CustomStringReplace( Result, '<NUMBER/>',
+                       Format(FORMT_NUM, [No, No, No]));
+               Result := CustomStringReplace( Result, '<MAILNAME/>',
+                       Format(FORMT_MAILNAME,[Res.FMailTo, Res.FName]));
+               Result := CustomStringReplace( Result, '<MESSAGE/>', Res.FBody);
                //----- \82©\82¿\82ã\81`\82µ\82á\8cÝ\8a·\97p\81B\83R\83\81\83\93\83g\83A\83E\83g\82µ\82Ä\82à\82æ\82µ
                if GikoSys.Setting.UseKatjushaType then begin
-                       Skin := CustomStringReplace( Skin, '&NUMBER',
+                       Result := CustomStringReplace( Result, '&NUMBER',
                                '<a href="menu:' + No + '" name="' + No + '">' + No + '</a>');
-                       Skin := CustomStringReplace( Skin, '&PLAINNUMBER', No);
-                       Skin := CustomStringReplace( Skin, '&NAME', '<b>' + Res.FName + '</b>');
-                       Skin := CustomStringReplace( Skin, '&MAILNAME',
+                       Result := CustomStringReplace( Result, '&PLAINNUMBER', No);
+                       Result := CustomStringReplace( Result, '&NAME', '<b>' + Res.FName + '</b>');
+                       Result := CustomStringReplace( Result, '&MAILNAME',
                                '<a href="mailto:' + Res.FMailTo + '"><b>' + Res.FName + '</b></a>');
-                       Skin := CustomStringReplace( Skin, '&MAIL', Res.FMailTo);
-                       Skin := CustomStringReplace( Skin, '&DATE', Res.FDateTime);
-                       Skin := CustomStringReplace( Skin, '&MESSAGE', Res.FBody);
-                       Skin := CustomStringReplace( Skin, '&SPAMMINESS', FloatToStr( spamminess ) );
-                       Skin := CustomStringReplace( Skin, '&NONSPAMMINESS', FloatToStr( 100 - spamminess ) );
+                       Result := CustomStringReplace( Result, '&MAIL', Res.FMailTo);
+                       Result := CustomStringReplace( Result, '&DATE', Res.FDateTime);
+                       Result := CustomStringReplace( Result, '&MESSAGE', Res.FBody);
+                       Result := CustomStringReplace( Result, '&SPAMMINESS', FloatToStr( spamminess ) );
+                       Result := CustomStringReplace( Result, '&NONSPAMMINESS', FloatToStr( 100 - spamminess ) );
                end;
                //----- \82±\82±\82Ü\82Å
-
-               Result := Skin;
+{$IFDEF SPAM_FILTER_ENABLED}
        finally
                wordCount.Free;
        end;
+{$ENDIF}
 
 end;
 (*************************************************************************
@@ -566,8 +574,8 @@ begin
                doc.open;
                // \83w\83b\83_
                doc.Write( boardPlugIn.GetHeader( DWORD( threadItem ),
-                       '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ) + #13#10 );
-               doc.Write('<p id="idSearch"></p>'#13#10 );
+                       '<style type="text/css">body {' + UserOptionalStyle + '}</style>' ));
+               doc.Write('<p id="idSearch"></p>');
 
                for i := 0 to threadItem.Count - 1 do begin
                        // 1 \82Í\95K\82¸\95\\8e¦
@@ -591,24 +599,24 @@ begin
                                try
                                        if GikoSys.Setting.UseSkin then begin
                                                if FileExists( GikoSys.GetSkinNewmarkFileName ) then
-                                                       doc.Write( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size ) + #13#10 )
+                                                       doc.Write( LoadFromSkin( GikoSys.GetSkinNewmarkFileName, ThreadItem, ThreadItem.Size ))
                                                else
-                                                       doc.Write( '<a name="new"></a>'#13#10 );
+                                                       doc.Write( '<a name="new"></a>');
                                        end else if GikoSys.Setting.UseCSS then begin
-                                               doc.Write('<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>'#13#10);
+                                               doc.Write('<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 else begin
                                                doc.Write('</dl>');
                                                doc.Write('<a name="new"></a>');
                                                doc.Write('<table width="100%" bgcolor="#3333CC" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#6666FF" valign="middle"><font size="-1" color="#ffffff"><b>\90V\92\85\83\8c\83X ' + FormatDateTime('yyyy/mm/dd(ddd) hh:mm', ThreadItem.RoundDate) + '</b></font></td></tr></table>');
-                                               doc.Write('<dl>'#13#10);
+                                               doc.Write('<dl>');
                                        end;
                                except
-                                       doc.Write( '<a name="new"></a>'#13#10);
+                                       doc.Write( '<a name="new"></a>');
                                end;
                        end;
 
                        // \83\8c\83X
-                       doc.Write( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ) + #13#10 );
+                       doc.Write( boardPlugIn.GetRes( DWORD( threadItem ), i + 1 ));
 
                        if ThreadItem.Kokomade = (i + 1) then begin
                                // \82±\82±\82Ü\82Å\93Ç\82ñ\82¾
@@ -617,23 +625,23 @@ begin
                                                if FileExists( GikoSys.GetSkinBookmarkFileName ) then
                                                        doc.Write( LoadFromSkin( GikoSys.GetSkinBookmarkFileName, ThreadItem, ThreadItem.Size ) + #13#10 )
                                                else
-                                                       doc.Write( '<a name="koko"></a>'#13#10 );
+                                                       doc.Write( '<a name="koko"></a>');
                                        end else if GikoSys.Setting.UseCSS then begin
-                                               doc.Write('<a name="koko"></a><div class="koko">\83R\83R\82Ü\82Å\93Ç\82ñ\82¾</div>'#13#10 );
+                                               doc.Write('<a name="koko"></a><div class="koko">\83R\83R\82Ü\82Å\93Ç\82ñ\82¾</div>');
                                        end else begin
                                                doc.Write('</dl>');
                                                doc.Write('<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>');
-                                               doc.Write('<dl>'#13#10 );
+                                               doc.Write('<dl>');
                                        end;
                                except
-                                       doc.Write( '<a name="koko"></a>'#13#10 );
+                                       doc.Write( '<a name="koko"></a>');
                                end;
                        end;
                end;
 
 
                // \83X\83L\83\93(\83t\83b\83^)
-               doc.Write( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ) + #13#10 );
+               doc.Write( boardPlugIn.GetFooter( DWORD( threadItem ), '<a name="bottom"></a>' ));
        finally
                doc.Close;
        end;
@@ -644,7 +652,6 @@ procedure THTMLCreate.CreateUseSKINHTML(doc: Variant; ThreadItem: TThreadItem; R
 var
        i: integer;
        No: string;
-       CSSFileName: string;
        NewReceiveNo: Integer;
        Res: TResRec;
        UserOptionalStyle: string;
@@ -653,15 +660,10 @@ var
        SkinRes: string;
        strTmp : string;
        ThreadName : string;
-       function ReplaceRes( skin: string ): string;
-       begin
-               Result := SkinedRes( skin, Res, No );
-       end;
 begin
        NewReceiveNo := ThreadItem.NewReceive;
        // \83t\83H\83\93\83g\82â\83T\83C\83Y\82Ì\90Ý\92è
        UserOptionalStyle := GikoSys.SetUserOptionalStyle;
-       CSSFileName := GikoSys.GetStyleSheetDir + GikoSys.Setting.CSSFileName;
        ThreadName := ChangeFileExt(ThreadItem.FileName, '');
 
        doc.open;
@@ -729,10 +731,10 @@ begin
                                try
                                        if NewReceiveNo <= (i + 1) then
                                                // \90V\92\85\83\8c\83X
-                                               strTmp := ReplaceRes( SkinNewRes )
+                                               strTmp := SkinedRes(SkinNewRes, Res, No) //ReplaceRes( SkinNewRes )
                                        else
                                                // \92Ê\8fí\82Ì\83\8c\83X
-                                               strTmp := ReplaceRes( SkinRes );
+                                               strTmp := SkinedRes(SkinRes, Res, No); //ReplaceRes( SkinRes );
 
                                        doc.Write( strTmp );
                                except
@@ -950,8 +952,10 @@ begin
                        ReadList := TStringList.Create;
                        try
                                if ThreadItem.IsLogFile then begin
+                                       ReadList.BeginUpdate;
                                        FileName := ThreadItem.GetThreadFileName;
                                        ReadList.LoadFromFile(FileName);
+                                       ReadList.EndUpdate;
                                        GikoSys.FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
                                        GikoSys.FAbon.Execute(ReadList);                //       \82 \82Ú\81`\82ñ\82µ\82Ä
                                        GikoSys.FSelectResFilter.Execute(ReadList); //\83\8c\83X\82Ì\83t\83B\83\8b\83^\83\8a\83\93\83O\82ð\82·\82é
@@ -972,6 +976,7 @@ begin
                                end else begin
                                        CreateDefaultHTML(doc, ThreadItem, ReadList, sTitle);
                                end;
+
                        finally
                                ReadList.Free;
                        end;