*** blosxom-xmlrpc.cgi.orig 2005-03-10 13:27:52.000000000 +0900 --- blosxom-xmlrpc.cgi 2006-07-06 02:56:10.000000000 +0900 *************** *** 99,106 **** --- 99,108 ---- use strict; use File::Find; use File::stat; + use File::Copy; use POSIX qw(strftime); use XMLRPC::Transport::HTTP; + use HTML::Entities; use CGI::Carp qw(fatalsToBrowser); use CGI; *************** *** 213,220 **** my $path_info = $ENV{'PATH_INFO'} || ''; ! if ( $path_info =~ /rpc2/i ) { ! XMLRPC::Transport::HTTP::CGI->dispatch_to( 'metaWeblog', 'blogger' ) ->handle; } elsif ( $path_info =~ /atom/i ) { # Do ATOM stuff here --- 215,223 ---- my $path_info = $ENV{'PATH_INFO'} || ''; ! BXR::debug( 2, "request", $path_info ); ! if ( $path_info =~ /RPC2/i ) { ! XMLRPC::Transport::HTTP::CGI->dispatch_to( 'metaWeblog', 'blogger', 'mt' ) ->handle; } elsif ( $path_info =~ /atom/i ) { # Do ATOM stuff here *************** *** 331,339 **** sub SetHtmlBegin { # set var with following html/css code (note: \n and extra white space will be included, don't use tabs!). # needs $PageTile, $Meta (optional) on entry, Printed as html header, mainly a color malleable style sheet. ! $_[0] = qq( ! $PageTitle $Meta --- 334,342 ---- sub SetHtmlBegin { # set var with following html/css code (note: \n and extra white space will be included, don't use tabs!). # needs $PageTile, $Meta (optional) on entry, Printed as html header, mainly a color malleable style sheet. ! $_[0] = qq( ! $PageTitle $Meta *************** *** 407,413 **** sub Error { # report fatal errors from Render (or other) and exit. ! print qq(Content-Type: text/html; charset=ISO-8859-1) if (shift); #print cgi header $PageTitle = 'Fatal Error'; $BlogText = qq($_[0] $_[1]); --- 410,416 ---- sub Error { # report fatal errors from Render (or other) and exit. ! print qq(Content-Type: text/html; charset=utf-8) if (shift); #print cgi header $PageTitle = 'Fatal Error'; $BlogText = qq($_[0] $_[1]); *************** *** 506,512 **** ? $cookie{'password'} = $c->param('password') : 0; unless ( BXR::auth( $cookie{'username'}, $cookie{'password'} ) ) { ! print $c->header(); $PageTitle = "Please Enter Password"; unless ( RenderExternalFlavour($BXR::weblogin) ) { SetHtmlVars(); --- 509,515 ---- ? $cookie{'password'} = $c->param('password') : 0; unless ( BXR::auth( $cookie{'username'}, $cookie{'password'} ) ) { ! print $c->header(-charset=>'utf-8'); $PageTitle = "Please Enter Password"; unless ( RenderExternalFlavour($BXR::weblogin) ) { SetHtmlVars(); *************** *** 528,534 **** -value => \%cookie, -expires => $expire ); ! print $c->header( -cookie => $cookie ); return 1; } } --- 531,537 ---- -value => \%cookie, -expires => $expire ); ! print $c->header( -cookie => $cookie, -charset => 'utf-8' ); return 1; } } *************** *** 1121,1126 **** --- 1124,1130 ---- defined($cats{$start}) ? delete($cats{$start}) : 0; $cats{"/"}++; + %cats = sort keys %cats; BXR::debug( 4, "blosxom::getCategories Category", keys(%cats) ); return ( \%cats ); } *************** *** 1205,1212 **** unless ( -e $filename ) { open POST, ">$filename" or die "Can't Open File $filename: $!"; ! print POST "$struct->{'title'}\n"; ! print POST "$struct->{'description'}\n"; close POST; my $files = chmod $BXR::file_permission, $filename; } --- 1209,1216 ---- unless ( -e $filename ) { open POST, ">$filename" or die "Can't Open File $filename: $!"; ! print POST HTML::Entities::decode_entities($struct->{'title'})."\n"; ! print POST HTML::Entities::decode_entities($struct->{'description'})."\n"; close POST; my $files = chmod $BXR::file_permission, $filename; } *************** *** 1319,1324 **** --- 1323,1330 ---- } else { my $date = BXR::getIsoTime( $post->{'dateCreated'} ); + $post->{'title'} = SOAP::Data->type(string => $post->{'title'}); + $post->{'description'} = SOAP::Data->type(string => $post->{'description'}); $post->{'dateCreated'} = SOAP::Data->type( dateTime => "$date" ); $post->{'postid'} = BXR::getPostIdFromFilename( $post->{'postid'} ); ( $post->{'link'} = $BXR::url . $post->{'postid'} ) =~ *************** *** 1349,1354 **** --- 1355,1361 ---- return \@retList; } + sub getCategoryList { return getCategories(@_) } sub getCategories { BXR::debug( 1, "metaWeblog.getCategories", @_ ); shift if UNIVERSAL::isa( $_[0] => __PACKAGE__ ); *************** *** 1428,1435 **** ######################################################## sub getUsersBlogs { BXR::debug( 1, "blogger.getUsersBlogs", @_ ); ! shift if UNIVERSAL::isa( $_[0] => __PACKAGE__ ); ! my $appkey = shift @_; my $username = shift @_; my $password = shift @_; --- 1435,1442 ---- ######################################################## sub getUsersBlogs { BXR::debug( 1, "blogger.getUsersBlogs", @_ ); ! shift if UNIVERSAL::isa( $_[0] => __PACKAGE__ ); ! my $appkey = shift @_; my $username = shift @_; my $password = shift @_; *************** *** 1456,1462 **** BXR::auth( $username, $password ); my %struct = ( ! userid => 1, firstname => $BXR::firstName, lastname => $BXR::lastName, nickname => $BXR::nickname, --- 1463,1469 ---- BXR::auth( $username, $password ); my %struct = ( ! userid => "mattn", firstname => $BXR::firstName, lastname => $BXR::lastName, nickname => $BXR::nickname, *************** *** 1572,1577 **** --- 1579,1658 ---- my $rc = blosxom::deletePost($filename); } + package mt; + sub getPostCategories { + BXR::debug( 1, "mt.getPostCategories", @_ ); + shift if UNIVERSAL::isa( $_[0] => __PACKAGE__ ); + my $postid = shift; + my $username = shift; + my $password = shift; + my $category = BXR::getCategoryFromFilename($postid); + my @return; + push @return, { + categoryName => $category, + categoryId => $category, + isPrimary => SOAP::Data->type(boolean => 1) + }; + return \@return; + } + sub setPostCategories { + BXR::debug( 1, "mt.setPostCategories", @_ ); + shift if UNIVERSAL::isa( $_[0] => __PACKAGE__ ); + my $postid = shift; + my $username = shift; + my $password = shift; + my $category = shift @_; + my $filename = BXR::getFilenameFromPostId($postid); + if ($category) { + my $fname = $filename; + $fname =~ s!.*/([^/]*)!$1!; + my $movepath = BXR::getFilenameFromPostId(@$category[0]->{categoryId}."/".$fname); + File::Copy::move $filename, $movepath; + } + return 1; + } + sub publishPost { + BXR::debug( 1, "mt.publishPost", @_ ); + shift if UNIVERSAL::isa( $_[0] => __PACKAGE__ ); + my $postid = shift; + my $username = shift; + my $password = shift; + my $filename = BXR::getFilenameFromPostId($postid); + if ( $filename !~ /$BXR::file_extension$/ ) { + $_ = $filename; + my ($fname, $ext) = /(.*)\.([^\.]+)/; + my $movepath = $fname.".".$BXR::file_extension; + File::Copy::move $filename, $movepath; + } + return 1; + } + sub getCategoryList { + BXR::debug( 1, "mt.getCategoryList", @_ ); + shift if UNIVERSAL::isa( $_[0] => __PACKAGE__ ); + my $blogid = shift; + my $username = shift; + my $password = shift; + + BXR::auth( $username, $password ); + + my $cats = blosxom::getCategories(); + my @return; + foreach ( keys %{$cats} ) { + $_ = BXR::getCategoryFromFilename($_); + push @return, { + categoryName => $_, + categoryId => $_ + }; + } + @return = sort {$a->{categoryName} cmp $b->{categoryName}} @return; + return \@return; + } + + sub getTrackbackPings { + my @data; + return \@data; + } + =head1 NAME BXR: The Blosxom XML-RPC and Web Editor Interface