OSDN Git Service

Samba対策が,設定値0秒だと作動しない不具合の修正。
authorh677 <h677>
Wed, 16 Aug 2006 02:22:33 +0000 (02:22 +0000)
committerh677 <h677>
Wed, 16 Aug 2006 02:22:33 +0000 (02:22 +0000)
レスエディタのプレビュー用HTML作成をTHTMLCreateに移行。

Editor.pas
HTMLCreate.pas

index a50a3ae..ac53180 100644 (file)
@@ -12,7 +12,7 @@ uses
        SHDocVw_TLB,
        MSHTML_TLB,
 {$IFEND}
-       ActiveX, {HTTPApp,} YofUtils, Trip, IniFiles, StrUtils,
+       ActiveX, {HTTPApp,} YofUtils, IniFiles, StrUtils,
        GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
        IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
        IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
@@ -210,7 +210,6 @@ type
                FResistWords: TStringList;      ///< \93ü\97Í\83A\83V\83X\83g\82Ì\8e«\8f\91\82©\82ç\82Ì\8c\9f\8dõ\8c\8b\89Ê
         FSambaTimer: TSambaTimer;   ///< Samba\91Î\8dô\82Ì\83^\83C\83}\81[
                procedure Preview;
-               function RepHtml(s: string): string;
                function Check: Boolean;
                procedure SetNameList(sName, sMail: string);
                procedure Send(ACOOKIE: string; SPID: string; PON: string; FirstWriting: Boolean);
@@ -264,7 +263,7 @@ implementation
 
 uses
        Giko, ItemDownload, MojuUtils, IdGlobal, GikoMessage,  Imm,
-  InputAssistDataModule, InputAssist;
+  InputAssistDataModule, InputAssist, HTMLCreate;
 const
        CAPTION_NAME_NEW: string = '\83M\83R\83i\83\83X\83\8c\97§\82Ä\83G\83f\83B\83^';
        CAPTION_NAME_RES: string = '\83M\83R\83i\83\83\8c\83X\83G\83f\83B\83^';
@@ -451,7 +450,7 @@ begin
        SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
        TitlePanel.Visible := True;
 
-    if (FSambaTimer.SetBoard(FBoard) > 0) then begin
+    if (FSambaTimer.SetBoard(FBoard) >= 0) then begin
         UpdateSambaStatus;
         FNow := Now();
         FSambaTimer.OnTimer := SambaTimer;
@@ -470,7 +469,7 @@ begin
        SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
        TitlePanel.Visible := False;
 
-    if (FSambaTimer.SetBoard(FThreadItem.ParentBoard) > 0) then begin
+    if (FSambaTimer.SetBoard(FThreadItem.ParentBoard) >= 0) then begin
         UpdateSambaStatus;
         FNow := Now();
         FSambaTimer.OnTimer := SambaTimer;
@@ -573,65 +572,32 @@ var
        No: string;
        Mail: string;
        Namae: string;
-       DateTime: string;
        Body: string;
        s: string;
-
-                               posTrip : Integer;
-                               tripOrigin : string;
 begin
        if FThreadItem = nil then begin
                No := '1';
-               Title := RepHtml(TitleEdit.Text);
+               Title := THTMLCreate.RepHtml(TitleEdit.Text);
        end else begin
                No := IntToStr(FThreadItem.Count + 1);
-               Title := RepHtml(FThreadItem.Title);
+               Title := THTMLCreate.RepHtml(FThreadItem.Title);
        end;
 
-       body := GetBody;
-       Namae := RepHtml(NameComboBox.Text);
-       Mail := RepHtml(MailComboBox.Text);
-       Body := RepHtml(body);
-       Body := StringReplace(Body, #13#10, '<br>', [rfReplaceAll]);
-       DateTime := FormatDateTime('yyyy/mm/dd(aaa) hh:nn', now);
+       Body := GetBody;
+       Namae := THTMLCreate.RepHtml(NameComboBox.Text);
+       Mail := THTMLCreate.RepHtml(MailComboBox.Text);
+       Body := THTMLCreate.RepHtml(Body);
+       Body := CustomStringReplace(Body, #13#10, '<br>', False);
+
 
        if Trim(Namae) = '' then
                Namae := '\96¼\96³\82µ\82³\82ñ';
 
-       s := '<HTML><HEAD>' + #13#10
-                       + '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">' + #13#10
-                       + '<TITLE>' + title + '</TITLE>' + #13#10
-//                     + '<STYLE><!--BODY{font-size : 9pt;font-family : "\82l\82\82o\83S\83V\83b\83N";}--></STYLE>' + #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;
-                               posTrip := AnsiPos( '#', Namae );
-                               if posTrip > 0 then
-                               begin
-                                                               tripOrigin := Copy( Namae, posTrip + 1, Length( Namae ) );
-                                                               Namae :=
-                                                                                               Copy( Namae, 1, posTrip - 1 ) + '</B> \81\9f' +
-                                                                                               get_2ch_trip( PChar( tripOrigin ) ) + '<B>';
-                               end;
-       if Mail = '' then
-               s := s + '<DT>' + No + ' \81F <FONT color="forestgreen"><B>' + Namae + '</B></FONT> \81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10
-       else
-               s := s + '<DT>' + No + ' \81F <A href="mailto:' + Mail + '"><B>' + Namae + '</B></A> [' + Mail + ']\81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10;
-       s := s + '</BODY></HTML>';
+    s := THTMLCreate.CreatePreviewHTML(Title, No, Mail, Namae, Body);
+    
        SetContent(s, Browser);
 end;
 
-function TEditorForm.RepHtml(s: string): string;
-begin
-//     s := StringReplace(s, '&', '&amp;', [rfReplaceAll]);
-       s := CustomStringReplace(s, '<', '&lt;');
-       s := CustomStringReplace(s, '>', '&gt;');
-//     s := StringReplace(s, ' ', '&nbsp;', [rfReplaceAll]);   //\8ed\97l\95Ï\8dX\82É\82æ\82è&nbsp;\8eg\97p\95s\89Â
-       s := CustomStringReplace(s, '"', '&quot;');
-       Result := s;
-end;
-
 procedure TEditorForm.EditorPageChange(Sender: TObject);
 var
         tmpBoard: TBoard;
@@ -842,7 +808,7 @@ var
 begin
        FAbort := False;
        State := gdsError;
-       Namae := RepHtml(NameComboBox.Text);
+       Namae := THTMLCreate.RepHtml(NameComboBox.Text);
        if FThreadItem = nil then
                Board := FBoard
        else
index 57f658c..ff690d9 100644 (file)
@@ -86,6 +86,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 +98,9 @@ var
 
 implementation
 
+uses
+    Trip;
+
 const
        URL_CHAR: string = '0123456789'
                                                                         + 'abcdefghijklmnopqrstuvwxyz'
@@ -1546,7 +1554,69 @@ 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;
 constructor TBufferedWebBrowser.Create(Browser: TWebBrowser; BuffSize: Integer);
 begin
        inherited Create;