forked from cersonsky-lab/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_member_page.py
More file actions
executable file
·90 lines (87 loc) · 4.05 KB
/
make_member_page.py
File metadata and controls
executable file
·90 lines (87 loc) · 4.05 KB
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
import os
with open("members/index.md", "w") as outf:
outf.write("---\nlayout: default\n---\n# Cersonsky Lab Members\n\n")
outf.write("<head>\n<style>\n.profile-container {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n"
" justify-content: center;\n align-items: center;\n gap: 25px 10px;\n max-width: 700px;\n"
" margin-left: auto;\n margin-right: auto;\n margin-top: 20px;\n margin-bottom: 20px;\n}\n"
".profile {\n text-align: center;\n width: 210px;\n}\n\n"
"ul {\n list-style-type: none;\n padding: 0\n}\n\n"
"li {\n text-align: center;\n}\n\n"
"@media print, screen and (max-width: 1100px) {\n .profile-container {\n max-width: 450px\n }\n"
" .profile{\n width: 47%;\n }\n\n"
"@media print, screen and (max-width: 960px) {\n .profile-container {\n max-width: 700px\n }\n"
" .profile{\n width: 31%;\n }\n\n"
"@media print, screen and (max-width: 720px) {\n .profile-container {\n max-width: 450px\n }\n"
" .profile{\n width: 47%;\n }\n\n"
"</style>\n</head>\n\n")
n = 0
subtitle = ""
peeps = []
peepcodes = []
for line in open("members.txt"):
if line in [
"principal investigator\n",
"postdoctoral researchers\n",
"graduate researchers\n",
"undergraduate researchers\n",
"visitors and collaborators\n",
"alumni\n",
]:
if n > 0:
s = f'\n\n<h2 style="text-align: center;"> {subtitle.title()}</h2>\n\n'
skip = n
outf.write(s)
outf.write('<div class="profile-container">\n')
images = ""
for j in range(len(peeps)):
if j < len(peeps):
ext = "png"
if not os.path.exists(
f"assets/img/{peepcodes[j]}.png"
):
if not os.path.exists(
f"assets/img/{peepcodes[j]}.jpg"
):
raise FileNotFoundError(
f"File assets/img/{peepcodes[j]}.png does not exist."
)
else:
ext = "jpg"
if not os.path.exists(
f"./members/{peepcodes[j]}.md"
):
raise FileNotFoundError(
f"./members/{peepcodes[j]}.md does not exist."
)
images += f'<div class="profile">\n<a href="{{{{ site.baseurl }}}}/members/{peepcodes[j]}"><img src="{{{{ site.baseurl }}}}/assets/img/{peepcodes[j]}.{ext}" style="width:200px; height:200px; object-fit:cover;"></a><br><a href="{{{{ site.baseurl }}}}/members/{peepcodes[j]}">{peeps[j]}</a>\n</div>\n'
images += "</div>\n"
outf.write(images)
outf.write("\n\n------\n")
n = 0
subtitle = line
peeps = []
peepcodes = []
elif line in [
"end\n"
]:
if n > 0:
s = f'\n\n<h2 style="text-align: center;"> {subtitle.title()}</h2>\n\n'
skip = n
outf.write(s)
outf.write('<div class="container">\n<ul>\n')
images = ""
for j in range(len(peeps)):
if j < len(peeps):
images += f'\t<li>{peeps[j]}</li>\n'
images += "</ul>\n</div>\n"
outf.write(images)
outf.write("\n\n------\n")
n = 0
subtitle = line
peeps = []
peepcodes = []
elif line != "\n":
line = line.strip("\n").strip(" - ")
peeps.append(line)
peepcodes.append(line.lower().replace(" ", "_"))
n += 1