Skip to content

Commit

Permalink
Item1256: Port MetaWorkflowPlugin to Foswiki
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/MetaWorkflowPlugin@3247 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
AndrewJones authored and AndrewJones committed Mar 23, 2009
1 parent 38b7e13 commit 166a9f0
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 69 deletions.
1 change: 1 addition & 0 deletions data/Sandbox/MetaWorkflowExample.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
%META:TOPICINFO{author="ProjectContributor" date="1170220558" format="1.1" version="0"}%
%META:TOPICPARENT{name="System.MetaWorkflowPlugin"}%

---+++ !MetaWorkflowPlugin Example

Expand Down
3 changes: 2 additions & 1 deletion data/Sandbox/MetaWorkflowExampleFormDefinition.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
%META:TOPICINFO{author="ProjectContributor" date="1170220558" format="1.1" version="0"}%
%META:TOPICPARENT{name="EngITProjectTemplate"}%
%META:TOPICPARENT{name="MetaWorkflowExample"}%

| *Name* | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* |
| Status | radio | 2 | Incomplete, Complete | | |

3 changes: 1 addition & 2 deletions data/Sandbox/MetaWorkflowExamplePhaseThree.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
%META:TOPICINFO{author="ProjectContributor" date="1170220558" format="1.1" version="0"}%
%META:TOPICPARENT{name="MetaWorkflowExample"}%
MetaWorkflowExample document.

-- Main.AndrewJones - 31 Jan 2007
MetaWorkflowExample document.

%META:FORM{name="Sandbox.MetaWorkflowExampleFormDefinition"}%
%META:FIELD{name="Status" attributes="" title="Status" value="Incomplete"}%
2 changes: 0 additions & 2 deletions data/Sandbox/MetaWorkflowExamplePhaseTwo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@

MetaWorkflowExample document.

-- Main.AndrewJones - 31 Jan 2007

%META:FORM{name="Sandbox.MetaWorkflowExampleFormDefinition"}%
%META:FIELD{name="Status" attributes="" title="Status" value="Complete"}%
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%META:TOPICINFO{author="ProjectContributor" date="1170220558" format="1.1" version="0"}%
---+!! !MetaWorkflowPlugin

This plugin defines a workflow based on updated meta data in a number of topics. It was originally written for use with the [[Foswiki:Extensions.WorkflowPlugin][WorkflowPlugin]], but can also be used to create a workflow using DataForms or any other changing meta data. To view the meta data of a topic, append ==?raw=debug== to the URL (i.e. %SCRIPTURL{"view"}%/%WEB%/%TOPIC%?raw=debug).
This plugin defines a workflow based on updated meta data in a number of topics. It was originally written for use with the [[Foswiki:Extensions.WorkflowPlugin][WorkflowPlugin]] and the [[Foswiki:Extensions.ApprovalPlugin][ApprovalPlugin]], but can also be used to create a workflow using DataForms or any other changing meta data. To view the meta data of a topic, append ==?raw=debug== to the URL (i.e. %SCRIPTURL{"view"}%/%WEB%/%TOPIC%?raw=debug).

%TOC%

Expand Down Expand Up @@ -34,7 +34,7 @@ A working example of using this plugin to create a workflow based on the value o

---++ Plugin Settings

* To suppress warnings on your topic, use the following (Note: only has effect on the topic it is set on):
To suppress warnings on your topic, use the following (Note: only has effect on the topic it is set on):
<verbatim>
* Set METAWORKFLOWWARNING = off
</verbatim>
Expand All @@ -50,15 +50,16 @@ A working example of using this plugin to create a workflow based on the value o

---++ Plugin Info

| Plugin Author(s): | TWiki:Main.AndrewRJones |
| Plugin Version: | %$VERSION% |
| Copyright: | &copy; |
| Plugin Author(s): | Foswiki:Main.AndrewJones |
| Copyright: | &copy; 2007 - 2009 Foswiki:Main.AndrewJones |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Plugin Release: | %$RELEASE% |
| Plugin Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 13997 | Initial version |
| 23 Mar 2009 | Foswiki:Tasks.Item1256 - Ported to Foswiki as 1.0 |
| 31 May 2007 | Initial version for TWiki |
| Dependencies: | %$DEPENDENCIES% |
| Plugin Home: | http://twiki.org/cgi-bin/view/Plugins/MetaWorkflowPlugin |
| Feedback: | http://twiki.org/cgi-bin/view/Plugins/MetaWorkflowPluginDev |
| Appraisal: | http://twiki.org/cgi-bin/view/Plugins/MetaWorkflowPluginAppraisal |
| Plugin Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC% |

<!-- Do _not_ attempt to edit this topic; it is auto-generated. Please add comments/questions/remarks to the Dev topic instead. -->
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2007 Andrew Jones, andrewjones86@googlemail.com
# Copyright (C) 2007 - 2009 Andrew Jones, andrewjones86@googlemail.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -12,31 +12,29 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For licensing info read LICENSE file in the TWiki root.
# For licensing info read LICENSE file in the Foswiki root.

package TWiki::Plugins::MetaWorkflowPlugin;
package Foswiki::Plugins::MetaWorkflowPlugin;
use strict;

require Foswiki::Func;
require Foswiki::Plugins;

use vars qw( $VERSION
$RELEASE
$NO_PREFS_IN_TOPIC
$SHORTDESCRIPTION
$pluginName
);

