Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/make_update_prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Update Member Pages

on:
schedule:
- cron: '0 0 30 6,12 *' # Every June 30 and December 30 at midnight UTC
workflow_dispatch:

jobs:
update-pages:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: pip install PyGithub python-dateutil

- name: Run update script
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
python <<EOF
import os
import re
import subprocess
from datetime import datetime
from dateutil.relativedelta import relativedelta
from github import Github

def check_date(filepath):
try:
result = subprocess.check_output(
["git", "log", "-1", "--format=%ad", "--", filepath], text=True
).strip()
last_edit = datetime.strptime(result, "%a %b %d %H:%M:%S %Y %z")
threshold = datetime.now(last_edit.tzinfo) - relativedelta(months=6)
return last_edit < threshold
except subprocess.CalledProcessError:
return True # Consider as out-of-date if not in history

with open("members.txt", "r") as f:
lines = f.readlines()

members = []
skip_sections = {"visitors", "alumni"}
in_skip_section = False

for line in lines:
line = line.strip()
if not line or line.lower() in skip_sections:
in_skip_section = True
continue
if line.lower() == "header":
in_skip_section = False
continue
if in_skip_section:
continue

match = re.match(r"-?\s*(.*) - (\S+)", line)
if match:
name, github_username = match.groups()
filename = "_".join(name.lower().strip().split())
members.append({
"github": github_username,
"file": f"members/{filename}.md"
})

g = Github(os.environ["GH_TOKEN"])
repo = g.get_repo(os.environ["REPO"])

for member in members:
path = member["file"]
if not os.path.exists(path):
print(f"File {path} not found, skipping.")
continue

if check_date(path):
branch_name = f"update-{member['github'].lower()}"
subprocess.run(["git", "checkout", "-b", branch_name], check=True)

with open(path, "a") as f:
f.write("\nThis page has become out-of-date.\n")

subprocess.run(["git", "config", "user.name", "github-actions"], check=True)
subprocess.run(["git", "config", "user.email", "github-actions@github.com"], check=True)
subprocess.run(["git", "add", path], check=True)
subprocess.run(["git", "commit", "-m", f"Mark {member['file']} as out-of-date"], check=True)
subprocess.run(["git", "push", "-u", "origin", branch_name], check=True)

body = f"This page has been automatically marked as out-of-date.\n\n@{member['github']}"
pr = repo.create_pull(
title=f'Mark {member["file"]} page as out-of-date',
body=body,
head=branch_name,
base="main"
)
pr.add_to_assignees(member["github"])

subprocess.run(["git", "checkout", "main"], check=True)
subprocess.run(["git", "branch", "-D", branch_name], check=True)
EOF

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Adding your page to the website
1. Begin by cloning the repository to your local computer. You can do this by clicking the green `<> code` button above, copying the URL to your clipboard, and then executing `git clone link` in the terminal in which you paste the link in place of the word `link` in your desired local directory.
2. In the terminal, travel to the website directory. Remain there for the rest of the instructions. Create a new branch by executing `git checkout -b your_name_branch` in the terminal.
3. Add your name to `members.txt` (by running `nano members.txt` in the terminal) under the appropriate category in alphabetic order by last name. Type your name _exactly_ how you would like it to show up in the directory.
3. Add your name to `members.txt` (by running `nano members.txt` in the terminal) under the appropriate category in alphabetic order by last name. Type your name _exactly_ how you would like it to show up in the directory, followed by a dash ' - ' and your GitHub username.
4. Execute `cp members/example_student.md members/your_name.md` in terminal where `your_name` is the name you wrote in (3), but lowercase and with '_' instead of spaces. This will create a file `members/your_name.md` that is an exact copy of `members/example_student.md`.
5. Fill out `members/your_name.md`! Access the file by executing `nano members/your_name.md` and make sure to replace all instances of `example student` with your name.
6. Add a professional photo (preferably square aspect ratio) at `assets/img/your_name.png`. This can be done manually on the cumputer desktop or by executing `cp /path/to/source/your_name.png ./assets/img`, where `/path/to/source` is the path to where the image is on your computer.
Expand Down
63 changes: 33 additions & 30 deletions make_member_page.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import re
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")
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 = ""
Expand All @@ -38,21 +41,15 @@
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"
):
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"
):
if not os.path.exists(f"./members/{peepcodes[j]}.md"):
raise FileNotFoundError(
f"./members/{peepcodes[j]}.md does not exist."
)
Expand All @@ -64,9 +61,7 @@
subtitle = line
peeps = []
peepcodes = []
elif line in [
"end\n"
]:
elif line in ["end\n"]:
if n > 0:
s = f'\n\n<h2 style="text-align: center;"> {subtitle.title()}</h2>\n\n'
skip = n
Expand All @@ -75,7 +70,7 @@
images = ""
for j in range(len(peeps)):
if j < len(peeps):
images += f'\t<li>{peeps[j]}</li>\n'
images += f"\t<li>{peeps[j]}</li>\n"
images += "</ul>\n</div>\n"
outf.write(images)
outf.write("\n\n------\n")
Expand All @@ -84,7 +79,15 @@
peeps = []
peepcodes = []
elif line != "\n":
line = line.strip("\n").strip(" - ")
peeps.append(line)
peepcodes.append(line.lower().replace(" ", "_"))
n += 1
line = line.strip('\n')
while line[0] in ['-',' ']:
line = line[1:]
if ' - ' in line:
line = line[:line.index(' - ')]
while line[-1] in ['-',' ']:
line = line[:-1]

if len(line) > 0:
peeps.append(line)
peepcodes.append(line.lower().replace(" ", "_"))
n += 1
26 changes: 13 additions & 13 deletions members.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
principal investigator
Rose (Rosy) Cersonsky
Rose (Rosy) Cersonsky - rosecers

postdoctoral researchers

graduate researchers
- Charles Carroll
- Ethan Deutsch
- Christian Jorgensen
- Hwigwang Lim
- Arthur Lin
- Charles Carroll - cbefan
- Ethan Deutsch - e-deutsch
- Christian Jorgensen - cajchristian
- Hwigwang Lim - hwigwanglim
- Arthur Lin - arthur-lin1027

undergraduate researchers
- Zachary Amsterdam
- Simon Hjaltason
- Natalie Hooven
- Lucas Ortengren
- Matthew Reuteman
- Rhushil Vasavada
- Caleb Youngwerth
- Zachary Amsterdam - zamsterdam
- Simon Hjaltason - simon-hjaltason
- Natalie Hooven - nat-hooven
- Lucas Ortengren - ortengren
- Matthew Reuteman - Matthew-Reuteman
- Rhushil Vasavada - rvasav26
- Caleb Youngwerth - cjyoungwerth

visitors and collaborators
- Lisa Je
Expand Down