8 loadPredefinedStylesheets.pl [ uwobo_panel_conf_file ]
9 loadPredefinedStylesheets.pl { -u | --unload } [ uwobo_panel_conf_file ]
10 loadPredefinedStylesheets.pl { -r | --reload } [ uwobo_panel_conf_file ]
11 loadPredefinedStylesheets.pl { -h | --help } [ uwobo_panel_conf_file ]
13 If uwobo_panel_conf_file is provided, it's used as HTML file from which
14 parse XSLT stylesheets, otherwise UWOBO_PANEL_CONF environment variable
18 sub getPredefinedStylesheets ($) {
21 my $inForm = 0; # currenlty inside 'predefinedStylesheets' form
22 open(CONF, "< $confile") || die "Can't open $confile";
23 while(my $l = <CONF>) {
26 if ($l =~ /<form name="predefinedStylesheets">/) {
30 if ($l =~ /<\/form>/) {
32 } elsif ($l =~ /<option value="[^"]+">/) {
34 $val =~ s/.*<option value="([^"]+)".*>/$1/;
35 my ($key, $ur, $use_getter) = split /,/, $val;
36 $stylesconf{$key}[0] = $ur;
37 if ($use_getter =~ /true/) {
39 } elsif ($use_getter =~ /false/) {
42 die "Unknown value '$use_getter' for 'use_getter' field.";
44 $stylesconf{$key}[1] = $use_getter;
53 my $opt = shift || "";
54 die $usage if (($opt eq "-h") or ($opt eq "--help"));
55 if (($opt eq "-u") or ($opt eq "--unload")) {
57 } elsif (($opt eq "-r") or ($opt eq "--reload")) {
60 unshift (@ARGV, $opt);
63 shift || $ENV{"UWOBO_PANEL_CONF"} || die "UWOBO_PANEL_CONF not defined";
64 my $getter_url = $ENV{"HELM_GETTER_URL"} || die "HELM_GETTER_URL not defined";
65 my $uwobo_url = $ENV{"HELM_UWOBO_URL"} || die "HELM_UWOBO_URL not defined";
66 my %styles = getPredefinedStylesheets($confile);
69 if ($action eq "load") { # load predefined stylesheets
70 foreach my $k (keys %styles) {
71 $request_url .= "&" unless ($request_url eq "");
72 my $ur = $styles{$k}[0];
73 my $use_getter = $styles{$k}[1];
74 $request_url .= "bind=$k,";
77 $tmp .= $getter_url . "getxslt?uri="
80 $request_url .= uri_escape($tmp);
82 $request_url = $uwobo_url . "add?$request_url";
84 } elsif ($action eq "unload") { # unload predefined stylesheets
85 $request_url = $uwobo_url . "remove?keys=" . join(',', keys %styles);
87 } elsif ($action eq "reload") { # reload predefined stylesheets
88 $request_url = $uwobo_url . "reload?keys=" . join(',', keys %styles);
90 } else { # unknown action
91 die "Unknown action '$action'";
94 my $agent = LWP::UserAgent->new();
95 my $response = $agent->get($request_url);
96 print $response->as_string();
97 # print "$request_url\n";