Date: Mon, 24 Mar 2003 23:45:13 +0100 From: "Peter Klausner" <peter.klausner@systor.com> To: freebsd-cvsweb@FreeBSD.org Subject: More complex links to PR database Message-ID: <OF1F74A825.C2FEAA63-ON41256CF3.007CFD4F-41256CF3.007CFD9D@systor.com>
next in thread | raw e-mail | index | archive | help
Cvsweb has a feature to link the comment text to
a (web-based) problem report database like GNAT.
Below is a small patch, which allows you to configure
a _routine_ to link to your PR/CR/MR/whatever system.
The example pr_link() implements the existing behaviour
plus links to T-Wiki pages.
Of course, it is more difficult to configure such a routine,
than the existing variables. But I guess, that admins,
who actually use this feature, will appreciate the flexibility.
HTH + Bye
Peter Klausner
Index: cvsweb.conf
===================================================================
RCS file: /var/cvs/cgi-bin/cvsweb.conf,v
retrieving revision 1.3
diff -c -r1.3 cvsweb.conf
*** cvsweb.conf 2003/03/14 13:55:56 1.3
--- cvsweb.conf 2003/03/17 17:42:37
***************
*** 9,15 ****
# based on work by Bill Fenner <fenner@FreeBSD.org>
#
# $FreeBSD: projects/cvsweb/cvsweb.conf,v 1.43 2002/11/16 00:01:01 scop
Exp $
! # $Id: cvsweb.conf,v 1.3 2003/03/14 13:55:56 peter Exp $
# $Idaemons: /home/cvs/cvsweb/cvsweb.conf,v 1.27 2001/08/01 09:48:39 knu
Exp $
#
###
--- 9,15 ----
# based on work by Bill Fenner <fenner@FreeBSD.org>
#
# $FreeBSD: projects/cvsweb/cvsweb.conf,v 1.43 2002/11/16 00:01:01 scop
Exp $
! # $Id: cvsweb.conf,v 1.4 2003/03/14 18:01:40 peter Exp $
# $Idaemons: /home/cvs/cvsweb/cvsweb.conf,v 1.27 2001/08/01 09:48:39 knu
Exp $
#
###
***************
*** 66,94 ****
# you enter the page
$cvstreedefault = $CVSrepositories[2 * 0]; # The first one
- ##############
- # Bug tracking system options
- # ("PR" means Problem Report, as in GNATS)
- ##############
- #@prcategories = qw(
- # advocacy
- # alpha
- # bin
- # conf
- # docs
- # gnu
- # i386
- # kern
- # misc
- # pending
- # ports
- # sparc
- #);
! #
! #$prcgi = "http://www.FreeBSD.org/cgi/query-pr.cgi?pr=%s";
#
! #$prkeyword = "PR";
##############
# Manual gateway
--- 66,90 ----
# you enter the page
$cvstreedefault = $CVSrepositories[2 * 0]; # The first one
! # Bug tracking system options:
! # Define a subroutine to scan cvs comment for linkable patterns.
#
! sub pr_link
! {
! my $comment = $_[0]; # return this comment with links
!
! $comment =~ s|\bPR[#: ]*(\d+)\b|<a href=/cgi-bin/pr.cgi?$1>PR#$1</a>|g;
! $comment =~ s(\b(advocacy|alpha|bin|conf|docs|gnu|i386)/(\d+)\b)
! (<a href=/cgi-bin/pr.cgi?$2>$1/$2</a>)g;
!
! $comment =~ m/^(.*?)([A-Z][A-Za-z0-9_-]+)(.*)$/s; # a wiki word?
! return "$1<a href=/twiki/view/Aproject/$2>$2</a>$3"
! if -f
"/var/twiki/data/Aproject/$2.txt";
! return "$1<a href=/twiki/view/Bproject/$2>$2</a>$3"
! if -f
"/var/twiki/data/Bproject/$2.txt";
! return $comment;
! }
!
##############
# Manual gateway
Index: cvsweb.cgi
===================================================================
RCS file: /var/cvs/cgi-bin/cvsweb.cgi,v
retrieving revision 1.4
retrieving revision 1.5
diff -c -r1.4 -r1.5
*** cvsweb.cgi 2003/03/14 13:55:56 1.4
--- cvsweb.cgi 2003/03/14 18:01:40 1.5
***************
*** 47,53 ****
#
# $Zeller: cvsweb.cgi,v 1.112 2001/07/24 13:03:16 hzeller Exp $
# $FreeBSD: projects/cvsweb/cvsweb.cgi,v 1.137 2002/11/24 16:29:13 scop
Exp $
! # @(#)$Id: cvsweb.cgi,v 1.4 2003/03/14 13:55:56 peter Exp $
#
###
--- 47,53 ----
#
# $Zeller: cvsweb.cgi,v 1.112 2001/07/24 13:03:16 hzeller Exp $
# $FreeBSD: projects/cvsweb/cvsweb.cgi,v 1.137 2002/11/24 16:29:13 scop
Exp $
! # @(#)$Id: cvsweb.cgi,v 1.5 2003/03/14 18:01:40 peter Exp $
#
###
***************
*** 498,506 ****
}
undef $config_cvstree;
- $re_prcategories = '(?:' . join ('|', @prcategories) . ')' if
@prcategories;
- $re_prkeyword = quotemeta($prkeyword) if defined($prkeyword);
- $prcgi .= '%s' if defined($prcgi) && $prcgi !~ /%s/;
$fullname = "$cvsroot/$where";
$mimetype = &getMimeTypeFromSuffix($fullname);
--- 498,503 ----
***************
*** 1256,1295 ****
>egix;
} $_;
! if ($extra) {
! # get PR #'s as link: "PR#nnnn" "PR: nnnn, ..." "PR nnnn, ..."
"bin/nnnn"
! if (defined($prcgi) && defined($re_prkeyword)) {
! my $prev;
!
! do {
! $prev = $_;
!
! $_ = htmlify_sub {
! s{
! (\b$re_prkeyword[:\#]?\s*
! (?:
! \#?
! \d+[,\s]\s*
! )*
! \#?)
! (\d+)\b
! }{
! $1 . &link($2, sprintf($prcgi, $2))
! }egix;
! } $_;
! } while ($_ ne $prev);
!
! if (defined($re_prcategories)) {
! $_ = htmlify_sub {
! s{
! (\b$re_prcategories/(\d+)\b)
! }{
! &link($1, sprintf($prcgi, $2))
! }egox;
! } $_;
! }
! }
# get manpage specs as link: "foo.1" "foo(1)"
if (defined($mancgi)) {
--- 1253,1261 ----
>egix;
} $_;
! $_ = pr_link($_) or die "pr_link fehlt!?";
! if ($extra) {
# get manpage specs as link: "foo.1" "foo(1)"
if (defined($mancgi)) {
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-cvsweb" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OF1F74A825.C2FEAA63-ON41256CF3.007CFD4F-41256CF3.007CFD9D>
