How to make a Mod. (From the WebAPP Main Site) So, you have installed WebAPP and you're pretty pleased with yourself, but you think to yourself, "I want a guestbook for my site!" Ok then. You have a look at the WebAPP site to see if there is a Guestbook Mod available. If there isn't, or you don't like the one(s) on offer, you may want to write your own. To make your guestbook fit in with the rest of your site, it is best to write a Mod! Here is how you can do this. Your basic mod is made up of 5 basic parts (give or take): An index.cgi: which displays the information. (Though you could call it guestbook.cgi!) A config.dat file: which holds the Mod information. (This can be made by the installed Mod Manager if you wish!) An admin script: which lets you edit the information. (Though this isn't always required!) A .html file that points to your mod. (Though a link on your main page pointing to the .cgi file is just as good) A Data directory (if required). If you wish to make use of the Language Support features of WebAPP, you'll have to make a language file too! Once you have these files you can create a structure for them to be uploaded to your server. An example structure of a FAQ Mod could look like this:
code: /faq.html /cgi-bin/mods/faq /cgi-bin/mods/faq/index.cgi /cgi-bin/mods/faq/config.dat /cgi-bin/mods/faq/language /cgi-bin/mods/faq/language/english.dat /cgi-bin/mods/faq/admin /cgi-bin/mods/faq/admin/admin.cgi /cgi-bin/mods/faq/data /cgi-bin/mods/faq/data/faq.txt /cgi-bin/mods/faq/language /cgi-bin/mods/faq/language/english.dat If all your paths are set right and you have chmod all the .cgi files to 755 you should be ready to go! Now, some more detail! config.dat Files Before the v0.9.3c release of Mod Manager, the config.dat file had to exist, but now that isn't the case. Mod developers need not create a config.dat file now, as the Mod Manager will do it for you. Here is an example of a v0.9.9.3.1 config.dat file.
code: $config_vers = "0.9.9.3.1"; $mod_name = "Name"; $mod_vers = "0.1"; $mod_desc = "Short Description"; $mod_admin = "0"; # 0=No, 1=Yes $admin_name = "admin.cgi"; $lang_support = "0"; # 0=No, 1=Yes $mod_lang = "english.dat"; 1;
If there are any new developments in the structure of the config.dat files, Mod Manager will let you know! Language Support It is fairly straight forward to create a language file for your mod. Here is a cut down example of a real Mod language file.
code: $linktous{'001'} = "If you would like to exchange banner links with us..."; $linktous{'002'} = "1. Please save one of the following graphics..."; $linktous{'003'} = "2. Add our link to your website using the URL "; $linktous{'004'} = "3. Then complete the form below and click Send."; < ----------------- > $linktous{'025'} = "Their site is at"; $linktous{'026'} = "Their banner is at"; $linktous{'027'} = "They have placed our link at"; $linktous{'028'} = "Thank you."; 1;
In the above example, I placed a file called "english.dat" in cgi-bin/mods/linktous/language. Once you have finished, save your language file as english.dat, for example and then upload it to your site. index.cgi Use the script below as your starting point!
code: #!/usr/bin/perl -w $| = 1; use CGI::Carp qw(fatalsToBrowser); ############################################################################### ############################################################################### # WebAPP - Automated Perl Portal # # # # Copyright (C) 2002 by Carter (carter@mcarterbrown.com) # # # # This program is free software; you can redistribute it and/or # # modify it under the terms of the GNU General Public License # # as published by the Free Software Foundation; either version 2 # # of the License, or (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License along # # with this program; if not, write to the Free Software Foundation, Inc., # # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # # # Last modified: 05/13/02 # ############################################################################### ############################################################################### use vars qw($scriptname $anonuser @months @days); eval { require "../../config.pl"; require "$sourcedir/subs.pl"; require "config.dat"; }; if ($@) { print "Content-type: text/html\n\n"; print qq~<h1>Software Error:</h1> Execution of <b>$scriptname</b> has been aborted due a compilation error:<br> <pre>$@</pre> <p>If this problem persists, please contact the webmaster and inform him about date and time you've received this error.</p> ~; exit; } $anonuser = "Guest"; @months = qw(January February March April May June July August September October November December); @days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday); getcgi(); getdate(); loadcookie(); loaduser(); logips(); &ban; logvisitors(); &getver; #################################### # A Wonderful Mod By Me! #################################### if ($lang_support eq "1") { mod_langsupp(); } < -The Bulk of Your script Goes Here, Then finish like...- > ################## sub mod_langsupp { ################## my $modlang = $userlang; $modlang =~ s/\.lng$//; eval { require "language/$modlang.dat"; }; if ($@) { mod_langsuppfail();} } ###################### sub mod_langsuppfail { ###################### eval { require "language/$mod_lang"; }; if ($@) { print "Content-type: text/html\n\n"; print qq~<h1>Software Error:</h1> Execution of <b>$scriptname</b> has been aborted due a compilation error:<br> <pre>$@</pre> <p>If this problem persists, please contact the webmaster and inform him about date and time you've received this error.</p> ~; exit; } } 1;
NOTE: If you are writing the admin.cgi script, don't forget to alter the paths!
code: eval { require "../../../config.pl"; require "$sourcedir/subs.pl"; require "../config.dat";
and...
code: eval { require "../language/$modlang.dat";
and...
code: eval { require "../language/$mod_lang";
Well, that should have given you a start! If you have made a wonderful Mod, then please share it with us! |