Gossamer Forum
Home : Products : Links 2.0 : Customization :

easy do to mod to stop "new" "cool" "rating" from being built

Quote Reply
easy do to mod to stop "new" "cool" "rating" from being built
In nph-buil.cgi the following editing is necessary:

Color coded in build staggered UNCOMMENT all lines as shown in this color

color coded in build all UNCOMMENT all lines in this color
sub build_staggered {
# --------------------------------------------------------
# Builds the directory in steps.
#
my %in = &parse_form;

$nph++;
&html_print_headers() if ($use_html);
my %steps = ( 1 => 'Updating New and Popular Records and rebuilding URL database',
2 => 'Rebuilding Category Pages',
3 => 'Building Detailed View Pages',
4 => 'Updating Home/New/Cool Pages'
);
my $step = $in{'step'} || 1;
my $limit = $in{'limit'} || 10;
my $offset = $in{'offset'} || 0;
my $auto = $in{'auto'} || 0;
my $start = time();
my $date = &get_date;
my $time = &get_time;

my $header = qq~
<html>
<head>
<title>Rebuilding Directory -- Phase $phase</title>
~;

my $sub_head = qq~
</head>

<body bgcolor=#FFFFFF>
<H2><TT>Building Pages</TT></H2>
<P><em>Step: $steps{$step}</em>
<PRE>
Pages built on $date at $time
--------------------------------------------------------

~;
CASE: {

($step == 1) and do {
print $header;
print qq~<meta http-equiv="Refresh" content="2; URL=nph-build.cgi?staggered=1&step=2&auto=$auto">~ if ($auto);
print $sub_head;

my $t1 = time();
print "Backing up database . . .\n";
&build_backup;
print "Done (", time - $t1, " s)\n\n";

$t1 = time();
print "Building URL Index . . .\n";
&build_url_index;
print "Done (", time - $t1, " s)\n\n";

# print "Updating New and Popular Records . . .\n";
# $t1 = time();
# &build_update_newpop;
# print "Done (", time - $t1, " s)\n\n";


# print "Updating ratings .. \n";
# $t1 = time();
# &build_update_ratings;
# print "Done (", time - $t1, " s)\n\n";


my $elapsed = time() - $start;
print "------------------------------------------------\n";
print "Step 1 took $elapsed seconds.\n\n";
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=2&auto=$auto">On to Step 2</A></B></FONT></P>~;
last CASE;
};

($step == 2) and do {
my @category_list = &category_list; my $i;
print $header;
if ($auto) {
($offset > $#category_list) ?
(print qq~<meta http-equiv="Refresh" content="0; URL=nph-build.cgi?staggered=1&step=3&auto=$auto">~) :
(print qq~<meta http-equiv="Refresh" content="2; URL=nph-build.cgi?staggered=1&step=2&limit=$limit&offset=~, $offset + $limit, qq~&auto=$auto">~);
}
print $sub_head;

print "Rebuilding Categories $offset -> ", $offset + $limit - 1, ".\n\n";
for ($i = $offset; $i <= $offset + $limit -1; $i++) {
last unless ($category_list[$i] =~ /\w+/);
%category = ();
%subcategories = ();
@links = ();
@new_links = ();
@cool_links = ();
%stats = ();
$grand_total = 0;
my $t1 = time();

print "** Building Category: $category_list[$i] ... \n";
&build_single_category ($category_list[$i]);
print "** Done (", time - $t1, " s)!\n\n";
}
$offset = $offset + $limit;

my $elapsed = time() - $start;
print "------------------------------------------------\n";
print "This phase of step 2 took $elapsed seconds.\n\n";
($offset > $#categories) ?
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=3">Go on to Step 3!</A></B></FONT></P>~ :
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=2&limit=$limit&offset=$offset&auto=$auto">Next $limit Categories!</A></B></FONT></P>~;
last CASE;
};

($step == 3) and do {
print $header;
print qq~<meta http-equiv="Refresh" content="2; URL=nph-build.cgi?staggered=1&step=4&auto=$auto">~ if ($auto);
print $sub_head;

if ($build_detailed) {
my $t1 = time();
print "Generating detailed view pages . . . \n";
&build_detailed_view;
print "** Done (", time - $t1, " s)!\n";
}
else {
print "Detailed Building is not turned on -- Skipping!\n\n";
}
my $elapsed = time() - $start;

print "------------------------------------------------\n";
print "Step 3 took $elapsed seconds.\n\n";
print qq~</PRE><P><B><font face="Verdana" size=2><a href="nph-build.cgi?staggered=1&step=4&auto=1">Go on to Step 4!</A></B></FONT></P>~;
last CASE;
};

($step == 4) and do {
print $header, $sub_head;

my $t1 = time();
print "** Loading Category information . . .\n";
&build_category_information;
print "** Done (", time - $t1, " s)!\n\n";

$t1 = time();
print "** Loading Summary information . . .\n";
&build_stats (1);
print "** Done (", time - $t1, " s)!\n\n";

$t1 = time();
print "** Creating Home Page . . .\n";
&build_home_page;
print "** Done (", time - $t1, " s)!\n\n";

# $t1 = time();
# print "** Creating What's New Pages . . .\n";
# &build_new_page;
# print "** Done (", time - $t1, " s)!\n\n";


# $t1 = time();
# print "** Creating What's Cool Page. . .\n";
# &build_cool_page;
# print "** Done (", time - $t1, " s)!\n\n";


# $t1 = time();
# print "** Creating Top Rated Page. . .\n";
# &build_rate_page;
# print "** Done (", time - $t1, " s)!\n\n";


my $elapsed = time() - $start;
print "------------------------------------------------\n";
print qq~Step 4 took $elapsed seconds.\n\n<b><a href="$build_root_url" target="_top">Your site</a> is now up to date!</b>~;
last CASE;
};

&cgierr("Unkown step: $step.");
};
}

sub build_all {
# --------------------------------------------------------
# Rebuild the entire directory.

# Determine if we are printing to command line, or to browser.
$nph++;
&html_print_headers() if ($use_html);

my $start = time();
my $date = &get_date;
my $time = &get_time;

# Print HTML Header
$use_html ?
print qq|<html><head><tittle>Links Manager: Building Pages</title></head>
<BASE TARGET="_top">
<BODY BGCOLOR=#FFFFFF><H2><TT>Building Pages</TT></H2>
<PRE>| :
print qq|Building Pages\n|;
print "Pages built on " . $date . " at " . $time . "\n";
print "--------------------------------------------------------\n\n";

# Backup the database.
print "Backing up database . . .\n";
&build_backup;
print "Done.\n\n";

# Rebuild URL Index (This file is auto-generated, you will never need to touch it!
print "Building URL Index . . .\n";
&build_url_index;
print "Done.\n\n";

# Update New and Popular Records..
print "Updating New and Popular Records . . .\n";
&build_update_newpop;
print "Done.\n\n";

# Update voting information ..
print "Updating ratings .. \n";
&build_update_ratings;
print "Done.\n\n";

# Load Category Information
print "Loading Category Information . . .\n";
&build_category_information;
print "Done.\n\n";

# Generate some stats for future pages...
print "Gathering Category and Link information . . .\n";
&build_stats;
print "Done\n\n";

# Generate detailed view pages.
if ($build_detailed) {
print "Generating detailed view pages . . . \n";
&build_detailed_view;
print "Done\n\n";
}

# Create Home Page
$use_html ?
print qq|Building <A HREF="$build_root_url/$build_index">Home Pages</A> . . .\n| :
print qq|Building Home Page . . .\n|;
&build_home_page;
print "\tDone\n\n";

# Create What's New Page
# $use_html ?
# print "Building <A HREF=\"$build_new_url/$build_index\">What's New</A> Page . . .\n" :
# print "Building What's New Page . . .\n";
# &build_new_page;
# print "Done\n\n";


# Create What's Cool Page
# $use_html ?
# print "Building <A HREF=\"$build_cool_url/$build_index\">What's Cool</A> Page . . .\n" :
# print "Building What's Cool Page . . .\n";
# &build_cool_page;
# print "Done\n\n";


# Create Top Rated Page
# $use_html ?
# print "Building <A HREF=\"$build_ratings_url/$build_index\">Top Rated</A> Page . . .\n" :
# print "Building Top Rated . . .\n";
# &build_rate_page;
# print "Done\n\n";


# Create Category Pages
print "Building Category Pages . . .\n";
&build_category_pages;
print "Done\n\n";

# We are finished!
print "Pages Built (", time() - $start, " s)!";
print "</PRE></BODY></HTML>" if ($use_html);
}



In links.def remove the lines in this color


# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, 'name', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, 'a@a.com', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes']
);


Do not copy and paste the changes in links.def as shown above as your settings and numbers are most likely different then the ones i used here, just remove the 4 lines in your script by hand.

Don't forget to CHMOD both files afterwards in 755!

What it will do:

When you have removed the 3 folders "cool" "new" "rating" (you can of course also keep any one of them and in that case you just uncomment or dlete the appropriate portions in the 2 scripts above only) out of your main dir completely hit "build" or "build staggered" (or auto staggered) and you'll notice that the usual rundown of "new" and such stuff is no longer taking up time, script runs straight and quick through step 1.

Once finished with building check back into your main dir, the 3 folders will no longer be installed there by Links which will save you disk space or time to clean those 3 folders out of old crap.



Now some help for me please nayone????

i want to find out how to do a similar thing to the BACKUP!!!

I want Links2 to build only one backup at the time and delete any older ones as it builds a new new during any build process.

There has been a mod postet that promised to do just that, but it didn't work!

Any corrections to that one or a better one or just some new hints please.
Quote Reply
Re: [gossy] easy do to mod to stop "new" "cool" "rating" from being built In reply to
With regards to your backup question,,,Have you tried the codes posted in the following thread?

http://www.gossamer-threads.com/...string=tar.gz;#39472

The codes do work and will allow you to save up to five backup files, you can modify the 5 in the codes and replace it with 1.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] easy do to mod to stop "new" "cool" "rating" from being built In reply to
In Reply To:
With regards to your backup question,,,Have you tried the codes posted in the following thread?

http://www.gossamer-threads.com/...string=tar.gz;#39472

The codes do work and will allow you to save up to five backup files, you can modify the 5 in the codes and replace it with 1.


yep, just finished reading the lot and here is my chronic problem;

I read stuff from pro programmers - as a non programmer.

TAR .GZ ??????

DELETE SPACE BETWEEN ALL "| |"s... ???????

i could copy a few other bits and pices that sound to me like aliens talk.

I can only take the cgi that's already written, uncomment a bit or shuffle some lines around or copy and paste some new ones in.

Here it appears i have to create first some tar file something i have not even heard of yet not to mention have no clue on how to...

I did copy the code section to study but it seems there was additional corrections that i also don't understand nor where they have to be made - in short, this solution might just be a number to complicated for me because of that tar.gz thing.

There must be another way that also someone like me can understand with common logic rather then the techno guru knowledge i don't have
Quote Reply
Re: [Stealth] easy do to mod to stop "new" "cool" "rating" from being built In reply to
so, this mod seemed something i can do (from the same thread as that tar.gz thing) but when i pasted it in i got a SERVER ERROR message, could you perhaps see if or what would be wrong with this mod or why it wouldn't be good to use?

Well, maybe i had the same problem here with that "time.bak" file.

something about producing such "empty" files with extensions i have never used and don't know where to put them or what CHOMD could be why i did not get this to work?????

# ***************************************** modification - begin ****************

#sub build_backup {
## --------------------------------------------------------
## Backs up important database files.
##
# my $date = &get_date;
# if (-e "$db_script_path/backup/$date.links.db") {
# print "\tBackup exists for today.. Skipping\n";
# return;
# }
#
## Try to do it the right way..
# eval { require File::Copy; };
# if (!$@) {
# print "\tBacking up links, category and email database (File::Copy) ... \n";
# &File::Copy::copy ("$db_script_path/data/links.db", "$db_script_path/backup/$date.links.db") or &cgierr ("Unable to copy links backup. Reason: $!");
# &File::Copy::copy ("$db_script_path/data/categories.db", "$db_script_path/backup/$date.category.db") or &cgierr ("Unable to copy category backup. Reason: $!");
# &File::Copy::copy ("$db_script_path/data/email.db", "$db_script_path/backup/$date.email.db") or &cgierr ("Unable to copy email backup. Reason: $!");
# }
## Otherwise, the ugly way.
# else {
# print "\tBacking up links, category and email database (Regular - $@) ... \n";
# foreach (qw!links categories email!) {
# open (TMP, "$db_script_path/data/$_.db") or &cgierr ("Unable to open $db_script_path/data/$_.db. Reason: $!");
# open (TMPOUT, ">$db_script_path/backup/$date.$_.db") or &cgierr ("Unable to open $db_script_path/$date.$_.db. Reason: $!");
# while (<TMP>) {
# print TMPOUT;
# }
# close TMP;
# close TMPOUT;
# }
# }
#}


sub build_backup {
# --------------------------------------------------------
# Backs up important database files.
#

my ($last_date, $date);

open (TIMEBAK, "<$db_script_path/backup/time.bak") or &cgierr ("Unable to open time file: $db_script_path/backup/time.bak. Reason: $!");
$last_date = int <TIMEBAK>;
close TIMEBAK;
$date = time;
if ($date < $last_date + 86400) {
print "\tBackup exists for today.. Skipping\n";
return;
}

# Try to do it the right way..
eval { require File::Copy; };
if (!$@) {
print "\tBacking up links, category and email database (File::Copy) ... \n";
&File::Copy::copy ("$db_script_path/data/links.db", "$db_script_path/backup/links.db") or &cgierr ("Unable to copy links backup. Reason: $!");
&File::Copy::copy ("$db_script_path/data/categories.db", "$db_script_path/backup/categories.db") or &cgierr ("Unable to copy categories backup. Reason: $!");
&File::Copy::copy ("$db_script_path/data/email.db", "$db_script_path/backup/email.db") or &cgierr ("Unable to copy email backup. Reason: $!");
}
# Otherwise, the ugly way.
else {
print "\tBacking up links, category and email database (Regular - $@) ... \n";
foreach (qw!links categories email!) {
open (TMP, "$db_script_path/data/$_.db") or &cgierr ("Unable to open $db_script_path/data/$_.db. Reason: $!");
open (TMPOUT, ">$db_script_path/backup/$_.db") or &cgierr ("Unable to open $db_script_path/backup/$_.db. Reason: $!");
while (<TMP>) {
print TMPOUT;
}
close TMP;
close TMPOUT;
}
}

$date = time;
open (TIMEBAK, ">$db_script_path/backup/time.bak") or &cgierr("Unable to open time file: $db_script_path/backup/time.bak. Reason: $!");
if ($db_use_flock) { flock (TIMEBAK, 2) or &cgierr ("Unable to get exclusive lock on $db_script_path/backup/time.bak. Reason: $!"); }
print TIMEBAK $date;
close TIMEBAK;
}