Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: Additional files added to the plug-in

Quote Reply
Re: Additional files added to the plug-in In reply to
I have a piece of code I munged from a bunch of code samples.

But you also need to change the path-to-perl to the users default,
and the admin library to the users admin.

It's fine for the regex to change the first line of the file, for
perl, that never changes.

But 'use lib' line, is a problem. There might be more than one
use lib in a file, so there should be a standard replace, such as

use lib 'links/admin'

which would be an exact pattern match for replacing the lib line.

These should be functions as well, so that:

Code:
my $file = $tar->get_file ('newfile.cgi');
$file->mode (0755);
$file->name ("$CFG->{admin_root_path}/newfile.cgi");
$file->path_to_perl (); ## where () can take an optional arguement
$file->path_to_admin_lib (); ## where () can take an optional arguement
unless ($file->write) {
$Plugins::Yourplugin::error = "Unable to extract newfile.cgi. Reason: $GT::Tar::error";
return;
}
The code I'm using I cut from a few scripts, and tweaked to make them work <G>

Code:
# Copying recommend.it.cgi to user_cgi directory.
$file = $tar->get_file ('recommend.it.cgi');
# Get the entire code as a string.
my $code = $file->body_as_string;
# Replace the path to perl with the users perl.
$code =~ s/^#!(.*)/#!$CFG->{path_to_perl}/;
# Replace the use lib with the users admin directory.
$code =~ s/use lib '[^']+'/use lib '$CFG->{admin_root_path}'/;
$file->body ($code);
# Set the name of the file
$file->name ("$CFG->{admin_root_path}/../recommend.it.cgi");
So, it would be much, much nicer to have the routines all in $file->,
so that they can be changed in one place, not in every plug-in.



PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Subject Author Views Date
Thread Additional files added to the plug-in pugdog 2879 Feb 27, 2001, 9:20 PM
Thread Re: Additional files added to the plug-in
Alex 2818 Feb 28, 2001, 11:43 AM
Post Re: Additional files added to the plug-in
pugdog 2816 Feb 28, 2001, 6:06 PM