File: fortune.sh

package info (click to toggle)
nanoblogger 3.1-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 480 kB
  • ctags: 96
  • sloc: sh: 1,585; xml: 104; makefile: 44
file content (26 lines) | stat: -rw-r--r-- 767 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# NanoBlogger Fortune plugin, requires the fortune program.

# sample code for templates, based off default stylesheet
#
# <div class="sidetitle">
# Random Fortune
# </div>
#
# <div class="side">
# $NB_Fortune
# </div>

# Fortune command, use "-s" for short fortunes
: ${FORTUNE_CMD:=fortune -s}

PLUGIN_OUTFILE="$BLOG_DIR/$PARTS_DIR/fortune.$NB_FILETYPE"

if $FORTUNE_CMD > "$PLUGIN_OUTFILE" 2>&1; then
	nb_msg "generating fortune ..."
	echo '<div class="fortune">' > "$PLUGIN_OUTFILE"
	$FORTUNE_CMD ${FORTUNE_FILE} \
		|sed -e '/[\<]/ s//\&#60;/g; /[\>]/ s//\&#62;/g; /^[ \t]/ s//\&nbsp;/g; /[\t]/ s//\&nbsp;/g; /^$/ s//<br \/>/g; /$/ s//<br \/>/g; /[\$]/ s//\\$/g' \
		>> "$PLUGIN_OUTFILE"
	echo '</div>' >> "$PLUGIN_OUTFILE"
	NB_Fortune=$(< "$PLUGIN_OUTFILE")
fi