I've gotten a couple of e-mails asking for how I did mine, so I'm posting it here.. Its VERY rough, and I can't help you with it, I just don't have the time! I'm in the middle of moving and planning my wedding ( yeah me! ) .. But I'm happy to post it and help point you in the right direction, although I like jerry's method alot as well!
This should point you guys in the right direction, and this info is posted as an aid,not a mod. I'm sure I can clean it up and stream line it.. this is DEF the long way of doing it.
Here is
one for site_html_templates.pl
Code:
sub site_html_link_cool {
# --------------------------------------------------------
# This routine is used to display what a link should look
# like.
my %rec = @_;
return &load_template ('mini_link.html', {
detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension",
rate_img => $rate_img,
%rec,
%globals });
}
here is the mini link template
Code:
<a class="main" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a> <%Hits%><br>
Here is the votes template
Code:
<%top_votes_include%>
Here is the rated template
Code:
<%top_rated_include%>
Here is my build_rate_page sub in nph_build.cgi. You'll have to see
whats different, cause I don't remember what
all I changed.
Code:
sub build_rate_page {
# --------------------------------------------------------
# Creates a Top 10 ratings page.
my (@values, $id, $votes, $rate, @top_votes, %top_votes, @top_rate, %top_rate);
local ($top_rated, $top_votes);
if ($build_ratings_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
$total = 0;
open (LINKS, $db_links_name) or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
LINE: while (<LINKS> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
$votes = $values[$db_votes];
$rate = $values[$db_rating];
next if ($votes < 10);
if (($#top_votes < 9) or ($votes > $top_votes[$#top_votes])) {
push (@{$top_votes{$votes}}, @values);
if ($#top_votes <= 10) {
push (@top_votes, $votes);
@top_votes = sort { $b <=> $a } @top_votes;
}
else {
splice (@{$top_votes{$#top_votes}}, 0, $#db_cols);
$#{$top_votes{$#top_votes}} or delete $top_votes{$#top_votes};
delete $top_votes{$top_votes[$#top_votes]-$id};
$top_votes[$#top_votes] = $votes;
@top_votes = sort { $b <=> $a } @top_votes;
}
}
if (($#top_rate < 9) or ($rate > $top_rate[$#top_rate])) {
push (@{$top_rate{$rate}}, @values);
if ($#top_rate <= 10) {
push (@top_rate, $rate);
@top_rate = sort { $b <=> $a } @top_rate;
}
else {
splice (@{$top_rate{$#top_rate}}, 0, $#db_cols);
$#{$top_rate{$#top_rate}} or delete $top_rate{$#top_rate};
delete $top_rate{$top_rate[$#top_rate]-$id};
$top_rate[$#top_rate] = $rate;
@top_rate = sort { $b <=> $a } @top_rate;
}
}
}
close LINKS;
$top_rated = ''; $top_votes = '';
#rate include
$top_rated_include = ''; $top_votes_include = '';
foreach (sort { $b <=> $a } @top_votes) {
$seen{$_}++;
%link = &array_to_hash ($seen{$_} - 1, @{$top_votes{$_}});
$top_votes .= qq~<tr><td align=center>$link{'Rating'}</td><td align=center>$link{'Votes'}</td><td><a href="$link{'URL'}">$link{'Title'}</a></td></tr>\n~;
#rate include
$top_votes_include .= qq~<a class=main href="$link{'URL'}">$link{'Title'}</a> $link{'Votes'} <br> \n~;
}
foreach (sort { $b <=> $a } @top_rate) {
$seen{$_}++;
%link = &array_to_hash ($seen{$_} - 1, @{$top_rate{$_}});
$top_rated .= qq~<tr><td align=center>$link{'Rating'}</td><td align=center>$link{'Votes'}</td><td><a href="$link{'URL'}">$link{'Title'}</a></td></tr>\n~;
#rate include
$top_rated_include .= qq~<a class=main href="$link{'URL'}">$link{'Title'}</a> $link{'Rating'} <br> \n~;
}
open (RATE, ">$build_ratings_path/$build_index") or &cgierr ("unable to open top rated page: $build_ratings_path/$build_index. Reason: $!");
print "\tVote Range: $top_votes[0] .. $top_votes[$#top_votes]\n";
print "\tRate Range: $top_rate[0] .. $top_rate[$#top_rate]\n";
print RATE &site_html_ratings;
close RATE;
#rate include
open (RATE_INCLUDE, ">$build_ratings_path/rated_mini$build_extension") or &cgierr ("unable to open top rated page: $build_ratings_path/rated_mini$build_extension. Reason: $!");
print "\tRate Range: $top_rate[0] .. $top_rate[$#top_rate]\n";
print RATE_INCLUDE &site_html_ratings_include; close RATE_INCLUDE;
#vote include
open (VOTE_INCLUDE, ">$build_ratings_path/vote_mini$build_extension") or &cgierr ("unable to open top rated page: $build_ratings_path/vote_mini$build_extension. Reason: $!"); print "\tVote Range: $top_votes[0] .. $top_votes[$#top_votes]\n";
print VOTE_INCLUDE &site_html_votes_include; close VOTE_INCLUDE;
}
Add these 2 to nph_build.cgi
Code:
#Build rate mini include
sub site_html_ratings_include {
# --------------------------------------------------------
# This routine determines how the top rated page will look like.
return &load_template ( 'rated_mini.html', {
top_rated_include => $top_rated_include,
%globals
});
}
#Build vote mini include
sub site_html_votes_include {
# --------------------------------------------------------
# This routine determines how the top rated page will look like.
return &load_template ( 'vote_mini.html', {
top_votes_include => $top_votes_include,
%globals
});
}
------------------
The Crowe
crowe@charter.net www.lit.org Links Engine for Writing on the net!