Files
i2p.newsxml/create_new_entry.sh

56 lines
1.8 KiB
Bash
Raw Normal View History

2015-06-07 22:49:44 +00:00
#!/bin/sh
# this script creates a new news entry
# it's a little smarter than it used to be to account for per-platform, per-branch updates
# You can still run it with just ./create_new_entry.sh but it will fill in some
# of the necessary fields for you and. You can also now pass it environment variables TITLE,
# HREF, and AUTHOR to set the title, href, and author of the entry.
#
# Example usage:
# TITLE="Title Here" AUTHOR=idk EDITOR=mousepad I2P_OS=win I2P_BRANCH=beta ./create_new_entry.sh
ENTRIES=data/$I2P_OS/$I2P_BRANCH/entries.html
2016-11-28 11:21:55 +00:00
UUIDGEN="`which uuidgen || which uuid`"
2024-07-16 00:36:55 -04:00
if [ -z "$DATE" ]; then
DATE=$(date +%Y-%m-%dT%H:00:00Z)
YEAR=$(date +%Y)
MONTH=$(date +%m)
DAY=$(date +%d)
else
DATE2=$(echo "$DATE" | sed 's/T.*//')
YEAR=$(echo "$DATE2" | cut -d - -f 1)
MONTH=$(echo "$DATE2" | cut -d - -f 2)
DAY=$(echo "$DATE2" | cut -d - -f 3)
2024-07-16 00:36:55 -04:00
fi
if [ -z "$HREF" ]; then
if [ ! -z "$CHANGEME_URL_HERE" ]; then
CHANGEME_URL_HERE=CHANGEME_URL_HERE
else
CHANGEME_URL_HERE=$(echo "$TITLE" | tr "[:upper:]" "[:lower:]" | sed 's| |_|g')
fi
HREF="http://i2p-projekt.i2p/en/blog/post/$YEAR/$MONTH/$DAY/$CHANGEME_URL_HERE"
fi
TITLE=${TITLE:-TITLE_HERE}
AUTHOR=${AUTHOR:-AUTHOR_HERE}
if [ -z "$SUMMARY_HERE" ]; then
SUMMARY_HERE="SUMMARY_HERE"
fi
if [ -z "$CONTENT_HERE" ]; then
CONTENT_HERE="<p>\n\n</p>"
fi
2015-06-07 23:02:19 +00:00
sed -i "3i <article\n id=\"urn:uuid:`$UUIDGEN`\"\n title=\"$TITLE\"\n href=\"$HREF\"\n author=\"$AUTHOR\"\n published=\"$DATE\"\n updated=\"$DATE\">\n<details>\n<summary>$SUMMARY_HERE</summary>\n</details>\n$CONTENT_HERE\n</article>\n\n\n" $ENTRIES
2015-06-07 23:02:19 +00:00
if [ ! -z "$EDITOR" ]; then
case "$EDITOR" in
"nano" | "vim")
2015-06-10 12:48:20 +00:00
$EDITOR +13 $ENTRIES
2015-06-07 23:02:19 +00:00
;;
*)
$EDITOR $ENTRIES
;;
esac
fi