MT覚え書き:Amazon AWS アマゾンウェブサービス

■このエントリーはMTを使っていた頃の覚え書きです■

Amazonウェブサービス(AWS) のデベロッパー・トークンを入手。
Amazon Webサービス

pluginsのディレクトリにaws.plを入れる。
mt-aws.zipsimple amazon log

そして、MTディレクトリextlib/XML/にSimple.pmを入れる。
XML::Simple

<MTAws dev_token="developer-token" search="KeywordSearch"
query="Movable Type標準ハンドブック Movable Typeで今すぐできるウェブログ入門" mode="books-jp">
<a href="<$MTAwsurl$>">
<img src="<$MTAwsImageUrlMedium$>">
<$MTAwsProductName$><br />
<$MTAwsAuthors$><br />
<$MTAwsListPrice$><br />
<$MTAwsReleaseDate$></a><br />
</MTAws>

場合によっては、
search="KeywordSearch"を search="AsinSearch" query="ASIN番号"
に。
ASINは商品ページのどっかに書いてある。

テンプレートに書き込む場合は以上でOK(かな?)
エントリーとして使う場合は、

pluginsのディレクトリにprocess_tags.plを入れる。
process_tags plugin

そして、
playground | blog
さんとこを参照。

aws.plの148〜155行目を変更。

#$res .= sprintf($out);
$res .= $out;
if ($q{lastn}>0) { $q{lastn}--; }
last if ($q{lastn} == 0);
}
#if ($charset ne 'utf8') { $res = Jcode->new($res, 'utf8')->$charset(); }
$res = Jcode->new($res, 'utf8')->$charset();
#sprintf($res);
return $res;
}

93行目の http://xml.amazon.com/ を http://xml.amazon.co.jp/ に。
16行目に自分のデベロッパートークンID、17行目にアソシエイトIDを入力、
上書き保存して、aws.pl を plugins ディレクトリにコピー。
※mt-awsに同梱されているreadme.txtの中のサンプルの dev-t は dev_tokenに変更。

次に、Process Tags pluginをダウンロードし解凍、その中のprocesstags.plの14行目、
use bradchoate::postproc; を #use bradchoate::postproc; に変更(コメントアウトする)
エントリーを表示させるページのテンプレートすべての
<$MTEntryBody$> を <$MTEntryBody process_tags="1"$>
に変更。(これを忘れると失敗)

で、MTディレクトリのtmplの中のcmsの中のheader.tmpl
のhead内に、

MTディレクトリにある、mt.jsに、
function insertAmazon () {
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
document.selection.createRange().text = '<MTAws dev_token="your_token" associate_id="your_id" search="KeywordSearch" query="' + str + '"><a href="<$MTAwsurl$>" target="_blank"><img src="<$MTAwsImageUrlSmall$>" align="left" hspace="10" border="0" /><$MTAwsProductName$></a> <br><$MTAwsAuthors$><br><$MTAwsListPrice$><br clear="all"></MTAws>';
}

ここも、場合によっては、
search="KeywordSearch"を search="AsinSearch"
に。

ただし、ウチの場合は、
function insertAmazon () {
if (!document.selection) return;
var str = document.selection.createRange().text;
if (!str) return;
document.selection.createRange().text = '<MTAws dev_token="デベロッパートークン(サブスクリプションID)" associate_id="自分のアソシエイトID" search="AsinSearch" query="' + str + '"><a href="<$MTAwsurl$>" target="_blank"><img src="<$MTAwsImageUrlMedium$>" border="0" /><br><b><$MTAwsProductName$></b></a> <$MTAwsAuthors$><br><b><$MTAwsListPrice$></b></MTAws>';
}

で、MTディレクトリのtmplの中のcmsの中のedit_entry.tmpl
の、”TMPL_IF NAME=CAN_UPLOAD”を検索機能で探し出し、
<TMPL_IF NAME=CAN_UPLOAD>
if (canFormat) {
with (document) {
write('<a title="<MT_TRANS phrase="Upload File">" href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=start_upload&amp;blog_id=<TMPL_VAR NAME=BLOG_ID>" onclick="window.open(this.href, 'upload', 'width=400,height=450,resizable=yes'); return false"><img src="<TMPL_VAR NAME=STATIC_URI>images/html-file.gif" alt="<MT_TRANS phrase="Upload File">" width="22" height="16" /></a>');
}
}
</TMPL_IF>

の、下部の、
</TMPL_IF>

の上に、
document.write('<td width="40"><a href="javascript:insertAmazon()"><img src="<TMPL_VAR NAME=STATIC_URI>images/amazon-button.gif" alt="amazon" width="40" height="18" border="0"></a></td>');

を追加。

で、指示通り、
アマゾンボタン
をダウンロードして、サーバの「images」ディレクトリ(フォルダ)にアップして完了。

Comment

Post a comment
















管理者にだけコメントをわたす。

 

Trackback

Trackback Pings

※この記事に関係の無いトラックバックは削除させていただきます。
FC2ブログユーザーは”こちら”をクリック。

このエントリーのURL
 

copyright © 武州屋 all rights reserved. Powered by FC2ブログ.ホームページ アフィリエイト レンタルサーバー FC2ブログ