Skip to content

Commit

Permalink
Item9742: initial checkin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/MoreFormfieldsContrib@9319 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Sep 23, 2010
0 parents commit 764620a
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 0 deletions.
39 changes: 39 additions & 0 deletions data/System/MoreFormfieldsContrib.txt
@@ -0,0 +1,39 @@
---+!! %TOPIC%
%SHORTDESCRIPTION%

%TOC%

This plugin implements a set of additional special purpose formfields to be used in [[%SYSTEMWEB%.DataForms][DataForm]] definitions.

These are:

* =ipaddress=: a general purpose IP4 address, consisting of 4 octets, e.g. =10.0.0.1=
* =netmask=: a special IP address used for routing, consisting of 4 octets, e.g. =255.255.255.0=
* =macaddress=: a hardware address given in 6 hex values, e.g. =00:1a:10:6f:ba:12=

---++ !ExampleForm definition

| *Name* | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* |
| <nop>IpAddress | ipaddress | 15 | | network address | M |
| Netmask | netmask | 15 | | netmask | |
| <nop>MacAddress | macaddress | 17 | | hardware-addresse | |

---++ Installation Instructions

%$INSTALL_INSTRUCTIONS%

---++ Info
<!--
* Set SHORTDESCRIPTION = Additionall formfield types for !DataForms
-->

| Author(s): | Michael Daum|
| Copyright: | &copy; 2010 Michael Daum http://michaeldaumconsulting.com |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 23 Sep 2010: | initial release |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |
21 changes: 21 additions & 0 deletions lib/Foswiki/Contrib/MoreFormfieldsContrib.pm
@@ -0,0 +1,21 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# MoreFormfieldsContrib is Copyright (C) 2010 Michael Daum http://michaeldaumconsulting.com
#
# 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.
#
# 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. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Contrib::MoreFormfieldsContrib;
our $VERSION = '$Rev$';
our $RELEASE = '0.01';
our $SHORTDESCRIPTION = 'Additionall formfield types for %SYSTEMWEB%.DataForms';

1;
1 change: 1 addition & 0 deletions lib/Foswiki/Contrib/MoreFormfieldsContrib/DEPENDENCIES
@@ -0,0 +1 @@
Foswiki::Plugins::JQueryPlugin,>3.31,perl,Required
16 changes: 16 additions & 0 deletions lib/Foswiki/Contrib/MoreFormfieldsContrib/MANIFEST
@@ -0,0 +1,16 @@
data/System/MoreFormfieldsContrib.txt 0644
lib/Foswiki/Contrib/MoreFormfieldsContrib.pm 0644
lib/Foswiki/Form/Ipaddress.pm 0644
lib/Foswiki/Form/Macaddress.pm 0644
lib/Foswiki/Form/Netmask.pm 0644
lib/Foswiki/Form/NetworkAddressField.pm 0644
pub/System/MoreFormfieldsContrib/Makefile 0644
pub/System/MoreFormfieldsContrib/moreformfields.css 0644
pub/System/MoreFormfieldsContrib/moreformfields.css.gz 0644
pub/System/MoreFormfieldsContrib/moreformfields.uncompressed.css 0644
pub/System/MoreFormfieldsContrib/networkaddress.js 0644
pub/System/MoreFormfieldsContrib/networkaddress.js.gz 0644
pub/System/MoreFormfieldsContrib/networkaddress.uncompressed.js 0644
pub/System/MoreFormfieldsContrib/validate.js 0644
pub/System/MoreFormfieldsContrib/validate.js.gz 0644
pub/System/MoreFormfieldsContrib/validate.uncompressed.js 0644
24 changes: 24 additions & 0 deletions lib/Foswiki/Contrib/MoreFormfieldsContrib/build.pl
@@ -0,0 +1,24 @@
#!/usr/bin/perl -w
BEGIN { unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} ); }
use Foswiki::Contrib::Build;

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

# (Optional) Set the details of the repository for uploads.
# This can be any web on any accessible Foswiki installation.
# These defaults will be used when expanding tokens in .txt
# files, but be warned, they can be overridden at upload time!

# name of web to upload to
$build->{UPLOADTARGETWEB} = 'Extensions';
# Full URL of pub directory
$build->{UPLOADTARGETPUB} = 'http://foswiki.org/pub';
# Full URL of bin directory
$build->{UPLOADTARGETSCRIPT} = 'http://foswiki.org/bin';
# Script extension
$build->{UPLOADTARGETSUFFIX} = '';

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

31 changes: 31 additions & 0 deletions lib/Foswiki/Form/Ipaddress.pm
@@ -0,0 +1,31 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# MoreFormfieldsContrib is Copyright (C) 2010 Michael Daum http://michaeldaumconsulting.com
#
# 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.
#
# 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. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Form::Ipaddress;

