all repos — site @ 817e4b96d2691995001b0670f6936b4b3f3429d8

source for my site, found at icyphox.sh

Quieter plaintext.sh, add update_index to post_build actions

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Sat, 25 Jan 2020 18:50:23 +0530
commit

817e4b96d2691995001b0670f6936b4b3f3429d8

parent

fcf383887b033bdb79aae706ed77dd655f0acf45

3 files changed, 18 insertions(+), 9 deletions(-)

jump to
M bin/plaintext.shbin/plaintext.sh

@@ -12,8 +12,7 @@

for p in pages/blog/*.md; do basename "$p" [ "$base" != "_index.md" ] && { - echo "$base" - pandoc -s -f "markdown+gutenberg" \ + pandoc --quiet -s -f "markdown+gutenberg" \ "$p" -o "pages/txt/${base%.*}.txt" } done
M bin/update_index.pybin/update_index.py

@@ -10,8 +10,11 @@ os.chdir("bin")

blog = "../pages/blog/" +print("this is going to take a while...") +print("you might as well serve the site!") + # order files by recency -def getrecents(path): +def get_recents(path): files = [path + f for f in os.listdir(blog) if f not in ["_index.md", "feed.xml"]] files.sort( key=lambda f: markdown_path(f, extras=["metadata"]).metadata["date"],

@@ -35,6 +38,12 @@

def update_blog(s): path = "../pages/blog/_index.md" s = s + "\n" + with open(path) as f: + tempf = f.readlines() + + if s in tempf: + print("index has already been updated. quitting...") + sys.exit() for l in fileinput.FileInput(path, inplace=1): if "--:" in l: l = l.replace(l, l + s)

@@ -47,13 +56,14 @@ lines = []

fnames = [] for i in range(5): - top_five.append(getrecents(blog)[i]) - metas.append(markdown_path(getrecents(blog)[i], extras=["metadata"]).metadata) - fnames.append(os.path.basename(os.path.splitext(getrecents(blog)[i])[0])) + top_five.append(get_recents(blog)[i]) + metas.append(markdown_path(get_recents(blog)[i], extras=["metadata"]).metadata) + fnames.append(os.path.basename(os.path.splitext(get_recents(blog)[i])[0])) for meta, fname in zip(metas, fnames): url = "/blog/" + fname - lines.append(f"| [{meta['title']}]({url}) | `{meta['date']}` |") + new_line = f"| [{meta['title']}]({url}) | `{meta['date']}` |" + lines.append(new_line) -update_index(lines) +#update_index(lines) update_blog(lines[0])
M config.pyconfig.py

@@ -19,4 +19,4 @@ <img class="footimgs" alt="xxiivv webring" src="/static/webring.svg">

</a> """ template = 'text.html' # default is index.html -post_build = ['./bin/rss.py', './bin/plaintext.sh'] +post_build = ['./bin/rss.py', './bin/plaintext.sh', './bin/update_index.py']