~schnouki/schnouki.net

0ac06a77b06964c3f343124caaa6dda29c02cc42 — Thomas Jost 2 years ago 4dd7966
Update helper scripts
2 files changed, 11 insertions(+), 4 deletions(-)

M helper-new.py
M webpize
M helper-new.py => helper-new.py +10 -4
@@ 15,26 15,32 @@ def main():

    content_title = prompt("Title: ")
    today = datetime.date.today()
    file_title = content_title

    if content_type == "post":
        content_date = prompt(
            "Date: ", default=today.isoformat())
        content_title = f"{content_date} {content_title}"
        file_title = f"{content_date} {content_title}"
        mtch = re.match(r"(\d+)-\d+-\d+", content_date)
        if mtch:
            content_title = f"{mtch.group(1)}/{content_title}"
            file_title = f"{mtch.group(1)}/{file_title}"
    elif content_type == "boook-review":
        content_title = f"{today.year}/{content_title}"
        file_title = f"{today.year}/{content_title}"


    yes_no_completer = WordCompleter(["yes", "no"])
    as_dir = prompt("Create as a directory? (yes/no) ", completer=yes_no_completer) == "yes"
    dir_suffix = "/index" if as_dir else ""

    hugo_path = f"{content_type}/{content_title}{dir_suffix}.md"
    hugo_path = f"{content_type}/{file_title}{dir_suffix}.md"
    command = ["hugo", "new", hugo_path]
    subprocess.run(command, check=True)

    commit_file = ".git/COMMIT_EDITMSG"
    if not os.path.isfile(commit_file):
        with open(commit_file, "w") as out:
            print(f"New {content_type.replace('-', ' ')}: {content_title}", file=out)

    editor = os.getenv("EDITOR")
    if editor:
        editor_path = f"content/{hugo_path}"

M webpize => webpize +1 -0
@@ 36,6 36,7 @@ find . -iname '*.jpg' -or -iname '*.png' |
            if [[ $szs -gt $szd ]]; then
                msg "$src: $szs --> ${GREEN}$szd${NOFORMAT}"
                cp "$tmpf" "$dst"
                chmod 0644 "$dst"
            else
                msg "$src: $szs --> ${YELLOW}$szd${NOFORMAT}"
            fi