CGI-Application-Bouquet-Rose

 view release on metacpan or  search on metacpan

lib/CGI/Application/Bouquet/Rose.pm  view on Meta::CPAN

	for (qw/content.tmpl main.menu.tmpl search.form.tmpl web.page.tmpl/)
	{
		my($output_file_name) = File::Spec -> catfile($output_dir_name, $_);

		$self -> log("Copying $output_file_name");

		copy($self -> tmpl_path . "/$_", $output_file_name);
	}

	# Process: search.fcgi.tmpl.

	$output_dir_name = File::Spec -> catdir('htdocs', 'search');

	$self -> log("Creating $output_dir_name");

	mkpath([$output_dir_name], 0, 0744);

	$output_file_name	= File::Spec -> catfile($output_dir_name, "$fcgi_name.fcgi");
	my($template)		= HTML::Template -> new(filename => File::Spec -> catfile($self -> tmpl_path, 'search.fcgi.tmpl') );

	$template -> param(prefix => $self -> prefix);

	$self -> log("Creating $output_file_name");

	open(OUT, "> $output_file_name") || die "Can't open(> $output_file_name):$ !";
	print OUT $template -> output();
	close OUT;

	# Process: CGI/CGIApp.pm.

	$self -> log('Creating ' . $self -> dir_name);

	mkpath([$self -> dir_name], 0, 0744);

	$output_file_name	= File::Spec -> catfile($self -> dir_name, 'CGIApp.pm');
	$template			= HTML::Template -> new(filename => File::Spec -> catfile($self -> tmpl_path, 'cgiapp.pm.tmpl') );

	$template -> param(module		=> $self -> module);
	$template -> param(prefix		=> $self -> prefix);
	$template -> param(tmpl_path	=> $real_tmpl_path);

	$self -> log("Creating $output_file_name");

	open(OUT, "> $output_file_name") || die "Can't open(> $output_file_name):$ !";
	print OUT $template -> output();
	close OUT;

	# Process: CGI/Dispatcher.pm.

	$output_file_name	= File::Spec -> catfile($self -> dir_name, 'Dispatcher.pm');
	$template			= HTML::Template -> new(filename => File::Spec -> catfile($self -> tmpl_path, 'dispatcher.pm.tmpl') );

	$template -> param(prefix => $self -> prefix);

	$self -> log("Creating $output_file_name");

	open(OUT, "> $output_file_name") || die "Can't open(> $output_file_name):$ !";
	print OUT $template -> output();
	close OUT;

	# Process: CGI/MainMenu.pm.

	$output_file_name	= File::Spec -> catfile($self -> dir_name, 'MainMenu.pm');
	$template			= HTML::Template -> new(filename => File::Spec -> catfile($self -> tmpl_path, 'main.menu.pm.tmpl') );

	$template -> param(prefix => $self -> prefix);

	$self -> log("Creating $output_file_name");

	open(OUT, "> $output_file_name") || die "Can't open(> $output_file_name):$ !";
	print OUT $template -> output();
	close OUT;

	# Process: CGI/CGIApp/*.pm (1 per table).

	$output_dir_name = File::Spec -> catdir($self -> dir_name, 'CGIApp');

	$self -> log("Creating $output_dir_name");

	mkpath([$output_dir_name], 0, 0744);

	$template = HTML::Template -> new(filename => File::Spec -> catfile($self -> tmpl_path, 'generator.pl.tmpl') );

	$template -> param(dir_name		=> $output_dir_name);
	$template -> param(module_loop	=> \@module);
	$template -> param(module		=> $self -> module);
	$template -> param(tmpl_path	=> $self -> tmpl_path);
	$template -> param(verbose		=> $self -> verbose || 0);

	print $template -> output();

	$self -> log('Success');

	return 0;

} # End of run.

# -----------------------------------------------

1;

=head1 NAME

CGI::Application::Bouquet::Rose - Generate a set of CGI::Application-based classes

=head1 Synopsis

=head2 Security Warning

The generated code allows SQL to be entered via a CGI form. This means you absolutely
must restrict usage of the generated code to trusted persons.

=head2 Sample Code

	Step 1: Run the steps from the synopsis for Rose::DBx::Bouquet.
	Remember, the current dir /must/ still be Local-Wines-1.29/.

	Step 2: Edit:
	o lib/Rose/DBx/Bouquet/.htcgi.bouquet.conf
   	o lib/Local/Wine/.htwine.conf

	Step 3: Run the third code generator (see scripts/rosy):
	shell> scripts/run.cgi.app.gen.pl > scripts/run.cgi.pl

	Step 4: This is the log from run.cgi.app.gen.pl:
	doc_root:         /var/www
	exclude:         ^(?:information_schema|pg_|sql_)
	module:          Local::Wines
	output_dir:      ./lib
	prefix:          Local::Wines::CGI
	remove:          0
	tmpl_path:       ../CGI-Application-Bouquet-Rose/templates
	verbose:         1
	Working dir:     lib/Local/Wine/CGI
	Rose::DB module: Local::Wines::Base::DB
	Processing tables:
	Table: grape. Module: Grape
	Table: vineyard. Module: Vineyard
	Table: wine. Module: Wine
	Table: wine_maker. Module: WineMaker
	Processing templates:
	Path to run-time templates: /var/www/assets/templates/local/wine
	Creating htdocs/assets/templates/local/wine
	Copying htdocs/assets/templates/local/wine/content.tmpl
	Copying htdocs/assets/templates/local/wine/main.menu.tmpl
	Copying htdocs/assets/templates/local/wine/search.form.tmpl
	Copying htdocs/assets/templates/local/wine/web.page.tmpl
	Creating htdocs/search
	Creating htdocs/search/wine.fcgi
	Creating lib/Local/Wine/CGI
	Creating lib/Local/Wine/CGI/CGIApp.pm
	Creating lib/Local/Wine/CGI/Dispatcher.pm
	Creating lib/Local/Wine/CGI/MainMenu.pm
	Creating lib/Local/Wine/CGI/CGIApp
	Success

	Step 5: Run the fourth code generator:
	shell> perl -Ilib scripts/run.cgi.pl

	Step 6: This is the log from run.cgi.pl:
	Processing CGI::Application-based modules:
	Updating htdocs/assets/templates/local/wine/main.menu.tmpl
	Generated lib/Local/Wine/CGI/CGIApp/Grape.pm
	Generated lib/Local/Wine/CGI/CGIApp/Vineyard.pm
	Generated lib/Local/Wine/CGI/CGIApp/Wine.pm
	Generated lib/Local/Wine/CGI/CGIApp/WineMaker.pm
	Success

	Step 7: Install the templates:
	shell> scripts/install.templates.pl

	Step 8: Install Local::Wines
	shell> perl Build.PL
	shell> perl Build
	shell> sudo perl Build install

	Step 9: Install the FastCGId script:
	shell> sudo cp -r htdocs/search /var/www
	shell> sudo chmod a+x /var/www/search/wine.fcgi

	Step 10: Patch httpd.conf (see httpd/httpd.conf.patch):
	LoadModule fcgid_module modules/mod_fcgid.so
	<Location /search>
	    SetHandler fcgid-script
	    Options ExecCGI
		Order deny,allow
	    Deny from all
	    Allow from 127.0.0.1
	</Location>

	Step 11: Restart Apache:
	shell> sudo /etc/init.d/apache2 restart

	Step 12: Use a web client to hit http://127.0.0.1/search/wine.fcgi
	Start searching!

=head1 Description

C<CGI::Application::Bouquet::Rose> is a pure Perl module.

It uses a database schema, and code generated by C<Rose::DBx::Bouquet>, to generate
C<CGI::Application-based> source code.

The result is an CGI script which implements a search engine customised to the given database.

At run-time, a menu of database tables is displayed in the web client, and when one is chosen, a CGI form
is displayed which allows the user to enter any value for any column. These values are the search keys, and
may include SQL tokens such as '%' and '_'.

The N rows returned by the search are displayed as a HTML table, and you can page back and forth around this
data set.

This documentation uses Local::Wines as the basis for all discussions. See the FAQ for the availability



( run in 1.725 second using v1.01-cache-2.11-cpan-5b529ec07f3 )