forked from f28wp/f28wp.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-html.py
273 lines (201 loc) · 5.93 KB
/
build-html.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
"""
Helper file to generate the index page
Search through subdirectories to find/build the homepage
* Help identify files incorrectly named
* Ensure consistency (structure/filenames)
Example:
\> python build-html.py > index.html
"""
# list of videos that correlate with the lectures - play through the commentary (sit and watch)
videos = { "Introduction" : "https://www.youtube.com/embed/V5jkHVk1fXE?start=5&autoplay=1",
"Internet and Web" : "https://www.youtube.com/embed/8CBhwckd9eo?start=5&autoplay=1",
"Fundamentals of HTML and CSS" : "https://www.youtube.com/embed/bFhOCKI4eUI?start=5&autoplay=1",
"Productive Web Programming" : "https://www.youtube.com/embed/9V2e_V1hl_c?start=5&autoplay=1"
}
import os
import sys
#print "This is the name of the script: ", sys.argv[0]
#print "Number of arguments: ", len(sys.argv)
#print "The arguments are: " , str(sys.argv)
showDetails = 0
if ( len(sys.argv)>1 ):
if ( sys.argv[1] == "details" ):
showDetails = 1
"""
(Lecture 23 - Web Services in action Prt 2.pptx)
(Notes 22.pdf)
(Lab 23 - Web Services in action Prt 2.docx)
(Revision 22 - Web Services in action Prt 1.docx)
(Revision 02 Ans - Forms and Tables.docx)
cw
"""
lectures = []
handouts = []
notes = []
labs = []
quizzes = []
cws = []
games = []
if 0:
for currentpath, dirs, files in os.walk('.'):
for file in files:
if 'images' in currentpath:
continue
if 'build' in currentpath:
continue
if '.py' in file:
continue
if '.txt' in file:
continue
if '.html' in file:
continue
#print(os.path.join(currentpath, file))
fn = file
pathandfn = os.path.join(currentpath, file)
print( "(%s) %s" % (fn, pathandfn) )
def finddir( str, str2=0 ):
for currentpath, dirs, files in os.walk('.'):
for file in files:
if 'images' in currentpath:
continue
if 'build' in currentpath:
continue
if '.py' in file:
continue
if '.txt' in file:
continue
if str in file:
if str2==0:
return [file, os.path.join(currentpath, file)]
else:
if str2 in file:
return [file, os.path.join(currentpath, file)]
#print(os.path.join(currentpath, file))
#fn = file
#pathandfn = os.path.join(currentpath, file)
return 0
def findNum( fileNameAndPath, subStr ):
fp = open( fileNameAndPath, 'rt' );
if ( fp == 0 ):
return 0;
txt = fp.read();
fp.close();
return txt.count( subStr );
# print( finddir('Lecture 01') )
str = ''
str += """
<link rel="shortcut icon" type="image/x-icon" href="./material/lectures/images/favicon.ico" />
<br>
<table align="center"><tr><td>
F28WP - <a href='http://www.macs.hw.ac.uk/students/cs/courses/f28wp-web-programming/'>Web Programming</a>
<br>
<br>
<table>
<tr>
<td>Wk </td>
<td>No </td>
<td>Topic </td>
<td>Lecture </td>
<td> </td>
<td>Video </td>
<td> </td>
<td>Notes </td>
<td>Labs </td>
<td>Quiz </td>
<td>Crossword </td>
<td>Demos </td>
</tr>
""";
week = 1
for i in range(0,25):
s = 'Lecture %02d' % (i)
val = finddir( s, 'html' )
if val == 0:
continue
str += '<tr>'
topic = val[0].split('.')
topic = topic[0].split(' -')[1]
topic = topic.strip()
if ( (i+1) % 2 == 0 or i==1) and i>0:
str += "<td>%2d</td>" % (week)
week+=1
else:
str += "<td> </td>"
str += "<td>%2d</td>" % (i)
str += "<td>%s</td>" % (topic)
if ( showDetails ):
str += "<td><a href='%s'>Slides (%d)</td>" % (val[1], findNum(val[1], '</section>') )
else:
str += "<td><a href='%s'>Slides</td>" % (val[1]) # , findNum(val[1], '</section>') )
str += '<td> </td>';
#tmp = finddir( 'Lecture %02d' % (i), 'pdf' )
#if tmp == 0:
# str += "<td> </td>"
#else:
# str += "<td><a href='%s'> pdf </td>" % tmp[1]
tmp = topic in videos; # 'Lecture %02d' % (i), 'pdf' )
if tmp == 0:
str += "<td> - </td>"
else:
str += "<td><a href='%s'> Video </td>" % videos[ topic ]
str += '<td> </td>';
tmp = finddir( 'Notes %02d' % (i), 'html' )
if tmp == 0:
str += "<td> - </td>"
else:
str += "<td><a href='%s'>Notes</td>" % tmp[1]
tmp = finddir( 'Lab %02d' % (i), 'html' )
if tmp == 0:
str += "<td> - </td>"
else:
str += "<td><a href='%s'>Lab</td>" % tmp[1]
tmp = finddir( 'Quiz %02d -' % (i) )
if tmp == 0:
str += "<td> - </td>"
else:
if ( showDetails ):
str += "<td><a href='%s'>Revision (%d)</td>" % (tmp[1], findNum(tmp[1], 'question:') )
else:
str += "<td><a href='%s'>Revision</td>" % tmp[1]
tmp = finddir( 'Crossword %02d' % (i), 'html' )
if tmp == 0:
str += "<td> - </td>"
else:
str += "<td><a href='%s'>Crossword</td>" % tmp[1]
tmp = finddir( 'Game %02d' % (i), 'html' )
if tmp == 0:
tmp = finddir( 'App %02d' % (i), 'html' )
if tmp == 0:
str += "<td> - </td>"
else:
str += "<td><a href='%s'>App</td>" % tmp[1]
else:
str += "<td><a href='%s'>Game</td>" % tmp[1]
str += '</tr>\n'
#if 'Review' in topic:
# str += '<tr><td> </td></tr>'
str += '</table>'
str += '<br>'
str += "Assessment:<br>"
str += "Exam 50% <br>"
# str += "Courseworks 50%<br>"
str += "Coursework (50%%) (<a href='%s'>Document Details</a>) " % ( finddir( 'cw01.pdf')[1] )
str += "(<a href='%s'>Support Sides</a>) " % ( finddir( 'Coursework.html')[1] )
str += "(<a href='%s'>Checksheet</a>)" % ( finddir( 'cw01-checklist.pdf')[1] )
str += "<!-- (<a href='%s'>Demonstration Sheet</a>) --> " % ( finddir( 'sheet.pdf')[1] )
str += "<br>"
#str += '<br><br>'
#str += "Coursework (50%%) <a href='%s'>Link</a> <br>" % ( finddir( 'cw01')[1] )
str += "</td></tr></table>"
str += """
<br>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-148326645-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-148326645-1');
</script>
"""
print( str )