/[debian]/nanobloggerplugins/trunk/calendar_prev.sh
ViewVC logotype

Annotation of /nanobloggerplugins/trunk/calendar_prev.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 160 - (hide annotations)
Sat Feb 25 18:12:14 2006 UTC (15 years, 5 months ago) by gregoa
Original Path: nanobloggerplugins/branches/upstream/current/calendar_prev.sh
File MIME type: application/x-sh
File size: 2820 byte(s)
[svn-inject] Installing original source of nanobloggerplugins
1 gregoa 160 # NanoBlogger Calendar Plugin, requires the cal command.
2     # converts the output of cal to an HTML Table and creates links of entries
3     # used for last month's calendar table!
4     #
5     # sample code for template - based off default stylesheet
6     #
7     # <div class="calendar">
8     # $NB_Calendar_prev
9     # </div>
10    
11     PLUGIN_OUTFILE="$BLOG_DIR/$PARTS_DIR/cal_prev.$NB_FILETYPE"
12     : ${CAL_CMD:=cal}
13    
14     if $CAL_CMD > "$PLUGIN_OUTFILE" 2>&1 ; then
15     nb_msg "generating calendar (last month) ..."
16     [ -z "$DATE_LOCALE" ] || CALENDAR=`LC_ALL="$DATE_LOCALE" $CAL_CMD $CAL_ARGS_PREV`
17     [ ! -z "$CALENDAR" ] || CALENDAR=`$CAL_CMD $CAL_ARGS_PREV`
18     CAL_HEAD=`echo "$CALENDAR" |sed -e '/^[ ]*/ s///g; 1q'`
19     WEEK_DAYS=`echo "$CALENDAR" |sed -n 2p`
20     DAYS=`echo "$CALENDAR" |sed 1,2d`
21     NUM_DAY_LINES=`echo "$DAYS" |grep -n "[0-9]" |cut -c1`
22    
23     curr_month=`date +%Y.%m --date "$(date +%Y-%m-15) 1 months ago"`
24     query_db all
25     set_baseurl "./"
26     MONTH_LIST=`echo "$DB_RESULTS" |sort $SORT_ARGS |grep ''$curr_month''`
27    
28     echo '<table border="0" cellspacing="4" cellpadding="0" summary="Calendar with links to days with entries">' > "$PLUGIN_OUTFILE"
29     echo '<caption class="calendarhead">'$CAL_HEAD'</caption>' >> "$PLUGIN_OUTFILE"
30     echo '<tr>' >> "$PLUGIN_OUTFILE"
31     for wd in $WEEK_DAYS ; do
32     echo '<th style="text-align: center;"><span class="calendarday">'$wd'</span></th>' >> "$PLUGIN_OUTFILE"
33     done
34     echo '</tr>' >> "$PLUGIN_OUTFILE"
35     for line in $NUM_DAY_LINES ; do
36     DN_LINES=`echo "$DAYS" |sed -n "$line"p`
37     [ -n "$DN_LINES" ] || continue
38     echo '<tr>' >> "$PLUGIN_OUTFILE"
39     echo "$DN_LINES" | sed -e '/ $/ Q; / [ \t]/ s//<td style="text-align: center;"><\/td>\ /g; /[0-9]/ s///g' >> "$PLUGIN_OUTFILE"
40     for dn in $DN_LINES ; do
41     set_link=0
42     MONTH_LINE=`echo "$MONTH_LIST" |grep $dn`
43     for entry in $MONTH_LINE ; do
44     entry_year=`echo $entry |cut -c1-4`
45     entry_month=`echo $entry |cut -c6-7`
46     entry_day=`echo $entry |cut -c9-10 |sed -e '/^0/ s///g'`
47     curr_month=`date +%m --date "$(date +%Y-%m-15) 1 months ago"`
48     curr_year=`date +%Y --date "$(date +%Y-%m-15) 1 months ago"`
49     if [ "$curr_year$curr_month$dn" = "$entry_year$entry_month$entry_day" ] ; then
50     set_link=1
51     NB_EntryID=`set_entryid $entry`
52     set_entrylink "$entry" altlink
53     dn='<a href="'${ARCHIVES_PATH}$NB_EntryPermalink'">'$dn'</a>'
54     echo '<td style="text-align: center;"><span class="calendar">'$dn'</span></td>' >> "$PLUGIN_OUTFILE"
55     fi
56     done
57     if [ "$set_link" != 1 ] ; then
58     echo '<td style="text-align: center;"><span class="calendar">'$dn'</span></td>' >> "$PLUGIN_OUTFILE"
59     fi
60     done
61     echo "$DN_LINES" | sed -e '/^ / Q; / [ \t]/ s//<td style="text-align: center;"><\/td>\ /g; /[0-9]/ s///g' >> "$PLUGIN_OUTFILE"
62     echo '</tr>' >> "$PLUGIN_OUTFILE"
63     done
64     echo '</table>' >> "$PLUGIN_OUTFILE"
65    
66     # The calendar's place-holder for the templates
67     NB_Calendar_prev=$(< "$PLUGIN_OUTFILE")
68     CALENDAR=
69     fi
70    

  ViewVC Help
Powered by ViewVC 1.1.26