From 227bc1cf0ca83a2158815093c485114101550c0a Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Tue, 18 Jan 2011 17:31:02 -0800 Subject: Permissions on newuser.cgi for ease of testing. --- pinyweb/cgi-bin/newuser.cgi | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 pinyweb/cgi-bin/newuser.cgi (limited to 'pinyweb/cgi-bin') diff --git a/pinyweb/cgi-bin/newuser.cgi b/pinyweb/cgi-bin/newuser.cgi old mode 100644 new mode 100755 -- cgit v1.2.3 From 0c395cf4516981ef0f9b56a082d700f6fc4697e9 Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Tue, 18 Jan 2011 17:45:58 -0800 Subject: Adding a CGI for doing AJAX-style live validation of constraints. --- pinyweb/cgi-bin/checkconstraint.cgi | 41 +++++++++++++++++++++++++++++++++++++ pinyweb/debian/control | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 pinyweb/cgi-bin/checkconstraint.cgi (limited to 'pinyweb/cgi-bin') diff --git a/pinyweb/cgi-bin/checkconstraint.cgi b/pinyweb/cgi-bin/checkconstraint.cgi new file mode 100755 index 0000000..8db0903 --- /dev/null +++ b/pinyweb/cgi-bin/checkconstraint.cgi @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use CGI; +use JSON qw( encode_json ); +use Moose::Util::TypeConstraints qw( find_type_constraint ); + +use Piny; + +my $q = CGI->new( ); + +my $type = $q->param( 't' ); +my $value = $q->param( 'v' ); + +if ( not defined $type or not defined $value ) { + print "Status: 400 Bad Request\nContent-type: application/json\n\n"; + print encode_json( { "ok" => JSON::false, "msg" => "Unable to validate due to client-side error, please reload this page. Required parameter missing." } ); +} else { + + my $constraint = find_type_constraint( $type ); + + if ( not defined $constraint ) { + print "Status: 400 Bad Request\nContent-type: application/json\n\n"; + print encode_json( { "ok" => JSON::false, "msg" => "Unable to validate due to client-side error, please reload this page. Invalid constraint name." } ); + } else { + + print "Status: 200 OK\nContent-type: application/json\n\n"; + + my $error = $constraint->validate( $value ); + + if ( defined $error ) { + print encode_json( { "ok" => JSON::false, "msg" => $error } ); + } else { + print encode_json( { "ok" => JSON::true } ); + }; + + }; + +}; diff --git a/pinyweb/debian/control b/pinyweb/debian/control index 3758c95..97e5537 100644 --- a/pinyweb/debian/control +++ b/pinyweb/debian/control @@ -8,7 +8,7 @@ Standards-version: 3.9.1 Package: pinyweb Architecture: any -Depends: ${perl:Depends}, ${misc:Depends}, ${shlibs:Depends}, libpiny-perl (>= 0.14), pinyadmin (>= 0.10) +Depends: ${perl:Depends}, ${misc:Depends}, ${shlibs:Depends}, libjson-perl, libpiny-perl (>= 0.14), pinyadmin (>= 0.10) Description: CGIs for managing piny repositories The CGI programs for day-to-day administrative tasks in the Piny infrastructure. -- cgit v1.2.3