summaryrefslogtreecommitdiff
path: root/scripts/gen_css_tables.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gen_css_tables.py')
-rwxr-xr-xscripts/gen_css_tables.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/scripts/gen_css_tables.py b/scripts/gen_css_tables.py
new file mode 100755
index 0000000..4bc5ea8
--- /dev/null
+++ b/scripts/gen_css_tables.py
@@ -0,0 +1,83 @@
1#!python3
2
3# This script generates the css tables needed for halfnarp to work
4# properly with different start and end dates, rooms and numers of
5# days. Adapt the to your conference's needs and place the result
6# in the css document, e.g. style_38c3_tables.css
7
8start_y = 400
9starttime = 10
10endtime = 28
11rooms = 3
12days = 4
13columns = days * rooms # how many columns does
14event_gap = { 'large': 5, 'medium': 3, 'small': 2 } # how much is an event shorter than what the grid would allow in px
15block_length = 210
16
17time_grid = 5 # what is the granularity of Fahrplan raster in minutes
18elem_per_hour = 60 / time_grid # how many sections does one hour get
19
20# how many pixels are in one hour vertically in LARGE, MEDIUM, SMALL
21hour_height={ 'large': 300, 'medium': 160, 'small': 120 }
22
23# What is the height of one grid element
24grid_height={ 'large': hour_height['large'] / elem_per_hour, 'medium': hour_height['medium'] / elem_per_hour, 'small': hour_height['small'] / elem_per_hour }
25
26for size in ['large', 'medium', 'small']:
27 y = start_y
28 for hour in range(starttime, endtime):
29 for minute in range(0,60,time_grid):
30 print ( '.size-' + size + ' .time_' + str(hour % 24).zfill(2) + str(minute).zfill(2) + ' { top: ' + str(y) + 'px; }' )
31 y += grid_height[size]
32
33for size in ['large', 'medium', 'small']:
34 for duration in range(300,12000,100):
35 height = hour_height[size] * duration / 3600 - event_gap[size]
36 print ( '.size-' + size + ' .duration_' + str(duration) + ' { min-height: ' + str(height) + 'px; max-height: ' + str(height) + 'px; }')
37 print ( '.size-' + size + ' .wholeblock { height: ' + str(hour_height[size] * block_length / 60) + 'px; }' )
38
39print ( '.size-large .grid { height: ' + str(grid_height['large']) + 'px; font-size: 1em; }' )
40print ( '.size-medium .grid { height: ' + str(grid_height['medium'])+ 'px; font-size: 0.5em; }' )
41print ( '.size-small .grid { height: ' + str(grid_height['small']) + 'px; font-size: 0.3em; }' )
42
43gap = 4
44width = ( 100 - gap * ( 1 + rooms ) ) / rooms
45for room in range(rooms):
46 print ( '.in-calendar .room' + str(room+1) +' { left: ' + str(gap * (room + 1) + width * room ) + '%; }' )
47
48print ('.in-calendar .event, .in-calendar .room-label, .in-calendar .grid { position: absolute; width: ' + str(width)+ '%; }' )
49print ('.in-calendar .r, .in-calendar .l { width: ' + str(width) + '%; }')
50print ('.in-calendar .rr, .in-calendar .ll { width: ' + str(2*width+gap) + '%; }')
51print ('.in-calendar .rrr, .in-calendar .lll { width: ' + str(3*width+2*gap) + '%; }')
52print ('.in-calendar .rrrr, .in-calendar .llll { width: ' + str(4*width+3*gap) + '%; }')
53print ('.in-calendar .r, .in-calendar .rr, .in-calendar .rrr, .in-calendar .rrrr { margin-left: ' + str(width / 2) + '% ; }')
54print ('.in-calendar .l { margin-left: -' + str(width / 2) + '% ; }')
55print ('.in-calendar .ll { margin-left: -' + str(width / 2 + gap + width) + '% ; }')
56print ('.in-calendar .lll { margin-left: -' + str(width / 2 + gap * 2 + width * 2) + '% ; }')
57print ('.in-calendar .llll { margin-left: -' + str(width / 2 + gap * 3 + width * 3) + '% ; }')
58
59gap = 0.5
60width = ( 100 - gap * ( 1 + columns ) ) / columns
61for day in range(days):
62 for room in range(rooms):
63 print ( '.in-calendar.alldays .day_' + str(day+1) + '.room' + str(room+1) +' { left: ' + str(gap * (day*rooms + room + 1) + width * (day * rooms + room ) ) + '%; }' )
64
65print ('.wholeday, .wholeblock { width: ' + str(100 / days)+ '% }')
66print ('.in-calendar.alldays .event, .in-calendar.alldays .room-label, .in-calendar.alldays .grid { width: ' + str(width)+ '%; }' )
67
68print ('.in-calendar.alldays .r, .in-calendar.alldays .l { width: ' + str(width) + '%; }')
69print ('.in-calendar.alldays .rr, .in-calendar.alldays .ll { width: ' + str(2*width+gap) + '%; }')
70print ('.in-calendar.alldays .rrr, .in-calendar.alldays .lll { width: ' + str(3*width+2*gap) + '%; }')
71print ('.in-calendar.alldays .rrrr, .in-calendar.alldays .llll { width: ' + str(4*width+3*gap) + '%; }')
72
73print ('.in-calendar.alldays .r, .in-calendar.alldays .rr, .in-calendar.alldays .rrr, .in-calendar.alldays .rrrr { margin-left: ' + str(width / 2) + '% ; }')
74print ('.in-calendar.alldays .l { margin-left: -' + str(width / 2) + '% ; }')
75print ('.in-calendar.alldays .ll { margin-left: -' + str(width / 2 + gap + width) + '% ; }')
76print ('.in-calendar.alldays .lll { margin-left: -' + str(width / 2 + gap * 2 + width * 2) + '% ; }')
77print ('.in-calendar.alldays .llll { margin-left: -' + str(width / 2 + gap * 3 + width * 3) + '% ; }')
78
79print ('.r, .rr, .rrr, .rrrr, .l, .ll, .lll, .llll { height: 4px; }')
80
81for size in ['large', 'medium', 'small']:
82 print ('.size-' + size +' .wholeday { height: ' + str( ( endtime - starttime ) * hour_height[size] ) + 'px; }' )
83 print ('.size-' + size +' .duration_inf { height: ' + str( 7 * hour_height[size] ) + 'px; }' )