- rfe: snippets should have titles too!

- Added a mechanism for using external folders for custom code. See 
   sbin/preload.custom.example for details.
This commit is contained in:
JT Smith 2007-06-21 17:58:58 +00:00
parent d32d4112f4
commit ec67b2e8fe
5 changed files with 34 additions and 7 deletions

View file

@ -0,0 +1,4 @@
# Add paths to lib folders where you have custom plugins for WebGUI.
# Note that the folder must contain the same directory structure of
# of WebGUI itself. This file should reside at WebGUI/sbin/preload.custom
/data/Custom/lib

View file

@ -1,3 +1,7 @@
# Create preload.exclude in your WebGUI/sbin directory and add modules to it
# that you don't want to be loaded by modperl. This will decrease the overall
# size of your modperl instances, which will increase performance, and reduce
# memory use.
WebGUI::Cache::Database
WebGUI::Auth::LDAP
WebGUI::Asset::Wobject::WSClient

View file

@ -1,8 +1,20 @@
my $webguiRoot;
my $customLibs;
BEGIN {
$webguiRoot = "/data/WebGUI";
unshift (@INC, $webguiRoot."/lib");
@{$customLibs} = ();
open(FILE,"<".$webguiRoot."/sbin/preload.custom");
while (my $line = <FILE>) {
next if $line =~ m/^#/;
chomp $line;
push(@{$customLibs}, $line);
}
close(FILE);
foreach my $lib (@customLibs) {
unshift (@INC, $lib);
}
}
$|=1;
@ -10,7 +22,6 @@ $|=1;
use strict;
print "\nStarting WebGUI ".$WebGUI::VERSION."\n";
#----------------------------------------
# Logger
#----------------------------------------
@ -39,12 +50,17 @@ my @modules = ();
# these modules should always be skipped
my @excludes = qw(WebGUI::i18n::English::Automated_Information WebGUI::PerformanceProfiler);
open(FILE,"<".$webguiRoot."/sbin/preload.exclude");
while (<FILE>) {
chomp;
push(@excludes,$_);
while (my $line = <FILE>) {
next if $line =~ m/^#/;
chomp $line;
push(@excludes, $line);
}
close(FILE);
File::Find::find(\&getWebGUIModules, $webguiRoot."/lib/WebGUI");
my @folders = ($webguiRoot."/lib/WebGUI");
foreach my $lib (@{$customLibs}) {
push(@folders, $lib."/WebGUI");
}
File::Find::find(\&getWebGUIModules, @folders);
foreach my $package (@modules) {
next if (WebGUI::Utility::isIn($package,@excludes));
my $use = "use ".$package." ()";
@ -79,7 +95,7 @@ sub getWebGUIModules {
my $filename = $File::Find::dir."/".$_;
return unless $filename =~ m/\.pm$/;
my $package = $filename;
$package =~ s/^$webguiRoot\/lib\/(.*)\.pm$/$1/;
$package =~ s/.*\/lib\/(.*)\.pm$/$1/;
$package =~ s/\//::/g;
push(@modules,$package);
}