Permalink
Browse files

Fix serving of static files.

This commit fixes the serving of static files for instances of
DJabberd not running relative to the docroot. It introduces a
new configuration option for this plugin called docroot.
  • Loading branch information...
1 parent a8fdfc1 commit 4880edc0be5662b39c8e242644a059e94a117953 @dominikschulz committed Feb 26, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/DJabberd/WebAdmin.pm
View
@@ -48,6 +48,14 @@ sub set_config_listenaddr {
$self->{listenaddr} = "127.0.0.1:".$self->{listenaddr} if $self->{listenaddr} =~ /^\d+$/;
}
+sub set_config_docroot {
+ my ($self, $dir) = @_;
+
+ if($dir && -d $dir) {
+ $self->{docroot} = $dir;
+ }
+}
+
sub finalize {
my ($self) = @_;
@@ -63,6 +71,7 @@ sub finalize {
$pbsvc->set('listen', $self->{listenaddr});
$pbsvc->set('role', 'web_server');
$pbsvc->set('plugins', 'cgilike');
+ $pbsvc->set('docroot', $self->{docroot}) if $self->{docroot};
# It'd be good if there was a nicer API to do this, but whatever
$pbsvc->run_manage_command('PERLHANDLER = DJabberd::WebAdmin::handle_web_request');
@@ -147,6 +156,7 @@ sub handle_static_resource {
$fn = 'stat/'.$name.'.png';
$type = 'image/png';
}
+ $fn = $r->{docroot}.'/'.$fn if $r->{docroot};
return 404 unless defined($fn) && -f $fn;
@@ -199,6 +209,7 @@ sub determine_page_for_request {
return DJabberd::WebAdmin::Page::VHostSummary->new($vhost);
}
}
+ # TODO add handlnig for client and server sessions here ...
return undef;
}

0 comments on commit 4880edc

Please sign in to comment.