new client side Ajax admin user interface
[bse.git] / site / cgi-bin / modules / BSE / UI / API.pm
1 package BSE::UI::API;
2 use strict;
3 use base "BSE::UI::Dispatch";
4
5 our $VERSION = "1.001";
6
7 my %actions =
8   (
9    config => 1,
10    fail => 1,
11   );
12
13 sub actions {
14   \%actions;
15 }
16
17 sub default_action {
18   "fail"
19 }
20
21 sub req_config {
22   my ($self, $req) = @_;
23
24   my $cfg = $req->cfg;
25   my %result =
26     (
27      success => 1,
28      perlbal => $cfg->entry("basic", "perlbal", 0),
29      access_control => $cfg->entry("basic", "access_control", 0),
30      tracking_uploads => $req->_tracking_uploads,
31     );
32
33   my %custom = $cfg->entries("extra a_config");
34   for my $key (keys %custom) {
35     exists $result{$key} and next;
36
37     my $section = $custom{$key};
38     $section =~ /\{(level|generator|parentid|template)\}/
39       and next;
40
41     $section eq "db" and die;
42
43     $result{$key} = { $cfg->entries($section) };
44   }
45
46   return $req->json_content(\%result);
47 }
48
49 sub req_fail {
50   my ($self, $req) = @_;
51
52   return $self->error($req, "Not for end-user use");
53 }
54
55 1;