Re: Marking changed entries

---------

Richard M. Mathews (richard@astro.West.Sun.COM)
Mon, 20 Dec 93 11:47:17 PST


----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Content-Lines: 37

>Does anybody have a script to do this kind of thing automatically?
>Do you post diffs instead? Any other ideas?

I have my FAQ set up to do diff-marks automatically.

Each part of my FAQ actually gets built from 4 files:
* The news headers and auxiliary headers for that part of the FAQ
* A common blurb that goes at the top of each part of the FAQ
* The body of that part of the FAQ
* A signature file
Diff mark generation is done on the 2nd and 3rd of those 4.

Consider the common blurb. I keep it in a file called "common". I
also keep last month's version in "common.orig". My posting script
runs "diff -D" to get the differences, then runs a "sed" script which
turns the diffs into diff-marks. (2 characters are added to the
beginning of each line, so watch out that this doesn't cause problems.)

After doing that on the common blurb and the bodies of each part of the
FAQ, the script concatenates all of the parts and leaves a copy in
XX.post where XX is the name of that part. The script then uses
post-faq to post those files. Finally, it copies XX to XX.orig to save
this month's version of the files for next month.

Oh, and somewhere in all of that, the script also looks at the dates of
all of the files which make up each part and uses the most recent date
to create an automatic "Last-modified:" line.

Attached is the script ("postit") and the sed script ("diffmk.sed").
These should be reasonably portable to different Unix systems provided
that your diff command supports -D. An exception is the method used
for getting the Last-modified date. I haven't actually tested this,
though, on anything other than Solaris for x86.

Richard M. Mathews D efend
E stonian-Latvian-Lithuanian
richard@West.Sun.COM I ndependence
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: diffmk.sed
X-Sun-Content-Lines: 33

/^#ifndef NEW$/,/^#e.*NEW$/{
/^#e/!d
/^#endif NEW$/{
s/.*/- /
h
d
}
/^#else NEW$/{
s/.*/| /
h
d
}
}
/^#ifdef NEW$/{
s/.*/+ /
h
d
}
/^#endif NEW$/{
s/.*/ /
h
d
}
x
s/^$/ /
G
s/\n//
s/^ $//
p
s/\(..\).*/\1/
s/^- $/ /
x
d
----------
X-Sun-Data-Type: shell-script
X-Sun-Data-Description: shell-script
X-Sun-Data-Name: postit
X-Sun-Content-Lines: 76

#!/bin/sh

# -debug don't actually post, output via pg
# -repost use existing *.post files

# make a lock file

echo "$$" > p$$
/usr/ucb/ln p$$ LOCK > /dev/null 2>&1
if [ $? -ne 0 ]; then
rm p$$
exit
fi

trap "rm -f common.mk AA.mk CA.mk EU.mk NA.mk p$$ LOCK; exit" 0 1 2 3 13 15

DEBUG=false
NEWPOST=true
for i
do
case "$i" in
-debug)
DEBUG=true
;;
-repost)
NEWPOST=false
;;
*)
echo "$0: unknown flag: $i" 1>&2
exit 1
esac
done

# produce diff marks

if $NEWPOST; then
for i in common AA CA EU NA
do
diff -D NEW $i.orig $i | sed -f diffmk.sed > $i.mk
if [ ! -s $i.mk ]; then
sed 's/./ &/' $i > $i.mk
fi
done

# piece the articles together

for i in AA CA EU NA
do
(
cat $i.head
/usr/local/bin/li -Im -En -Sm $i.head common $i |
sed -e 's/^/Last-modified:/' -e 1q
cat common.mk $i.mk ../.sig
) > $i.post
rm $i.mk
done
rm common.mk
fi

# post the articles

if $DEBUG; then
post_faq.pl -config post_faq.cfg -debug -inewscmd "/bin/pg -n"
exit
else
post_faq.pl -config post_faq.cfg # -quiet 2
fi

if $NEWPOST; then
# save files for next month's diff marks

for i in common AA CA EU NA
do
cp $i $i.orig
done
fi



[ Usenet Hypertext FAQ Archive | Search Mail Archive | Authors | Usenet ]
[ 1993 | 1994 | 1995 | 1996 | 1997 ]

---------

faq-admin@landfield.com

© Copyright The Landfield Group, 1997
All rights reserved