同心聲氣默猶通
알림: 본 블로그는 'Clear Type'이 적용된 '맑은 고딕'글꼴을 사용합니다. 링크를 클릭하여 글꼴을 설치하시고 CT을 적용하세요.
MT에서 중첩코멘트를 달 수 있는 플러그인으로서 3.121버전에서 동작하도록 패치를 바꿔봤습니다.
우선 MT용 플러그인중에 가장 힘들다는 소문이 있는 녀석인 만큼…
삽질도 많았습니다. (물론 이것도 이쪽으로는 절대 무지한 관계로 심하게 삽질 -_-)
원본 패치의 출처는 다음과 같습니다.
MTThreadedComments - MT2.6
inel’s home의 MTThreadedComments for MT 3.0 - MT3.0
MT에서 중첩코멘트를 달 수 있는 플러그인으로서 MT용 플러그인중에 가장 힘들다는 소리를 듣는 녀석이다.
플러그인의 설치방법은 MTThreadedComments를 참조하시면 됩니다. 영문사이트라서 조금 읽기 귀찮지만, 찬찬히 읽으시면 해볼만은 합니다. (해석은 아니고 그냥 눈치만 채시면 되죠… 본인도 그 수준이므로)
3.0버전의 패치는 MTThreadedComments for MT 3.0의 코멘트나 트랙백을 활용하시길 바랍니다.
다운로드
플러그인: Download file
3.121용의 패치: Download file
패치된 comment.pl, comments.pl파일: Download file
원본 comment.pl, comments.pl파일: Download file
알아두셔야 할 것은 패치파일은 동작을 안할 수도 있습니다.
고친다고 고친것 같은데 계속 2번째 hunk에서 에러가 납니다.
제 계정 문제일듯 싶어서 파일을 올려놓습니다만, 패치 해 보시고 결과를 알려주셨으면 합니다. 잘 되는지 아니면 에러가 있는지.
패치가 실패될 경우를 대비해서 패치되기 전의 원본 comment.pl, comments.pl파일도 첨부하며, 귀차니즘이 발동하시면 편하게 쓰시라고 패치된 comment.pl, comments.pl도 첨부합니다. 활용해 주십시오.
주의: MT3.121용임을 유의하시길 바랍니다. 다른 버전에서는 어찌 동작될지 모릅니다.
여기서는 실제 플러그인의 설치 보다는 패치에 대해서 이야기 하겠습니다.
플러그인의 설치는 MTThreadedComments에 나온대로 따라만 하시면 그리 어렵진 않습니다. (단계는 조금 많습니다.)
패치의 코드입니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | diff -urN lib/MT/App/Comments.pm lib/MT/App/Comments.pm --- lib/MT/App/Comments.pm Fri Jul 2 05:29:58 2004 +++ lib/MT/App/Comments.pm Thu Jul 15 00:46:32 2004 @@ -420,6 +420,9 @@ $comment->email(remove_html($email)); $comment->url(MT::Util::is_valid_url($url, 'stringent')); $comment->text($q->param('text')); + $comment->subject($q->param('subject')); + $comment->parent_id($q->param('parent_id')); + return ($comment, $commenter); } @@ -462,6 +465,7 @@ (is_valid_email($comment->email)? (comment_email => $comment->email):()), comment_url => $comment->url, + comment_subject => $comment->subject, comment_text => $comment->text, unapproved => !$comment->visible(), ); @@ -820,6 +824,7 @@ my $ctx = MT::Template::Context->new; $ctx->stash('entry', $entry); + $ctx->stash('comment_parent_id', $q->param('parent_id')); $ctx->stash('commenter', $cmntr) if ($cmntr); $ctx->{current_timestamp} = $entry->created_on; my %cond = ( diff -urN lib/MT/Comment.pm lib/MT/Comment.pm --- lib/MT/Comment.pm Thu Apr 29 11:42:57 2004 +++ lib/MT/Comment.pm Thu Jul 15 00:44:05 2004 @@ -11,7 +11,7 @@ __PACKAGE__->install_properties({ columns => [ 'id', 'blog_id', 'entry_id', 'author', 'commenter_id', - 'visible', 'email', 'url', 'text', 'ip', + 'visible', 'email', 'url', 'text', 'ip', 'subject', 'parent_id', ], indexes => { ip => 1, @@ -21,6 +21,7 @@ email => 1, commenter_id => 1, visible => 1, + parent_id => 1, }, audit => 1, datasource => 'comment', |
굵게 표시된 것은 고쳐야 될 해당파일과, 각 행 번호 입니다.
첫번째것은 420행에서 +된 것만 추가 시켜주시면 됩니다.
참고로 두번째 hunk에서 -462,6 +465,7 인것은 원 코드에서는 462행이지만, 이미 첫번째 hunk에서 3줄을 추가 하였으므로 원코드의 462행의 465행으로 간다는 것을 나타냅니다.
일단 제가 패치를 실행 시켰을 때는 2번째 hunk만 에러가 나도 나머지는 다 적용되었습니다. 그럴경우 수작업으로 파일을 열고 (이미 나머지 패치가 되었으므로 462라인 대신) 465라인을 찾으셔서 +된 부분만 적용 시키시면 편합니다.
혹시나 수작업 하실분들은 참고하시라고 코드 올립니다.
쩝… 기왕 하는 김에 플러그인 설치에 대해서 적겠습니다.
원본은 MTThreadedComments를 참조하십시오.
1) 다운받은 MTThreadedComments.pl을 MT의 plugin폴더에 올립니다.
2) 패치를 하시던지 수동으로 하시던지 코드를 변경 시킵니다.
3) 만약에 SQL DB를 사용하시면 추가로 테이블을 만들어야 합니다.
(버클리DB일 경우 만드실 필요는 없습니다. 본인은 버클리 사용)
1 2 3 | ALTER TABLE mt_comment ADD COLUMN comment_subject text ALTER TABLE mt_comment ADD COLUMN comment_parent_id integer ALTER TABLE mt_comment ADD INDEX comment_parent_id |
4) 개별 엔트리 아카이브에서
1 2 3 4 5 | <mtrootcomments> <div class="comments-body"> < $MTInclude module="Nested Comments" $> </div> </mtrootcomments> |
코드를 사용해서 고칩니다.
5) 새 탬플릿 모듈을 만듭니다. 모듈의 이름은 Nested Comments입니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <mtifcommentsubject> <h3 class="title">< $MTCommentSubject$></h3> </mtifcommentsubject> < $MTCommentBody$> <span class="comments-post"><b>Posted by:</b> < $MTCommentAuthorLink spam_protect="1"$> on < $MTCommentDate$> <mtentryifcommentsopen> | <a href="<$MTCGIPath$>< $MTCommentScript$>?entry_id=< $MTEntryID$>; parent_id=< $MTCommentID$>">Reply to this</a> </mtentryifcommentsopen> </span> <mtcommentifchildren> <div class="comments-nest-box"> <mtcommentchildren> <div class="comments-body"> < $MTInclude module="Nested Comments" $> </div> </mtcommentchildren> </div> </mtcommentifchildren> |
6) Comment List Template를 변경하는데 이것은 사이트를 참조하시길 바랍니다.
중요한 것은 전송 폼에
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <input type="hidden" name="static" value="1" />
<input type="hidden" name="parent_id" value="<$MTCommentPreviewParentID$/>" />
<label for="subject">Subject:</label>
<mtcommentpreviewunlessparent>
<input id="subject" name="subject"
value="Re: <$MTEntryTitle encode_html="1" $/>" />
</mtcommentpreviewunlessparent>
<mtcommentpreviewifparent>
<mtcommentpreviewparent>
<input id="subject" name="subject"
value="<$MTCommentResponseSubject encode_html="1" $/>" />
</mtcommentpreviewparent>
</mtcommentpreviewifparent>
<br /><br /> |
위의 코드를 넣으라고 하는데 제일 위의 input코드 2개만 살려두셔도 됩니다.
7) 스타일시트에 중첩코멘드용의 항목을 추가합니다.
1 2 3 4 | .comments-nest-box { padding-left:15px; border-left:5px solid #AAA; } |
그다음은 사이트를 보시면 대충 알아서 되실 것이라 생각됩니다.
중요한것은 패치… 자동으로 안되면 수동으로 돌아가는 삽질정도는 하실 것이라 믿습니다.
의견 아직 없음 @ “[MT] MTThreadedComments for MT3.121”
의견을 남겨 주세요.
의견 남기기
(의견 등록중...)