Browse Source

Tweaked Wala logging.

pull/1/head
Brennen Bearnes 17 years ago
parent
commit
4460b09a42
2 changed files with 32 additions and 19 deletions
  1. +25
    -16
      lib/Wala.pm
  2. +7
    -3
      markup.pl

+ 25
- 16
lib/Wala.pm View File

@ -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 .= " ...";
}


+ 7
- 3
markup.pl View File

@ -8,15 +8,19 @@ use Data::Dumper;
# Create and compile the source file
my $grammar = <<'GRAMMAR';
<autotree>
markup : expression(s)
tag : SIGIL /[a-z]+/
SIGIL : "~"
END_SIGIL : "~"
LEFT_BRACKET : "["
RIGHT_BRACKET : "]"
expression : tag expression(s) END_SIGIL
expression : tag LEFT_BRACKET expression(s) RIGHT_BRACKET
| word(s)
word : character(s)
@ -29,6 +33,6 @@ my $parser = Parse::RecDescent->new($grammar);
# Test it on sample data
print "\nValid text\n" if $parser->markup(<<'SAMPLE'
~title ~italics Motherfucker ~ ~
~title[~italics[Title!]]
SAMPLE
);

|||||||
x
 
000:0
Loading…
Cancel
Save