Compare commits
3 Commits
c36ce7dd20
...
0c89da7c3d
Author | SHA1 | Date | |
---|---|---|---|
|
0c89da7c3d | ||
|
41b18b8b05 | ||
|
d7a434ea11 |
2
host.sh
2
host.sh
@ -1,3 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
python3 -m http.server --directory ./html/
|
||||
python3 -m http.server --directory ./html/ & xdg-open http://0.0.0.0:8000/
|
||||
|
40
new-article.sh
Executable file
40
new-article.sh
Executable file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set +e
|
||||
|
||||
printf "%s" "Enter title: "
|
||||
read title
|
||||
|
||||
printf "%s" "Enter directory name: "
|
||||
read directory
|
||||
|
||||
if [ -d "./articles/$directory/" ]; then
|
||||
echo "Directory already exists, aborted."
|
||||
exit
|
||||
fi
|
||||
|
||||
printf "%s" "Enter brief: "
|
||||
read brief
|
||||
|
||||
printf "%s" "Enter tags: "
|
||||
read tags
|
||||
|
||||
mkdir "./articles/$directory/"
|
||||
|
||||
mask=$(cat <<-format
|
||||
Title: %s
|
||||
Brief: %s
|
||||
Date: %s
|
||||
Tags: %s
|
||||
CSS: /style.css
|
||||
|
||||
format
|
||||
)
|
||||
date=$(date +%s)
|
||||
|
||||
printf "$mask" "$title" "$brief" "$date" "$tags" \
|
||||
> "./articles/$directory/page.mmd"
|
||||
|
||||
if which xdg-open &> /dev/null; then
|
||||
xdg-open "./articles/$directory/page.mmd"
|
||||
fi
|
@ -2,7 +2,7 @@ import time, subprocess
|
||||
|
||||
def the_line_after_metadata(lines: []) -> int:
|
||||
i = 0
|
||||
while lines[i].strip():
|
||||
while i < len(lines) and lines[i].strip():
|
||||
i += 1
|
||||
return i
|
||||
|
||||
@ -19,7 +19,7 @@ def parse_metadata(filepath: str) -> {}:
|
||||
result["Date"] = time.gmtime(int(val))
|
||||
elif key == "Tags":
|
||||
result["Tags"] = [v.strip() for v in val.split(",")]
|
||||
else:
|
||||
elif val:
|
||||
result[key] = val
|
||||
result["Last Edit"] = time.gmtime(int(subprocess.getoutput(r"stat -c %Y " + filepath)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user