my website at https://anirudh.fi
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

Create bin dir, script to update new post

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>

+70 -18
+49
bin/update_index.py
··· 1 + #!/usr/bin/env python3 2 + 3 + from markdown2 import markdown_path 4 + import os 5 + import fileinput 6 + import sys 7 + 8 + # change our cwd 9 + os.chdir('bin') 10 + 11 + blog = '../pages/blog/' 12 + 13 + # bunch of file hacks to get to the most recent file 14 + def getrecent(path): 15 + files = [path + f for f in os.listdir(blog) 16 + if f not in ['_index.md', 'feed.xml']] 17 + files.sort(key=os.path.getmtime, reverse=True) 18 + return files[0] 19 + 20 + 21 + def update_index(s): 22 + path = '../pages/_index.md' 23 + with open(path, 'r') as f: 24 + md = f.readlines() 25 + latest = md.index('# latest post\n') 26 + md[latest + 2] = s + '\n' 27 + 28 + with open(path, 'w') as f: 29 + f.writelines(md) 30 + 31 + 32 + def update_blog(s): 33 + path = '../pages/blog/_index.md' 34 + s = s + '\n' 35 + for l in fileinput.FileInput(path, inplace=1): 36 + if "marker" in l: 37 + l=l.replace(l, l + s) 38 + print(l, end=''), 39 + 40 + # fetch title and date 41 + meta = markdown_path(getrecent(blog), extras=['metadata']).metadata 42 + fname = os.path.basename(os.path.splitext(getrecent(blog))[0]) 43 + url = '/blog/' + fname 44 + line = f"`{meta['date']}` [{meta['title']}]({url})" 45 + 46 + update_index(line) 47 + update_blog(line) 48 + 49 +
+8 -7
build/blog/index.html
··· 36 36 <div align="left"> 37 37 <h1 id="all-posts-rssblogfeedxml">all posts (<a href="/blog/feed.xml">rss</a>)</h1> 38 38 39 - <p><code>2019-09-17</code> &#8211; <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> 39 + <p><!&#8211;marker&#8211;!> 40 + <code>2019-09-17</code> <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> 40 41 41 - <p><code>2019-09-10</code> &#8211; <a href="/blog/disinfo">Disinformation demystified</a></p> 42 + <p><code>2019-09-10</code> <a href="/blog/disinfo">Disinformation demystified</a></p> 42 43 43 - <p><code>2019-08-15</code> &#8211; <a href="/blog/mailserver">Setting up my personal mailserver</a></p> 44 + <p><code>2019-08-15</code> <a href="/blog/mailserver">Setting up my personal mailserver</a></p> 44 45 45 - <p><code>2019-08-06</code> &#8211; <a href="/blog/fb50">Picking the FB50 smart lock (CVE-2019-13143)</a></p> 46 + <p><code>2019-08-06</code> <a href="/blog/fb50">Picking the FB50 smart lock (CVE-2019-13143)</a></p> 46 47 47 - <p><code>2019-06-06</code> &#8211; <a href="/blog/rop-on-arm">Return Oriented Programming on ARM (32-bit)</a></p> 48 + <p><code>2019-06-06</code> <a href="/blog/rop-on-arm">Return Oriented Programming on ARM (32-bit)</a></p> 48 49 49 - <p><code>2019-13-05</code> &#8211; <a href="/blog/my-setup">My Setup</a></p> 50 + <p><code>2019-13-05</code> <a href="/blog/my-setup">My Setup</a></p> 50 51 51 - <p><code>2019-02-08</code> &#8211; <a href="/blog/python-for-re-1/">Python for Reverse Engineering #1: ELF Binaries</a></p> 52 + <p><code>2019-02-08</code> <a href="/blog/python-for-re-1/">Python for Reverse Engineering #1: ELF Binaries</a></p> 52 53 53 54 </div> 54 55 <hr />
+1 -1
build/index.html
··· 51 51 52 52 <h1 id="latest-post">latest post</h1> 53 53 54 - <p><code>2019-09-17</code> &#8211; <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> 54 + <p><code>2019-09-17</code> <a href="/blog/2019-09-17">Weekly status update, 09/08 - 09/17</a></p> 55 55 56 56 <p>(<a href="/blog">see all</a>)</p> 57 57
+1 -1
config.py
··· 17 17 </a> 18 18 """ 19 19 template = 'index.html' # default is index.html 20 - post_build = ['./rss.py'] 20 + post_build = ['./bin/rss.py']
+3 -2
pages/_index.md
··· 19 19 Want to contact me? The best way is via email (plain-text please), at [x@icyphox.sh](mailto:x@icyphox.sh) 20 20 or via [Twitter](https://twitter.com/icyphox) DMs. 21 21 22 - # latest post 22 + # latest post 23 23 24 - `2019-09-17` -- [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) 24 + `2019-09-17` [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) 25 25 26 26 ([see all](/blog)) 27 27 ··· 31 31 *still reading* | by **Vikram Sood** | started **8th August, 2019** 32 32 33 33 ([see all](/reading)) 34 +
+8 -7
pages/blog/_index.md
··· 6 6 7 7 # all posts ([rss](/blog/feed.xml)) 8 8 9 - `2019-09-17` -- [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) 9 + <!--marker--!> 10 + `2019-09-17` [Weekly status update, 09/08 - 09/17](/blog/2019-09-17) 10 11 11 - `2019-09-10` -- [Disinformation demystified](/blog/disinfo) 12 + `2019-09-10` [Disinformation demystified](/blog/disinfo) 12 13 13 - `2019-08-15` -- [Setting up my personal mailserver](/blog/mailserver) 14 + `2019-08-15` [Setting up my personal mailserver](/blog/mailserver) 14 15 15 - `2019-08-06` -- [Picking the FB50 smart lock (CVE-2019-13143)](/blog/fb50) 16 + `2019-08-06` [Picking the FB50 smart lock (CVE-2019-13143)](/blog/fb50) 16 17 17 - `2019-06-06` -- [Return Oriented Programming on ARM (32-bit)](/blog/rop-on-arm) 18 + `2019-06-06` [Return Oriented Programming on ARM (32-bit)](/blog/rop-on-arm) 18 19 19 - `2019-13-05` -- [My Setup](/blog/my-setup) 20 + `2019-13-05` [My Setup](/blog/my-setup) 20 21 21 - `2019-02-08` -- [Python for Reverse Engineering #1: ELF Binaries](/blog/python-for-re-1/) 22 + `2019-02-08` [Python for Reverse Engineering #1: ELF Binaries](/blog/python-for-re-1/) 22 23
rss.py bin/rss.py