added install/uninstall functions to asset and wobject skeletons to make distributing custom assets and wobjects easier
This commit is contained in:
parent
45b11e0a1a
commit
f503b4328e
3 changed files with 139 additions and 53 deletions
|
|
@ -186,4 +186,59 @@ adminConsole views.
|
|||
# WebGUI::International::get("edit_title","NewWobject"));
|
||||
#}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Everything below here is to make it easier to install your custom
|
||||
# wobject, but has nothing to do with wobjects in general
|
||||
#-------------------------------------------------------------------
|
||||
# cd /data/WebGUI/lib
|
||||
# perl -MWebGUI::Asset::Wobject::NewWobject -e install www.example.com.conf [ /path/to/WebGUI ]
|
||||
# - or -
|
||||
# perl -MWebGUI::Asset::Wobject::NewWobject -e uninstall www.example.com.conf [ /path/to/WebGUI ]
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
||||
use base 'Exporter';
|
||||
our @EXPORT = qw(install uninstall);
|
||||
use WebGUI::Session;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub install {
|
||||
my $config = $ARGV[0];
|
||||
my $home = $ARGV[1] || "/data/WebGUI";
|
||||
die "usage: perl -MWebGUI::Asset::Wobject::NewWobject -e install www.example.com.conf\n" unless ($home && $config);
|
||||
print "Installing asset.\n";
|
||||
my $session = WebGUI::Session->open($home, $config);
|
||||
$session->config->addToArray("assets","WebGUI::Asset::Wobject::NewWobject");
|
||||
$session->db->write("create table NewWobject (
|
||||
assetId varchar(22) binary not null,
|
||||
revisionDate bigint not null,
|
||||
primary key (assetId, revisionDate)
|
||||
)");
|
||||
$session->var->end;
|
||||
$session->close;
|
||||
print "Done. Please restart Apache.\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub uninstall {
|
||||
my $config = $ARGV[0];
|
||||
my $home = $ARGV[1] || "/data/WebGUI";
|
||||
die "usage: perl -MWebGUI::Asset::Wobject::NewWobject -e uninstall www.example.com.conf\n" unless ($home && $config);
|
||||
print "Uninstalling asset.\n";
|
||||
my $session = WebGUI::Session->open($home, $config);
|
||||
$session->config->deleteFromArray("assets","WebGUI::Asset::Wobject::NewWobject");
|
||||
my $rs = $session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::NewWobject'");
|
||||
while (my ($id) = $rs->array) {
|
||||
my $asset = WebGUI::Asset->new($session, $id, "WebGUI::Asset::Wobject::NewWobject");
|
||||
$asset->purge if defined $asset;
|
||||
}
|
||||
$session->db->write("drop table NewWobject");
|
||||
$session->var->end;
|
||||
$session->close;
|
||||
print "Done. Please restart Apache.\n";
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue