diff options
| author | Yuval Adam <_@yuv.al> | 2022-11-17 00:35:42 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2022-11-17 15:38:21 +0200 |
| commit | f9229cf066eb810a97b3b324527e42d5acba254d (patch) | |
| tree | d6f592695e4e00179e04182d015a240d341ecc16 | |
| parent | bcf0ce69c5ae552797f4daf30214fab446c61d14 (diff) | |
Split list and render candidates
| -rw-r--r-- | Pipfile | 1 | ||||
| -rw-r--r-- | build.py | 12 | ||||
| -rw-r--r-- | scripts/ghpr.py | 26 | ||||
| -rw-r--r-- | templates/index.html | 14 |
4 files changed, 41 insertions, 12 deletions
@@ -14,4 +14,5 @@ black = "*" [scripts] build = "python build.py" scan = "python scripts/scan.py" +ghpr = "python scripts/ghpr.py" serve = "python -m http.server --directory build" @@ -12,7 +12,7 @@ BUILD_DIR = ROOT_PATH / "build" STATIC_DIR = ROOT_PATH / "static" REQUIRED_FIELDS = set(["domain", "name"]) -OPTIONAL_FIELDS = set(["url", "title", "email", "github"]) +OPTIONAL_FIELDS = set(["url", "title", "email", "github", "candidate"]) TEMPLATES = ["index.html"] @@ -24,6 +24,7 @@ for f in listdir(STATIC_DIR): # process all name yamls names = [] +candidates = [] for name in listdir(NAMES_DIR): with open(NAMES_DIR / name, "r") as f: fields = yaml.load(f.read(), Loader=yaml.Loader) @@ -34,8 +35,13 @@ for name in listdir(NAMES_DIR): invalid_fields = field_set - OPTIONAL_FIELDS - REQUIRED_FIELDS if invalid_fields: raise Exception(f"Invalid fields {invalid_fields} in {name}") - names.append(fields) + + if fields.get("candidate"): + candidates.append(fields) + else: + names.append(fields) names = list(sorted(names, key=lambda x: x["domain"])) +candidates = list(sorted(candidates, key=lambda x: x["domain"])) def render_link(value, classes): @@ -56,6 +62,6 @@ env = Environment(loader=PackageLoader("build"), autoescape=select_autoescape()) env.filters["render_link"] = render_link for template in TEMPLATES: t = env.get_template(template) - index = t.render(names=names) + index = t.render(names=names, candidates=candidates) with open(BUILD_DIR / "index.html", "w") as f: f.write(index) diff --git a/scripts/ghpr.py b/scripts/ghpr.py index 4406ba1..6c9f7f9 100644 --- a/scripts/ghpr.py +++ b/scripts/ghpr.py @@ -11,15 +11,25 @@ with open(path, "r") as f: for line in f: l = line.strip().split(",") domain, handle, name = [x.strip() for x in l] + handle = None if "@" in handle else handle fn = domain.replace(".", "") - with open(ROOT_PATH / "names" / f"{fn}.yml", "w") as out: - s = f"domain: {domain}\nname: {name}\ngithub: {handle}\n" + + path = ROOT_PATH / "names" / f"{fn}.yml" + if path.exists(): + print(f"{domain} already exists") + continue + + with open(path, "w") as out: + s = f"domain: {domain}\nname: {name}\n" + if handle: + s += f"github: {handle}\n" + s += "candidate: true\n" out.write(s) - run(["git", "checkout", "-b", domain]) - run(["git", "add", f"names/{fn}.yml"]) - run(["git", "commit", "-m", f"Add {domain}"]) - run(["git", "push", "-u", "origin", domain]) - run(["gh", "pr", "create", "-t", f"Add {domain}", "-b", f"Hey @{handle}, would you like to merge this PR adding you to https://namehack.club?"]) - run(["git", "checkout", "main"]) + # run(["git", "checkout", "-b", domain]) + # run(["git", "add", f"names/{fn}.yml"]) + # run(["git", "commit", "-m", f"Add {domain}"]) + # run(["git", "push", "-u", "origin", domain]) + # run(["gh", "pr", "create", "-t", f"Add {domain}", "-b", f"Hey @{handle}, would you like to merge this PR adding you to https://namehack.club?"]) + # run(["git", "checkout", "main"]) diff --git a/templates/index.html b/templates/index.html index aa366de..762e5a6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,7 +27,8 @@ class="link dim dark-pink">domain hack</a> to their name, and serve their personal homepage from it. Are you one of us? <a href="https://github.com/yuvadm/namehack.club" class="link dim dark-pink">Join the club.</a></p> - <ul class="list pl0 pv4"> + <h2 class="pt4">Members</h2> + <ul class="list pl0"> {% for name in names %} <li class="mb3"> <div class="f3">{{ name|render_link("link dim blue")|safe }}</div> @@ -35,6 +36,17 @@ </li> {% endfor %} </ul> + + <h2 class="pt4">Candidates<span class="infolink"></span></h2> + <ul class="list pl0"> + {% for name in candidates %} + <li class="mb3"> + <div class="f4">{{ name|render_link("link dim blue")|safe }}</div> + <div class="light-silver serif mt1">{{ name.title }}</div> + </li> + {% endfor %} + </ul> + <hr class="mt4 white-20"> <footer class="tr lh-copy mb4"> Created by <a href="https://yuv.al" class="link dim green">Yuval Adam</a>. Maintained collaboratively on <a |
