« Yoshiori が彼女募集中です | ホーム | VimperatorでコピーやペーストとかOSのショートカットが効かない »

2008年7月 1日

Movable TypeのHomeをAutoPagerizeに対応させる@Vicuna

Movable TypeのHomeをAutoPagerizeに対応させる@Vicuna

エントリを見返すのに、AutoPagerizeが動作しないと不便なので対応した。

  1. PageButeプラグインでHomeを分割
  2. AutoPagerize用のmicroformatsを仕込む

ページ分割にPHPを使用したくなかったので、静的なHTMLを出力してくれるPageButeプラグインを使用した。
あと「次のページ」へのリンクをA要素丸ごと出力するタグしか無いので、URLだけを出力するタグを追加した(そのままだとAutoPagerize用のrel属性を追加できない)。

この辺をクリアできる分割プラグインがあればそっち使った方が楽そう。

PageButeプラグインでHomeを分割

PageButeプラグインをインストール、PageBute.plとテンプレートを編集する。

MTPageNextがMT標準のテンプレートタグと被る

PageBute.plを書き替える。わかりやすく全てのタグ(MTPage〜)をMTPageBute〜とした。

MT::Template::Context->add_container_tag(PageButeContents => ¥&_page_contents);
MT::Template::Context->add_container_tag(IfPageButeNext => ¥&_if_page_next);
MT::Template::Context->add_container_tag(IfPageButeBefore => ¥&_if_page_before);
MT::Template::Context->add_tag(PageButeNext => ¥&_page_next);
MT::Template::Context->add_tag(PageButeBefore => ¥&_page_before);
MT::Template::Context->add_tag(PageButeNextURL => ¥&_page_next_url);
MT::Template::Context->add_tag(PageButeBeforeURL => ¥&_page_before_url);
MT::Template::Context->add_tag(PageButeSeparator => ¥&_separator);
MT::Template::Context->add_tag(PageButeLists => ¥&_page_lists);

そのままだとリンクにrel属性を追加できないので、MTPageButeNextURLを作る

プラグインに用意されているMTPageButeNextだと、A要素まで含んだ <a href="url">name</a> という形式で出力してしまうので、AutoPagerize用のrel属性を仕込めない。
URLのみを出力するMTPageButeNextURLを追加する。(追加箇所が散発的でめんどいのでDiff。+のとこを追加する)

$ diff -c Downloads/PageBute.pl Desktop/PageBute.pl
*** Downloads/PageBute.pl   2006-07-11 04:06:00.000000000 +0900
--- Desktop/PageBute.pl 2008-07-01 16:34:50.000000000 +0900
***************
*** 17,22 ****
--- 17,24 ----
  my %garbage = (
        NextLink => '<!-- NextLink for PageBute -->',
        BeforeLink => '<!-- BeforeLink for PageBute -->',
+       NextURL => '<!-- NextURL for PageBute -->',
+       BeforeURL => '<!-- BeforeURL for PageBute -->',
        Separator => '<!-- Separator for PageBute -->',
        PageLists => '<!-- PageLists for PageBute -->',
        Contents => '<!-- Contents for PageBute -->',
***************
*** 80,85 ****
--- 84,97 ----
    $garbage{BeforeLink};
  }

+ sub _page_next_url {
+   $garbage{NextURL};
+ }
+ 
+ sub _page_before_url {
+   $garbage{BeforeURL};
+ }
+ 
  sub _separator {
    $garbage{Separator};
  }
***************
*** 164,169 ****
--- 176,183 ----
            my $lists = &_create_lists($page_count, $page_limit);
            my $before = $lists->{before} ? &_create_link($page_count - 1, $site_url . $filename, $file_ext, $pb->{before_delim}) : '';
            my $next = $lists->{next} ? &_create_link($page_count + 1, $site_url . $filename, $file_ext, $pb->{next_delim}) : '';
