Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $/ = undef;
- my $text = <>;
- # Don't replace existing form
- 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 Pub
- lic License]])',
- Home => 'http://foswiki.org/Extensions/%$ROOTMODULE%',
- Support => 'http://foswiki.org/Support/%$ROOTMODULE%',
- Repository => 'https://github.com/foswiki/distro'
- );
- 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*(.*?)\s*
- \|\n/\n/i) {
- $data{$field} = $1;
- $data{$field} =~ s/%TOPIC%/%\$ROOTMODULE%/g;
- $data{$field} =~ s/(["\r\n])/'%'.sprintf('%02x',ord($1))/ge;
- }
- $form .= "\%META:FIELD{name=\"$field\" ";
- $form .= "title=\"$field\" value=\"$data{$field}\"}%\n";
- }
- $text .= $form;
- }
- print $text;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement