Gossamer Forum
Home : Products : Links 2.0 : Customization :


(Page 2 of 2)
> >
Quote Reply
Re: ReviewIt In reply to

don't take them seriously. If there's someone who's interested in what he's doing, meaning who's willing to learn and to understand what he's even doing there, there ain't no better way but to follow up with your (or anybody elses) mods! If people just wanted the mods to brush up their sites they should really pay the makers of a mod, but if they get everything for free they really shoudn't complain!!
ACtually I'm also just a beginner in Perl, but I have my book over here and my interest to learn that stuff and I have been able (finally, but have learned a lot!) to install all you mods I found useful for me - including review and mylinks. BTW for non-templates. SInce I had my first contact with PERL mid of last year it means it can't be that hard to follow, if one's really interested. Even I could.

Would be very much a pitty if you'd never look in here again. What would be LINKS especially without your mods? Thanks a lot for all of them, I found them extremely useful and quite a help in learning some more Perl.


Quote Reply
Re: ReviewIt In reply to
Ah, and why I actually came here:
I didn't check if this has been discussed before, but for anybody else who's looking for that in the future I wanted to leave the following codes here:

If you're using review.cgi, but DON'T (!) use it for collecting the votes given with it, in addition (I hope in addition, cause when I installed this mod long time ago I believe those instructions haven't been there and I hope noone else already put this in the forums already, then I'd be sorry for double posting) to what Jerry instructed you'll also have to put back codes in nph-build.cgi, under "sub build_update_ratings" to the following:

sub build_update_ratings {
# --------------------------------------------------------
# Updates the ratings of each link.
# Let's collect the ratings.
my ($id, %rating, %votes, @values, $input);
opendir (HITS, $db_rates_path) or &cgierr ("unable to open ratings directory: $db_rates_path. Reason: $!");
while (defined ($id = readdir HITS)) {
next unless ($id =~ /^\d+$/);
open (HIT, "$db_rates_path/$id") or &cgierr ("unable to open rating counter: $db_rates_path/$id. Reason: $!");
my $input = <HIT>;
chomp $input;
($votes{$id}, $rating{$id}) = split /\s/, $input;
close HIT;
closedir HITS;

# Count the Reviews
open (REVIEW,"$db_review_name") or &cgierr ("unable to open review database: $db_review_name. Reason: $!");
LINE: while (<REVIEW> ) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[1];
close REVIEW;

# Update the links database.
open (DB, "$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DBTMP, ">$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
LINE: while (<DB>) {
/^#/ and print OUT and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = split /\Q$db_delim\E/;
$id = $values[0];

if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
$values[$db_votes] = $values[$db_votes] + $votes{$id};
print "\t<b>Updating rating</b> to $values[$db_rating] for link id $id\n";
if ($values[$db_reviews] != $review{$id}) {
$values[$db_reviews] = $review{$id};
print "\t<b>Updating reviews</b> to $review{$id} for link id $id\n";

print DBTMP &join_encode(&array_to_hash(0, @values));
close DB;
close DBTMP;

# my $output = '';
# local ($^I, @ARGV) = ('.bak', $db_links_name);
# LINE: while (<> ) {
# /^#/ and print OUT and next LINE; # Skip comment Lines.
# /^\s*$/ and next LINE; # Skip blank lines.
# chomp; # Remove trailing new line.
# @values = split /\Q$db_delim\E/;
# $id = $values[0];
# if (exists $votes{$id}) {
# $values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
# ($values[$db_votes] + $votes{$id});
# $values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
# $values[$db_votes] = $values[$db_votes] + $votes{$id};
# $output .= "\tUpdating rating to $values[$db_rating] for link id $id\n";
# }
# if ($values[$db_reviews] != $review{$id}) {
# $values[$db_reviews] = $review{$id};
# $output .= "\tUpdating reviews to $review{$id} for link id $id\n";
# }
# print &join_encode(&array_to_hash(0, @values));
# }
# }
# print $output;

if (-s "$db_links_name.bak" > 0) {
if (! rename ("$db_links_name.bak", $db_links_name)) {
print "\tCouldn't rename! Had to copy. Strange: $!\n";
open (DBTMP, ">$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!");
open (DB, "$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!");
while (<DB>) { print DBTMP; }
close DB;
close DBTMP;
else {
&cgierr ("Error building! Links database is 0 bytes!");

# Delete the ratings.
foreach (keys %votes) {
unlink ("$db_rates_path/$_") or &cgierr ("unable to remove rating: $db_rates_path/$_. Reason: $!");

# This was added for review.cgi

sub build_auto_review {
my ($output, $validate);
my ($reviews) = 0;

open (VAL, "<$db_valrev_name") or &cgierr("error in build_auto_review. unable to open validate file: $db_valrev_name. Reason: $!");
if ($db_use_flock) { flock (VAL, 1); }
LINE: while (<VAL>) {
(/^#/) and ($output .= $_ and next LINE);
(/^\s*$/) and next LINE;
$validate .= "$_\n" and $reviews++;
close VAL;

open (VAL, ">$db_valrev_name") or &cgierr("error in validate_record. unable to open validate file: $db_valrev_name. Reason: $!");
flock(VAL, 2) unless (!$db_use_flock);
print VAL $output;
close VAL;

open (DB, ">>$db_review_name") or &cgierr("error in build_auto_review, unable to open db file: $db_review_name. Reason: $!");
flock(DB, 2) if ($db_use_flock);
print DB $validate;
print "\tValidated: $reviews Reviews\n";
close DB;

The outcommented lines are what you might have IF you are using the votes. ONLY if you're not wanting to use review votes you should set up above codes. They're almost like the originals, except to the bolded part which adds the reviews for a link.

The mod will also work if you're using the outcommented lines without the bolded part, but then link.db.bak will not be deleted.
Thanks to Eliot I found that out after months of using this mod succesfully, but always wondering why the .bak file has never been deleted automatically.
So, if you find your link.db.bak also isn't deleted, you should try above codes.

Elsewise Jerry's codes are 100% working as he gave instructions.

So long,

Quote Reply
Re: ReviewIt In reply to
Jerry, I'm sorry if I offended you. It was not intended that way. I believe your attitude toward your mods is more a product of your interests and youth. (God, I wish I had that second part.) Perhaps "not caring" was a very bad choice of words.

I agree that review.cgi and mylinks.cgi are your best mods and probably the best that have ever been written for Links. I also think your programming skills are nearly that of Alex and within a few more years will exceed Alex and I feel confident that he would agree.

Having frequented these boards for more that a year, the emphasis is "people helping people". Everyone tries to help others to the limits of their ability and time. This forum is what has made Links so successful. People have been crying for help with mylinks.cgi ever since you put it up. That's because it is such an important mod. I truly feel lucky to have it working on my site. It literally took hours of reading the threads to filter out the steps. One more hour of your time could have saved that and could have helped all the others that have been unable to make it work. It was almost like a tease. "Here it is, now you figure out how to install it." Maybe you don't care about your mods but others do because they are very good.

Learning Perl. I have called every school, university, training center and whatever in my area. Nobody offers any classes in Perl. I'm stuck getting what little I can the hard way. It's not easy, once you have been around the block a few times and your brain gets a little mushy, to learn a programming language just by picking up a book. I could also be the drugs from back in the 60s. I'm sure I had a great time if I could only remember.

Once again, if I have offended you, I apologize. That was not my intention. I have great respect for you and for everyone who contributes to these boards.

I would like to think that when I have to upgrade to SQL, I will be able to hire you to make some of the mods that will be needed.

This board is probably not the best place for this exchange. If you wish to continue this, I suggest you contact me at willdeb@adelphia.net.

FishHoo! Search Index for Fishermen
> >