Gossamer Forum
Home : Products : Links 2.0 : Customization :

Mirror (in different directory) of the html pages

Quote Reply
Mirror (in different directory) of the html pages
Hi,
this may sound really stupid, but I want to create two sets of html pages, in two different directories.
(I just have too much space - hehe - NOT ;-).

Anyway, I will of course be using this mirror to modify it. Problem is - that I know what to modify, but I don't know an easy way of modifying nph-build.cgi to build in two different locations at the same time..

Please advice.
Quote Reply
Re: Mirror (in different directory) of the html pages In reply to
Hmm...after looking through the code more thoroughly - I would like to revise my question a bit.

I would like to build the category html files in two different directories. That is all the pages built from the build_category_pages subroutine in nph-build.cgi

Can I just make a new build_category_pages subroutine, and hardcode the new directory (dirty hack I know)?
Or would I destroy any variables by doing it this way.
Quote Reply
Re: Mirror (in different directory) of the html pages In reply to
In nph-build.cgi, sub build_category_pages, change:

Quote:
# Create the main page.
open (CAT, ">$dir/$build_index") or &cgierr ("unable to open category page: $dir/$build_index. Reason: $!");
print CAT &site_html_category;
close CAT;

to read:

Quote:
# Create the main page.
open (CAT, ">$dir/$build_index") or &cgierr ("unable to open category page: $dir/$build_index. Reason: $!");
open (CAT2, ">/full/path/to/category/mirror/$build_index") or &cgierr ("unable to open category mirror page: /full/path/to/category/mirror/$build_index. Reason: $!");
print CAT &site_html_category;
print CAT2 &site_html_category;
close CAT;

Then change:

Quote:
open (CAT, ">$dir/more$page_num$build_extension") or &cgierr ("unable to open category page: $dir/index$page_num$build_extension. Reason: $!");
print CAT &site_html_category;
close CAT;

To read:

Quote:
open (CAT, ">$dir/more$page_num$build_extension") or &cgierr ("unable to open category page: $dir/index$page_num$build_extension. Reason: $!");
open (CAT2, ">/full/path/to/category/mirror/more$page_num$build_extension") or &cgierr ("unable to open category page: /full/path/to/category/mirror/index$page_num$build_extension. Reason: $!");
print CAT &site_html_category;
print CAT2 &site_html_category;
close CAT;

I hope this helps.
Quote Reply
Re: Mirror (in different directory) of the html pages In reply to
Wow, this little exchange is so awesome and powerful...with these few lines you can create many different versions of links and send it to different places while keeping everything in one database....coooool.

To really make this flexible you could have an additional field in the category.db which tells you which mirror each category belongs to and supress cats on that basis...like I said, cooool.
Quote Reply
Re: Mirror (in different directory) of the html pages In reply to
well, it's way easier than what I managed to come up with the last few hours before Bobsie replied to my posting... :-)
Thanks Bobsie, I'm going to try it out, just have to wait for my sysadmin to fix a permission problem. Perl runs as nobody/nobody here, and when I took out the tar backup - all the files got my user/group instead - thus "permission denied all over".

The thing I wonder about here though, is - shouldn't I have a "close CAT2;" on the end there? Or is there any magic?
Thanks again.
Quote Reply
Re: Mirror (in different directory) of the html pages In reply to
do you use the same template? what i'm trying to ask is it possible to use the same data yet get 2 different looking directory?
Quote Reply
Re: Mirror (in different directory) of the html pages In reply to
theguy,

Since the original request was for a "mirror" it does use the same templates. Thus, the mirror is an exact copy of the original. I am still not sure why he would want a mirror on the same server though. To me, that is a backup, not a mirror. A mirror would be an identical site on another server. Also note that this is just for the category pages. You would need to do the same type of thing for all the other pages as well such as New and Cool and Home pages.

Mines not to reason why. I just provided an answer. Smile

[This message has been edited by Bobsie (edited June 19, 1999).]