Whatnew - Generate links of recently documents.

Access counter


NAME

Whatnew - Generate links of recently documents.

$Id: Whatnew.pm,v 1.7 2002/04/20 13:48:24 T.Shigetome Exp $


SYNOPSIS

        use Whatnew;
        my($form) = new Whatnew;
        my(%config) = (
                'html_root'     =>      '/home/foo/public_html=http://www.any.com/~foo',
                'search'        =>      '/home/foo/public_html',
                'temp'          =>      '/home/foo/public_html/work/whatnew.tmp',
                'template'      =>      '/home/foo/public_html/work/template.html',
        );
        $form->ParseQuery();
        $form->SetParameter(\%config);
        $form->OutResponse();


DESCRIPTION

This is for CGI program. Create links of newest items automatically. If you update some HTML contents on Web server, it will be automatically appended to links. And, you can append topics about update to links. That way is very easy, you just only describe about update information in that HTML file. Update information is described with meta tag in head block.

Like as...

        <META name="UpdateInfo" content="
                Second update information
                Also you can describe more than two lines.
        _ThIs_Is_A_BoUnDaRy_StRiNg_
                First update information
        _ThIs_Is_A_BoUnDaRy_StRiNg_
                It's NEW!!
        _ThIs_Is_A_BoUnDaRy_StRiNg_
        ">

Above `_ThIs_Is_A_BoUnDaRy_StRiNg_' is used for boundary string of each update information record.

CGI ARGUMENT

This module will be used for CGI program. Like as...

        http://www.any.com/~foo/cgi-bin/sample.cgi?config=test&;func=disp
func
There are two functions.
disp
Response links of newest items as HTML page. Usually use this function.

get
Response newest items record file. This is used for join another server information. This function will be used described in parameter of `remote'.

config
Value of `config' in QUERY STRING.

That value is used for hint of selecting from parameter set. I hope to use with Params.pm.

METHOD

new([$cgi_object])
Create new instance
        my($form) = new Whatnew;

The CGI instance will be created by Whatnew automatically.

or

        my($q) = new CGI;
        my($form) = new Whatnew($q);

SetParameter($rh_para)
Setup of parameter The $rh_para is reference of hash or filename of parameter file. If you specify a parameter file name, that parameter file will be parsed with Params.pm.
        my($form) = new Whatnew($q);
        my(%config) = (
                'html_root'     =>      'file path=url path',
                'search'        =>      'search file path',
                'temp'          =>      'temporary file',
                'template'      =>      'HTML template',
                'remote'        =>      'http://www.another.server/cgi-bin/sample.cgi?config=configname&;func=get',
                'hidden'        =>      'hidden path',
                'mask'          =>      'regular expression for mask',
        );
        $form->SetParameter(\%config);
html_root
Specify file path connection with URL path. If you want to two or more html root, you can describe separated each one by `;'. Do NOT insert space character between each define.

search
Scan file path of newest items. This module will search all of items under specified path. If you want to two or more, you can describe separated each one by `;'. Do NOT insert space character between each define.

temp
Temporary file. This module will generate temporary file for performance.

template
Used for links page. It's easy customizing. Like as...
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
        <HTML lang="en">
        <HEAD>
        <META http-equiv="Content-Type" CONTENT="text/html; charset=ISO-8859-5">
        <META name="Author" content="Foo">
        <TITLE>What's NEW?</TITLE>
        <MEATA name="UpdateInfo" content="
                What's NEW template
        _ThIs_Is_A_BoUnDaRy_StRiNg_"
        >
        </HEAD>
        <BODY>
        <H1>What's NEW?</H1>
        <HR>
        <TABLE summary="NEW contents" rule="none" cellspacing="0">
        <!--
                Following comment statement will be replaced to new documents information.
                You can customize that.
                These keywords will be handled about associated document.
                Like as...
                %mtime% : Modified time
                %URL%   : URL
                %title% : Title in head block of that document
                %x-meta-updateinfo%
                        : Update information
                          It's described in head block of that document.
                          If you want to use this field, you must append it along specified format when you update document.
        -->
        <!-- NEW items
        <TR>
        <TD VALIGN="top">%mtime%</TD><TD><P><A HREF="%URL%">%title%</A></P><PRE>%x-meta-updateinfo%</PRE></TD>
        </TR>
        NEW items -->
        </TABLE>
        <HR>
        </BODY>
        </HTML>

remote
Optional parameter. Specify another Whatnew CGI program with `func=get'. If you have several server, you can merge to one links page from each server. If you want to two or more, you can describe separated each one by `;'. Do NOT insert space character between each define.

