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"
92 echo "generating ${headlinefile}"
93 CLEANUP_FILES="${CLEANUP_FILES} ${headlinefile}"
95 echo "<!-- BEGIN: ${headlinefile} -->"
96 echo "<li> ${utcdate} <a href=\"${href}\">${HEADLINE}</a></li>"
97 echo "<!-- END: ${headlinefile} -->"
100 echo "generating ${bodyfile}"
101 CLEANUP_FILES="${CLEANUP_FILES} ${bodyfile}"
103 echo "<!-- BEGIN: ${bodyfile} -->"
104 echo "<h5><a name=\"${NAME}\">${utcdate}</a></h5>"
105 echo "<p class=headline>${HEADLINE}</p>"
107 echo "<!-- TODO: add your content here -->"
110 echo "<!-- TODO: add more content here -->"
113 echo "<!-- TODO: remove the above line or move it to where you want the front-page preview to end, also remove this comment -->"
114 echo "<!-- END: ${bodyfile} -->"
117 LC_ALL="${SAVE_LC_ALL}" \
118 LANG="${SAVE_LANG}" \
119 LANGUAGE="${SAVE_LANGUAGE}" \
120 ${EDITOR} ${bodyfile}
122 if grep -q "<!-- SNIP -->" $bodyfile; then
123 snipfile="posted_news/${utctime}.${NAME}.snip.html"
124 echo "generating ${snipfile}"
125 CLEANUP_FILES="${CLEANUP_FILES} ${snipfile}"
127 echo "<!-- BEGIN: ${snipfile} -->"
128 while read -r line || [[ -n "$line" ]]; do
129 if [[ $line == *"<!-- BEGIN"* ]]; then
131 elif [[ $line == *"<!-- SNIP -->"* || $line == *"<!-- END"* ]]; then
132 echo ${line%%<!--*}"<p><a href=\"/samba/latest_news.html#${NAME}\">(Read more)</a></p>"
138 echo "<!-- END: ${snipfile} -->"
143 CLEANUP_RESET_COMMIT="HEAD"
144 git add ${headlinefile} ${bodyfile} ${snipfile}
145 git commit --signoff --message "NEWS[${NAME}]: ${HEADLINE}"
146 CLEANUP_RESET_COMMIT="HEAD^"
149 echo "Once you have pushed the commit a cronjob updates"
150 echo "the webserver content every 5-10 mins."
152 echo "Please verify the commit carefully before pushing:"
154 echo " git show -p --stat HEAD"
158 trap - INT QUIT TERM EXIT