webcalendar

Check-in [cb0f89b99e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Handle event count on monthly by day. Handle display when there are no timed events.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:cb0f89b99e7415ebe428c8bf8016cadfa3999732b2ca3e927bcddd94ae2036b8
User & Date: ajv-899-334-8894@vsta.org 2017-06-10 17:15:32
Context
2017-06-14
14:18
Another variant of weekly by day; infer day and week index from base time. check-in: d993e79f2f user: ajv-899-334-8894@vsta.org tags: master, trunk
2017-06-10
17:15
Handle event count on monthly by day. Handle display when there are no timed events. check-in: cb0f89b99e user: ajv-899-334-8894@vsta.org tags: master, trunk
2017-06-09
00:26
Handle multiple days of the week under a weekly repeat check-in: 77276890af user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to cgi-bin/today.py.

2
3
4
5
6
7
8

9
10
11
12
13
14
15
..
60
61
62
63
64
65
66

67


68
69
70
71
72
73
74
..
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
98
99
...
107
108
109
110
111
112
113

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#
# today.py
#	Display events for today
#
import sys, time, os
from webcal import cmp_time
import webcal, auth


# By default, display events for Today
Target = webcal.Today

# Filled in by authen (or debug)
uname = None

................................................................................
	    if depth > col.get(ev, 0):
		col[ev] = depth
	    hour += 1
	    if hour > hourend:
		break

    hours = set(rows.iterkeys())

    nhour = (max(hours) - min(hours)) + 1


    w("""<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>%s</title>
</head>
<link rel="stylesheet" type="text/css" href="/webcal/includes/css/cal.css" />
<script src="/webcal/includes/js/cal.js"></script>
................................................................................
    # Label for untimed first
    idx = 0
    if untimed:
	w('<span style="left: 0px; top: 0px;">---</span>\n')
	idx += len(untimed)

    # An hour label for each row, in its own table column

    for hour in xrange(min(hours), max(hours)+1):
	w('<span style="left: 0px; top: %dpx;">%02d:00</span>\n' %
	     (idx*LINEPIX, hour))
	idx += 1
    w("""</td>
  <td id="calevents">
""")

    #
    # Now the actual events, each at their own hour and column offset
    #
................................................................................
	if ev.color:
	    w(' color: %s;' % (ev.color,))
	w('">%s</span>\n' % (ev.name,))
	houridx += 1

    # Divvy up display width across columns.  Assume some used
    #  for leading hour column.

    colpix = 80/(max(rows.itervalues()))
    maxcol = int(colpix * 1.2)

    curidx = 0
    for hour in xrange(min(hours), max(hours)+1):
	while (curidx < len(evs)) and (evs[curidx].begin.tm_hour == hour):
	    ev = evs[curidx]
	    w(
	     '<span onclick="view_ev(%d);"' % (ev.evid,))
	    w(
	     ' style="left: %dvw; top: %dpx; height: %dpx;' %
	     (((col[ev] - 1) * colpix),
	      houridx * LINEPIX, max(ev.dur / 60.0, 0.75) * LINEPIX))
	    w(' max-width: %dvw; z-index: %d;' % (maxcol, col[ev]))
	    if ev.color:
		w(' color: %s;' % (ev.color,))
	    w('">%s</span>\n' % (ev.name,))
	    curidx += 1
	houridx += 1
    w("""</td>
 </tr>
</table>

</body>
</html>
""")







>







 







>
|
>
>







 







>
|
|
|
|







 







>
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
...
112
113
114
115
116
117
118
119
120
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#
# today.py
#	Display events for today
#
import sys, time, os
from webcal import cmp_time
import webcal, auth
import pdb

# By default, display events for Today
Target = webcal.Today

# Filled in by authen (or debug)
uname = None

................................................................................
	    if depth > col.get(ev, 0):
		col[ev] = depth
	    hour += 1
	    if hour > hourend:
		break

    hours = set(rows.iterkeys())
    if hours:
	nhour = (max(hours) - min(hours)) + 1
    else:
	nhour = 0
    w("""<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <title>%s</title>
</head>
<link rel="stylesheet" type="text/css" href="/webcal/includes/css/cal.css" />
<script src="/webcal/includes/js/cal.js"></script>
................................................................................
    # Label for untimed first
    idx = 0
    if untimed:
	w('<span style="left: 0px; top: 0px;">---</span>\n')
	idx += len(untimed)

    # An hour label for each row, in its own table column
    if hours:
	for hour in xrange(min(hours), max(hours)+1):
	    w('<span style="left: 0px; top: %dpx;">%02d:00</span>\n' %
		 (idx*LINEPIX, hour))
	    idx += 1
    w("""</td>
  <td id="calevents">
""")

    #
    # Now the actual events, each at their own hour and column offset
    #
................................................................................
	if ev.color:
	    w(' color: %s;' % (ev.color,))
	w('">%s</span>\n' % (ev.name,))
	houridx += 1

    # Divvy up display width across columns.  Assume some used
    #  for leading hour column.
    if hours:
	colpix = 80/(max(rows.itervalues()))
	maxcol = int(colpix * 1.2)

	curidx = 0
	for hour in xrange(min(hours), max(hours)+1):
	    while (curidx < len(evs)) and (evs[curidx].begin.tm_hour == hour):
		ev = evs[curidx]
		w(
		 '<span onclick="view_ev(%d);"' % (ev.evid,))
		w(
		 ' style="left: %dvw; top: %dpx; height: %dpx;' %
		 (((col[ev] - 1) * colpix),
		  houridx * LINEPIX, max(ev.dur / 60.0, 0.75) * LINEPIX))
		w(' max-width: %dvw; z-index: %d;' % (maxcol, col[ev]))
		if ev.color:
		    w(' color: %s;' % (ev.color,))
		w('">%s</span>\n' % (ev.name,))
		curidx += 1
	    houridx += 1
    w("""</td>
 </tr>
</table>

</body>
</html>
""")

Changes to cgi-bin/webcal.py.

292
293
294
295
296
297
298

299
300
301
302
303







304
305
306
307
308
309
310
	wday = wday[:-2]
	if wday:
	    self.offset = int(wday)
	else:
	    self.offset = None

    def _applies(self, target):


	# Not right day of week
	basetm = self.basetm
	if self.basetm.tm_wday != target.tm_wday:
	    return False








	# Every Friday, etc.
	if self.offset == None:
	    return True

	# This one?
	return self.offset == week_idx(target.tm_mday)







>





>
>
>
>
>
>
>







292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
	wday = wday[:-2]
	if wday:
	    self.offset = int(wday)
	else:
	    self.offset = None

    def _applies(self, target):
	assert self.intvl == 1

	# Not right day of week
	basetm = self.basetm
	if self.basetm.tm_wday != target.tm_wday:
	    return False

	# Only this many
	if self.count:
	    months = 12 * (Today.tm_year - basetm.tm_year) + \
		(Today.tm_mon - basetm.tm_mon)
	    if months >= self.count:
		return False

	# Every Friday, etc.
	if self.offset == None:
	    return True

	# This one?
	return self.offset == week_idx(target.tm_mday)