hidden
Optional parameter. Specify hidden path. That path and under items will be ignored. If you want to two or more, you can describe separated each one by `;'. Do NOT insert space character between each define.

There is another way to hide. Describe `NOPICK' as update information. That content will be ignored. Basically you should not use this way, it is heavy.

mask
Optional parameter. Specify mask. If full path filename is matched to mask, that will be ignored. If you want to two or more, you can describe separated each one by `;'. Do NOT insert space character between each define.

Above delimiter string that is `;' is defined by `$Params::delimiter' in Params.pm.

OutResponse()
Output response of newest items link along specified function by`func'.

config()
Return configuration name of `config' from CGI query string. I think, that configuration name is useful with Params.pm. ;)

Like as... sample.cgi

        use Whatnew;
        my($form)= new Whatnew;
        $form->ParseQuery();
        local($main::configname) = $form->config();
        $form->SetParameter("sample.par");
        $form->OutResponse();

sample.par

        ########################################################
        #if $main::configname eq 'test'
                #define CONFIG_NAME test
        #endif
        #define ROOTPATH /home/foo/public_html
        #define WORKPATH %ROOTPATH%/work
        #define HTML_ROOT http://www.any.com/~foo
        # 12*60*60
        #
        # define config1 parameters
        #
        #
        # File path to HTML root
        #
        %CONFIG_NAME% html_root{
                %ROOTPATH%=%HTML_ROOT%;
        };
        #
        # temporary file
        #
        %CONFIG_NAME% temp{
                %WORKPATH%/whatnew.tmp;
        };
        #
        # HTML template
        #
        %CONFIG_NAME% template{
                %WORKPATH%/template.html;
        };
        #
        # Common update information
        #
        %CONFIG_NAME% search{
                %ROOTPATH%;
        };
        #
        # No care directries
        #
        %CONFIG_NAME% hidden{
                %ROOTPATH%/debug;
        };
        %CONFIG_NAME%   mask{
                template\.html;
                test;
        };

charset($ocode)
$ocode is to give to jcode::covert(). If your contents is used some code, it will be cause of corrupt. This to do is made clear that problem.

debug($debug_opt)
Toggle each debug condition. Default is debug off. There are four debugging options.
        $form->debug('configpara');
        $form->debug('remote');
        $form->debug('search');
        $form->debug('template');

Message of debugging will be outputted to STDERR. Also. you can log by redirect STDERR with debuglog.pl or other.

When you terminate debugging, you can strip debugging code from this module. All of debugging code are between line of `#>>>DEBUG_CODE'. These are able to strip by striper.pl.

configpara
Debug of parameter

remote
Debug of getting records via HTTP.

search
Debug of search process.

template
Debug of parsing template.

Require modules

strict.pm, Carp.pm, CGI.pm, HTML::HeadParser.pm, Params.pm, Timestr.pm,

Following modules are used for get from remote. So, if you want to get update information from other server, you must use these modules yourself.

LWP::UserAgent, HTTP::Request, HTTP::Message,


SEE ALSO

Params.pm, Timestr.pm, CGI.pm


AUTHOR

Tetsuya Shigetome, <t_shigetome@muf.biglobe.ne.jp>.


HISTORY

$Revision: 1.7 $
$Log: Whatnew.pm,v $ Revision 1.7 2002/04/20 13:48:24 T.Shigetome Compliant

History.pm

Some variable is globalised.

Revision: 1.6
Log: Whatnew.pm,v Revision 1.6 2002/04/14 15:25:03 T.Shigetome

Fixed bugs

o Sort order is not numerically.

Compliant Timestr.pm and Params.pm. I hope, it's given simplified to use parameter file.

Revision: 1.5
Log: Whatnew.pm,v Revision 1.5 2001/07/30 09:28:33 shige
 o Fixed problem of Server error 500 when get from remote.

Revision 1.4 2001/05/19 16:54:03 shige

 o Correct corrupt problem when comment avail after replace keyword.

Revision: 1.3
Log: Whatnew.pm,v Revision 1.3 2001/02/10 16:32:34 shige

o Change some comments.

Revision: 1.2
Log: Whatnew.pm,v Revision 1.2 2001/02/10 16:02:07 shige
 o Correct merge display problem.
 o Change to sepcify debug options.
 o Some new capables
    Support convert code.
    Support hide temporary.

Revision: 1.1
Log: Whatnew.pm,v Revision 1.1 2000/12/14 16:59:34 shige

First of Perl module version

 Whatnew - Generate links of recently documents.