+           my $before_url = $lists->{before} ? &_create_url($page_count - 1, $site_url . $filename, $file_ext) : '';
+           my $next_url = $lists->{next} ? &_create_url($page_count + 1, $site_url . $filename, $file_ext) : '';
            my $page_lists = '';
            for (my $i = $lists->{min_page}; $i <= $lists->{max_page}; $i++) {
                $page_lists .= $i == $lists->{min_page} ? '' : $delim;
***************
*** 186,191 ****
--- 200,221 ----
                $output =~ s/$garbage{IfPageNext}.*$garbage{IfPageNext}//g;
            }

+           #replace before url
+           if ($before_url) {
+               $output =~ s/$garbage{IfPageBefore}//g;
+               $output =~ s/$garbage{BeforeURL}/$before_url/g;
+           } else {
+               $output =~ s/$garbage{IfPageBefore}.*$garbage{IfPageBefore}//g;
+           }
+ 
+           #replace next url
+           if ($next_url) {
+               $output =~ s/$garbage{IfPageNext}//g;
+               $output =~ s/$garbage{NextURL}/$next_url/g;
+           } else {
+               $output =~ s/$garbage{IfPageNext}.*$garbage{IfPageNext}//g;
+           }
+ 
            #replace page lists
            $output =~ s/$garbage{PageLists}/$page_lists/g;

***************
*** 247,250 ****
--- 277,288 ----
    $url =~ s|\\|\/|g;
    return "<a href=\"${url}\">$name</a>";
  }
+ 
+ sub _create_url {
+   my ($page, $file, $extension) = @_;
+   my $url = $file . ( $page == 1 ? '' : "_${page}" ) . ".${extension}";
+   #for windows
+   $url =~ s|\\|\/|g;
+   return "${url}";
+ }
  1;

メインページ テンプレートを編集

<MTEntries>
    <$MTEntryTrackbackData$>
    <$MTInclude module="ブログ記事の概要"$>
    <$MTPageSeparator$>
</MTEntries>

<$MTSetVar name="tmpPaginateValue" value="10"$>
<MTPageContents count="$tmpPaginateValue">
    <MTEntries lastn="0">
        <$MTEntryTrackbackData$>
        <$MTInclude module="ブログ記事の概要"$>
        <$MTPageSeparator$>
    </MTEntries>
</MTPageContents>
<$MTInclude module="ページ番号"$>

ページ番号 テンプレートモジュールを新規作成

<$MTBlogEntryCount setvar="tmpBlogEntriesCount"$>
<MTIf name="tmpBlogEntriesCount" gt="$tmpPaginateValue">
    <ol id="paginate">
        <MTIfPageBefore><li class="prev"><a href="<$MTPageBeforeURL$>" rel="prev">&laquo;&nbsp;前の<$MTGetVar name="tmpPaginateValue"$>件</a></li></MTIfPageBefore>
        <li class="firstChild"><$MTPageLists delim="</li><li>"$></li>
        <MTIfPageAfter><li class="next"><a href="<$MTPageAfterURL$>" rel="next">次の<$MTGetVar name="tmpPaginateValue"$>件&nbsp;&raquo;</a></li></MTIfPageAfter>
    </ol>
</MTIf>

AutoPagerize用のmicroformatsを仕込む

