Changeset 13777


Ignore:
Timestamp:
01/22/12 15:23:10 (4 weeks ago)
Author:
GeorgeClark
Message:

Item9551: More updates to ImmediateNotify

Pulled the Twitter and IRC code from TweetOnSavePlugin and IrcPlugin.
Not functional here yet, need converting. Changed the templates to real
templates, so they can be more easily overridden using Topic templates.

Added a beforeSaveHandler and a NewTopic context - so the messages can
more easily show created vs updated topics.

Eliminated the MIME multipart headers from the email template, since a
single part message using multipart headers causes issues in Outlook.

Location:
trunk/ImmediateNotifyPlugin
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin.pm

    r13772 r13777  
    8181        next if ( $method eq "Module" ); 
    8282        next if ( $method eq "Enabled" ); 
     83        next if ( $method eq "Bitly" ); 
    8384        if ( $Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{$method}{Enabled} ) { 
    8485            debug("Allowing method $method"); 
     
    215216                my ( $method, $parms ) = 
    216217                  $methodString =~ m/^(.*?)(?:\((.*?)\))?$/; 
     218                  $parms |= ''; 
    217219                debug( 
    218220"- ImmediateNotifyPlugin: processName: User $name found method ($method) parms ($parms) " 
     
    236238} 
    237239 
     240 
     241=begin TML 
     242 
     243---+ beforeSaveHandler 
     244 
     245Set a flag if this is a new topic. 
     246 
     247=cut 
     248 
     249sub beforeSaveHandler { 
     250    my ( $text, $topic, $web, $meta ) = @_; 
     251 
     252    unless ( Foswiki::Func::topicExists($web, $topic) ) { 
     253      Foswiki::Func::getContext()->{'NewTopic'} = 1; 
     254    } 
     255} 
     256 
    238257=begin TML 
    239258 
  • trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin/Config.spec

    r12051 r13777  
    11# ---+ Extensions 
    22# ---++ ImmediateNotifyPlugin 
     3# ---+++ EMail Notifications 
    34# **BOOLEAN** 
    45# Enable SMTP for mailing messages. Note:  This plugin uses Foswiki core email support for sending 
     
    1516$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{SMTP}{EmailFilterIn} = ''; 
    1617 
     18# ---+++ Jabber / XMPP 
    1719# **BOOLEAN** 
    1820# Enable XMPP (XMPP) for notifications. 
     
    3335$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{XMPP}{Password} = ''; 
    3436 
     37# ---+++ Twitter 
     38# **BOOLEAN** 
     39# Enable Twitter for notifications. 
     40$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Twitter}{Enabled} = $FALSE; 
     41 
     42# **STRING 30** 
     43# Specify the username for the twitter account 
     44$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Twitter}{Username} = ''; 
     45 
     46# **PASSWORD 30** 
     47# Specify the password for the twitter account 
     48$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Twitter}{Password} = ''; 
     49 
     50# ---+++ Bit.ly URL Shortening 
     51# **BOOLEAN** 
     52# Enable URL Shortening with Bit.ly. 
     53$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Bitly}{Enabled} = $FALSE; 
     54 
     55# **STRING** 
     56# Optionally, specify a bit.ly username 
     57$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Bitly}{Username} = ''; 
     58 
     59# **STRING** 
     60# Optionally, specify a bit.ly API key 
     61$Foswiki::cfg{Plugins}{ImmediateNotifyPlugin}{Bitlly}{APIKey} = ''; 
  • trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin/SMTP.pm

    r12252 r13777  
    4343    my ($template) = Foswiki::Func::readTemplate( 'smtp', 'immediatenotify' ); 
    4444 
    45     # &$debug("- SMTP:  template read $template"); 
     45    # Expand legacy macros 
    4646    my ($from) = Foswiki::Func::getPreferencesValue("WIKIWEBMASTER"); 
    47  
    4847    $template =~ s/%EMAILFROM%/$from/go; 
    49     $template =~ s/%WEB%/$info->{web}/go; 
    5048    $template =~ s/%TOPICNAME%/$info->{topic}/go; 
    5149    $template =~ s/%USER%/$info->{user}/go; 
  • trunk/ImmediateNotifyPlugin/lib/Foswiki/Plugins/ImmediateNotifyPlugin/XMPP.pm

    r13772 r13777  
    105105    my ($template) = Foswiki::Func::readTemplate( 'xmpp', 'immediatenotify' ); 
    106106 
    107     # &$debug("- SMTP:  template read $template"); 
     107    &$debug("- XMPP:  template read $template"); 
     108 
     109    # Expand Legacy variables - not used in latest templates 
    108110    my ($from) = Foswiki::Func::getPreferencesValue("WIKIWEBMASTER"); 
    109  
    110111    $template =~ s/%EMAILFROM%/$from/go; 
    111     $template =~ s/%WEB%/$info->{web}/go; 
     112    $template =~ s/%USER%/$info->{user}/go; 
    112113    $template =~ s/%TOPICNAME%/$info->{topic}/go; 
    113     $template =~ s/%USER%/$info->{user}/go; 
    114114    $template =~ s/%REV%/$info->{version}/go; 
    115115 
     
    125125        &$debug(" processing $user"); 
    126126 
    127         #&$debug(" userref = ".ref($userHash->{$user})); 
    128127        my %uHash = %{ $userHash->{$user} }; 
    129128 
  • trunk/ImmediateNotifyPlugin/templates/smtp.immediatenotify.tmpl

    r12048 r13777  
    1 From: %WIKIWEBMASTER% 
     1%TMPL:DEF{smtpHeaders}%From: %WIKIWEBMASTER% 
    22To: %EMAILTO% 
    33Subject: %WIKITOOLNAME%.%WEB%.%TOPICNAME% - Immediate notification of topic change 
    44MIME-Version: 1.0 
    5 Content-Type: multipart/mixed; boundary="------------2D594AE113AD25493C2C7246" 
    6  
    7 This is a multi-part message in MIME format. 
    8 --------------2D594AE113AD25493C2C7246 
    95Content-Type: text/plain; charset=%CHARSET% 
    106Content-Transfer-Encoding: 8bit 
    117 
     8%TMPL:END% 
     9%TMPL:DEF{smtpMessage}% 
    1210This is an automatically generated email. 
    1311 
    14 %USER% has created or changed the topic 
    15 %SCRIPTURL{"view"}%/%WEB%/%TOPICNAME% - Revision %REV% 
     12%WIKINAME% has %IF{"context NewTopic" then="created" else="changed"}% the topic 
     13%SCRIPTURL{"view"}%/%WEB%/%TOPIC% - Revision %REVINFO{format="r1.$rev"}% 
    1614 
    1715-- 
     
    2018   * The IMMEDIATENOTIFY list in the modified topic 
    2119   * The %SCRIPTURL{"view"}%/%WEB%/WebImmediateNotify topic 
     20%TMPL:END% 
     21%TMPL:P{smtpHeaders}%%TMPL:P{smtpMessage}% 
  • trunk/ImmediateNotifyPlugin/templates/xmpp.immediatenotify.tmpl

    r12051 r13777  
    1 %USER% has created or changed the topic %SCRIPTURL{"view"}%/%WEB%/%TOPICNAME% - Revision %REV% 
     1%TMPL:DEF{xmppBody}%%WIKINAME% has %IF{"context NewTopic" then="created" else="changed"}% the topic %SCRIPTURL{"view"}%/%WEB%/%TOPIC% Rev:%REVINFO{format="r1.$rev"}% %INCLUDE{"%WEB%.%TOPIC%" section="NOTIFYTEXT" warn="off"}%%TMPL:END% 
     2%TMPL:P{xmppBody}% 
Note: See TracChangeset for help on using the changeset viewer.