OSDN Git Service

initial version 0.0.1
authorTaku Amano <taku@bakersterrace.net>
Thu, 19 Feb 2009 12:58:34 +0000 (21:58 +0900)
committerTaku Amano <taku@bakersterrace.net>
Thu, 19 Feb 2009 12:58:34 +0000 (21:58 +0900)
.gitattributes [new file with mode: 0644]
Build.PL [new file with mode: 0644]
LICENSE [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
MANIFEST.SKIP [new file with mode: 0644]
config.yaml [new file with mode: 0644]
lib/Nabeatsu.pm [new file with mode: 0644]
lib/Nabeatsu/L10N.pm [new file with mode: 0644]
lib/Nabeatsu/L10N/en_us.pm [new file with mode: 0644]
lib/Nabeatsu/L10N/ja.pm [new file with mode: 0644]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..bf17ac3
--- /dev/null
@@ -0,0 +1,4 @@
+*.pm       ident
+*.html       ident
+*.tmpl       ident
+*.yaml       ident
diff --git a/Build.PL b/Build.PL
new file mode 100644 (file)
index 0000000..cad1022
--- /dev/null
+++ b/Build.PL
@@ -0,0 +1,119 @@
+use strict;
+use warnings;
+use Module::Build;
+use File::Spec;
+use File::Basename;
+use YAML qw/ Load /;
+
+my $class = Module::Build->subclass(
+       class => 'MTToiplanPluginDirectoryBuilder',
+       code => q{
+               # Don't make blib
+               # sub ACTION_code {};
+               # Don't make blib
+               sub ACTION_docs {};
+               # Don't make META.yml
+               sub ACTION_distmeta {
+                       # no warning on ACTION_distdir
+                       $_[0]->{metafile} = 'MANIFEST';
+               };
+               # Don't add MEATA.yml to MANIFEST
+               sub ACTION_manifest {
+                       $_[0]->{metafile} = 'MANIFEST',
+                       $_[0]->SUPER::ACTION_manifest(@_);
+               };
+               sub ACTION_test {
+                       my $p = $_[0]->{properties};
+                       unshift(
+                               @INC,
+                               File::Spec->catdir($p->{base_dir}, 'extlib'),
+                               File::Spec->catdir($p->{base_dir}, '../../lib'),
+                               File::Spec->catdir($p->{base_dir}, '../../extlib'),
+                       );
+
+                       $_[0]->SUPER::ACTION_test(@_);
+               };
+               sub ACTION_upload_google {
+                       my ($self) = @_;
+                       my $prj = 'toiplan-mtplugin-directory';
+                       my $ver = $self->dist_version;
+                       my $dist_dir = $self->dist_dir;
+                       my $name = $self->dist_name;
+
+                       $self->depends_on('dist');
+                       #$self->_call_action('distdir');
+                       $self->ACTION_distdir;
+                       $self->depends_on('zipdist');
+                       system(
+                               "googlecode_upload.py -s 'Release $ver (TGZ)' -p $prj -l $name $dist_dir.tar.gz"
+                       );
+                       system(
+                               "googlecode_upload.py -s 'Release $ver (ZIP)' -p $prj -l $name $dist_dir.zip"
+                       );
+                       unlink("$dist_dir.tar.gz");
+                       unlink("$dist_dir.zip");
+               };
+
+               sub ACTION_zipdist {
+                       my ($self) = @_;
+                       my $dist_dir = $self->dist_dir;
+                       $self->depends_on('distdir');
+                       print "Creating $dist_dir.zip\n";
+                       system("zip -r $dist_dir.zip $dist_dir") == 0 or die $?;
+                       $self->delete_filetree($dist_dir);
+               }
+
+               sub ACTION_distdir {
+                       my ($self) = @_;
+
+                       $_[0]->SUPER::ACTION_distdir(@_);
+
+                       my $dist_dir = $self->dist_dir;
+                       rename($dist_dir, $self->{properties}{dist_name});
+                       use File::Path;
+                       use File::Spec;
+                       use File::Basename;
+                       my $plugins = File::Spec->catfile($dist_dir, 'plugins');
+                       mkpath($plugins, 1, 0755);
+
+                       my $static = File::Spec->catfile($dist_dir, 'mt-static/plugins');
+                       mkpath($static, 1, 0755);
+
+                       my $new_dist_dir = File::Spec->catfile(
+                               $plugins, $self->{properties}{dist_name}
+                       );
+                       rename($self->{properties}{dist_name}, $new_dist_dir);
+
+                       foreach my $f (glob(File::Spec->catfile($new_dist_dir, 'LIC*'))) {
+                               rename($f, File::Spec->catfile($dist_dir, basename($f)));
+                       }
+
+                       if (my @statics = glob(File::Spec->catfile($new_dist_dir, 'static/*'))) {
+                               my $d = File::Spec->catfile($static, $self->{properties}{dist_name});
+                               mkpath($d, 1, 0755);
+                               foreach my $f (@statics) {
+                                       rename($f, File::Spec->catfile($d, basename($f)));
+                               }
+                       }
+               }
+       }
+);
+
+my $yaml_string = do {
+       open(my $fh, File::Spec->catfile(dirname(__FILE__), 'config.yaml'));
+       local $/;
+       <$fh>
+};
+$yaml_string =~ s/^(\s*)\*/$1App::\*/gm;
+my $yaml = Load($yaml_string);
+
+my $builder = $class->new(
+       dist_name           => $yaml->{name},
+    dist_author         => 'Movable Type ACME Plugin Project',
+    dist_version        => $yaml->{version},
+    module_name         => $yaml->{name} . '::App',
+    license             => 'MIT License',
+    add_to_cleanup      => [ $yaml->{name} . '-*' ],
+);
+
+$builder->create_build_script();
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..638ae64
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+Nabeatsu - Something bad at multiple of three or including three.
+
+Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..10461ae
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,6 @@
+config.yaml
+lib/Nabeatsu.pm
+lib/Nabeatsu/L10N.pm
+lib/Nabeatsu/L10N/en_us.pm
+lib/Nabeatsu/L10N/ja.pm
+LICENSE
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
new file mode 100644 (file)
index 0000000..0d160a2
--- /dev/null
@@ -0,0 +1,48 @@
+^MANIFEST
+\bBuild.PL$
+#^Makefile
+#^META.yml$
+#^blib/
+#~$
+
+
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+\B\.cvsignore$
+\B\.git
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\bBuild.bat$
+\b_build
+
+# Avoid Devel::Cover generated files
+\bcover_db
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\.#
+\.rej$
+
+# Avoid OS-specific files/dirs
+#   Mac OSX metadata
+\B\.DS_Store
+#   Mac OSX SMB mount metadata files
+\B\._
+# Avoid archives of this distribution
+\bArchiveUploader-[\d\.\_]+
diff --git a/config.yaml b/config.yaml
new file mode 100644 (file)
index 0000000..d436aec
--- /dev/null
@@ -0,0 +1,41 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+# plugin name
+name: Nabeatsu
+version: 0.0.1
+
+# about this plugin
+description: <__trans phrase="Something bad at multiple of three or including three.">
+author_name: <__trans phrase="Movable Type ACME Plugin Project">
+author_link: http://mt-acme.sourceforge.jp/
+plugin_link: http://mt-acme.sourceforge.jp/nabeatsu/
+doc_link: http://mt-acme.sourceforge.jp/nabeatsu/
+
+#Localization
+l10n_class: Nabeatsu::L10N
+
+#tag
+tags:
+    help_url: http://mt-acme.sourceforge.jp/nabeatsu/tags#%t
+    block:
+        Entries: Nabeatsu::_hdlr_nabeatsu
+        Blogs: Nabeatsu::_hdlr_nabeatsu
+        Categories: Nabeatsu::_hdlr_nabeatsu
diff --git a/lib/Nabeatsu.pm b/lib/Nabeatsu.pm
new file mode 100644 (file)
index 0000000..4388e4c
--- /dev/null
@@ -0,0 +1,101 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package MT::Entry;
+
+sub jumble {
+       my $self = shift;
+       my $plugin = MT->component('Nabeatsu');
+
+       $self->title($plugin->translate('foo'));
+       $self->text($plugin->translate('bar'));
+       $self->text_more($plugin->translate('buz'));
+}
+
+package MT::Blog;
+
+sub jumble {
+       my $self = shift;
+       my $plugin = MT->component('Nabeatsu');
+
+       $self->name($plugin->translate('foo'));
+       $self->description($plugin->translate('bar'));
+}
+
+package MT::Category;
+
+sub jumble {
+       my $self = shift;
+       my $plugin = MT->component('Nabeatsu');
+
+       $self->label($plugin->translate('foo'));
+       $self->description($plugin->translate('bar'));
+}
+
+package Nabeatsu;
+use strict;
+
+sub _hdlr_nabeatsu {
+    my($ctx, $args, $cond) = @_;
+       my $nabeatsu = $args->{'nabeatsu'} || '';
+
+       my %keys = qw(
+               entries         entry
+               blogs           blog
+               categories      category
+       );
+
+       my $tag = lc($ctx->stash('tag'));
+       my $key = $keys{$tag};
+       my $build = undef;
+
+       if ($nabeatsu =~ m/of\s+the\s+world/) {
+               local $SIG{__WARN__} = sub {  }; 
+
+               my $current_id = 0;
+               my $index = 0;
+               require MT::Builder;
+               $build = \&MT::Builder::build;
+               *MT::Builder::build = sub {
+                       my ($builder, $ctx, $tokens, $cond) = @_;
+                       my $obj = $ctx->{__stash}{$key};
+                       if ($obj && $obj->id != $current_id) {
+                               $index++;
+                               $current_id = $obj->id;
+                               if (($index % 3) == 0 || $index =~ m/3/) {
+                                       $obj->jumble;
+                               }
+                       }
+
+                       $build->(@_);
+               };
+       }
+
+    defined(my $result = $ctx->super_handler( $args, $cond ))
+        or return $ctx->error($ctx->errstr);
+
+       if ($build) {
+               *MT::Builder::build = $build;
+       }
+
+    return $result;
+}
+
+1;
diff --git a/lib/Nabeatsu/L10N.pm b/lib/Nabeatsu/L10N.pm
new file mode 100644 (file)
index 0000000..420a2b5
--- /dev/null
@@ -0,0 +1,25 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package Nabeatsu::L10N;
+use strict;
+use base 'MT::Plugin::L10N';
+
+1;
diff --git a/lib/Nabeatsu/L10N/en_us.pm b/lib/Nabeatsu/L10N/en_us.pm
new file mode 100644 (file)
index 0000000..7c30425
--- /dev/null
@@ -0,0 +1,29 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package Nabeatsu::L10N::en_us;
+
+use strict;
+
+use base 'Nabeatsu::L10N';
+use vars qw( %Lexicon );
+%Lexicon = ();
+
+1;
diff --git a/lib/Nabeatsu/L10N/ja.pm b/lib/Nabeatsu/L10N/ja.pm
new file mode 100644 (file)
index 0000000..ffda12c
--- /dev/null
@@ -0,0 +1,36 @@
+# Copyright (c) 2008 Movable Type ACME Plugin Project, All rights reserved.
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+package Nabeatsu::L10N::ja;
+
+use strict;
+use base 'Nabeatsu::L10N::en_us';
+use vars qw( %Lexicon );
+
+%Lexicon = (
+       'Something bad at multiple of three or including three.' =>
+       '3の倍数と3の付く数字で正しくない動きをします。',
+
+       'foo' => 'アホ',
+       'bar' => 'アホ',
+       'buz' => 'アホ',
+);
+
+1;