Skip to content

Commit

Permalink
Item13285: admin: simplify extension forms but making a standard Pack…
Browse files Browse the repository at this point in the history
…ageForm (that can be overridden in Extensions web to add more good stuff)
  • Loading branch information
Comment committed Mar 1, 2015
1 parent 7027a86 commit 023e0e5
Show file tree
Hide file tree
Showing 42 changed files with 598 additions and 431 deletions.
20 changes: 11 additions & 9 deletions AutoViewTemplatePlugin/data/System/AutoViewTemplatePlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1302471867" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1425223586" format="1.1" version="1"}%
---+ <nop>AutoViewTemplatePlugin
%SHORTDESCRIPTION%

Expand Down Expand Up @@ -72,12 +72,6 @@ The following settings can be defined in configure
* Set SHORTDESCRIPTION = Automatically sets VIEW_TEMPLATE and EDIT_TEMPLATE
%JQREQUIRE{"chili"}%
-->
| Plugin Author: | Foswiki:Main.OliverKrueger |
| Copyright: | &copy; 2008-2009, Oliver Krueger |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Contributors: | Foswiki:Main.MichaelDaum |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 16 Dec 2012: | Version released with Foswiki 1.1.7. Foswikitask:Item12297: Minor perllcritic change.|
| 10 Apr 2011: | Version released with Foswiki 1.1.3. Only a minor change related to how the plugin is being upgraded |
Expand All @@ -97,5 +91,13 @@ The following settings can be defined in configure
| Foswiki Dependency: | $Foswiki::Plugins::VERSION 1.026 |
| CPAN Dependencies: | none |
| Other Dependencies: | none |
| Home: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Extensions/%TOPIC% |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Home" title="Home" value="Foswiki:Extensions/AutoViewTemplatePlugin"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Author" title="Author" value="Foswiki:Main.OliverKrueger, Foswiki:Main.MichaelDaum"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2008-2009, Oliver Krueger"}%
%META:FIELD{name="Support" title="Support" value="Foswiki:Extensions/AutoViewTemplatePlugin"}%

41 changes: 41 additions & 0 deletions BuildContrib/lib/Foswiki/Contrib/BuildContrib/Targets/stage.pm
Expand Up @@ -19,6 +19,45 @@ use strict;

our @stageFilters;

sub form_repair {
my ( $this, $from, $to ) = @_;

$this->filter_file(
$from, $to,
sub {
my ( $this, $text ) = @_;

# Don't replace existing form
return $text if $text =~ /^\%META:FORM{/m;

# Extract form data from text
my %data = (
Author => "ProjectContributor",
Release => '%$RELEASE%',
Version => '%$VERSION%',
Copyright => 'Foswiki Contributors, All Rights Reserved',
License =>
'GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])',
Home => 'http://foswiki.org/Extensions/%$ROOTMODULE%',
Support => 'http://foswiki.org/Support/%$ROOTMODULE%'
);
my $form = "\n\%META:FORM{name=\"PackageForm\"}%\n";
foreach my $field ( sort keys %data ) {
if ( $text =~
s/\n\|\s*(?:Plugin\s+)?$field(?:\(s\))?:?\s*\|\s*(.*?)\s*\|\n/\n/i
)
{
$data{$field} = $1;
$data{$field} =~ s/(["\r\n])/'%'.sprintf('%02x',ord($1))/ge;
}
$form .= "\%META:FIELD{name=\"$field\" ";
$form .= "title=\"$field\" value=\"$data{$field}\"}%\n";
}
return $text . $form;
}
);
}

=begin TML
---++++ target_stage
Expand All @@ -30,6 +69,8 @@ sub target_stage {
my $this = shift;
my $project = $this->{project};

push( @stageFilters,
{ RE => qr/$project\.txt$/, filter => 'form_repair' } );
push( @stageFilters, { RE => qr/\.txt$/, filter => 'filter_txt' } );
push( @stageFilters, { RE => qr/\.pm$/, filter => 'filter_pm' } );

Expand Down
107 changes: 60 additions & 47 deletions BuildContrib/lib/Foswiki/Contrib/BuildContrib/Targets/upload.pm
Expand Up @@ -60,6 +60,32 @@ my $lastUpload = 0; # time of last upload (0 means none yet)
}
}

sub recover_form {

#my ($text, $form) = @_;
my $sawn = 0;

while ( $_[0] =~
s/(^|\n)%META:FIELD{name="([^"]*?)"[^}]*?value="([^"]*?)"[^}]*?}%(\n|$)/$1/s
)
{
my $name = $1;
my $val = $2;

# decode the value
$val =~ s/%([\da-f]{2})/chr(hex($1))/gei;

# Trim null values or we end up damaging the form
if ( defined $val && length($val) ) {
$_[1]->{$name} = $val;
}
$sawn++;
}
$_[0] =~ s/(^|\n)%META:FORM{name=[^}]*?}%(\n|$)/$1/s;

return $sawn;
}

