Changeset 200

Show
Ignore:
Timestamp:
02/11/07 10:12:59 (3 years ago)
Author:
gboggs
Message:

pluginbuilder.pl:
- Simplified syntax. Removed cargo-cult artifact. Added standard plugin registration metadata.
PluginBuilder/App.pm & pluginbuilder.tmpl:
- Pass validated plugin metadata back and forth between the templates.

Location:
trunk/PluginBuilder/plugins/PluginBuilder
Files:
3 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/PluginBuilder/plugins/PluginBuilder/lib/PluginBuilder/App.pm

    r199 r200  
    11# $Id$ 
    2  
    32package PluginBuilder::App; 
    4  
    53use strict; 
    64use warnings; 
    7  
    85our $VERSION = '0.00_4'; 
    9  
    106use MT::App; 
    117@PluginBuilder::App::ISA = 'MT::App'; 
     
    1511    $app->SUPER::init(@_) or return; 
    1612    $app->add_methods( show_config => \&show_config ); 
     13    $app->add_methods( set_metadata => \&set_metadata ); 
    1714    $app->{default_mode} = 'show_config'; 
    1815    $app->{requires_login} = 1; 
    19  
    2016    return $app; 
    2117} 
     
    2420    my $app = shift; 
    2521    my $param = { 
    26         version => $VERSION, 
    27         user => $app->user, 
    28         blog => $app->blog, 
     22        pb_author_link => 'http://', 
     23        pb_author_name => $app->user->nickname || $app->user->name || $app->user->email, 
     24        pb_description => 'Frobnicate Whirlygigs', 
     25        pb_doc_link    => 'http://', 
     26        pb_plugin_link => 'http://', 
     27        pb_plugin_name => 'Foo', 
     28        pb_plugin_version => '0.00_0', 
     29        plugin_version => $VERSION, 
     30    }; 
     31    $app->build_page( 'pluginbuilder.tmpl', $param ); 
     32} 
     33 
     34sub set_metadata { 
     35    my $app = shift; 
     36    my $q = $app->param; 
     37    my $param = { 
     38        have_metadata => 1, 
     39        pb_author_link => $q->param('pb_author_link'), 
     40        pb_author_name => $q->param('pb_author_name'), 
     41        pb_description => $q->param('pb_description'), 
     42        pb_doc_link => $q->param('pb_doc_link'), 
     43        pb_plugin_link => $q->param('pb_plugin_link'), 
     44        pb_plugin_name => $q->param('pb_plugin_name'), 
     45        pb_plugin_version => $q->param('pb_plugin_version'), 
     46        plugin_version => $VERSION, 
    2947    }; 
    3048    $app->build_page( 'pluginbuilder.tmpl', $param ); 
  • trunk/PluginBuilder/plugins/PluginBuilder/pluginbuilder.pl

    r196 r200  
    22# $Id$ 
    33use strict; 
    4 my $PLUGIN_NAME = "PluginBuilder"; 
    54require MT::Plugin; 
    65my $plugin = MT::Plugin->new( 
    7     name => $PLUGIN_NAME,  
    8     dir_name => lc($PLUGIN_NAME), 
     6    author_link => 'http://www.sixapart.com/', 
     7    author_name => 'Gene Boggs', 
     8    config_link => 'mt-pluginbuilder.cgi', 
    99    description => 'Plugin Stubber', 
    10     config_link => 'mt-'. lc($PLUGIN_NAME). '.cgi', 
     10    doc_link    => 'http://www.lifewiki.net/sixapart/PluginBuilder documentation', 
     11    name        => 'PluginBuilder',  
     12    plugin_link => 'http://code.sixapart.com/svn/mtplugins/trunk/PluginBuilder/', 
    1113); 
    1214return MT->add_plugin($plugin); 
  • trunk/PluginBuilder/plugins/PluginBuilder/tmpl/pluginbuilder.tmpl

    r199 r200  
    11<TMPL_INCLUDE NAME="header.tmpl"> 
    22 
    3 <h2>Plugin metadata:</h2> 
    4 <ul> 
    5 <li>Plugin name: <TMPL_VAR NAME=PLUGIN_NAME></li> 
    6 <li>Plugin version: <TMPL_VAR NAME=PLUGIN_VERSION></li> 
    7 <!-- <li>Plugin link: <TMPL_VAR NAME=PLUGIN_LINK></li> --> 
    8 <li>Author name: <TMPL_VAR NAME=AUTHOR_NAME></li> 
    9 <li>Author link: <TMPL_VAR NAME=AUTHOR_LINK></li> 
    10 <li>Description: <TMPL_VAR NAME=DESCRIPTION></li> 
    11 <!-- <li>Blog config template: <TMPL_VAR NAME=BLOG_CONFIG_TEMPLATE></li> --> 
    12 <li>Current blog: <TMPL_VAR NAME=BLOG></li> 
    13 <li>Current user: <TMPL_VAR NAME=USER></li> 
    14 </ul> 
     3<script type="text/javascript"> 
     4<!-- 
     5function validate (f) { 
     6/* 
     7    if (!is_valid_url(f.pb_author_link.value)){ 
     8        alert('<MT_TRANS phrase="You must set a valid Author link." escape="singlequotes">'); 
     9        return false; 
     10    } else if (!is_valid_url(f.pb_doc_link.value)){ 
     11        alert('<MT_TRANS phrase="You must set a valid Documentation link." escape="singlequotes">'); 
     12        return false; 
     13    } else if (!is_valid_url(f.pb_plugin_link.value)){ 
     14        alert('<MT_TRANS phrase="You must set a valid Plugin link." escape="singlequotes">'); 
     15        return false; 
     16    } else 
     17*/ 
     18    if (!f.pb_author_name.value){ 
     19        alert('<MT_TRANS phrase="You must set a valid Author name." escape="singlequotes">'); 
     20        return false; 
     21    } else if (!f.pb_description.value){ 
     22        alert('<MT_TRANS phrase="You must set a valid Description." escape="singlequotes">'); 
     23        return false; 
     24    } else if (!f.pb_plugin_name.value) { 
     25        alert('<MT_TRANS phrase="You must set your Plugin name." escape="singlequotes">'); 
     26        return false; 
     27    } else if (!f.pb_plugin_version.value) { 
     28        alert('<MT_TRANS phrase="You must set your Plugin version." escape="singlequotes">'); 
     29        return false; 
     30    } 
     31    return true; 
     32} 
     33function is_valid_url(url_){ 
     34    return url_.match( /^https?:\/\/[A-Za-z0-9!$%()=_.:,;@~-]+/ ); 
     35} 
     36function is_valid_path(path_){ 
     37    for(i = 0; i < path_.length; i++){ 
     38        var buf = escape(path_.substr(i, 1)); 
     39        if (buf.match(/^%u.*/)){ 
     40            return false; 
     41        } 
     42        if (buf.match(/(%.{2}){2}?/)){ 
     43            return false; 
     44        } 
     45    } 
     46    return true; 
     47} 
     48//--> 
     49</script> 
     50 
     51<TMPL_IF NAME=have_metadata> 
     52 
     53<TMPL_INCLUDE NAME="readme.tmpl"> 
     54<hr/> 
     55<TMPL_INCLUDE NAME="plugin.tmpl"> 
     56 
     57<TMPL_ELSE> 
     58 
     59<TMPL_INCLUDE NAME="collect-metadata.tmpl"> 
     60 
     61</TMPL_IF> 
    1562 
    1663<hr/> 
    1764<p> 
    18 <MT_TRANS phrase="PluginBuilder"> version <TMPL_VAR NAME=VERSION> 
    19 <br/> 
    20 Please see the 
    21 <a href="http://www.lifewiki.net/sixapart/PluginBuilder">PluginBuilder documentation</a>. 
     65<a href="http://www.lifewiki.net/sixapart/PluginBuilder"><MT_TRANS phrase="PluginBuilder"></a> 
     66version <TMPL_VAR NAME=PLUGIN_VERSION> 
    2267</p> 
    2368