Update of /cvsroot/woc/woc/data/wml
In directory usw-pr-cvs1:/tmp/cvs-serv5309
Modified Files:
mkwml
Log Message:
Updated to work with new dir layout.
Index: mkwml
===================================================================
RCS file: /cvsroot/woc/woc/data/wml/mkwml,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** mkwml 8 Jun 2002 18:49:07 -0000 1.1
--- mkwml 8 Jun 2002 19:27:44 -0000 1.2
***************
*** 1,9 ****
#!/usr/local/bin/perl -w
use strict;
use check_digit;
# location of the item files and the templates #
! my $wmldatadir = "/vol/www/woc/data/wml";
my $templatedir = "$wmldatadir/templates";
--- 1,12 ----
#!/usr/local/bin/perl -w
+ use lib '../../lib/perl';
use strict;
use check_digit;
+ print "The wmldatadir layout has changed! Use this script with care!\n";
+
# location of the item files and the templates #
! my $wmldatadir = ".";
my $templatedir = "$wmldatadir/templates";
***************
*** 18,22 ****
&process_arguments();
! print "Creating new item $wmldatadir/$item.xml with ID=";
my $wocnumber = &get_next_wocnumber;
--- 21,27 ----
&process_arguments();
! my $targetfile = "$wmldatadir/" . substr($item,0,1) . "/$item.xml";
!
! print "Creating new item $targetfile with ID=";
my $wocnumber = &get_next_wocnumber;
***************
*** 30,37 ****
"code" => $item));
! &save_item ($template, "$wmldatadir/$item.xml");
! chmod 0775, "$wmldatadir/$item.xml";
! `chgrp wwwwoc "$wmldatadir/$item.xml"`;
print "Done!$/";
--- 35,42 ----
"code" => $item));
! &save_item ($template, "$targetfile");
! chmod 0775, "$targetfile";
! `chgrp wwwwoc "$targetfile"`;
print "Done!$/";
***************
*** 122,129 ****
sub get_next_wocnumber {
! my @item_start_elements = `grep -i "ITEM\.*ID=" $wmldatadir/*.xml`;
# make a list of current ID's
! my @idlist;
foreach (@item_start_elements) {
/ID=\"WOC(.*?)\".*/i;
--- 127,139 ----
sub get_next_wocnumber {
! my @allfiles = `find $wmldatadir -name "*xml"`;
! my @item_start_elements = ();
! foreach my $file (@allfiles) {
! my $line = `grep -i "ITEM\.*ID=" $file`;
! push (@item_start_elements, $line);
! }
# make a list of current ID's
! my @idlist = ();
foreach (@item_start_elements) {
/ID=\"WOC(.*?)\".*/i;
***************
*** 132,136 ****
# sort thislist
! @idlist = sort @idlist;
# what is the highest ID?
--- 142,148 ----
# sort thislist
! if (scalar(@idlist) > 0) {
! @idlist = sort @idlist;
! }
# what is the highest ID?
***************
*** 169,172 ****
--- 181,189 ----
my $file = shift;
+ if (-e $file) {
+ print "File $file already exists!\n";
+ exit 1;
+ }
+
open (FILE, ">$file") || die "$file: $!$?";
print FILE $template;
|