gfsd-hackers
[Top][All Lists]
Advanced

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

[gfsd]cgi script


From: Brian Gough
Subject: [gfsd]cgi script
Date: Mon, 3 Sep 2001 22:51:51 +0100 (BST)

I have written a small prototype script for editing Free Software
Directory entries via the web.

At the moment it just creates a form and displays the submitted input.

The script is available for downloading at
http://www.network-theory.co.uk/cgi-edit.pl.txt

It will display an existing entry for editing using a ?package=NAME
cgi argument in the URL.  Otherwise it will give a blank form for a
new entry.

>From reading the archives of the list I saw that the plan is to have
the results sent by email and then incorporated into CVS after manual
inspection.  

If the cgi-script made a 'diff' and emailed it to
address@hidden would this be the best way to do this, rather
than dealing with whole files?  This would make it possible to combine
several independent changes, and would also be easier to inspect.  

An emacs macro could be used to apply the patch directly from the
email with a single key press. The form could have an extra space for
a check-in message provided by the user, also their email address,
which could go into the mail and be processed automatically too
(e.g. to send them a 'thank-you' message when it is commited).

The use of the external diff command from the cgi script would need
some care from a security point of view, but I think it is manageable.

Let me know if this sounds reasonable.

regards
Brian Gough

p.s. I needed to make a couple of patches to GNU/Directory/Package.pm
for this purpose (attached below).  They were,

-- return undef instead of "not found."  for missing field.

-- modified the regexp in FETCH to match %%fields at the very
beginning or end of the file.

-- modified the regexp in FIRSTKEY to match %%fields containing spaces
(some of them do).


Index: GNU/Directory/Package.pm
===================================================================
RCS file: /cvsroot/gnulist/gnulist/GNU/Directory/Package.pm,v
retrieving revision 1.1
diff -c -r1.1 Package.pm
*** GNU/Directory/Package.pm    2001/08/05 07:52:11     1.1
--- GNU/Directory/Package.pm    2001/09/03 21:02:31
***************
*** 20,29 ****
        my @lines = <FILE>;
        my $file = join('',@lines);
        close(FILE);
!       if ($file =~ /\n%%$key\:\s?(.*?)\n%%/s)
        {
!               return $1;
!       } else { return "not found." }
  }
  
  sub EXISTS
--- 20,29 ----
        my @lines = <FILE>;
        my $file = join('',@lines);
        close(FILE);
!       if ($file =~ /(^|\n)%%$key\:\s?(.*?)(\n%%|$)/s)
        {
!               return $2;
!       } else { return undef }
  }
  
  sub EXISTS
***************
*** 50,56 ****
        $self->[1] = [];        
        for $i (<FILE>)
        {
!               if ($i =~ /^%%([\w-]+):/) {
                        push @{$self->[1]}, $1;
                }
        }
--- 50,56 ----
        $self->[1] = [];        
        for $i (<FILE>)
        {
!               if ($i =~ /^%%([^:]+):/) {
                        push @{$self->[1]}, $1;
                }
        }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]