all repos — site @ 37125d30188086eeffb1ab1e4484cdbe2a425a78

source for my site, found at icyphox.sh

Create bin dir, script to update new post

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Wed, 18 Sep 2019 23:25:51 +0530
commit

37125d30188086eeffb1ab1e4484cdbe2a425a78

parent

e1233e644ec33bebea7f0ec7c2ee05d3a96bcd04

A bin/update_index.py

@@ -0,0 +1,49 @@

+#!/usr/bin/env python3 + +from markdown2 import markdown_path +import os +import fileinput +import sys + +# change our cwd +os.chdir('bin') + +blog = '../pages/blog/' + +# bunch of file hacks to get to the most recent file +def getrecent(path): + files = [path + f for f in os.listdir(blog) + if f not in ['_index.md', 'feed.xml']] + files.sort(key=os.path.getmtime, reverse=True) + return files[0] + + +def update_index(s): + path = '../pages/_index.md' + with open(path, 'r') as f: + md = f.readlines() + latest = md.index('# latest post\n') + md[latest + 2] = s + '\n' + + with open(path, 'w') as f: + f.writelines(md) + + +def update_blog(s): + path = '../pages/blog/_index.md' + s = s + '\n' + for l in fileinput.FileInput(path, inplace=1): + if "marker" in l: + l=l.replace(l, l + s) + print(l, end=''), + +# fetch title and date +meta = markdown_path(getrecent(blog), extras=['metadata']).metadata +fname = os.path.basename(os.path.splitext(getrecent(blog))[0]) +url = '/blog/' + fname +line = f"`{meta['date']}` [{meta['title']}]({url})" + +update_index(line) +update_blog(line) + +
M build/blog/index.htmlbuild/blog/index.html

@@ -36,19 +36,20 @@ <div class="content">

<div align="left"> <h1 id="all-posts-rssblogfeedxml">all posts (<a href="/blog/feed.xml">rss</a>)</h1> -<p><code>2019-09-17</code> &#8211; <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> +<p><!&#8211;marker&#8211;!> +<code>2019-09-17</code> <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> -<p><code>2019-09-10</code> &#8211; <a href="/blog/disinfo">Disinformation demystified</a></p> +<p><code>2019-09-10</code> <a href="/blog/disinfo">Disinformation demystified</a></p> -<p><code>2019-08-15</code> &#8211; <a href="/blog/mailserver">Setting up my personal mailserver</a></p> +<p><code>2019-08-15</code> <a href="/blog/mailserver">Setting up my personal mailserver</a></p> -<p><code>2019-08-06</code> &#8211; <a href="/blog/fb50">Picking the FB50 smart lock (CVE-2019-13143)</a></p> +<p><code>2019-08-06</code> <a href="/blog/fb50">Picking the FB50 smart lock (CVE-2019-13143)</a></p> -<p><code>2019-06-06</code> &#8211; <a href="/blog/rop-on-arm">Return Oriented Programming on ARM (32-bit)</a></p> +<p><code>2019-06-06</code> <a href="/blog/rop-on-arm">Return Oriented Programming on ARM (32-bit)</a></p> -<p><code>2019-13-05</code> &#8211; <a href="/blog/my-setup">My Setup</a></p> +<p><code>2019-13-05</code> <a href="/blog/my-setup">My Setup</a></p> -<p><code>2019-02-08</code> &#8211; <a href="/blog/python-for-re-1/">Python for Reverse Engineering #1: ELF Binaries</a></p> +<p><code>2019-02-08</code> <a href="/blog/python-for-re-1/">Python for Reverse Engineering #1: ELF Binaries</a></p> </div> <hr />
M build/index.htmlbuild/index.html

@@ -51,7 +51,7 @@ or via <a href="https://twitter.com/icyphox">Twitter</a> DMs.</p>

<h1 id="latest-post">latest post</h1> -<p><code>2019-09-17</code> &#8211; <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> +<p><code>2019-09-17</code> <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> <p>(<a href="/blog">see all</a>)</p>
M config.pyconfig.py

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

</a> """ template = 'index.html' # default is index.html -post_build = ['./rss.py'] +post_build = ['./bin/rss.py']
M pages/_index.mdpages/_index.md

@@ -19,9 +19,9 @@

Want to contact me? The best way is via email (plain-text please), at [x@icyphox.sh](mailto:x@icyphox.sh) or via [Twitter](https://twitter.com/icyphox) DMs. -# latest post +# latest post -`2019-09-17` -- [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) +`2019-09-17` [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) ([see all](/blog))

@@ -31,3 +31,4 @@ [The Undending Game: A Former R&AW Chief's Insights into Espionage](https://www.amazon.in/Unending-Game-Former-Insights-Espionage/dp/0670091502)

*still reading* | by **Vikram Sood** | started **8th August, 2019** ([see all](/reading)) +
M pages/blog/_index.mdpages/blog/_index.md

@@ -6,17 +6,18 @@ ---

# all posts ([rss](/blog/feed.xml)) -`2019-09-17` -- [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) +<!--marker--!> +`2019-09-17` [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) -`2019-09-10` -- [Disinformation demystified](/blog/disinfo) +`2019-09-10` [Disinformation demystified](/blog/disinfo) -`2019-08-15` -- [Setting up my personal mailserver](/blog/mailserver) +`2019-08-15` [Setting up my personal mailserver](/blog/mailserver) -`2019-08-06` -- [Picking the FB50 smart lock (CVE-2019-13143)](/blog/fb50) +`2019-08-06` [Picking the FB50 smart lock (CVE-2019-13143)](/blog/fb50) -`2019-06-06` -- [Return Oriented Programming on ARM (32-bit)](/blog/rop-on-arm) +`2019-06-06` [Return Oriented Programming on ARM (32-bit)](/blog/rop-on-arm) -`2019-13-05` -- [My Setup](/blog/my-setup) +`2019-13-05` [My Setup](/blog/my-setup) -`2019-02-08` -- [Python for Reverse Engineering #1: ELF Binaries](/blog/python-for-re-1/) +`2019-02-08` [Python for Reverse Engineering #1: ELF Binaries](/blog/python-for-re-1/)