Skip to content

Instantly share code, notes, and snippets.

@junnama
junnama / gist:11106932
Last active August 29, 2015 14:00
EntriesFromRSS/php/config.php
<?php
require_once( 'MTUtil.php' );
class EntriesFromRSS extends MTPlugin {
var $registry = array(
'config_settings' => array(
'RewriteArchiverRewriteTo' => array( 'default' => '/archiver.html' ),
),
'callbacks' => array(
'post_init' => 'rewrite_archiver',
),
@junnama
junnama / config.yaml
Created December 25, 2015 04:59
Add entry's title for edit entry screen.
callbacks:
MT::App::CMS::template_param.edit_entry: >
sub {
my ( $cb, $app, $param, $tmpl ) = @_;
if ( $param->{ id } ) {
my $title_tags = $tmpl->getElementsByName( 'page_title' );
for my $tag ( @$title_tags ) {
my $value = $tag->getAttribute( 'value' );
my $title = $param->{ title };
$title = MT::Util::encode_html( $title ) if $title;
@junnama
junnama / config.yaml
Created January 12, 2016 04:12
Not overwrite Main Index by Page.
callbacks:
cms_save_filter.page: >
sub {
my ( $cb, $app ) = @_;
if ( ( $app->param( 'category_ids' ) eq '-1' ) &&
( $app->param( 'basename' ) eq 'index' ) ) {
return $cb->error( $app->translate( 'File [_1] exists; could not overwrite.',
$app->translate( 'Main Index' ) ) );
}
1;
@junnama
junnama / Proxy.pm
Last active January 18, 2016 12:18
MT::Meta::Proxy - MySQL bulk inserts
sub save {
my $proxy = shift;
# perl funkiness ... keys %{ $proxy->{__objects} } will automatically clobber
# empty hash reference on that key!
return unless $proxy->{__objects};
my @cols = qw( type vchar vchar_idx vdatetime
vdatetime_idx vinteger vinteger_idx vfloat
vfloat_idx vblob vclob );
my $od = lc( MT->config( 'ObjectDriver' ) );
@junnama
junnama / config.yaml
Created January 21, 2016 07:42
Remove MTIgnore tag and HTML comments.
tags:
modifier:
remove_ignore: >
sub {
my ( $text, $arg ) = @_;
$text =~ s/<mt:{0,1}ignore>.*?<\/mt:{0,1}ignore>//gsi;
if ( $arg ne '1' ) {
my $comment = quotemeta( '<!--' );
my $comment_end = quotemeta( '-->' );
$text =~ s/$comment.*?$comment_end//sg;
@junnama
junnama / revert-to-the-previous
Created January 22, 2016 07:15
Revert to the previous templates.
#!/usr/bin/perl
package MT::Tool::RevertToThePrevious;
use strict;
use warnings;
use File::Spec;
use FindBin;
use lib map File::Spec->catdir( $FindBin::Bin, File::Spec->updir, $_ ),
qw/lib extlib/;
use base qw( MT::Tool );