$VERSION = '$Rev: 9813$';
$RELEASE = 'Dakar';
$NO_PREFS_IN_TOPIC = 1;
$SHORTDESCRIPTION = 'Defines a workflow based on updated meta data (such as form fields, or meta data from another plugin)';
$pluginName = 'MetaWorkflowPlugin';
our $VERSION = '$Rev: 9813$';
our $RELEASE = '1.0';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Defines a workflow based on updated meta data (such as form fields, or meta data from another plugin)';
our $pluginName = 'MetaWorkflowPlugin';

# =========================
sub initPlugin {
# check for Plugins.pm versions
if( $TWiki::Plugins::VERSION < 1.026 ) {
TWiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" );
return 0;
}

# plugin correctly initialized
return 1;
}
Expand All @@ -57,17 +55,17 @@ sub _handleTag {

# look for METAWORKFLOWDEFINITION setting
my $defTopic = '';
($theWeb, $theTopic) = TWiki::Func::normalizeWebTopicName($theWeb, $defTopic)
if $defTopic = TWiki::Func::getPreferencesValue("METAWORKFLOWDEFINITION");
($theWeb, $theTopic) = Foswiki::Func::normalizeWebTopicName($theWeb, $defTopic)
if $defTopic = Foswiki::Func::getPreferencesValue("METAWORKFLOWDEFINITION");

return _returnError("Topic [[$theWeb.$theTopic]] does not exist. Check your METAWORKFLOWDEFINITION setting.")
unless TWiki::Func::topicExists($theWeb, $theTopic);
unless Foswiki::Func::topicExists($theWeb, $theTopic);

my (undef, $text) = TWiki::Func::readTopic($theWeb, $theTopic);
my (undef, $text) = Foswiki::Func::readTopic($theWeb, $theTopic);

if($text =~ m/%METAWORKFLOW{(.*)}%\n/g){
# in definition table
my %params = TWiki::Func::extractParameters($1);
my %params = Foswiki::Func::extractParameters($1);

while($text =~ m/\G\|(.*)\|(.*)\|(.*)\|\n?/gc){ # each row in table
my ($webTopic, $value, $message) = ($1, $2, $3);
Expand All @@ -82,13 +80,13 @@ sub _handleTag {
$webTopic =~ s/ //g;
next if $webTopic =~ m/\*.*\*/; # table header
return $message if lc$webTopic eq 'final';
my ($web, $topic) = TWiki::Func::normalizeWebTopicName($theWeb, $webTopic);
my ($web, $topic) = Foswiki::Func::normalizeWebTopicName($theWeb, $webTopic);

return _returnError("Topic [[$web.$topic]] does not exist. Check your %<nop>METAWORKFLOW{...}% table.")
unless TWiki::Func::topicExists($web, $topic);
unless Foswiki::Func::topicExists($web, $topic);

# get meta data
my ($meta, undef) = TWiki::Func::readTopic($web, $topic);
my ($meta, undef) = Foswiki::Func::readTopic($web, $topic);
my $att = $meta->get($params{type}, $params{name});
my $key = $params{key} || 'name';

Expand All @@ -109,18 +107,18 @@ sub _returnError {

_Debug($text);

my $warn = TWiki::Func::getPreferencesValue("METAWORKFLOWWARNING");
my $warn = Foswiki::Func::getPreferencesValue("METAWORKFLOWWARNING");
return if lc$warn eq 'off';

return "<span class='twikiAlert'>${pluginName} error: $text</span>";
return "<span class='foswikiAlert'>${pluginName} error: $text</span>";
}

sub _Debug {
my $text = shift;

my $debug = $TWiki::cfg{Plugins}{$pluginName}{Debug} || 0;
my $debug = $Foswiki::cfg{Plugins}{$pluginName}{Debug} || 0;

TWiki::Func::writeDebug( "- TWiki::Plugins::${pluginName}: $text" ) if $debug;
Foswiki::Func::writeDebug( "- Foswiki::Plugins::${pluginName}: $text" ) if $debug;
}

1;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

# Release manifest for MetaWorkflowPlugin
data/TWiki/MetaWorkflowPlugin.txt 0644 Documentation
data/System/MetaWorkflowPlugin.txt 0644 Documentation
data/Sandbox/MetaWorkflowExample.txt 0644 Example
data/Sandbox/MetaWorkflowExampleFormDefinition.txt 0644 Example
data/Sandbox/MetaWorkflowExamplePhaseOne.txt 0644 Example
data/Sandbox/MetaWorkflowExamplePhaseThree.txt 0644 Example
data/Sandbox/MetaWorkflowExamplePhaseTwo.txt 0644 Example
lib/TWiki/Plugins/MetaWorkflowPlugin.pm 0644 Perl module
lib/Foswiki/Plugins/MetaWorkflowPlugin.pm 0644 Perl module

12 changes: 12 additions & 0 deletions lib/Foswiki/Plugins/MetaWorkflowPlugin/build.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/perl -w
BEGIN {
unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} );
}
use Foswiki::Contrib::Build;

# Create the build object
$build = new Foswiki::Contrib::Build('MetaWorkflowPlugin');

# Build the target on the command line, or the default target
$build->build($build->{target});

27 changes: 0 additions & 27 deletions lib/TWiki/Plugins/MetaWorkflowPlugin/build.pl

This file was deleted.

0 comments on commit 166a9f0

Please sign in to comment.