Skip to content

Instantly share code, notes, and snippets.

View alfasado's full-sized avatar

Alfasado Inc. alfasado

View GitHub Profile
@alfasado
alfasado / mt-tool-speed-rebuild
Last active April 4, 2016 06:32
Alternative script of MT::Worker::Publish.
#!/usr/bin/perl
package MT::Tool::SpeedRebuild;
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 );
use MT::FileMgr;
use MT::Util qw( log_time );
@alfasado
alfasado / mt-tool-rebuild-file
Created February 18, 2016 04:00
Run MT::Worker::Publish specify the file path or template_id.
#!/usr/bin/perl
package MT::Tool::RebuildFile;
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 );
use MT::Util qw( log_time );
sub usage { '--file /path/to/file or or --template_id n' }
<?php
define( 'DataAPICacheDir', '/tmp/api_cache' );
define( 'DataAPIUploadCacheDir', '/tmp/upload' );
define( 'DataAPICacheTtl', 1200 );
define( 'DataAPICacheWithAuth', TRUE );
define( 'DataAPIURL', 'http://localhost/mt/mt-data-api.cgi' );
define( 'SendHTTPHeaderMethod', '' );
$cache_ttl = DataAPICacheTtl;
$cache_with_auth = DataAPICacheWithAuth;
$cache_dir = DataAPICacheDir;
@alfasado
alfasado / zipsearch.html
Created March 21, 2013 03:34
Find the address from the zip code using PowerCMS's CustomObject.
<?php
global $app;
$q = $app->param( 'q' );
$q = $app->db()->escape( $q );
$q = preg_replace( '/[^0-9]/', '', $q );
if ( $q ) {
$terms = array( 'name' => $q,
'class' => 'postalcode' );
$extra = array( 'limit' => 1 );
$postalcode = $app->load( 'CustomObject', $terms, $extra );
@alfasado
alfasado / PowerCMS config
Last active December 14, 2015 07:58
PowerCMS config for demonstration.
Trigger1:
params:
- __mode=view
- _type=entrygroup
- saved=1
template_id: 93
Trigger2:
params:
- __mode=view
- _type=campaigngroup
<mt:Asset id="1">
<mt:AssetThumbnailFile width="32" square="1" convert2base64="1" setvar="src">
<mt:Var name="src" get_content_length="1" setvar="image_size">
<mt:If name="image_size" lt="32768">
<img src="data:<mt:AssetMimeType>;base64,<mt:Var name="src">" width="32" height="32" alt="<mt:AssetLabel escape="html">" />
<mt:else>
<img src="<mt:AssetThumbnailURL>" width="32" height="32" alt="<mt:AssetLabel escape="html">" />
</mt:If>
</mt:Asset>
@alfasado
alfasado / mt-rebuild-queue
Created February 1, 2013 00:27
Movable Type's Publish Queue
use MT;
my $mt = MT->new;
require MT::TheSchwartz::FuncMap;
require MT::TheSchwartz::Job;
require MT::FileInfo;
require MT::WeblogPublisher;
my $funcmap = MT::TheSchwartz::FuncMap->load( { funcname => 'MT::Worker::Publish' } );
return unless $funcmap;
my @jobs = MT::TheSchwartz::Job->load( { funcid => $funcmap->funcid, },
{ 'sort' => 'priority',
@alfasado
alfasado / mt-tools-template.pl
Created November 29, 2012 09:26
Template for MT::Tool::Foo
#!/usr/bin/perl
package MT::Tool::Foo;
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 );
sub usage { '--debug 1' }
@alfasado
alfasado / mt-plugin-http-https-transfer.php
Created April 2, 2014 07:31
mt/plugins/HttpHttpsTransfer/php/config.php
<?php
class HttpHttpsTransfer extends MTPlugin {
var $registry = array(
'config_settings' => array(
'HttpHttpsTransferPathBegin' => array( 'default' => '/entry_form/' ),
),
'callbacks' => array(
'post_init' => 'post_init',
),
);
@alfasado
alfasado / mt-plugin-rewritearchiver.php
Last active August 29, 2015 13:57
mt/plugin/RewriteArchiver/php/config.php
<?php
class RewriteArchiver extends MTPlugin {
var $registry = array(
'config_settings' => array(
'RewriteArchiverRewriteTo' => array( 'default' => '/archiver.html' ),
),
'callbacks' => array(
'post_init' => 'rewrite_archiver',
),
);