Today’s alley

Suppose that there is primary surface in a city, also it has background surface there.
Alley is able to say both that it doesn’t belong to that, but it’s belonging to that.
I like this space.
This picture was taken in Umeda.
I was walking arround here. Many people is walking, laughing, and sitting. Many eyes meet my.
I don’t think anything, looking with just only relying on my sense.
But yet taking photograph is shameful, I guess.
Don’t be shy? Yes, I wish I could be wildly for getting a good pic..

Modified the Gallery

ギャラリーを久しぶりに更新した。
アップロードが面倒臭くて過去の古い絵も一緒にアップ。

「助けを求める人」は時間はあんましかからなかったけど中々いい感じに描けたと思う。
もうちょっと更新作業を楽に出来るようにサイトを改良したので、今後はこまめにアップできるかな?。

FormatTextとIso_2022_jp_mail

こちらのサイトで公開されているPlaggerのプラグイン。
フィードを携帯とかに送りたい時、PlainTextのメールで欲しいとかMIMEがmixedなのは嫌だって時に便利な以下の二つのプラグインだが、上手く動かなかったりスペル間違いがあったりしたので自分なりにがんばって修正してみた。

Filter::FormatText

package Plagger::Plugin::Filter::FormatText;
use strict;
use base qw( Plagger::Plugin );

use HTML::TreeBuilder;
use HTML::FormatText;
use Encode;

sub register {
    my($self, $context) = @_;
    $context->register_hook(
        $self,
        'update.entry.fixup' => &filter,
    );
}

sub filter {
     my($self, $context, $args) = @_;
     my $cfg   = $self->conf;
     my $entry = $args->{entry};

     my $left  = $cfg->{left_margin}  || 0;
     my $right = $cfg->{right_margin} || 72;
     my $tree      = HTML::TreeBuilder->new()->parse($entry->body);
     my $formatter = HTML::FormatText->new(
         leftmargin => $left,
         rightmargin => $right,
     );
     my $body = $formatter->format($tree);
     my $len  = length($body);

     my $start = $cfg->{start}  || 0;
     my $end   = $cfg->{length} || $len;

     if ($cfg->{start} || $cfg->{length}) {
       my $more = '';
          $more = ' ...' if $len > $end;
       $body = substr($body, $start, $end) . $more;
     }
#     $entry->body('</pre><pre>'.$body.'</pre>');
     $entry->body($body);

     $context->log(info => "format $entry->{link}") if $entry->{link};
}


1;

__END__

Publish::Iso_2022_jp_mail

package Plagger::Plugin::Publish::Iso_2022_jp_mail;
use strict;
use base qw( Plagger::Plugin );

use DateTime;
use DateTime::Format::Mail;
use Encode;
use Encode::MIME::Header;
use Jcode;
use MIME::Lite;

our %TLSConn;

sub rule_hook { 'publish.entry.fixup' }

sub register {
    my($self, $context) = @_;
    $context->autoload_plugin({ module => "Filter::FormatText" });
    $context->register_hook(
        $self,
        'publish.entry.fixup' => &notify,
    );
}

sub init {
  my $self = shift;
  $self->SUPER::init(@_);

  $self->conf->{mailto} or Plagger->context->error("mailto is required");
  $self->conf->{mailfrom} ||= 'plagger@localhost';
  print "....n";
}


sub notify {
  my ($self, $context, $args) = @_;

  return if $args->{feed}->count == 0;

  my $cnf = $self->conf;
  my $now = Plagger::Date->now(timezone => $context->conf->{timezone});
  my $subject = $args->{feed}->title || '(no-title)';
  my $from = $cnf->{mailfrom};

  my $msg = MIME::Lite->new(
    Date     => $now->format('Mail'),
    From     => encode('MIME-Header-ISO_2022_JP', $from),
    To       => encode('MIME-Header-ISO_2022_JP', $cnf->{mailto}),
    Subject  => encode('MIME-Header-ISO_2022_JP', $subject),
    Type     => 'text/plain; charset=ISO-2022-JP',
    Encoding => '7bit',
    Data     => encode_body($args->{entry}->body),
  );

  $msg->send();

  $context->log(info => "Sending $subject to $cnf->{mailto}");
}

sub encode_body {
  my $str = shift;
  $str = remove_utf8_flag($str);
  $str =~ s/x0Dx0A/n/g;
  $str =~ tr/r/n/;
  return Jcode->new($str, guess_encoding($str))->jis;
}

sub guess_encoding {
  my $str = shift;
  my $enc = Jcode::getcode($str) || 'euc';
  $enc = 'euc' if $enc eq 'ascii' || $enc eq 'binary';
  return $enc;
}

sub remove_utf8_flag { pack 'C0A*', $_[0] }



1;