4 SAVE_LC_ALL="${LC_ALL}"
6 SAVE_LANGUAGE="${LANGUAGE}"
20 echo "Run this script from the top-level directory in the"
26 echo "usage: $0 <NAME> <HEADLINE>"
28 echo "This will open \$EDITOR in order to fill in the body content"
32 test -n "${EDITOR-}" || {
38 test -n "${NAME}" || {
43 HEADLINE=$(echo "$@" | xargs)
44 test -n "${HEADLINE}" || {
49 grep -q "<a name=\"${NAME}\"" posted_news/*.body.html && {
50 echo "NAME[${NAME}] is not unique, choose another name"
51 grep "<a name=\"${NAME}\"" posted_news/*.body.html
55 nd=$(git diff -p --stat HEAD | wc -l)
56 test x"${nd}" = x"0" || {
57 echo "You have uncommited changes your working tree"
64 echo "ERROR: cleaning up"
67 for f in ${CLEANUP_FILES}; do
68 echo "Removing file[${f}]"
71 echo "failed to remove ${f}"
76 test -n "${CLEANUP_RESET_COMMIT}" && {
77 echo "Reverting to commit[${CLEANUP_RESET_COMMIT}]"
78 git reset "${CLEANUP_RESET_COMMIT}"
83 trap trap_handler INT QUIT TERM EXIT
86 utcdate=$(date --utc +"%d %B %Y")
87 utctime=$(date --utc +"%Y%m%d-%H%M%S")
89 headlinefile="posted_news/${utctime}.${NAME}.headline.html"
90 bodyfile="posted_news/${utctime}.${NAME}.body.html"
91 echo "generating ${headlinefile}"
92 CLEANUP_FILES="${CLEANUP_FILES} ${headlinefile}"
94 echo "<!-- BEGIN: ${headlinefile} -->"
95 echo "<li> ${utcdate} <a href=\"${href}\">${HEADLINE}</a></li>"
96 echo "<!-- END: ${headlinefile} -->"
99 echo "generating ${bodyfile}"
100 CLEANUP_FILES="${CLEANUP_FILES} ${bodyfile}"
102 echo "<!-- BEGIN: ${bodyfile} -->"
103 echo "<h5><a name=\"${NAME}\">${utcdate}</a></h5>"
104 echo "<p class=headline>${HEADLINE}</p>"
106 echo "<!-- TODO: add your context here -->"
109 echo "<!-- TODO: add more context here -->"
111 echo "<!-- END: ${bodyfile} -->"
114 LC_ALL="${SAVE_LC_ALL}" \
115 LANG="${SAVE_LANG}" \
116 LANGUAGE="${SAVE_LANGUAGE}" \
117 ${EDITOR} ${bodyfile}
120 CLEANUP_RESET_COMMIT="HEAD"
121 git add ${headlinefile} ${bodyfile}
122 git commit --signoff --message "NEWS[${NAME}]: ${HEADLINE}"
123 CLEANUP_RESET_COMMIT="HEAD^"
125 echo "Once you have pushed the commit a cronjob updates"
126 echo "the webserver content every 5 mins."
128 echo "Please verify the commit carefully before pushing:"
130 echo " git show -p --stat HEAD"
134 trap - INT QUIT TERM EXIT