|
|
@ -395,20 +395,7 @@ sub write_page |
|
|
|
# Check for edit collisions: |
|
|
|
my $new_timestamp = get_mtime($self->PagesDir . "/$pagename"); |
|
|
|
if ( $old_timestamp and ($new_timestamp > $old_timestamp) ) { |
|
|
|
my $form = $self->edit_form($pagename); |
|
|
|
return <<"HTML"; |
|
|
|
<h1>Probable edit collision.</h1> |
|
|
|
|
|
|
|
<p>This page has changed since you started editing it. You'll find your text |
|
|
|
below the edit box - please incorporate your changes here and save the new |
|
|
|
version.</p> |
|
|
|
|
|
|
|
$form |
|
|
|
|
|
|
|
<h1>your text</h1> |
|
|
|
|
|
|
|
$file_text |
|
|
|
HTML |
|
|
|
return $self->collision_form($pagename, $file_text); |
|
|
|
} |
|
|
|
|
|
|
|
# Write the diff, and return a one-line summary. |
|
|
@ -441,6 +428,28 @@ HTML |
|
|
|
return (0); |
|
|
|
} |
|
|
|
|
|
|
|
sub collision_form { |
|
|
|
my ($self) = shift; |
|
|
|
my ($pagename, $file_text) = @_; |
|
|
|
|
|
|
|
my $form = $self->edit_form($pagename); |
|
|
|
|
|
|
|
return <<"HTML"; |
|
|
|
<h1>Probable edit collision.</h1> |
|
|
|
|
|
|
|
<p>This page has changed since you started editing it. You'll find your text |
|
|
|
below the edit box - please incorporate your changes here and save the new |
|
|
|
version.</p> |
|
|
|
|
|
|
|
$form |
|
|
|
|
|
|
|
<h1>your text</h1> |
|
|
|
|
|
|
|
<pre> |
|
|
|
$file_text |
|
|
|
</pre> |
|
|
|
HTML |
|
|
|
} |
|
|
|
|
|
|
|
# Is there a good chance this is spam? |
|
|
|
# This is a very, very naive mechanism, but it mostly seems to work. |
|
|
@ -489,7 +498,6 @@ sub pagelinks { |
|
|
|
return (@camels, @brackets); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sub add_to_page { |
|
|
|
my $self = shift; |
|
|
|
my ($pagename, $new_text) = @_; |
|
|
@ -499,7 +507,8 @@ sub add_to_page { |
|
|
|
return $self->print_page($pagename) . $self->get_footer($pagename); |
|
|
|
} |
|
|
|
|
|
|
|
my ($summary) = $new_text =~ m/(.*?)(\n|$)/; |
|
|
|
# This regex is a touch tricky. |
|
|
|
my ($summary) = $new_text =~ m/(.+?)(\n|$)/; |
|
|
|
if ((length($new_text) - length($summary)) > 2) { |
|
|
|
$summary .= " ..."; |
|
|
|
} |
|
|
|