#!/usr/bin/perl -w
use strict;
-my $confile = $ENV{"UWOBO_PANEL_CONF"} || die "UWOBO_PANEL_CONF not defined";
-
use LWP::UserAgent;
use URI::Escape;
-sub getPredefinedStylesheets () {
+my $usage = <<EOHELP;
+loadPredefinedStylesheets.pl
+loadPredefinedStylesheets.pl { -u | --unload }
+loadPredefinedStylesheets.pl { -r | --reload }
+loadPredefinedStylesheets.pl { -h | --help }
+EOHELP
+
+sub getPredefinedStylesheets ($) {
+ my $confile = shift;
my %stylesconf;
my $inForm = 0; # currenlty inside 'predefinedStylesheets' form
open(CONF, "< $confile") || die "Can't open $confile";
return %stylesconf;
}
-sub main () {
- my $getter_url = $ENV{"HELM_GETTER_URL"} || die "HELM_GETTER_URL not defined";
- my $uwobo_url = $ENV{"HELM_UWOBO_URL"} || die "HELM_UWOBO_URL not defined";
- my %styles = getPredefinedStylesheets();
- my $request_url = "";
+my $action = "load";
+my $opt = shift || "";
+die $usage if (($opt eq "-h") or ($opt eq "--helm"));
+$action = "unload" if (($opt eq "-u") or ($opt eq "--unload"));
+$action = "reload" if (($opt eq "-r") or ($opt eq "--reload"));
+
+my $confile = $ENV{"UWOBO_PANEL_CONF"} || die "UWOBO_PANEL_CONF not defined";
+my $getter_url = $ENV{"HELM_GETTER_URL"} || die "HELM_GETTER_URL not defined";
+my $uwobo_url = $ENV{"HELM_UWOBO_URL"} || die "HELM_UWOBO_URL not defined";
+my %styles = getPredefinedStylesheets($confile);
+my $request_url = "";
+
+if ($action eq "load") { # load predefined stylesheets
foreach my $k (keys %styles) {
$request_url .= "&" unless ($request_url eq "");
my $ur = $styles{$k}[0];
$request_url .= uri_escape($tmp);
}
$request_url = $uwobo_url . "add?$request_url";
- my $agent = LWP::UserAgent->new();
- my $response = $agent->get($request_url);
- print $response->as_string();
-# print "$request_url\n";
+
+} elsif ($action eq "unload") { # unload predefined stylesheets
+ $request_url = $uwobo_url . "remove?keys=" . join(',', keys %styles);
+
+} elsif ($action eq "reload") { # reload predefined stylesheets
+ $request_url = $uwobo_url . "reload?keys=" . join(',', keys %styles);
+
+} else { # unknown action
+ die "Unknown action '$action'";
}
-main();
+my $agent = LWP::UserAgent->new();
+my $response = $agent->get($request_url);
+print $response->as_string();
+# print "$request_url\n";