From: <Cra...@nt...> - 2005-02-15 12:14:46
|
Author: CrawfordCurrie Date: 2005-02-15 04:12:27 -0800 (Tue, 15 Feb 2005) New Revision: 3627 Modified: twiki/branches/DEVELOP/lib/TWiki/Merge.pm twiki/branches/DEVELOP/lib/TWiki/Prefs.pm twiki/branches/DEVELOP/lib/TWiki/Prefs/Parser.pm twiki/branches/DEVELOP/lib/TWiki/Prefs/TopicPrefs.pm twiki/branches/DEVELOP/lib/TWiki/Store.pm twiki/branches/DEVELOP/lib/TWiki/UI/Changes.pm twiki/branches/DEVELOP/lib/TWiki/UI/Manage.pm twiki/branches/DEVELOP/lib/TWiki/UI/Register.pm twiki/branches/DEVELOP/lib/TWiki/UI/Save.pm twiki/branches/DEVELOP/lib/TWiki/UI/Statistics.pm twiki/branches/DEVELOP/lib/TWiki/User.pm Log: MakeLinkChangesSilent: changes as described in the topic, plus minor fixes to change diff presentation and some comments Modified: twiki/branches/DEVELOP/lib/TWiki/Merge.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Merge.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/Merge.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -77,9 +77,26 @@ sub _change { my ( $a, $b, $out, $ai, $bi ) = @_; + my $simpleInsert = 0; - push( @$out, "<del>$ai->[$a]</del>" ); - push( @$out, "<ins>$bi->[$b]</ins>" ); + # Diff isn't terribly smart sometimes; it will generate changes + # with a or b empty, which I would have thought should have + # been accepts. + if( $ai->[$a] =~ /\S/ ) { + # there is some non-white text to delete + push( @$out, "<del>$ai->[$a]</del>" ); + } else { + # otherwise this insert is not replacing anything + $simpleInsert = 1; + } + + if( !$simpleInsert && $bi->[$b] =~ /\S/ ) { + # this insert is replacing something with something + push( @$out, "<ins>$bi->[$b]</ins>" ); + } else { + # otherwise it is replacing nothing, or is whitespace or null + push( @$out, $bi->[$b] ); + } } 1; Modified: twiki/branches/DEVELOP/lib/TWiki/Prefs/Parser.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Prefs/Parser.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/Prefs/Parser.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -30,6 +30,8 @@ package TWiki::Prefs::Parser; +use Assert; + my $formPrefPrefix = "FORM_"; =pod @@ -62,7 +64,7 @@ foreach my $line ( split( /\r?\n/, $text ) ) { if( $line =~ /^\t+\*\sSet\s(\w+)\s\=\s*(.*)$/ ) { if( $isKey ) { - $prefs->_insertPrefsValue( $key, $value ); + $prefs->insertPrefsValue( $key, $value ); } $key = $1; $value = (defined $2) ? $2 : ""; @@ -72,13 +74,13 @@ # follow up line, extending value $value .= "\n$line"; } else { - $prefs->_insertPrefsValue( $key, $value ); + $prefs->insertPrefsValue( $key, $value ); $isKey = 0; } } } if( $isKey ) { - $prefs->_insertPrefsValue( $key, $value ); + $prefs->insertPrefsValue( $key, $value ); } } @@ -105,11 +107,11 @@ my $title = $field->{"title"}; my $prefixedTitle = $formPrefPrefix . $title; my $value = $field->{"value"}; - $prefs->_insertPrefsValue( $prefixedTitle, $value ); + $prefs->insertPrefsValue( $prefixedTitle, $value ); my $attributes = $field->{"attributes"}; if( $attributes && $attributes =~ /[S]/o ) { my $name = $field->{"name"}; - $prefs->_insertPrefsValue( $name, $value ); + $prefs->insertPrefsValue( $name, $value ); } } } Modified: twiki/branches/DEVELOP/lib/TWiki/Prefs/TopicPrefs.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Prefs/TopicPrefs.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/Prefs/TopicPrefs.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -49,52 +49,24 @@ $self->{web} = $theWeb; $self->{topic} = $theTopic; - $self->readPrefs(); - - return $self; -} - -sub store { my $this = shift; return $this->{session}->{store}; } - -=pod - ----+++ sub Prefs() - -Rereads preferences from the topic, updating the TopicPrefs object. - -=cut - -sub readPrefs { - my $self = shift; - ASSERT(ref($self) eq "TWiki::Prefs::TopicPrefs") if DEBUG; - - my $theWeb = $self->{web}; - my $theTopic = $self->{topic}; - $self->{prefs} = {}; - return unless $self->store()->topicExists( $theWeb, $theTopic ); + if( $session->{store}->topicExists( $theWeb, $theTopic )) { + my( $meta, $text ) = + $session->{store}->readTopic( undef, + $theWeb, $theTopic, + undef ); + my $parser = new TWiki::Prefs::Parser(); + $parser->parseText( $text, $self ); + $parser->parseMeta( $meta, $self ); + } - my( $meta, $text ) = - $self->store()->readTopic( undef, - $theWeb, $theTopic, - undef ); - - my $parser = new TWiki::Prefs::Parser(); - $parser->parseText( $text, $self ); - $parser->parseMeta( $meta, $self ); + return $self; } -=pod - ----+++ sub _insertPrefsValue( $key, $value ) - -Adds a key-value pair to the TopicPrefs object. -SMELL: this is almost the same as insertPreference, below. - -=cut - -sub _insertPrefsValue { +# Adds a key-value pair to the TopicPrefs object. Callback defined for +# the Prefs::Parser object. +sub insertPrefsValue { my( $self, $theKey, $theValue ) = @_; return if exists $self->{finalHash}{$theKey}; # key is final, may not be overridden Modified: twiki/branches/DEVELOP/lib/TWiki/Prefs.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Prefs.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/Prefs.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -65,7 +65,7 @@ ---+++ sub initializeUser( $user, $usertopic ) -STATIC Reads preferences from the user's personal topic. +Reads preferences from the user's personal topic. =cut Modified: twiki/branches/DEVELOP/lib/TWiki/Store.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/Store.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/Store.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -546,7 +546,8 @@ \$newItemText ); $this->saveTopic( $user, $itemWeb, $itemTopic, $newItemText, $meta, - { unlock => 1, dontnotify => 1 } ); + { unlock => 1, + minor => 1 } ); $this->unlockTopic( $user, $itemWeb, $itemTopic ); } else { $result .= ";$item does not exist;"; @@ -699,10 +700,10 @@ | =$options= | Ref to hash of options | =$options= may include: | =dontlog= | don't log this change in twiki log | -| =dontnotify= | don't log this change in .changes | | =hide= | if the attachment is to be hidden in normal topic view | | =comment= | comment for save | | =file= | Temporary file name to upload | +| =minor= | True if this is a minor change (used in log) | | =savecmd= | Save command | | =forcedate= | grr | | =unlock= | | @@ -752,7 +753,7 @@ | =$opts= | Ref to hash of options | =$opts= may include: | =dontlog= | don't log this change in twiki log | -| =dontnotify= | don't log this change in .changes | +| =minor= | don't log this change in .changes | | =hide= | if the attachment is to be hidden in normal topic view | | =comment= | comment for save | | =file= | Temporary file name to upload | @@ -888,23 +889,19 @@ return $error if( $error ); - if( ! $options->{dontnotify} ) { - # update .changes - my @revi = $this->getRevisionInfo( $web, $topic, "", undef, $topicHandler ); + # update .changes + my @foo = split( /\n/, $this->readMetaData( $web, "changes" )); + shift( @foo) if( $#foo > 500 ); + my $minor = ""; + $minor = "\tminor" if $options->{minor}; + push( @foo, "$topic\t".$user->login()."\t".time()."\t$nextRev$minor" ); + $this->saveMetaData( $web, "changes", join( "\n", @foo )); + close(FILE); - my @foo = split( /\n/, $this->readMetaData( $web, "changes" )); - if( $#foo > 100 ) { - shift( @foo); - } - push( @foo, "$topic\t".$user->login()."\t".time()."\t$revi[2]" ); - $this->saveMetaData( $web, "changes", join( "\n", @foo )); - close(FILE); - } - if( ( $TWiki::cfg{Log}{save} ) && ! ( $options->{dontlog} ) ) { # write log entry my $extra = ""; - $extra .= "dontNotify" if( $options->{dontnotify} ); + $extra .= "minor" if( $options->{minor} ); $this->{session}->writeLog( "save", "$web.$topic", $extra ); } @@ -961,7 +958,7 @@ my $extra = "repRev by ".$user->login().": $rev " . $revuser->login(). " ". TWiki::formatTime( $epochSec, "rcs", "gmtime" ); - $extra .= " dontNotify" if( $options->{dontnotify} ); + $extra .= " minor" if( $options->{minor} ); $this->{session}->writeLog( "save", "$web.$topic", $extra ); } return ""; Modified: twiki/branches/DEVELOP/lib/TWiki/UI/Changes.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/UI/Changes.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/UI/Changes.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -42,7 +42,6 @@ my $skin = $session->getSkin(); my $text = $session->{templates}->readTemplate( "changes", $skin ); - my $changes= $session->{store}->readMetaData( $webName, "changes" ); my $summary = ""; @@ -52,8 +51,14 @@ my( $page, $eachChange, $after) = split( /%REPEAT%/, $text ); + my $changeData = $session->{store}->readMetaData( $webName, "changes" ); + my @changes = split( /\r?\n/, $changeData ); + unless( $query->param( 'minor' )) { + @changes = grep { !/\tminor$/ } @changes; + $page .= "<b>Note:</b>This page is showing major changes only. To see all changes <a href='".$query->url() . "/$webName?minor=1'>click here</a>"; + } my %done = (); - foreach my $change ( reverse split( /\r?\n/, $changes ) ) { + foreach my $change ( reverse @changes ) { my( $changedTopic, $login, $time, $rev ) = split( /\t/, $change ); unless( $done{$changedTopic} ) { next unless $session->{store}->topicExists( $webName, $changedTopic ); @@ -82,20 +87,13 @@ ( $query->{user}, $webName, $changedTopic, $rev - 1 ); $text = $session->{renderer}->TML2PlainText ( $text, $webName, $changedTopic, "nonop" ); + $text = substr( $text, 0, 162 )."..." + if ( length($text) > 162); $otext = $session->{renderer}->TML2PlainText ( $otext, $webName, $changedTopic, "nonop" ); + $otext = substr( $otext, 0, 162 )."..." + if ( length($otext) > 162); $summary = TWiki::Merge::merge( $otext, $text, qr/\s+/ ); - if( length( $summary ) > 162 ) { - $text = $summary; - $summary = ""; - # SMELL: there's got to be a better way to do this - foreach my $c ( split( /(<\/?(?:ins|del)>)/i, $text )) { - if( $c !~ /<\/?(ins|del)>/i ) { - $c =~ s/^(.{12}).*(.{12})$/$1...$2/s; - } - $summary .= $c; - } - } $summary = $session->{renderer}->protectPlainText( $summary ); } else { # only one version, show summary Modified: twiki/branches/DEVELOP/lib/TWiki/UI/Manage.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/UI/Manage.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/UI/Manage.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -85,7 +85,7 @@ #TODO: need to handle the NoPasswdUser case (userPasswordExists will retun false here) if( $user && !$user->passwordExists()) { throw TWiki::UI::OopsException( $webName, $topic, - "notwikiuser", $user->toString() ); + "notwikiuser", $user->stringify() ); } #check to see it the user we are trying to remove is a memebr of a group. @@ -121,7 +121,7 @@ $user->remove(); throw TWiki::UI::OopsException( $webName, $topic, "removeuserdone", - $user->toString() ); + $user->stringify() ); } #changePassword is now in register (belongs in User.pm though) Modified: twiki/branches/DEVELOP/lib/TWiki/UI/Register.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/UI/Register.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/UI/Register.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -457,13 +457,13 @@ unless ($email) { throw TWiki::UI::OopsException ( undef, $user->wikiName(), "regemail", - "Can't get an email address for " . $user->toString()); + "Can't get an email address for " . $user->stringify()); } my $message = ""; unless( $user->passwordExists() ) { $email = "ResetPassword created new htpasswd entry for ". - $user->toString()." as it was missing in .htpasswd"; + $user->stringify()." as it was missing in .htpasswd"; } my $password = $user->resetPassword(); @@ -541,7 +541,7 @@ # OK - password may be changed $user->changePassword( $passwordA ); - $session->writeLog("changepasswd", $user->toString()); + $session->writeLog("changepasswd", $user->stringify()); #recording the email would be nice # OK - password changed Modified: twiki/branches/DEVELOP/lib/TWiki/UI/Save.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/UI/Save.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/UI/Save.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -124,7 +124,7 @@ $newText =~ s/ {3}/\t/go; my $saveOpts = {}; - $saveOpts->{dontnotify} = 1 if $query->param( "dontnotify" ); + $saveOpts->{minor} = 1 if $query->param( "dontnotify" ); $saveOpts->{forcenewrevision} = 1 if $query->param( "forcenewrevision" ); if( $saveCmd eq "repRev" ) { @@ -170,7 +170,9 @@ # assumes rev numbers start at 1 if ( $originalrev ) { my ( $date, $author, $rev ) = $newMeta->getRevisionInfo(); - + # temporary to find problem + print STDERR "Merge ",$user->stringify(), + $author->stringify(), $originalrev, $rev\n"); if ( $rev ne $originalrev ) { $newText = TWiki::Merge::merge( $currText, $newText, "\\r?\\n" ); $newMeta->merge( $currMeta ); Modified: twiki/branches/DEVELOP/lib/TWiki/UI/Statistics.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/UI/Statistics.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/UI/Statistics.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -248,10 +248,12 @@ my ($webName, $opName, $topicName, $userName, $newTopicName, $newTopicWeb); binmode $TMPFILE; - while ( <$TMPFILE> ) { - my $line = $_; + while ( my $line = <$TMPFILE> ) { $line =~ s/\r*\n$//; # Clean out line endings + # ignore minor changes - not statistically helpful + next if( $line =~ / (minor|dontNotify) / ); + $line =~ /^\|[^\|]*\| ($webNameRegex\.$userRegex) \| ($opRegex) \| ($webNameRegex)[. ]/o; $userName = $1 || ""; # Main.FredBloggs $opName = $2 || ""; @@ -269,7 +271,6 @@ } my $logContrib = 0; - if ($opName eq 'view' ) { $statViews{$webName}++; # Pick up the topic name and any error string @@ -466,7 +467,7 @@ $session->{store}->saveTopic( $user, $webName, $statsTopic, $text, $meta, - { dontnotify => 1, + { minor => 1, dontlog => 1 } ); _printMsg( " - Topic $statsTopic updated", $session ); Modified: twiki/branches/DEVELOP/lib/TWiki/User.pm =================================================================== --- twiki/branches/DEVELOP/lib/TWiki/User.pm 2005-02-15 10:45:29 UTC (rev 3626) +++ twiki/branches/DEVELOP/lib/TWiki/User.pm 2005-02-15 12:12:27 UTC (rev 3627) @@ -159,13 +159,13 @@ =pod ----++ toString() +---++ stringify() Generate a string representation of this object, suitable for debugging =cut -sub toString { +sub stringify { my $this = shift; ASSERT(ref($this) eq "TWiki::User") if DEBUG; |