=begin TML
---++++ target_upload
Expand Down Expand Up @@ -181,9 +207,17 @@ END
# Get the old form data and attach it to the update
print "Downloading $topic to recover form\n";
my $response = $userAgent->get("$url?raw=all");
my $etype = "Contrib";
if ( $this->{project} =~ /(Plugin|Skin|Contrib|AddOn)$/ ) {
$etyle = $1 unless $1 eq 'AddOn';
}

my %newform;
my $formExists = 0;
my %form = (
formtemplate => 'PackageForm',
ExtensionType => $etype . 'Package',
SupportUrl => 'Support.' . $this->{project},
DemoUrl => 'http://'
);

# SMELL: There appears to be no way to distinguish if Foswiki didn't
# find the topic and returns the topic creator form, or if the GET
Expand All @@ -192,9 +226,19 @@ END
# For now, look to see if there is a newtopicform present. If found,
# it means that the get should be treated as a NOT FOUND.

unless ( $response->is_success()
if ( $response->is_success()
&& !( $response->content() =~ m/<form name="newtopicform"/s ) )
{
print "Recovering form from $topic\n";

# SMELL: would be better to use Foswiki::Meta to do this
unless ( recover_form( $response->content(), \%form ) ) {
print STDERR "======= WARNING =======\n";
print STDERR
"A default package form was created. Please verify the setting on the uploaded topic\n";
}
}
else {
if ( !$response->is_success ) {
print 'Failed to GET old topic ', $response->request->uri,
' -- ', $response->status_line, "\n";
Expand All @@ -205,60 +249,29 @@ END
{
print "Downloading $topic from $alturl to recover form\n";
$response = $userAgent->get("$alturl?raw=all");
unless ( $response->is_success ) {
print 'Failed to GET old topic from Alternate location',
$response->request->uri,
$newform{formtemplate} = 'PackageForm';
if ( $this->{project} =~ /(Plugin|Skin|Contrib|AddOn)$/ ) {
$newform{ExtensionType} = $1 . 'Package';
}
if ( $response->is_success
&& !( $response->content() =~ m/<form name="newtopicform"/s )
&& recover_form( $response->content(), \%form ) )
{
}
}
}
if ( $response->is_success()
&& !( $response->content() =~ m/<form name="newtopicform"/s ) )
{
print "Recovering form from $topic\n";

# SMELL: would be better to use Foswiki::Meta to do this
foreach my $line ( split( /\n/, $response->content() ) ) {

if ( $line =~ m/%META:FIELD{name="(.*?)".*?value="(.*?)"/ ) {
my $name = $1;
my $val = $2;

# URL-decode the value
$val =~ s/%([\da-f]{2})/chr(hex($1))/gei;

# Trim null values or we end up damaging the form
if ( defined $val && length($val) ) {
$newform{$name} = $val;
else {
unless ( $response->is_success ) {
print 'Failed to GET old topic from Alternate location',
$response->request->uri,
;
}
}
elsif ( $line =~ /META:FORM{name="PackageForm/ ) {
$newform{formtemplate} = 'PackageForm';
$formExists = 1;
}
}

# Assign a package form and set some basic defaults
if ( !$formExists ) {
$newform{formtemplate} ||= 'PackageForm';
if ( $this->{project} =~ /(Plugin|Skin|Contrib|AddOn)$/ ) {
$newform{ExtensionType} ||= $1 . 'Package';
$newform{ExtensionType} =~ s/^AddOn/Contrib/;
$newform{SupportUrl} = 'Support.' . $this->{project};
$newform{DemoUrl} = 'http://';
print STDERR "======= WARNING =======\n";
print STDERR
"A default package form was created. Please verify the setting on the uploaded topic\n";
}
}
}

$newform{text} = $topicText;
# Override what is read from the web with the form in the new topic
recover_form( $topicText, \%form );
$form{text} = $topicText;

$this->_uploadTopic( $userAgent, $user, $pass, $topic, \%newform );
$this->_uploadTopic( $userAgent, $user, $pass, $topic, \%form );

# Upload any 'Var*.txt' topics published by the extension
my $dataDir = $this->{basedir} . '/data/System';
Expand Down
20 changes: 11 additions & 9 deletions CommentPlugin/data/System/CommentPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1423445948" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1425223965" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
---+!! Comment Plugin

Expand Down Expand Up @@ -253,11 +253,6 @@ This plugin has been significantly changed from the =10 April 2011= version ship
---++ Info
Another great extension from the <a style="text-decoration:none" href="http://wikiring.com"><img src="%ATTACHURLPATH%/wikiringlogo20x20.png" alt="" /> *WikiRing* </a> - working together to improve your wiki experience!

| Plugin Author: | Foswiki:Main.CrawfordCurrie http://www.c-dot.co.uk inspired by the work of TWiki:Main.DavidWeller and TWiki:Main.PeterMasiar |
| Copyright: | &copy; 2004, Foswiki:Main.CrawfordCurrie<br />&copy; 2004-2014 Foswiki:%SYSTEMWEB%.ProjectContributor |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | |
| 2.3 ( 18 Dec 2014) | Foswikitask:Item12855: Core extensions should require JQueryPlugin 6.00<br />\
Foswikitask:Item13125: CGI changes for multi-value parameters<br />\
Expand Down Expand Up @@ -290,7 +285,14 @@ Another great extension from the <a style="text-decoration:none" href="http://wi
| 13 Jan 2009 | Foswikitask:Item736 - Make !CommentPlugin aware of CompareRevisionsAddOn bin script. |
| 16 Dec 2008 | Foswiki version |
| 06 Mar 2002 | initial commit |
| Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC% |

%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" date="1423445948" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" date="1425223965" user="ProjectContributor" version="1"}%

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/CommentPlugin"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Copyright" title="Copyright" value="&copy; 2004, Foswiki:Main.CrawfordCurrie<br />&copy; 2004-2014 Foswiki:%SYSTEMWEB%.ProjectContributor"}%
%META:FIELD{name="Author" title="Author" value="Foswiki:Main.CrawfordCurrie http://www.c-dot.co.uk inspired by the work of TWiki:Main.DavidWeller and TWiki:Main.PeterMasiar"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/CommentPlugin"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
20 changes: 12 additions & 8 deletions CompareRevisionsAddOn/data/System/CompareRevisionsAddOn.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1421599902" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1425223586" format="1.1" version="1"}%
<!--
One line description, required for extensions repository catalog.
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
Expand Down Expand Up @@ -132,11 +132,7 @@ This Add-On comes pre-installed on Foswiki. You should only need to re-install i

---++ Add-On Info

| Plugin Author: | Foswiki:Main.KennethLavrsen |
| Copyright &copy;: | 2006, !JChristophFuchs; 2008-2014 Kenneth Lavrsen and Foswiki Contributors |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 18 Dec 2014 (1.113) | Foswikitask:Item13068: Remove the CompareRevisionsAddOn demo, don't ship revision history<br />\
Foswikitask:Item11737: Change hardcoded Main to %USERSWEB% <br \>/
Expand Down Expand Up @@ -176,8 +172,16 @@ This Add-On comes pre-installed on Foswiki. You should only need to re-install i
| 20 Jan 2005 | Initial version |
| Dependencies: | %$DEPENDENCIES% |
| Add-on Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC% |
__Related Topic:__ %SYSTEMWEB%.ContributedAddOns

%META:FILEATTACHMENT{name="interweave.png" attachment="interweave.png" attr="h" comment="" date="1421599902" path="interweave.png" size="24037" stream="interweave.png" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="sidebyside.png" attachment="sidebyside.png" attr="h" comment="" date="1421599902" path="sidebyside.png" size="35098" stream="interweave.png" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="interweave.png" attachment="interweave.png" attr="h" comment="" date="1425223586" path="interweave.png" size="24037" stream="interweave.png" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="sidebyside.png" attachment="sidebyside.png" attr="h" comment="" date="1425223586" path="sidebyside.png" size="35098" stream="interweave.png" user="ProjectContributor" version="1"}%

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="Foswiki:Main.KennethLavrsen"}%
%META:FIELD{name="Copyright" title="Copyright" value="Foswiki Contributors, All Rights Reserved"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%$ROOTMODULE%"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/%$ROOTMODULE%"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
18 changes: 10 additions & 8 deletions ConfigurePlugin/data/System/ConfigurePlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1418948242" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1425223586" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
<!--
One line description, required for extensions repository catalog.
Expand Down Expand Up @@ -44,13 +44,15 @@ The plugin uses the =JsonRpcContrib=, which must be installed.

---++ Info

| Author: | CrawfordCurrie |
| Copyright: | 2013-2014, CrawfordCurrie http://c-dot.co.uk, All Rights Reserved |
| License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
| Dependencies: | %$DEPENDENCIES% |
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change&nbsp;History: | <!-- versions below in reverse order -->&nbsp; |
| 1.01 (18 Dec 2014): | Initial version |
| Home: | http://foswiki.org/Extensions/%TOPIC% |
| Support: | http://foswiki.org/Support/%TOPIC% |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="CrawfordCurrie"}%
%META:FIELD{name="Copyright" title="Copyright" value="2013-2014, CrawfordCurrie http://c-dot.co.uk, All Rights Reserved"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%$ROOTMODULE%"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Release" title="Release" value="%$RELEASE%"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/%$ROOTMODULE%"}%
%META:FIELD{name="Version" title="Version" value="%$VERSION%"}%
Expand Up @@ -105,7 +105,13 @@ var Types = {};
// trim ' from the default
var val = this.spec['default'];
if (typeof(val) === 'string') {
val = val.replace(/^\s*(["'])(.*)\1\s*$/, "$2");
if (/^\s*'.*'\s*$/.test(val)) {
// We can't use eval because JS eval behaves differently
// to perl eval of a single-quoted string. The currentValue
// comes from a perl eval.
val = val.replace(/^\s*'(.*)'\s*$/, "$1");
val = val.replace(/\\'/g, "'");
}
}
return this.currentValue() === val;
}
Expand Down

0 comments on commit 023e0e5

Please sign in to comment.