Skip to content

Instantly share code, notes, and snippets.

View naoaki011's full-sized avatar

naoaki onozaki naoaki011

  • Alfasado Inc.
  • Souka Saitama,Japan
View GitHub Profile
@naoaki011
naoaki011 / gist:972172
Created May 14, 2011 12:27 — forked from aklaswad/gist:844870
search with meta column
#!/usr/bin/perl
use strict;
use warnings;
use lib qw( lib extlib );
use MT;
MT->new;
use Data::ObjectDriver;
$Data::ObjectDriver::DEBUG = 1;
MT->model('blog')->load(
<MTUnless regex_replace="/\t/g","" strip_linefeeds="1">
<mt:if tag="AssetType" eq="image">
<mt:setvarblock name="href"><mt:if name="image_width" gt="640"><mt:AssetThumbnailURL width="640"><mt:else><mt:var name="a_href"></mt:if></mt:setvarblock>
<div class="article-image" style="text-align: left; width: <mt:var name="img_width">px;<mt:If name="align" eq="left"> float: left; margin-right: 10px;</mt:If><mt:If name="align" eq="right"> float: right; margin-left: 10px;</mt:If><mt:If name="align" eq="center"> margin: 0px auto;</mt:If>">
<mt:var name="form_tag">
<a rel="lightbox" href="<mt:var name="href">" title="<mt:if name="caption"><mt:var name="caption" escape="html"> </mt:if>(click to enlarge)"><mt:var name="img_tag"></a>
<mt:if name="description"><p class="credit"><mt:var name="description"></p></mt:if>
<mt:if var="caption" ne=""><p class="caption"><mt:var name="caption"></p></mt:if>
<mt:if name="enclose"></form></mt:if>
</div>
@naoaki011
naoaki011 / asset_insertion.mtml
Created May 15, 2011 17:17
Other Asset Insertion Template module
<div class="cntBodyPhoto<mt:Unless name="align" eq="none"> <$mt:Var name="align"$></mt:Unless>" style="width:<$mt:Var name="img_width" op="+" value="4"$>px">
<div class="img"><img src="<$mt:Var name="img_src"$>" alt="<mt:if name="img_alt"><$mt:var name="img_alt"$><mt:else><mt:If tag="AssetDescription" trim="1" strip_linefeeds="1"><$MTAssetDescription$><mt:Else><$mt:AssetLabel$></mt:If></mt:if>" width="<$mt:Var name="img_width"$>" height="<$mt:Var name="img_height"$>" /></div><mt:if name="caption" trim="1" strip_linefeeds="1">
<div class="caption"><$mt:Var name="caption" nl2br="xhtml"$></div>
</mt:If></div>
@naoaki011
naoaki011 / asset_insertion.mtml
Created May 15, 2011 17:27
Asset Insertion Template module width Create Thumbnail
<mt:unless regex_replace="/\t/g","" strip_linefeeds="1">
<mt:SetVar name="max_width" value="800" />
<mt:SetVar name="max_thumbnail_width" value="450" />
<mt:SetVarBlock name="alt_text">
<mt:if name="caption">
<$mt:var name="caption" remove_html="1" strip_linefeeds="1" trim="1"$>
<mt:else>
<$mt:AssetDescription remove_html="1" strip_linefeeds="1" trim="1"$>
</mt:if>
</mt:SetVarBlock>
@naoaki011
naoaki011 / gist:1008006
Created June 4, 2011 15:54
MakeLinkの変数
MakeLink 11.03:
%text%
ページのタイトル。リンクから右クリックした時は、リンク文字列。テキスト選択時はそのテキスト
%url%
ページのURL。リンクから右クリックした時は、リンク先のURL
以下は未確認:
%title%
metaタグのdescriptionの値。リンクから右クリックした時は、リンクのtitle要素。テキスト選択時はページのタイトル
%imgurl%
画像を右クリックした時のその画像のURL
@naoaki011
naoaki011 / gist:1008017
Created June 4, 2011 16:04
Make Link Help - Defining Link Types
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Make Link Help - Defining Link Types</title>
<link rel="stylesheet" href="chrome://makelink/content/help/help.css"/>
</head>
@naoaki011
naoaki011 / gist:1015745
Created June 8, 2011 23:53
正規表現:パラメーターにマッチ
like="(^|,)2,3(,|$)"
<MTVar name="total_entries" op="/" value="10" setvar="totalpages" />
<MTIf name="total_entries" op="mod" value="10"><MTVar name="totalpages" regex_replace="/.\d$/","" setvar="totalpages" /><MTSetVar name="totalpages" op="++" /></MTIf>
<MTIf name="totalpages" gt="1">
<MTPager>
<MTIfPagerHeader>
<MTPagerCurrent setvar="currentpage" />
<MTVar name="currentpage" op="-" value="3" setvar="cutoffpagemin" />
<MTVar name="currentpage" op="+" value="3" setvar="cutoffpagemax" />
@naoaki011
naoaki011 / gist:1099387
Created July 22, 2011 12:50
なぜ、再構築しない・・・
if ($entry) {
my $releasedate = 'field.dolreleasedate';
if ($entry->authored_on < $entry->$releasedate) {
$entry->authored_on($entry->$releasedate);
$entry->save
or
die $app->trans_error( "Error saving : [_1]", $entry->errstr );
MT::Util::start_background_task(
sub {
$app->rebuild_entry(
@naoaki011
naoaki011 / gist:1102699
Created July 24, 2011 14:55
Callcack object MT
=head1 Object Callbacks
The Object callbacks are those that are tied to I<MT::Object> and its
descendants. This includes classes such as I<MT::Entry>, I<MT::Blog>, etc.
=over 4
=item * <package>::pre_save
callback($cb, $obj, $original)