#!/usr/bonsaitools/bin/perl -- # -*- Mode: perl; indent-tabs-mode: nil -*- # # The contents of this file are subject to the Netscape Public License # Version 1.0 (the "License"); you may not use this file except in # compliance with the License. You may obtain a copy of the License at # http://www.mozilla.org/NPL/ # # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the # License for the specific language governing rights and limitations # under the License. # # The Original Code is the Bonsai CVS tool. # # The Initial Developer of the Original Code is Netscape Communications # Corporation. Portions created by Netscape are Copyright (C) 1998 # Netscape Communications Corporation. All Rights Reserved. # SourceChecker.cgi -- tools for creating or modifying the dictionary # used by cvsblame.cgi. # # Created: Scott Collins , 4 Feb 1998. # # Arguments (passes via GET or POST): # ... # use CGI; use SourceChecker; # # Global # $query = new CGI; # # Subroutines # sub print_page_header() { print <<'END_OF_HEADER';

SourceChecker Dictionary Maintainance

END_OF_HEADER } sub print_page_trailer() { print <<'END_OF_TRAILER';
Last updated 5 Feb 1998. Dictionary maintainance and help. Mail feedback to <scc@netscape.com>. END_OF_TRAILER } $error_header = '

I couldn\'t process your request...

'; sub print_error($) { local $message = shift; print "$error_header

Error: $message

"; $error_header = ''; } sub print_query_building_form() { print $query->start_multipart_form; print '

Build a new request

'; print '

...to modify or create a remote dictionary with words from one or more local files.

'; print '

Files on the server

'; print '

...i.e., the dictionary to be created or modified.

'; print $query->textfield( -name=>'dictionary', -default=>'', -override=>1, -size=>30 ); print '-- the path to dictionary.'; print '

Files on your local machine

'; print '

...that will be uploaded to the server, so their contents can be added to the dictionary.

'; print '
'; print $query->filefield( -name=>'ignore_english', -size=>30 ); print '-- contains english (i.e., transformable) words to ignore.'; print '
'; print $query->filefield( -name=>'ignore_strings', -size=>30 ); print '-- contains identifiers (i.e., non-transformable) words to ignore.'; print '
'; print $query->filefield( -name=>'flag_strings', -size=>30 ); print '-- contains identifiers words to be flagged.'; print '
'; print $query->filefield( -name=>'ignore_names', -size=>30 ); print '-- contains user names to be ignored.'; print '
'; print $query->submit; print $query->endform; } sub do_add_good_words($) { local $file = shift; while ( <$file> ) { next if /\#/; add_good_words($_); } } sub do_add_bad_words($) { local $file = shift; while ( <$file> ) { next if /\#/; add_bad_words($_); } } sub do_add_good_english($) { local $file = shift; while ( <$file> ) { next if /\#/; add_good_english($_); } } sub do_add_names($) { local $file = shift; while ( <$file> ) { next if /\#/; add_names($_); } } sub handle_query() { $dictionary_path = $query->param('dictionary'); if ( ! $dictionary_path ) { print_error('You didn\'t supply a path to the dictionary file.'); return; } dbmopen %SourceChecker::token_dictionary, "$dictionary_path", 0666 || print_error("The dictionary you named could not be opened."); $added_some_words = 0; if ( $file_of_good_english = $query->param('ignore_english') ) { do_add_good_english($file_of_good_english); $added_some_words = 1; } if ( $file_of_good_words = $query->param('ignore_strings') ) { do_add_good_words($file_of_good_words); $added_some_words = 1; } if ( $file_of_bad_words = $query->param('flag_strings') ) { do_add_bad_words($file_of_bad_words); $added_some_words = 1; } if ( $file_of_names = $query->param('ignore_names') ) { do_add_names($file_of_names); $added_some_words = 1; } if ( ! $added_some_words ) { print_error("You did not supply any words to add to the dictionary."); } dbmclose %SourceChecker::token_dictionary; } # # The main script # print $query->header; print $query->start_html(-title=>'SourceChecker Dictionary Maintainance', -author=>'scc@netscape.com'); print_page_header(); if ( $query->param ) { handle_query(); } print_query_building_form(); print_page_trailer(); print $query->end_html; __DATA__