次のページのリンクを示す rel="next" はすでに仕込んであるので、AutoPagerizeで継ぎ足す対象を示す class="autopagerize_page_element" のみ仕込めばOK。(autopagerize_insert_before は無くてもいいみたい。ない場合、最後のautopagerizepageelement`の後ろに入る)

ブログ記事の概要 テンプレートモジュールを編集

<div class="section entr" id="entry<$MTEntryID pad="1"$>">
    <$MTInclude module="エントリー詳細内部"$>
    <$MTInclude module="リアクションリンク"$>
</div>

<div class="section entry autopagerize_page_element" id="entry<$MTEntryID pad="1"$>">
    <$MTInclude module="エントリー詳細内部"$>
    <$MTInclude module="リアクションリンク"$>
</div>

インデックステンプレートを再構築して終了。
ページ番号のスタイルを指定してないけど面倒になったのでまた今度。

トラックバック(1)

トラックバックURL: http://retlet.net/cgi-bin/mt5/mt-tb.cgi/42

"[...]Movable TypeのHomeをAutoPagerizeに対応させる@Vicuna - retlet.net[...]" 続きを読む

コメント(135)

Great job with the blog, I’ve been stopping by here for quite some time, just wanted to let you know!

I every time used to study paragraph in news papers but now as I am a user of web therefore from now I am using net for posts, thanks to web.

Hey rather cool internet web-site!! Man .. Beautiful .. Wonderful .. I’ll bookmark your internet site and take the feeds also’I'm happy to uncover numerous beneficial details correct here inside the submit, we will want develop far more strategies in this regard, thanks for sharing. . . . . .

Thanks for the post, is there any way I can get an alert email when you publish a fresh post?

It's the best time to make some plans for the future and it is time to be happy. I have read this post and if I could I want to suggest you few interesting things or advice. Perhaps you could write next articles referring to this article. I want to read more things about it!

hey there, your website is cheap. We do thank you for function

I discovered your weblog site on google and check a number of of your early posts. Continue to maintain up the excellent operate. I simply extra up your RSS feed to my MSN Information Reader. In search of ahead to reading extra from you afterward!…

My wife and i ended up being quite fulfilled Albert managed to finish off his basic research through the entire ideas he made from your very own site. It's not at all simplistic to just possibly be giving freely guidelines which usually most people could have been making money from. And we all discover we need the writer to appreciate for this. The main explanations you made, the straightforward website navigation, the friendships you will give support to instill - it's got most powerful, and it is facilitating our son and our family believe that the theme is enjoyable, and that is extraordinarily pressing. Many thanks for all!

I like the efforts you've got put in this, thanks for all the fantastic blog posts.

Yes you are correct, YouTube is best video distribution web site, because YouTube is a lightly no much streaming time rather than other web pages.

I wish more blog owners took the time & care of which you definitely take to create such high top quality content. Well done.

Merely wanna input on few common issues, The site style is perfect, the subject material is rattling superb : D.

Although, regardless how positive you really are in treating an actual platform, at some point you'll find an incident wherever you need to want to do some people regular supervision; and in addition dependant on your real age and in addition wellbeing, and so the body-weight using the caravan it is actually a completely hard do physical exercise. caravan touch up paint

Continually, when men and women manage employment seeks they can deal with employment paying about my subject also known as job opportunities in my specific geographic location. There is absolutely nothing other in that. In addition, across frustrating economical occasions when girls and men is required to be modest additional potent by acquiring a task search engine. Inside the event you look at it, the important reason that people young and old want to know a activity associated with neighborhood is about efficiency. Whatever simple to have emplyment in the vicinity of home hold the way it drops the hassles, duress, and / or expense on carrying. One more reason why that men attempt occupations hiring into my field is actually because seriously is invaluable staying near home within the event that numerous vital internal send out appears. Nevertheless this is to speak about surely nothing of their advantages engaging in case you've school children.

I always emailed this web site post page to all my associates, because if like to read it after that my contacts will too.

When I originally commented I clicked the -Notify me when new feedback are added- checkbox and now each time a remark is added I get 4 emails with the same comment. Is there any way you can take away me from that service? Thanks!

Hi there mates, is there any other good web site related to JavaScript posts, while this one is pleasant for PHP programming.

Your web page does not display correctly on my iphone - you might wanna try and fix that

You’ve produced various nice points there. I did specific search terms around the matter and found mainly individuals will believe your site

Nice read, I just passed this onto a friend who was doing some research on that. And he actually bought me lunch since I found it for him smile Therefore let me rephrase that: Thank you for lunch!

An attention-grabbing dialogue is value comment. I’m confident that its far better to write on this subject, towards the often be a taboo subject but typically persons are not sufficient to speak on such topics. To another location. Cheers

Quality articles or reviews is the secret to attract the viewers to pay a quick visit the website, that’s what this site is providing.

I think other web-site proprietors should take this website as an model, very clean and magnificent user genial style and design, let alone the content. You're an expert in this topic!

When someone writes an post he/she maintains the thought of a user in his/her mind that how a user can be aware of it. So that’s why this article is outstdanding. Thanks!

I really like your wp theme, wherever would you obtain it from?

Hi! I know this is somewhat off topic but I was wondering which blog platform are you using for this website? I'm getting tired of Wordpress because I've had problems with hackers and I'm looking at alternatives for another platform. I would be fantastic if you could point me in the direction of a good platform.

Today I was so tired, and now this time I have got some relax by seeing this humorous YouTube video, thanks, keep it up.

I have realized that online degree is getting common because attaining your college degree online has become a popular choice for many people. A large number of people have not had a possible opportunity to attend a normal college or university nevertheless seek the increased earning possibilities and career advancement that a Bachelors Degree affords. Still other individuals might have a college degree in one discipline but would want to pursue another thing they now develop an interest in.

Magnificent web site. A lot of useful info here. I am sending it to some pals ans also sharing in delicious. And naturally, thanks to your sweat!

Cool layout! How did you get it?

you've got got a fantastic weblog here! do you want to make some invite posts in my weblog?

I likewise conceive thus, perfectly written post! .

Pretty nice post. I just stumbled upon your blog and wanted to say that I've really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon.

I've observed that more than the course of producing a relationship with real estate proprietors, you’ll be able to get them to understand that, in every real estate financial transaction, a payment is paid. Within the end, FSBO sellers will not “save” the commission rate. Rather, they fight to earn the commission by just doing a very good agent’s work. In accomplishing this, they devote their cash and also time to execute, as best they might, the responsibilities of an broker. Those tasks include revealing the home by way of marketing, introducing the home to prospective buyers, building a sense of buyer emergency to be able to make prompt an offer, organizing home inspections, dealing with qualification check ups with the loan company, supervising repairs, and facilitating the closing.

It’s hard to find knowledgeable people on this topic, but you sound like you know what you’re talking about! Thanks

Attempting to secure a mortgage on huge purchases may be hard for some, but I believe what was covered in this article is universal in that it may support any person. Great facts right here, thank you.

Thanks for generating the honest attempt to speak about this. I believe very robust approximately it and want to read a lot more. If it is OK, as you gain a lot more in depth wisdom, would you thoughts adding extra articles similar to this one with additional information? It may well be very beneficial and beneficial for me and my friends.

quite good post, i surely enjoy this incredible internet site, persist in it

I truly prize your piece of work, Fantastic post.

I've been absent for a while, but now I remember why I used to love this site. Thanks , I will try and check back more frequently. How frequently you update your web site?

It can be tough to write about this topic. I think you did an exceptional job though! Thanks for this!

I believe 1 of your advertisements triggered my internet browser to resize, you might want to put that on your blacklist.

WONDERFUL Post.thanks for share..extra wait .. …

Well I truly enjoyed studying it. This information procured by you is very practical for good planning.

Wow! This could be one specific of the most valuable blogs We’ve ever arrive across on this topic. In fact Fantastic. I'm also an expert in this subject so I can realize your hard work.

Hi there! Nice post! Please do inform us when we could see a follow up!

The electronic cigarette makes use of a battery and a small heating aspect the vaporize the e-liquid. This vapor can then be inhaled and exhaled

Thank you for sharing with us, I conceive this site actually stands out : D.

Regards for this grand post, I am glad I observed this internet site on yahoo.

I admire your work , regards for all of the beneficial blog posts.