summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libpiny/share/ikiwiki.setup2
-rw-r--r--pinyweb/Makefile2
-rwxr-xr-xpinyweb/cgi-bin/checkconstraint.cgi38
3 files changed, 24 insertions, 18 deletions
diff --git a/libpiny/share/ikiwiki.setup b/libpiny/share/ikiwiki.setup
index 18f8418..e6619d4 100644
--- a/libpiny/share/ikiwiki.setup
+++ b/libpiny/share/ikiwiki.setup
@@ -54,7 +54,7 @@ use IkiWiki::Setup::Standard {
prefix_directives => 1,
httpauth => 1,
# To add plugins, list them here.
- add_plugins => [qw{sidebar toc meta table tag graphviz httpauth img attachment rename remove map teximg version edittemplate}],
+ add_plugins => [qw{sidebar toc meta table tag graphviz httpauth img attachment rename remove map teximg version edittemplate rawhtml}],
disable_plugins => [qw{openid passwordauth}],
teximg_prefix => "\\documentclass{scrartcl}
\\usepackage[version=3]{mhchem}
diff --git a/pinyweb/Makefile b/pinyweb/Makefile
index 4c0055d..1dad8bd 100644
--- a/pinyweb/Makefile
+++ b/pinyweb/Makefile
@@ -3,7 +3,7 @@ build:
install:
install -o root -g root -m 755 -d $(DESTDIR)/usr/lib/cgi-bin/piny $(DESTDIR)/usr/sbin
- install -o root -g root -m 755 cgi-bin/newuser.cgi $(DESTDIR)/usr/lib/cgi-bin/piny
+ install -o root -g root -m 755 cgi-bin/checkconstraint.cgi cgi-bin/newuser.cgi $(DESTDIR)/usr/lib/cgi-bin/piny
install -o root -g root -m 755 cgi-bin/auth/* $(DESTDIR)/usr/lib/cgi-bin/piny/auth
install -o root -g shadow -m 4754 suid/piny-suid $(DESTDIR)/usr/sbin # FIXME: this should really be www-data somehow
diff --git a/pinyweb/cgi-bin/checkconstraint.cgi b/pinyweb/cgi-bin/checkconstraint.cgi
index 8db0903..e0a59c3 100755
--- a/pinyweb/cgi-bin/checkconstraint.cgi
+++ b/pinyweb/cgi-bin/checkconstraint.cgi
@@ -11,29 +11,35 @@ 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." } );
+if ( $q->request_method( ) eq "OPTIONS" ) {
+ print "Status: 200 OK\nAccess-Control-Allow-Headers: *\nAccess-Control-Allow-Methods: GET, OPTIONS, POST\nAccess-Control-Allow-Origin: *\nAccess-Control-Max-Age: 3600\nContent-Type: text/plain\n\n";
} 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 {
+ my $type = $q->param( 't' );
+ my $value = $q->param( 'v' );
+ if ( not defined $type or not defined $value ) {
print "Status: 200 OK\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 $error = $constraint->validate( $value );
+ my $constraint = find_type_constraint( $type );
- if ( defined $error ) {
- print encode_json( { "ok" => JSON::false, "msg" => $error } );
+ if ( not defined $constraint ) {
+ print "Status: 200 OK\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 encode_json( { "ok" => JSON::true } );
+
+ 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 } );
+ };
+
};
};