-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item1156: Create Release01x00 branch
git-svn-id: http://svn.foswiki.org/branches/Release01x00@2725 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
- Loading branch information
KennethLavrsen
authored and
KennethLavrsen
committed
Feb 26, 2009
1 parent
6aa7634
commit fc00f55
Showing
20 changed files
with
3,107 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
213 changes: 213 additions & 0 deletions
213
MailerContrib/lib/Foswiki/Contrib/MailerContrib/Change.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
# Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
# | ||
# Copyright (C) 2004 Wind River Systems Inc. | ||
# Copyright (C) 1999-2006 Foswiki Contributors. | ||
# All Rights Reserved. Foswiki Contributors | ||
# are listed in the AUTHORS file in the root of this distribution. | ||
# NOTE: Please extend that file, not this notice. | ||
# | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. For | ||
# more details read LICENSE in the root of this distribution. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# | ||
# As per the GPL, removal of this notice is prohibited. | ||
|
||
use strict; | ||
|
||
=pod | ||
---+ package Foswiki::Contrib::MailerContrib::Change | ||
Object that represents a change to a topic. | ||
=cut | ||
|
||
package Foswiki::Contrib::MailerContrib::Change; | ||
|
||
use Foswiki; | ||
|
||
use URI::Escape; | ||
use Assert; | ||
|
||
=pod | ||
---++ new($web) | ||
* =$web= - Web name | ||
* =$topic= - Topic name | ||
* =$author= - String author of change | ||
* =$time= - String time of change | ||
* =$rev= - Revision identifier | ||
Construct a new change object. | ||
=cut | ||
|
||
sub new { | ||
my ( $class, $session, $web, $topic, $author, $time, $rev ) = @_; | ||
|
||
my $this = bless( {}, $class ); | ||
|
||
$this->{SESSION} = $session; | ||
$this->{WEB} = $web; | ||
$this->{TOPIC} = $topic; | ||
my $user; | ||
# SMELL: call to unpublished core function | ||
if (defined(&Foswiki::Users::findUser)) { | ||
$user = $session->{users}->findUser( $author, undef, 1 ); | ||
$this->{AUTHOR} = $user ? $user->wikiName() : $author; | ||
} else { | ||
$this->{AUTHOR} = Foswiki::Func::getWikiName($author); | ||
} | ||
$this->{TIME} = $time; | ||
ASSERT($rev) if DEBUG; | ||
# rev at this change | ||
$this->{CURR_REV} = $rev; | ||
# previous rev | ||
$this->{BASE_REV} = $rev - 1 || 1; | ||
|
||
return $this; | ||
} | ||
|
||
sub stringify { | ||
my $this = shift; | ||
|
||
return "$this->{WEB}.$this->{TOPIC} by $this->{AUTHOR} at $this->{TIME} from r$this->{BASE_REV} to r$this->{CURR_REV}"; | ||
} | ||
|
||
=pod | ||
---++ merge($change) | ||
* =$change= - Change record to merge | ||
Merge another change record with this one, so that the combined | ||
record is a reflection of both changes. | ||
=cut | ||
|
||
sub merge { | ||
my( $this, $other ) = @_; | ||
ASSERT($this->isa( 'Foswiki::Contrib::MailerContrib::Change' )) if DEBUG; | ||
ASSERT($other->isa( 'Foswiki::Contrib::MailerContrib::Change' )) if DEBUG; | ||
|
||
if( $other->{CURR_REV} > $this->{CURR_REV} ) { | ||
$this->{CURR_REV} = $other->{CURR_REV}; | ||
$this->{AUTHOR} = $other->{AUTHOR}; | ||
$this->{TIME} = $other->{TIME}; | ||
} | ||
|
||
$this->{BASE_REV} = $other->{BASE_REV} | ||
if($other->{BASE_REV} < $this->{BASE_REV}); | ||
} | ||
|
||
=pod | ||
---++ expandHTML($html) -> string | ||
* =$html= - Template to expand keys within | ||
Expand an HTML template using the values in this change. The following | ||
keys are expanded: %<nop>TOPICNAME%, %<nop>AUTHOR%, %<nop>TIME%, | ||
%<nop>REVISION%, %<nop>BASE_REV%, %<nop>CUR_REV%, %<nop>TEXTHEAD%. | ||
Returns the expanded template. | ||
=cut | ||
|
||
sub expandHTML { | ||
my ( $this, $html ) = @_; | ||
|
||
unless( defined $this->{HTML_SUMMARY} ) { | ||
if( defined &Foswiki::Func::summariseChanges ) { | ||
$this->{HTML_SUMMARY} = | ||
Foswiki::Func::summariseChanges( | ||
$this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, | ||
$this->{CURR_REV}, 1 ); | ||
} else { | ||
$this->{HTML_SUMMARY} = | ||
$this->{SESSION}->{renderer}->summariseChanges | ||
( undef, $this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, | ||
$this->{CURR_REV}, 1 ); | ||
} | ||
} | ||
|
||
$html =~ s/%TOPICNAME%/$this->{TOPIC}/g; | ||
$html =~ s/%AUTHOR%/$this->{AUTHOR}/g; | ||
my $tim = Foswiki::Time::formatTime( $this->{TIME} ); | ||
$html =~ s/%TIME%/$tim/go; | ||
$html =~ s/%CUR_REV%/$this->{CURR_REV}/g; | ||
$html =~ s/%BASE_REV%/$this->{BASE_REV}/g; | ||
my $frev = ''; | ||
if( $this->{CURR_REV} ) { | ||
if( $this->{CURR_REV} > 1 ) { | ||
$frev = 'r'.$this->{BASE_REV}. | ||
'->r'.$this->{CURR_REV}; | ||
} else { | ||
# new _since the last notification_ | ||
$frev = CGI::span( { class=>'foswikiNew' }, 'NEW' ); | ||
} | ||
} | ||
$html =~ s/%REVISION%/$frev/g; | ||
$html = Foswiki::Func::expandCommonVariables( | ||
$html, $this->{TOPIC}, $this->{WEB} ); | ||
$html = Foswiki::Func::renderText( $html ); | ||
$html =~ s/%TEXTHEAD%/$this->{HTML_SUMMARY}/g; | ||
|
||
return $html; | ||
} | ||
|
||
=pod | ||
---++ expandPlain() -> string | ||
Generate a plaintext version of this change. | ||
=cut | ||
|
||
sub expandPlain { | ||
my ( $this, $template ) = @_; | ||
|
||
unless( defined $this->{TEXT_SUMMARY} ) { | ||
my $s; | ||
if( defined &Foswiki::Func::summariseChanges ) { | ||
$s = Foswiki::Func::summariseChanges( | ||
$this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, | ||
$this->{CURR_REV}, 0 ); | ||
} else { | ||
$s = $this->{SESSION}->{renderer}->summariseChanges( | ||
undef, $this->{WEB}, $this->{TOPIC}, $this->{BASE_REV}, | ||
$this->{CURR_REV}, 0 ); | ||
} | ||
$s =~ s/\n/\n /gs; | ||
$s = " $s"; | ||
$this->{TEXT_SUMMARY} = $s; | ||
} | ||
|
||
my $tim = Foswiki::Time::formatTime( $this->{TIME} ); | ||
|
||
# URL-encode topic names for use of I18N topic names in plain text | ||
# DEPRECATED! DO NOT USE! | ||
$template =~ s#%URL%#%SCRIPTURL{view}%/%ENCODE{%WEB%}%/%ENCODE{%TOPIC%}%#g; | ||
$template =~ s/%AUTHOR%/$this->{AUTHOR}/g; | ||
$template =~ s/%TIME%/$tim/g; | ||
$template =~ s/%CUR_REV%/$this->{CURR_REV}/g; | ||
$template =~ s/%BASE_REV%/$this->{BASE_REV}/g; | ||
$template =~ s/%TOPICNAME%/$this->{TOPIC}/g; # deprecated DO NOT USE! | ||
$template =~ s/%TOPIC%/$this->{TOPIC}/g; | ||
my $frev = ''; | ||
if( $this->{CURR_REV} ) { | ||
if( $this->{CURR_REV} > 1 ) { | ||
$frev = 'r'.$this->{BASE_REV}. | ||
'->r'.$this->{CURR_REV}; | ||
} else { | ||
# new _since the last notification_ | ||
$frev = 'NEW'; | ||
} | ||
} | ||
$template =~ s/%REVISION%/$frev/g; | ||
|
||
$template =~ s/%TEXTHEAD%/$this->{TEXT_SUMMARY}/g; | ||
return $template; | ||
} | ||
|
||
1; |
64 changes: 64 additions & 0 deletions
64
MailerContrib/lib/Foswiki/Contrib/MailerContrib/CompatibilityHacks.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Hack for older TWiki versions | ||
package CompatibilityHacks; | ||
|
||
package IteratorHack; | ||
|
||
sub new { | ||
my ($class, $list) = @_; | ||
my $this = bless({list => $list, index => 0, next => undef }, $class); | ||
return $this; | ||
} | ||
|
||
sub hasNext { | ||
my( $this ) = @_; | ||
return 1 if $this->{next}; | ||
if( $this->{index} < scalar(@{$this->{list}}) ) { | ||
$this->{next} = $this->{list}->[$this->{index}++]; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
sub next { | ||
my $this = shift; | ||
$this->hasNext(); | ||
my $n = $this->{next}; | ||
$this->{next} = undef; | ||
return $n; | ||
} | ||
|
||
package Foswiki::Func; | ||
|
||
sub eachChangeSince { | ||
my ($web, $since) = @_; | ||
|
||
my $changes; | ||
if( open(F, "<$Foswiki::cfg{DataDir}/$web/.changes")) { | ||
local $/ = undef; | ||
$changes = <F>; | ||
close(F); | ||
} | ||
|
||
$changes ||= ''; | ||
|
||
my @changes = | ||
map { | ||
# Create a hash for this line | ||
{ topic => $_->[0], user => $_->[1], time => $_->[2], | ||
revision => $_->[3], more => $_->[4] }; | ||
} | ||
grep { | ||
# Filter on time | ||
$_->[2] && $_->[2] >= $since | ||
} | ||
map { | ||
# Split line into an array | ||
my @row = split(/\t/, $_, 5); | ||
\@row; | ||
} | ||
reverse split( /[\r\n]+/, $changes); | ||
|
||
return new IteratorHack( \@changes ); | ||
} | ||
|
||
1; |
11 changes: 11 additions & 0 deletions
11
MailerContrib/lib/Foswiki/Contrib/MailerContrib/Config.spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ---+ Mail and Proxies | ||
# **REGEX** | ||
# Define the regular expression that an email address entered in WebNotify | ||
# must match to be identified as a legal email by the notifier. You can use | ||
# this expression to - for example - filter email addresses on your company | ||
# domain, or even block use of raw emails in WebNotify altogether (just make | ||
# it something that will never match, e.g. ='^notAnEmail$'=). | ||
# If this is not defined, then the default setting of | ||
# =[A-Za-z0-9.+-_]+\@[A-Za-z0-9.-]+= is used. | ||
$Foswiki::cfg{MailerContrib}{EmailFilterIn} = ''; | ||
|
22 changes: 22 additions & 0 deletions
22
MailerContrib/lib/Foswiki/Contrib/MailerContrib/Constants.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
=pod | ||
---+ package MailerConst | ||
$ALWAYS - always send, even if there are no changes | ||
$FULL_TOPIC - send the full topic rather than just changes | ||
Note that this package is defined in a file with a name different to that | ||
of the package. This is intentional (it's to keep the length of the constants | ||
package name short). | ||
=cut | ||
|
||
package MailerConst; | ||
|
||
our $ALWAYS = 1; # Always send, even if there are no changes | ||
our $FULL_TOPIC = 2; # Send the full topic rather than just changes | ||
|
||
# ? = FULL_TOPIC | ||
# ! = FULL_TOPIC | ALWAYS | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
URI,>=1.35,cpan,Required. Available from the CPAN:URI archive. | ||
URI::Escape,>=3.28,cpan,Required. Available from the CPAN:URI::Escape archive. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
lib/Foswiki/Contrib/MailerContrib/Config.spec 0444 Spec file for =configure= | ||
lib/Foswiki/Contrib/MailerContrib/WebNotify.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib/Subscriber.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib/Subscription.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib/TopicContext.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib/Change.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib/Constants.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib/UpData.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib/CompatibilityHacks.pm 0444 | ||
lib/Foswiki/Contrib/MailerContrib.pm 0444 | ||
data/System/MailerContrib.txt 0644 | ||
tools/mailnotify 0555 | ||
templates/mailnotify.tmpl 0444 | ||
templates/newsletter.tmpl 0444 | ||
pub/System/MailerContrib/wikiringlogo20x20.png 0660 | ||
pub/System/MailerContrib/logo.gif 0660 |
Oops, something went wrong.