|
Whatnew - Generate links of recently documents. |
Whatnew - 最近更新されたdocumentのLinkを生成する
$Id: Whatnew.pm,v 1.7 2002/04/20 13:48:24 T.Shigetome Exp $
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();
これはCGI program用moduleである。自動的に最新のペイヂへのLinkを作成する。 コンテンツが更新されると、それは自動的にLinkに追加される。 そして、そのLinkに更新情報を付け加えることもできる。 それはとても簡単で、HTML file中に更新情報をMETA tagを使って記述するだけである。
例...
<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_
">
上記 `_ThIs_Is_A_BoUnDaRy_StRiNg_' は更新情報の境界文字列として使用される。
TこのmoduleはCGI programから次のように使われる。
http://www.any.com/~foo/cgi-bin/sample.cgi?config=test&func=disp
remote で使用される。
new([$cgi_object])
my($form) = new Whatnew;
CGIインスタンスは本moduleによって自動的に生成される。
or
my($q) = new CGI;
my($form) = new Whatnew($q);
SetParameter($rh_para)
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);
例...
<!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>
func=get'を使って指定する。
複数のサーバーがある場合、それぞれの更新情報を1つに結合することができる。
もし、複数の定義が必要ならば`;'で区切って記述できる。
その場合、間に空白文字を入れてはならない。
T他にも隠す方法があり、更新情報として `NOPICK' と記述すればそのコンテンツは無視される。 通常この方法は使用すべきではない、この方法は処理をかなり重くする。
上記の区切り文字 `;' は Params.pm中の `$Params::delimiter' で定義される。
OutResponse()func'で指定されたfunctionに沿って更新されたペイヂの情報を返す。 .
config()例...
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)debug($debug_opt)
$form->debug('configpara');
$form->debug('remote');
$form->debug('search');
$form->debug('template');
デバッグ情報は標準エラー出力に出力される。 標準エラー出力を debuglog.pl か若しくは他の方法でリダイレクトすれば記録できる。
デバッグを完了すれば、このmoduleからデバッグコードを取り除く事ができる。 全てのデバッグコードは `#>>>DEBUG_CODE' で挟まれている。 striper.pl を使って削除できるだろう。
strict.pm, Carp.pm, CGI.pm, HTML::HeadParser.pm, Params.pm, Timestr.pm,
次のmoduleはremoteからgetする為に使用される。 もし、複数の更新情報を結合表示する場合、これらのmoduleをuseしなければならない。
LWP::UserAgent, HTTP::Request, HTTP::Message,
Params.pm, Timestr.pm, CGI.pm
Tetsuya Shigetome, <t_shigetome@muf.biglobe.ne.jp>.
History.pm
Some variable is globalised.
Fixed bugs
o Sort order is not numerically.
Compliant Timestr.pm and Params.pm. I hope, it's given simplified to use parameter file.
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.
o Change some comments.
o Correct merge display problem.
o Change to sepcify debug options.
o Some new capables
Support convert code.
Support hide temporary.
First of Perl module version
|
Whatnew - Generate links of recently documents. |