*Tag wrapper

 <a>   <b>   <em>   <i>   <strong>   <blockquote> 




MobavleTypeでの、設置手順

まず「個別エントリーアーカイブ」のヘッダ内に、
以下のJavaScriptを挿入。


<script type="text/javascript">
<!--
function linkage(tag){
var url = prompt("please input url,","http://");
if((url != "") && (url != null)){
var ans = url.match(/(http|ftp):\/\/[a-zA-Z0-9_\.\~\-\/\?\&\+\=\:\;\@\%\#]+/);

if((ans != "") && (ans != null)){
var txt = prompt("& text for a link.","");
var obj = document.getElementById("text");

if((txt != "") && (txt != null)){
obj.value += '<' + tag + ' href="' + url + '" target="_blank">' + txt + '</' + tag + '>';
obj.focus();
obj.value += "";
document.getElementById("a").checked = false;
}else if(txt == ""){
obj.value += '<' + tag + ' href="' + url + '" target="_blank">' + url + '</' + tag + '>';
obj.focus();
obj.value += "";
document.getElementById("a").checked = false;
}else if(txt == null){
obj.focus();
obj.value += "";
document.getElementById("a").checked = false;
}else{
document.getElementById("a").checked = false;
alert("incorrect text!");
}

}else{
document.getElementById("a").checked = false;
alert("incorrect url!");
}

}else if(url == ""){
document.getElementById("a").checked = false;
alert("incorrect url!");
}else if(url == null){
document.getElementById("a").checked = false;
}else{
document.getElementById("a").checked = false;
alert("incorrect url!");
}

}

function wrapper(tag){
var txt = prompt("please input text.","");

if((txt != "") && (txt != null)){
var obj = document.getElementById("text");
obj.focus();
obj.value += "";
obj.value += '<' + tag + '>' + txt + '</' + tag + '>';
document.getElementById(tag).checked = false;
}else if(txt == ""){
document.getElementById(tag).checked = false;
alert("incorrect text!");
}else if(txt == null){
document.getElementById(tag).checked = false;
}else{
document.getElementById(tag).checked = false;
alert("incorrect text!");
}

}

function popup(tag,filename,newwin){
var W = 300;
var H = 300;
var L = Math.round((screen.width-W)/2);
var T = Math.round((screen.height-H)/2);
var F = filename;
var S = newwin;
var menu = "";
menu += '"' + F + '",';
menu += '"' + S + '",';
menu += '"toolbar=no,';
menu += 'location=no,';
menu += 'directories=no,';
menu += 'status=no,';
menu += 'menubar=no,';
menu += 'scrollbars=no,';
menu += 'resizable=yes,';
menu += 'left=' + L + ',';
menu += 'top=' + T + ',';
menu += 'width=' + W + ',';
menu += 'height=' + H + '"';
eval(S + "= window.open(" + menu + ")");
}

function erase(){
var txt = "";
document.getElementById("text").value = txt;
}

//-->
</script>


同じく、「個別エントリーアーカイブ」に、各種ラジオボタンを配置。
1行目より、"a","b","em","i","strong","blockquote"の順。


<form name="comments_form">

中略・・・

<input type="radio" name="supple" value="a" id="a" onClick="linkage('a')"> &lt;a&gt; 
<input type="radio" name="supple" value="b" id="b" onClick="wrapper('b')"> &lt;b&gt; 
<input type="radio" name="supple" value="em" id="em" onClick="wrapper('em')"> &lt;em&gt; 
<input type="radio" name="supple" value="i" id="i" onClick="wrapper('i')"> &lt;i&gt; 
<input type="radio" name="supple" value="strong" id="strong" onClick="wrapper('strong')"> &lt;strong&gt; 
<input type="radio" name="supple" value="blockquote" id="blockquote" onClick="popup('blockquote','blockquote.htm','blockquote')"> &lt;blockquote&gt; 

中略・・・

</form>


また、"blockquote.htm"というファイルを、新規作成。任意のディレクトリに保存。
その絶対パスを、下記のハイライト部分に置き換え(個別エントリーアーカイブ)。


"blockquote"のラジオボタン部分より、
<input type="radio" name="supple" value="blockquote" id="blockquote" onClick="popup('blockquote','blockquote.htm','blockquote')"> blockquote.htm絶対パス

なお、"blockquote.htm"のソースは、以下の通り。


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>blockquote</title>
<script type="text/javascript">
<!--
function exe(tag){
var txt = document.getElementById("text").value;
if(txt != ""){
var R;
var others = false;
var num1 = txt.indexOf("\r\n");
(num1 != -1)? R = "\r\n" : others = true;

if(others){
var num2 = txt.indexOf("\r");
(num2 != -1)? R = "\r" : R = "\n";
}else{
R = "";
}

//var Q = R + ">";
//var lines = txt.split(R);
//txt = lines.join(Q);
var obj = opener.document.getElementById("text");
obj.focus();
obj.value += "";
obj.value += R + '<' + tag + '>' + R + txt + R + '</' + tag + '>' + R;
opener.document.getElementById(tag).checked = false;
window.close();
}else{
alert("incorrect text!");
}
}

function start(){
document.getElementById("text").focus();
}

function end(tag){
opener.document.getElementById(tag).checked = false;
}

function can(tag){
opener.document.getElementById(tag).checked = false;
window.close();
}

//-->
</script>

<style type="text/css">
<!--
a {
	text-decoration: underline;
	}

a:link {
	color: #CC99FF;
	}

a:visited {
	color: #CCCCFF;
	}

a:active {
	color: #CCCCFF;
	}

a:hover {
	color: #CCCCFF;
	}

.main {
	color: #333333;
	font-family: Arial, Verdana, sans-serif;
	font-size: 12px;
	text-align: left;
	line-height: 150%;
	margin-top: 15px;
	margin-right: 15px;
	margin-bottom: 15px;
	margin-left: 15px;
	}
-->
</style>

</head>

<body class="main" onBlur="window.focus()" onLoad="start()" onUnload="end('blockquote')">

*Excerpt from ...

<form>
<textarea id="text" rows=12 cols=24></textarea><br>
<input type="button" value="Cancel" onClick="can('blockquote')">
<input type="button" value="Submit" onClick="exe('blockquote')">
</form>

</body>
</html>


"Util.pm"ファイルの変更。mt → lib → MT → Util.pm
ハイライトの部分("blockquote")を削除。約1500行中の250行目付近...


sub html_text_transform {
    my $str = shift;
    $str ||= '';
    my @paras = split /\r?\n\r?\n/, $str;
    for my $p (@paras) {
        if ($p !~ m@^</?(?:h1|h2|h3|h4|h5|h6|table|ol|dl|ul|menu|dir|p|pre|center|form|fieldset|select|blockquote|address|div|hr)@) {
            $p =~ s!\r?\n!<br />\n!g;
            $p = "<p>$p</p>";
        }
    }
    join "\n\n", @paras;
}


「コメントでのHTMLの利用を許可する」に、チェック。