Gossamer Forum
Home : Products : DBMan : Customization :

Build static .html pages for details

(Page 1 of 2)
> >
Quote Reply
Build static .html pages for details
I’m trying to build a Static HTML page for each record with all the details I am currently using the Short/Long view.


Thanks
Quote Reply
Re: [citybizz] Build static .html pages for details In reply to
You will find some ideas and solution in the FAQ noted below under the section "Files" and then under

SSI & External Files

The thread called "Creating html-pages" may be what you could try, or check the other references in that section.

Hope this helps


Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [citybizz] Build static .html pages for details In reply to
Hi something like this may work:

Code:
#!/usr/bin/perl

print "Content-type: text/html\n\n";

my $db= "/full/path/to/database/default.db";
my $path = "/path/to/build/pages";
my @bla = ();

open (DB, $db) or die $!;
while (<DB>) {
chomp;
@bla = split /\|/;
open (F, ">$path/$bla[0].html") or die $!;
print F @bla;
close F;
}
close DB;

print "Done";

It can obviously be customized but should work. (although not tested)


Last edited by:

RedRum: Oct 2, 2001, 6:32 PM
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
thanks for the help you saved me a lot of time
Quote Reply
Re: [citybizz] Build static .html pages for details In reply to
I was playing around with this and it seems pretty neat. When I viewed the file it created, it just had the line from the db file, and the seperator was taken out. What I was thinking was this actually could be a really hot mod for all of us that use DBMAN if it had a few more features. A lot of us are missing out on search engines because of the meta features. What if you took this simple script and expanded it do the following:

Reads each line of the db. Creates an html file with the record display of how we see it according to our html_record_long (i'm using short/long version). This way people can just run their script to update the records and the search engines pick up these files. Just a thought.

thanks!

ryan

Quote Reply
Re: [ryans] Build static .html pages for details In reply to
That was the idea - I just used print @bla because I couldn't be bothered creating some html :)

Just add:

require "/path/to/html.pl";
require "/path/to/db.cgi";

....and then use:

my (%rec) = &get_record($bla[0]);

print F &html_record_long(%rec);
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
Do you think you can post the whole code? I tried it but I'm getting "Search Item Not Found, Please Retry your Search".

thanks!

ryan

Quote Reply
Re: [ryans] Build static .html pages for details In reply to
Ok well I don't use short/long so I was guessing at the code. I'll post the code today sometime....
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
Cool! I know a lot of people will find this mod handy.

thanks!

ryan

Quote Reply
Re: [ryans] Build static .html pages for details In reply to
Code:
#!/usr/bin/perl

eval {
require "default.cfg";
require "html.pl";
require "db.cgi";
};
$@ and &cgierr ("Error loading required libraries : $@"); }

print "Content-type: text/html\n\n";

my $path = "/path/to/build/pages";

my @bla = ();

open (DB, "<$db_file_name") or &cgierr("Can't open db : $!");
while (<DB>) {
chomp;
@bla = split /\|/;
open (F, ">$path/$bla[0].html") or &cgierr("Can't open db : $!");
my (%rec) = &get_record($bla[0]);
print F &html_record(%rec);
close F;
print "Detailed Page $bla[0]....created!";
}
close DB;

Well that's the general idea. I've not tested it so it is guaranteed not to work but feel free to let me know if it craps out.

You can change &html_record(%rec) to whatever you want but I don't use short/long so I can't give an example with that code at the moment.

Last edited by:

RedRum: Oct 26, 2001, 10:33 AM
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
hmm...same thing :(. I'll install a fresh copy of dbman withouth the long/short and see if it works.


Quote Reply
Re: [ryans] Build static .html pages for details In reply to
Actually I get this error message:

syntax error at ./produce2.pl line 8, near "; }"
Execution of ./produce2.pl aborted due to compilation errors.

Quote Reply
Re: [ryans] Build static .html pages for details In reply to
Oops.

Change

$@ and &cgierr ("Error loading required libraries : $@"); }

to

$@ and &cgierr ("Error loading required libraries : $@");
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
Hmm..i had my friend look at it earlier, he came up with this. He doesnt know DB man though.

#!/usr/bin/perl
eval
{
require "default.cfg";
require "html.pl";
require "db.cgi";
$@ and &cgierr ("Error loading required libraries : $@");
};

print "Content-type: text/html\n\n";
my $path = "pages";
my @bla = ();
#open (DB, "<$db_file_name") or &cgierr("Can't open db : $!");

open (DB, "<$db_file_name") || die "cant open db : $!";
while (<DB>) {
chomp;
@bla = split /\,/;
open (F, ">$path/$bla[0].html") or &cgierr("Can't open db : $!");
my (%rec) = &get_record($bla[0]);
print F &html_record(%rec);
close F;
print "Detailed Page $bla[0]....created!";
}
close DB;

With this it says

cant open db : No such file or directory at ./produce2.pl line 15.


?? :)

Last edited by:

ryans: Oct 26, 2001, 6:58 PM
Quote Reply
Re: [ryans] Build static .html pages for details In reply to
You shouldn't put:

$@ and &cgierr ("Error loading required libraries : $@");

Inside the eval { }; block.

Try replacing $db_file_name with the full path to your database like : /full/path/to/default.db

Also make sure these:

eval
{
require "default.cfg";
require "html.pl";
require "db.cgi";
};


......are pointing to the correct place. Currently it assumes that the files are in the current directory.

Last edited by:

RedRum: Oct 27, 2001, 3:40 AM
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
Yup, I was pointing to the correct code, just edited it so people don't really see my paths. I still get the same error message. I setup a clean version and still get the same probs.

thanks

ryan



Quote Reply
Re: [ryans] Build static .html pages for details In reply to
You can't still be getting the same error on the same line.
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
Ok, here is the code that i'm using:

#!/usr/bin/perl
eval
{
require "default.cfg";
require "html.pl";
require "db.cgi";
};
$@ and &cgierr ("Error loading required libraries : $@");

print "Content-type: text/html\n\n";
my $path = "/web/docs/www.mysite.com/htdocs/cgi-bin/dbman/pages";
my @bla = ();
open (DB, "</web/docs/www.mysite.com/htdocs/cgi-bin/dbman/default.db") or &cgierr("Can't open db : $!");
while (<DB>) {
chomp;
@bla = split /\,/;
open (F, ">$path/$bla[0].html") or &cgierr("Can't open db : $!");
my (%rec) = &get_record($bla[0]);
print F &html_record(%rec);
close F;
print "Detailed Page $bla[0]....created!";
}
close DB;

and the error message I get:

./produce.pl
Undefined subroutine &main::cgierr called at ./produce.pl line 8.

Quote Reply
Re: [ryans] Build static .html pages for details In reply to
You shouldn't get that as you are requiring the file that has sub cgierr in it.

Anyway change:

open (DB, "</web/docs/www.mysite.com/htdocs/cgi-bin/dbman/default.db") or &cgierr("Can't open db : $!");

to

open (DB, "</web/docs/www.mysite.com/htdocs/cgi-bin/dbman/default.db") or print "Can't open db : $!" and exit;

....and.........

open (F, ">$path/$bla[0].html") or &cgierr("Can't open db : $!");

to:

open (F, ">$path/$bla[0].html") or print "Can't open db : $!" and exit;

Last edited by:

RedRum: Oct 28, 2001, 1:26 PM
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
Ok Made the changes but still get the error on line 8

Undefined subroutine &main::cgierr called at ./produce.pl line 8.

-ryan
Quote Reply
Re: [ryans] Build static .html pages for details In reply to
you think I should't get that error message?
Quote Reply
Re: [ryans] Build static .html pages for details In reply to
You shouldn't be getting the error about cgierr if you made the changes I suggested.

You should also change:

$@ and &cgierr ("Error loading required libraries : $@");

print "Content-type: text/html\n\n";

to:

print "Content-type: text/html\n\n";

$@ and print "Error loading required libraries : $@" and exit;

Last edited by:

RedRum: Oct 29, 2001, 2:49 PM
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
getting much closer....here is the new error message:

Error loading required libraries : Can't locate /html.pl at default.cfg line 8.
Compilation failed in require at ./produce.pl line 4.

Quote Reply
Re: [ryans] Build static .html pages for details In reply to
Use full paths in all the require's

Once that is working then &cgierr will work too.

Last edited by:

RedRum: Oct 29, 2001, 4:20 PM
Quote Reply
Re: [RedRum] Build static .html pages for details In reply to
yup, still got the same message. looks like it might be in default.cfg file?

#!/usr/bin/perl
eval
{
require "/web/docs/www.mysite.com/htdocs/cgi-bin/dbman/default.cfg";
require "/web/docs/www.mysite.com/htdocs/cgi-bin/dbman/html.pl";
require "/web/docs/www.mysite.com/htdocs/cgi-bin/dbman/db.cgi";
};
print "Content-type: text/html\n\n";
$@ and print "Error loading required libraries : $@" and exit;
my $path = "/web/docs/www.mysite.com/htdocs/cgi-bin/dbman/pages";
my @bla = ();
open (DB, "</web/docs/www.mysite.com/htdocs/cgi-bin/dbman/default.db") or &cgierr("Can't open db : $!");
while (<DB>) {
chomp;
@bla = split /\,/;
open (F, ">$path/$bla[0].html") or &cgierr("Can't open db : $!");
my (%rec) = &get_record($bla[0]);
print F &html_record(%rec);
close F;
print "Detailed Page $bla[0]....created!";
}
close DB;
> >