[ic] Rewriting URLs with ActionMap

Stefan Hornburg racke at linuxia.de
Wed Mar 9 03:53:37 EST 2005


On Wed, 9 Mar 2005 14:41:55 +0800
"Cameron G" <ritontor at icenet.com.au> wrote:

> Hi guys, 
> 
> I'm trying to remove the scan stuff from the URL to pretty up things for
> search engines, and finding that I'm either a dribbling idiot, or doing
> things completely the wrong way. What I'm trying to rwrite the whole scan
> url to a single word, like this: 
> 
> ActionMap productname sub { $CGI->{mv_nextpage} =
> "scan/st=db/co=yes/sf=prod_group/se=productname" }

Where did you get that idea from ?

I already posted real world examples in the mailing list, here is another
one. I hope you get the idea :-D

# Searching for courses
#
# Syntax: {INSTITUTE}[+-{LOCATION}][/past[/{YEAR}]]
#
# Examples:
# /rpo                 current courses RPO
# /rpo+Vienna          current courses RPO in Vienna
# /rpo-Vienna          current offsite courses RPO  
# /rpo/past/		   past courses RPO
# /rpo/past/FY04	   past courses RPO fiscal year 2004
# /rpo+Rome/past/FY05  past courses RPO fiscal year 2005 in Rome
# /rpo-Vienna/past     past offsite courses RPO

ActionMap courses <<EOR
sub {
	my ($name, $tc, $mode, $arg) = split('/', shift);
	my (@sf, @se, @op, @status, $location);

	# global search parameters
	$CGI->{mv_coordinate} = 1;
	$CGI->{mv_sort_field} = 'month';
	$CGI->{mv_matchlimit} = 70;

	# looking for past or current courses
	if ($mode eq 'past') {
		# past courses
		@status = qw(Archive);

		if ($arg) {
			# courses for a certain year
			push (@sf, 'sku');
			push (@se, $arg);
			push (@op, 'rm');
		}
	} else {
		# recent courses
		@status = qw(Pending Confirmed);
	}

	# check for location
	if ($tc =~ s/(.*?)([+-])(.*)/$1/) {
		$location = $3;
		push (@sf, 'location');
		push (@se, $location);
		push (@op, ($2 eq '+' ? 'eq' : 'ne'));
	}

	# which institute ?
	$tc = lc($tc);

	if ($tc eq 'rpo') {
		$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'results';
		push (@sf, 'institute');
		push (@se, 'RPO');
		push (@op, 'rm');
	} elsif ($tc eq 'rsc') {
		$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'results_rsc';
		push (@sf, 'institute');
		push (@se, 'RSC');
		push (@op, 'eq');
	} elsif ($tc eq 'frc') {
		$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'results_frc';
		push (@sf, 'institute');
		push (@se, 'FRC');
		push (@op, 'eq');
	} elsif ($tc eq 'fsi') {
		$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'results_fsi';
		push (@sf, 'institute');
		push (@se, 'FSI');
		push (@op, 'eq');
	} elsif ($tc eq 'alm') {
		$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'results_alm';
		# recognized by title
		@sf = qw(title);
		@se = qw(Property);
	} elsif ($tc eq 'aope') {
		$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'results_alm';
		# recognized by title
		@sf = qw(title);
		@se = ('Grants', 'contract');
	} else {
		$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'results';
	}

	if (@status == 2) {
		my $fields = @sf;
		push (@sf, 'status', 'status');
		push (@op, 'rm', 'rm');

		$CGI->{mv_orsearch} = $CGI->{mv_search_group} = join("\0", ((0) x $fields), 1, 1);
	} else {
		push (@sf, 'status');
		push (@op, 'rm');

		$CGI->{mv_orsearch} = 0;
	}
	
	push (@se,  @status);

	$CGI->{mv_search_field} = join("\0", @sf);
	$CGI->{mv_searchspec} = join("\0", @se);
	$CGI->{mv_column_op} = join("\0", @op);

	# advise Interchange to perform search with the parameters we
	# specified above

	$CGI->{mv_todo} = 'search';
	$Tag->update('process');

	return 1;
}
EOR

Ciao
	Racke


-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team



More information about the interchange-users mailing list