Namazu-users-en(old)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

namazu doing CGI env check (was Re: Formats of NMZ.* files)



On August 30, 2002 at 15:48, Makoto Fujiwara wrote:

> namazu +message-id:'<real-message-id-with-quotes>' -l index-directory
> will return the path to the file you are looking for.
> 
> For example,
> > namazu +message-id:'<4B598UC7H96X3B.6HPS9T.makoto@xxxxx>' -l /hoge/index
> Mail/from/myself/3113

When I tried this via a CGI program, namazu complains that namazu.cgi
should be used.  However, namazu.cgi does not give me what I want, so
I did the following hack to keep namazu from complaining:

  ...
  my $uri = undef;
  my @cmd = ($namazu_prg, '+message-id:'.$id, '-l', $index);
  local(*NMZ);
  my $child_pid = open(NMZ, '-|');
  if (!$child_pid) {
    # child process
    # reset envariables to keep namazu from complaining
    local(%ENV) = ( );
    $ENV{'PATH'} = $bin_search_path;
    select(STDERR); $| = 1;
    select(STDOUT); $| = 1;
    open(STDERR, '>&STDOUT');
    exec(@cmd);
  }

  # parent process
  local $_;
  while (<NMZ>) {
    chomp;
    next  unless /\S/;
    $uri = $_  if /^\//;
  }
  if (!close(NMZ)) {
    warn qq/Non-zero exit status from "@cmd": $! $?\n/;
  }
  ...

Now, I can get the full pathname of an archived message with reading
the NMZ.* files myself (thanks goto Makoto).

I still parse the .namazurc file inorder to get the URL version of
the file (by using the Replace directives).  Reason: The CGI program
will actually serve up the message file itself, but when it encounters
the <head> tag, it adds a <base href> tag so the relative links of
the message file will work properly.

The goal of the CGI is to allow for a "permanent" bookmark to an
archived message.  A problem with MHonArc's message number system is
that if archive is rebuilt from raw messages, but some raw messages have
been deleted and/or are in different order, the message numbering will
be different.  This is a problem for people you reference archived
messages in their mail.

My CGI program is an attempt to fix the problem.  For each archive page,
I plan to add a "[Bookmark Link]" anchor.  This anchor is to be used
for bookmarking an archived message or to provide a persistent link to
the message.

The CGI and "[Bookmark Link]" anchor layout will be added in a future
release of the mharc archiving system.

--ewh

--ewh