use strict;
use warnings;

use Foswiki::Form::NetworkAddressField ();
our @ISA = ('Foswiki::Form::NetworkAddressField');

sub new {
my $class = shift;
my $this = $class->SUPER::new(@_);
$this->{_class} = 'foswikiIpAddress';
return $this;
}

1;
31 changes: 31 additions & 0 deletions lib/Foswiki/Form/Macaddress.pm
@@ -0,0 +1,31 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# MoreFormfieldsContrib is Copyright (C) 2010 Michael Daum http://michaeldaumconsulting.com
#
# 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.
#
# 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. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Form::Macaddress;

use strict;
use warnings;

use Foswiki::Form::NetworkAddressField ();
our @ISA = ('Foswiki::Form::NetworkAddressField');

sub new {
my $class = shift;
my $this = $class->SUPER::new(@_);
$this->{_class} = 'foswikiMacAddress';
return $this;
}

1;
32 changes: 32 additions & 0 deletions lib/Foswiki/Form/Netmask.pm
@@ -0,0 +1,32 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# MoreFormfieldsContrib is Copyright (C) 2010 Michael Daum http://michaeldaumconsulting.com
#
# 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.
#
# 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. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Form::Netmask;

use strict;
use warnings;

use Foswiki::Form::NetworkAddressField ();
our @ISA = ('Foswiki::Form::NetworkAddressField');

sub new {
my $class = shift;
my $this = $class->SUPER::new(@_);
$this->{_class} = 'foswikiNetmask';
return $this;
}


1;
101 changes: 101 additions & 0 deletions lib/Foswiki/Form/NetworkAddressField.pm
@@ -0,0 +1,101 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# MoreFormfieldsContrib is Copyright (C) 2010 Michael Daum http://michaeldaumconsulting.com
#
# 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.
#
# 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. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Form::NetworkAddressField;

use strict;
use warnings;

use Foswiki::Form::Text ();
use Foswiki::Plugins::JQueryPlugin ();
our @ISA = ('Foswiki::Form::Text');

sub addJavascript {
#my $this = shift;
Foswiki::Func::addToZone("script",
"MOREFORMFIELDSCONTRIB::IPADDRESS::JS",
"<script src='%PUBURLPATH%/%SYSTEMWEB%/MoreFormfieldsContrib/networkaddress.js'></script>",
"JQUERYPLUGIN::FOSWIKI, JQUERYPLUGIN::LIVEQUERY, JQUERYPLUGIN::VALIDATE");

if ($Foswiki::cfg{Plugins}{MoreFormfieldsContrib}{Debug}) {
Foswiki::Plugins::JQueryPlugin::createPlugin("debug");
}

}

sub addStyles {
#my $this = shift;
Foswiki::Func::addToZone("head",
"MOREFORMFIELDSCONTRIB::IPADDRESS::CSS",
"<link rel='stylesheet' media='all' href='%PUBURLPATH%/%SYSTEMWEB%/MoreFormfieldsContrib/moreformfields.css' />");

}

sub renderForEdit {
my $this = shift;

# get args in a backwards compatible manor:
my $metaOrWeb = shift;

my $meta;
my $web;
my $topic;

if (ref($metaOrWeb)) {
# new: $this, $meta, $value
$meta = $metaOrWeb;
$web = $meta->web;
$topic = $meta->topic;
} else {
# old: $this, $web, $topic, $value
$web = $metaOrWeb;
$topic = shift;
($meta, undef) = Foswiki::Func::readTopic($web, $topic);
}

my $value = shift;

$this->addJavascript();
$this->addStyles();

my $required = '';
if ($this->{attributes} =~ /\bM\b/i) {
$required = 'required';
}

return (
'',
CGI::textfield(
-class => $this->cssClasses('foswikiInputField', $this->{_class}, $required),
-name => $this->{name},
-size => $this->{size},
-value => $value
)
);
}

sub renderForDisplay {
my ($this, $format, $value, $attrs) = @_;

my $result = "<div class='" . $this->{_class} . "'>$value</div>";
$format =~ s/\$value/$result/g;

$this->addStyles();

return $this->SUPER::renderForDisplay($format, $value, $attrs);
}


1;
6 changes: 6 additions & 0 deletions pub/System/MoreFormfieldsContrib/Makefile
@@ -0,0 +1,6 @@
FOSWIKI_ROOT?=~/foswiki/trunk/core
TARGET= \
moreformfields.css \
networkaddress.js

-include $(FOSWIKI_ROOT)/pub/System/JQueryPlugin/Makefile.include
@@ -0,0 +1,5 @@
.foswikiIpAddress,
.foswikiNetmask,
.foswikiMacAddress {
font-family:monospace;
}

0 comments on commit 764620a

Please sign in to comment.