[PerlWikiBot] SF.net SVN: perlwikibot: [32] trunk/includes
Status: Pre-Alpha
Brought to you by:
rotemliss
|
From: <rot...@us...> - 2006-09-26 17:45:47
|
Revision: 32
http://svn.sourceforge.net/perlwikibot/?rev=32&view=rev
Author: rotemliss
Date: 2006-09-26 10:45:37 -0700 (Tue, 26 Sep 2006)
Log Message:
-----------
Get the edit page contents via the edit page, if not adding prefix.
Modified Paths:
--------------
trunk/includes/actions.pm
trunk/includes/functions.pm
Modified: trunk/includes/actions.pm
===================================================================
--- trunk/includes/actions.pm 2006-09-16 17:49:12 UTC (rev 31)
+++ trunk/includes/actions.pm 2006-09-26 17:45:37 UTC (rev 32)
@@ -6,30 +6,33 @@
use strict;
# Get the contents of a page
-sub getPageContents {
+sub getEditPage {
# Get parameters
my ( $title ) = @_;
- # Get page contents
- return http::getPage( $title, "raw" );
-}
+ my ( $page, $text );
+ if ( $configure::sendPages == 2 ) {
+ # Add prefix
+ my $serverPrefix = $configure::serverPrefixes{ $ARGV[0] };
+ my $prefixedTitle = $serverPrefix.$title;
-# Edit page
-sub editPage {
- # Get parameters
- my ( $title, $text, $summary ) = @_;
+ # Get the edit page contents
+ $page = http::getPage( $prefixedTitle, "edit" );
+
+ # Get the page text
+ $text = http::getPage( $title, "raw" );
+ } else {
+ # Get the edit page contents
+ $page = http::getPage( $title, "edit" );
- print "Editing page $title...\n";
-
- # Add prefix if necessary
- if ( $configure::sendPages == 2 ) {
- my $serverPrefix = $configure::serverPrefixes{ $ARGV[0] };
- $title = $serverPrefix.$title;
+ # Get the page text
+ $page =~ /<textarea tabindex='1' accesskey="." name="wpTextbox1" id="wpTextbox1" rows='\d+'\ncols='\d+' >([^<]*)<\/textarea>/;
+ $text = $1;
+ $text =~ s/</</g;
+ $text =~ s/>/>/g;
+ $text =~ s/&/&/g;
}
- # Get the edit page contents
- my $page = http::getPage( $title, "edit" );
-
# Get the start time
$page =~ /<input type='hidden' value="([0-9]{14})" name="wpStarttime" \/>/;
my $startTime = $1;
@@ -42,6 +45,22 @@
$page =~ /<input type='hidden' value="([0-9a-f]{32})" name="wpEditToken" \/>/;
my $editToken = $1;
+ return ( $text, $startTime, $editTime, $editToken );
+}
+
+# Edit page
+sub editPage {
+ # Get parameters
+ my ( $title, $summary, $text, $startTime, $editTime, $editToken ) = @_;
+
+ print "Editing page $title...\n";
+
+ # Add prefix if necessary
+ if ( $configure::sendPages == 2 ) {
+ my $serverPrefix = $configure::serverPrefixes{ $ARGV[0] };
+ $title = $serverPrefix.$title;
+ }
+
# Send page
if ( defined( $editToken ) && $editToken =~ /[0-9a-f]{32}/ ) {
if ( $configure::sendPages == 1 || $configure::sendPages == 2 ) {
@@ -69,7 +88,7 @@
my ( $title ) = @_;
# Null edit
- editPage( $title, getPageContents( $title ), "Refreshing page" );
+ editPage( $title, "Refreshing page", getEditPage( $title ) );
}
# Move page
Modified: trunk/includes/functions.pm
===================================================================
--- trunk/includes/functions.pm 2006-09-16 17:49:12 UTC (rev 31)
+++ trunk/includes/functions.pm 2006-09-26 17:45:37 UTC (rev 32)
@@ -163,8 +163,8 @@
# Send page
if ( $configure::sendPages == 1 || $configure::sendPages == 2 ) {
- # Get the edited page contents
- my $page = actions::getPageContents( $title );
+ # Get the edit page
+ my ( $text, $startTime, $editTime, $editToken ) = actions::getEditPage( $title );
# Set initial edit summary
my $summary = $configure::initialEditSummaries{ $ARGV[0] };
@@ -181,9 +181,9 @@
for ( my $i = 0; $i <= $#actions; $i++ ) {
my $action = $actions[$i];
my $search = $configure::texts{ $action };
- if ( $page =~ /$search/ ) {
+ if ( $text =~ /$search/ ) {
my $replace = $configure::news{ $action };
- $page =~ s/$search/$replace/g;
+ $text =~ s/$search/$replace/g;
if ( $replaced == 1 ) {
$summary = "$summary, ";
}
@@ -194,7 +194,7 @@
# Edit page only of replaced something
if ( $replaced == 1 ) {
- actions::editPage( $title, $page, $summary );
+ actions::editPage( $title, $summary, $text, $startTime, $editTime, $editToken );
}
} else {
print "Replaced in page $title.\n";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|