diff options
author | erdgeist <erdgeist@erdgeist.org> | 2024-12-22 21:53:57 +0100 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2024-12-22 21:53:57 +0100 |
commit | e3481a4a35091b32b6fbee80c1c9ba2b6d7b50d6 (patch) | |
tree | 58f90b32cbd89599acfaab07377cc0447f1190c1 /scripts/gen_css_tables.py |
Rework of halfnarp and fullnarp into a self contained repository. Still WIP
Diffstat (limited to 'scripts/gen_css_tables.py')
-rwxr-xr-x | scripts/gen_css_tables.py | 83 |
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 | |||
8 | start_y = 400 | ||
9 | starttime = 10 | ||
10 | endtime = 28 | ||
11 | rooms = 3 | ||
12 | days = 4 | ||
13 | columns = days * rooms # how many columns does | ||
14 | event_gap = { 'large': 5, 'medium': 3, 'small': 2 } # how much is an event shorter than what the grid would allow in px | ||
15 | block_length = 210 | ||
16 | |||
17 | time_grid = 5 # what is the granularity of Fahrplan raster in minutes | ||
18 | elem_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 | ||
21 | hour_height={ 'large': 300, 'medium': 160, 'small': 120 } | ||
22 | |||
23 | # What is the height of one grid element | ||
24 | grid_height={ 'large': hour_height['large'] / elem_per_hour, 'medium': hour_height['medium'] / elem_per_hour, 'small': hour_height['small'] / elem_per_hour } | ||
25 | |||
26 | for 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 | |||
33 | for 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 | |||
39 | print ( '.size-large .grid { height: ' + str(grid_height['large']) + 'px; font-size: 1em; }' ) | ||
40 | print ( '.size-medium .grid { height: ' + str(grid_height['medium'])+ 'px; font-size: 0.5em; }' ) | ||
41 | print ( '.size-small .grid { height: ' + str(grid_height['small']) + 'px; font-size: 0.3em; }' ) | ||
42 | |||
43 | gap = 4 | ||
44 | width = ( 100 - gap * ( 1 + rooms ) ) / rooms | ||
45 | for room in range(rooms): | ||
46 | print ( '.in-calendar .room' + str(room+1) +' { left: ' + str(gap * (room + 1) + width * room ) + '%; }' ) | ||
47 | |||
48 | print ('.in-calendar .event, .in-calendar .room-label, .in-calendar .grid { position: absolute; width: ' + str(width)+ '%; }' ) | ||
49 | print ('.in-calendar .r, .in-calendar .l { width: ' + str(width) + '%; }') | ||
50 | print ('.in-calendar .rr, .in-calendar .ll { width: ' + str(2*width+gap) + '%; }') | ||
51 | print ('.in-calendar .rrr, .in-calendar .lll { width: ' + str(3*width+2*gap) + '%; }') | ||
52 | print ('.in-calendar .rrrr, .in-calendar .llll { width: ' + str(4*width+3*gap) + '%; }') | ||
53 | print ('.in-calendar .r, .in-calendar .rr, .in-calendar .rrr, .in-calendar .rrrr { margin-left: ' + str(width / 2) + '% ; }') | ||
54 | print ('.in-calendar .l { margin-left: -' + str(width / 2) + '% ; }') | ||
55 | print ('.in-calendar .ll { margin-left: -' + str(width / 2 + gap + width) + '% ; }') | ||
56 | print ('.in-calendar .lll { margin-left: -' + str(width / 2 + gap * 2 + width * 2) + '% ; }') | ||
57 | print ('.in-calendar .llll { margin-left: -' + str(width / 2 + gap * 3 + width * 3) + '% ; }') | ||
58 | |||
59 | gap = 0.5 | ||
60 | width = ( 100 - gap * ( 1 + columns ) ) / columns | ||
61 | for 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 | |||
65 | print ('.wholeday, .wholeblock { width: ' + str(100 / days)+ '% }') | ||
66 | print ('.in-calendar.alldays .event, .in-calendar.alldays .room-label, .in-calendar.alldays .grid { width: ' + str(width)+ '%; }' ) | ||
67 | |||
68 | print ('.in-calendar.alldays .r, .in-calendar.alldays .l { width: ' + str(width) + '%; }') | ||
69 | print ('.in-calendar.alldays .rr, .in-calendar.alldays .ll { width: ' + str(2*width+gap) + '%; }') | ||
70 | print ('.in-calendar.alldays .rrr, .in-calendar.alldays .lll { width: ' + str(3*width+2*gap) + '%; }') | ||
71 | print ('.in-calendar.alldays .rrrr, .in-calendar.alldays .llll { width: ' + str(4*width+3*gap) + '%; }') | ||
72 | |||
73 | print ('.in-calendar.alldays .r, .in-calendar.alldays .rr, .in-calendar.alldays .rrr, .in-calendar.alldays .rrrr { margin-left: ' + str(width / 2) + '% ; }') | ||
74 | print ('.in-calendar.alldays .l { margin-left: -' + str(width / 2) + '% ; }') | ||
75 | print ('.in-calendar.alldays .ll { margin-left: -' + str(width / 2 + gap + width) + '% ; }') | ||
76 | print ('.in-calendar.alldays .lll { margin-left: -' + str(width / 2 + gap * 2 + width * 2) + '% ; }') | ||
77 | print ('.in-calendar.alldays .llll { margin-left: -' + str(width / 2 + gap * 3 + width * 3) + '% ; }') | ||
78 | |||
79 | print ('.r, .rr, .rrr, .rrrr, .l, .ll, .lll, .llll { height: 4px; }') | ||
80 | |||
81 | for 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; }' ) | ||