Show
Ignore:
Timestamp:
11/18/08 12:00:13 (5 years ago)
Author:
tokuhirom
Message:

- プラグイン機構は package 宣言ありにした。
- 多少 css いじったけど、かっこよくはらならない。だれかやって ><

Location:
lang/perl/MENTA/trunk
Files:
1 added
10 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/MENTA/trunk/app/controller/index.mt

    r24047 r24060  
    1010//--></script> 
    1111 
    12 <h1><?= $title ?></h1> 
    1312<p><?= localtime time ?></p> 
    1413 
  • lang/perl/MENTA/trunk/app/controller/tutorial.mt

    r24047 r24060  
    11? my $title = "MENTA 取り扱い説明書" 
    22?=r render_partial('header.mt', $title) 
    3  
    4 <h1><?= $title ?></h1> 
    53 
    64<h2>ダウンロードする</h2> 
     
    4745<p><a href="<?= uri_for('counter') ?>">実際にうごいている様子</a></p> 
    4846 
     47<h2>プラグインの作り方</h2> 
     48 
     49あとでかく。 
     50 
    4951?=r render_partial('footer.mt') 
  • lang/perl/MENTA/trunk/app/static/style-sites.css

    r23559 r24060  
    1 body { font-family: monospace } 
    2 h1   { padding: 0.5em } 
     1body { font-family: monospace; } 
     2.container { width: 640px; margin: auto;padding: 0 0 0 0; } 
     3h1   { padding: 0.5em;  margin-top: 0; margin-bottom: 0; } 
     4.bodyContainer { background-color: white; padding-left: 4px; padding-right: 4px; } 
    35 
    46table { 
  • lang/perl/MENTA/trunk/app/tmpl/footer.mt

    r23986 r24060  
     1</div> 
    12<p><a href="<?= uri_for('index') ?>">トップにもどる</a></p> 
     3</div> 
  • lang/perl/MENTA/trunk/app/tmpl/header.mt

    r23986 r24060  
    33<title><? if ($title) { ?><?= "$title - " ?><? } ?>MENTA</title> 
    44<link rel="stylesheet" type="text/css" href="<?= docroot ?>static/style-sites.css"> 
     5<div class="container"> 
     6<h1><? if ($title) { ?><?= "$title - " ?><? } ?>MENTA</h1> 
     7<div class="bodyContainer"> 
  • lang/perl/MENTA/trunk/lib/MENTA.pm

    r24043 r24060  
    1010our $CARRIER; 
    1111our $STASH; 
     12our $PLUGIN_LOADED; 
    1213our $BUILT = 0; 
    1314BEGIN { 
     
    416417sub load_plugin { 
    417418    my $plugin = shift; 
    418     require_once($MENTA::BUILT ? "plugins/${plugin}.pl" : "plugins/${plugin}.pl"); 
     419    return if $MENTA::PLUGIN_LOADED->{$plugin}; 
     420    my $path = "plugins/${plugin}.pl"; 
     421    require $path; 
     422    $MENTA::PLUGIN_LOADED->{$plugin}++; 
     423    my $package = __menta_extract_package($path); 
     424    no strict 'refs'; 
     425    for ( 
     426        grep { /$plugin/o } 
     427        grep { defined &{"${package}::$_"} } 
     428        keys %{"${package}::"} 
     429    ) { 
     430        *{"main::$_"} = *{"${package}::$_"} 
     431    } 
     432} 
     433 
     434sub __menta_extract_package { 
     435    my $modulefile = shift; 
     436    open my $fh, '<', $modulefile or die "$modulefile を開けません: $!"; 
     437    my $in_pod = 0; 
     438    while (<$fh>) { 
     439        $in_pod = 1 if m/^=\w/; 
     440        $in_pod = 0 if /^=cut/; 
     441        next if ( $in_pod || /^=cut/ );    # skip pod text 
     442        next if /^\s*\#/; 
     443 
     444        /^\s*package\s+(.*?)\s*;/ and return $1; 
     445    } 
     446    return; 
    419447} 
    420448 
  • lang/perl/MENTA/trunk/plugins/counter.pl

    r24048 r24060  
    1 use MENTA; 
     1package MENTA::Plugin::Counter; 
     2use MENTA::Plugin; 
    23use Fcntl ':flock'; 
    34use Carp; 
  • lang/perl/MENTA/trunk/plugins/mail.pl

    r23559 r24060  
    1 #   mb_send_mail('to@example.jp', 'サブジェクト', '本文', 'From: from@example.jp'); 
    2 # という風にして、送るとよい。 
    3 # TODO: ヘッダの処理とかが甘いので、なんとかする 
    4 # iso-2022-jp に MIME encode する? 
    5  
    6 use utf8; 
     1package MENTA::Plugin::Mail; 
     2use MENTA::Plugin; 
    73use Symbol (); 
    84 
     
    3935 
    40361; 
     37__END__ 
     38#   mb_send_mail('to@example.jp', 'サブジェクト', '本文', 'From: from@example.jp'); 
     39# という風にして、送るとよい。 
     40# TODO: ヘッダの処理とかが甘いので、なんとかする 
     41# iso-2022-jp に MIME encode する? 
     42 
  • lang/perl/MENTA/trunk/plugins/sql.pl

    r23992 r24060  
    1 # AUTHOR: tokuhirom, mattn 
    2  
    3 use strict; 
    4 use warnings; 
    5 use utf8; 
     1package MENTA::Plugin::SQL; 
     2use MENTA::Plugin; 
    63use DBI; 
    74 
     
    7673 
    77741; 
     75# AUTHOR: tokuhirom, mattn