From: Chris W. <la...@us...> - 2005-02-02 13:08:11
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Manage/Website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23852/Manage/Website Modified Files: Create.pm Log Message: use functionality from OI2::Brick to do the resource copying for us Index: Create.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Manage/Website/Create.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Create.pm 26 Jan 2005 02:36:11 -0000 1.25 --- Create.pm 2 Feb 2005 13:08:01 -0000 1.26 *************** *** 7,10 **** --- 7,11 ---- use File::Spec::Functions qw( catdir ); use File::Path qw( rmtree ); + use OpenInteract2::Brick; use OpenInteract2::Config::Readonly; use OpenInteract2::Context qw( CTX ); *************** *** 111,128 **** $self->notify_observers( progress => 'Directories created' ); ! $self->_copy_widgets( $website_dir, $source_dir ); ! $self->notify_observers( ! progress => 'Global templates copied' ); ! ! $self->_copy_cgi( $website_dir, $source_dir ); ! $self->notify_observers( ! progress => 'CGI interface copied' ); ! ! $self->_copy_messages( $website_dir, $source_dir ); ! $self->_copy_server_conf( $website_dir, $source_dir ); ! $self->_copy_apache_conf( $website_dir, $source_dir ); ! $self->_copy_daemon_conf( $website_dir, $source_dir ); $self->notify_observers( ! progress => 'OI2 and web server configuration copied' ); # This will initialize the context to our new website... --- 112,120 ---- $self->notify_observers( progress => 'Directories created' ); ! $self->_copy_from_bricks( $website_dir, ! 'apache', 'apache2', 'cgi', 'daemon', ! 'messages', 'websiteconfig', 'widgets' ); $self->notify_observers( ! progress => 'All files from sample website copied' ); # This will initialize the context to our new website... *************** *** 135,139 **** $self->notify_observers( progress => 'Installing packages', { long => 'yes' } ); ! $self->_install_packages( $source_dir, SYSTEM_PACKAGES ); $self->notify_observers( progress => 'Packages installed' ); --- 127,131 ---- $self->notify_observers( progress => 'Installing packages', { long => 'yes' } ); ! $self->_install_packages_from_bricks( $website_dir, SYSTEM_PACKAGES ); $self->notify_observers( progress => 'Packages installed' ); *************** *** 172,286 **** } ! sub _copy_widgets { ! my ( $self, $website_dir, $source_dir ) = @_; ! my $source_widget_dir = ! catdir( $source_dir, 'sample', 'website', 'template' ); ! my $transferred = OpenInteract2::Config::TransferSample ! ->new( $source_widget_dir ) ! ->run( $website_dir ); ! foreach my $copied ( @{ $transferred } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => 'copy widget', ! message => 'Copied file from sample site', ! filename => $copied, ! }); ! } ! } ! ! sub _copy_messages { ! my ( $self, $website_dir, $source_dir ) = @_; ! my $source_msg_dir = catdir( $source_dir, 'sample', 'website', 'msg' ); ! my %vars = ( website_dir => $website_dir ); ! my $transferred = OpenInteract2::Config::TransferSample ! ->new( $source_msg_dir ) ! ->run( $website_dir, \%vars ); ! foreach my $copied ( @{ $transferred } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => 'copy localized messages', ! message => 'Copied file from sample site', ! filename => $copied, ! }); ! } ! } ! ! sub _copy_server_conf { ! my ( $self, $website_dir, $source_dir ) = @_; ! my $source_conf_dir = catdir( $source_dir, 'sample', 'website', 'conf' ); ! my %vars = ( website_dir => $website_dir ); ! my $transferred = OpenInteract2::Config::TransferSample ! ->new( $source_conf_dir ) ! ->run( $website_dir, \%vars ); ! foreach my $copied ( @{ $transferred } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => 'copy server config', ! message => 'Copied file from sample site', ! filename => $copied, ! }); ! } ! } ! ! sub _copy_cgi { ! my ( $self, $website_dir, $source_dir ) = @_; ! my $source_cgi_dir = catdir( $source_dir, 'sample', 'website', 'cgi-bin' ); my %vars = ( website_dir => $website_dir ); ! my $transferred = OpenInteract2::Config::TransferSample ! ->new( $source_cgi_dir ) ! ->run( $website_dir, \%vars ); ! foreach my $copied ( @{ $transferred } ) { ! $self->_add_status( { is_ok => 'yes', ! action => 'copy CGI', ! message => 'Copied file from sample site', ! filename => $copied } ); ! # OIN-10: hack just to ensure we get the right perms ! if ( $copied =~ /cgi$/ ) { ! chmod( 0755, $copied ); } } } ! ! sub _copy_apache_conf { ! my ( $self, $website_dir, $source_dir ) = @_; ! $self->_copy_webserver_conf( $website_dir, $source_dir, ! 'apache', 'apache 1.x' ); ! $self->_copy_webserver_conf( $website_dir, $source_dir, ! 'apache2', 'apache 2.x' ); ! } ! ! sub _copy_webserver_conf { ! my ( $self, $website_dir, $source_dir, $type, $desc ) = @_; ! my $source_apache_dir = catdir( $source_dir, 'sample', $type ); ! my %vars = ( website_dir => $website_dir ); ! my $transferred = OpenInteract2::Config::TransferSample ! ->new( $source_apache_dir ) ! ->run( $website_dir, \%vars ); ! foreach my $copied ( @{ $transferred } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => "copy $desc config", ! message => 'Copied file from sample site', ! filename => $copied, ! }); ! } ! ! } ! ! sub _copy_daemon_conf { ! my ( $self, $website_dir, $source_dir ) = @_; ! my $source_daemon_dir = catdir( $source_dir, 'sample', 'daemon' ); ! my %vars = ( website_dir => $website_dir ); ! my $transferred = OpenInteract2::Config::TransferSample ! ->new( $source_daemon_dir ) ! ->run( $website_dir, \%vars ); ! foreach my $copied ( @{ $transferred } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => 'copy standalone daemon config', ! message => 'Copied file from sample site', ! filename => $copied, ! }); } } --- 164,212 ---- } ! sub _copy_from_bricks { ! my ( $self, $website_dir, @brick_names ) = @_; my %vars = ( website_dir => $website_dir ); ! foreach my $brick_name ( @brick_names ) { ! my $brick = OpenInteract2::Brick->new( $brick_name ); ! my $status = $brick->copy_all_resources_to( $website_dir, \%vars ); ! foreach my $file_copied ( @{ $status->{copied} } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => "copy '$brick_name'", ! message => 'Copied file from class resource', ! filename => $file_copied, ! }); ! } ! foreach my $file_skipped ( @{ $status->{skipped} } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => "copy '$brick_name'", ! message => 'Skipped copying file from class resource - marked as readonly', ! filename => $file_skipped, ! }); ! } ! foreach my $file_same ( @{ $status->{same} } ) { ! $self->_add_status({ ! is_ok => 'yes', ! action => "copy '$brick_name'", ! message => 'Skippe copying file from class resource - resources same', ! filename => $file_same, ! }); } } } ! sub _install_packages_from_bricks { ! my ( $self, $website_dir, $package_names ) = @_; ! foreach my $name ( @{ $package_names } ) { ! my $brick_name = 'pkg_' . $name; ! my $brick = OpenInteract2::Brick->new( $brick_name ); ! foreach my $pkg_name ( $brick->list_resources ) { ! my $pkg_info = $brick->load_resource( $pkg_name ); ! my $pkg_file = OpenInteract2::Util->decode_base64_and_store( ! \$pkg_info->{content} ! ); ! $self->_install_package_file( undef, $pkg_file, $website_dir ); ! } } } *************** *** 411,422 **** feedback. - =head1 BUGS - - None known. - - =head1 TO DO - - Nothing known. - =head1 COPYRIGHT --- 337,340 ---- |