about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--_libs/formbox/comment.xml2
-rwxr-xr-x_libs/formbox/format101
-rw-r--r--config.md2
-rw-r--r--index.md8
-rw-r--r--utils.jl3
5 files changed, 7 insertions, 109 deletions
diff --git a/_libs/formbox/comment.xml b/_libs/formbox/comment.xml
index 524e0c7..3d8ff93 100644
--- a/_libs/formbox/comment.xml
+++ b/_libs/formbox/comment.xml
@@ -1,7 +1,7 @@
 <item>
   <link>https://lists.sr.ht/~cnx/site/{message_id}</link>
   <guid>https://lists.sr.ht/~cnx/site/{message_id}</guid>
-  <pubDate>{date}</pubDate>
+  <pubDate>{rfc822}</pubDate>
   <dc:creator>{author}</dc:creator>
   <title>On {date}, {author} wrote:</title>
   <content:encoded><![CDATA[{body}<br>
diff --git a/_libs/formbox/format b/_libs/formbox/format
deleted file mode 100755
index 2136a0c..0000000
--- a/_libs/formbox/format
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/usr/bin/env python
-# Format mbox as HTML/XML
-# Copyright (C) 2021-2022  Nguyễn Gia Phong
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published
-# by the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-from argparse import ArgumentParser
-from collections import defaultdict
-from email.header import decode_header
-from email.utils import parsedate_to_datetime
-from functools import partial
-from mailbox import mbox
-from pathlib import Path
-from urllib.parse import quote, unquote, urlencode
-
-from bleach import clean, linkify
-from markdown import markdown
-
-sanitise = partial(clean, tags=('a', 'code', 'em', 'strong', 'sub', 'sup',
-                                'blockquote', 'p', 'pre', 'ul', 'ol', 'li'),
-                   protocols=('ftp', 'gemini', 'gopher', 'http', 'https',
-                              'irc', 'ircs', 'mailto', 'matrix', 'xmpp'))
-
-
-def get_body(message):
-    """Return the Markdown message body converted to HTML."""
-    if message.is_multipart():
-        for payload in map(get_body, message.get_payload()):
-            if payload is not None: return payload
-    elif message.get_content_type() in ('text/markdown', 'text/plain'):
-        payload = message.get_payload(decode=True).decode()
-        return sanitise(linkify(markdown(payload, output_format='html5')))
-    return None
-
-
-def decode(header):
-    """Return the decoded email header."""
-    for string, charset in decode_header(header):
-        encoding = 'utf-8' if charset is None else charset
-        yield string.decode(encoding)
-
-
-def reply_to(message):
-    """Return mailto parameters for replying to the given email."""
-    yield 'In-Reply-To', message['Message-ID']
-    yield 'Cc', message.get('Reply-To', message['From'])
-    subject = message['Subject']
-    if subject is None: return
-    if subject.lower().startswith('re:'):
-        yield 'Subject', subject
-    else:
-        yield 'Subject', f'Re: {subject}'
-
-
-def date(message):
-    """Parse given email's Date header."""
-    return parsedate_to_datetime(message['Date']).date()
-
-
-def render(template, archive, parent):
-    """Render the thread recursively based on given template."""
-    for self in sorted(archive[parent], key=date):
-        body = get_body(self)
-        if body is None: continue
-        message_id = self['Message-Id']
-        # Please don't have space in email addresses
-        author = ' '.join(decode(self['From'])).rsplit(maxsplit=1)[0]
-        rendered_children = render(template, archive, message_id)
-        yield template.format(in_reply_to=quote(parent),
-                              message_id=quote(message_id),
-                              mailto_params=urlencode(dict(reply_to(self))),
-                              date=date(self).isoformat(), author=author,
-                              body=body, children='\n'.join(rendered_children))
-
-
-def main():
-    """Parse command-line arguments and pass them to routines."""
-    parser = ArgumentParser(description='format mbox as HTML/XML')
-    parser.add_argument('mbox', type=mbox, help='path to mbox file')
-    parser.add_argument('id', type=unquote, help='root message ID')
-    parser.add_argument('template', type=Path, help='path to template')
-    args = parser.parse_args()
-
-    archive = defaultdict(list)
-    for message in args.mbox: archive[message['In-Reply-To']].append(message)
-    template = args.template.read_text()
-    print(*render(template, archive, args.id), sep='', end='')
-
-
-if __name__ == '__main__': main()
diff --git a/config.md b/config.md
index 615c2b2..e70fb85 100644
--- a/config.md
+++ b/config.md
@@ -8,7 +8,7 @@ date_format = "yyyy-mm-dd"
 mintoclevel = 2
 generate_rss = true
 ignore = [".builds/", "Manifest.toml", "Project.toml",
-          "node_modules/", "package-lock.json"]
+          "node_modules/", "package.json", "package-lock.json"]
 +++
 
 \newcommand{\R}{\mathbb R}
diff --git a/index.md b/index.md
index 1c1166b..b8499a6 100644
--- a/index.md
+++ b/index.md
@@ -1,9 +1,9 @@
 # About Me
 
-Hi!  [My name is] Nguyễn Gia Phong and I'm a Vietnamese [free software]
-enthusiast who is generally interested in programming languages,
-concurrency, reproducibility and decentralization.  In meatspace
-I also like cooking, dogs[^culture] and urban music.
+Hi!  [My name is] Nguyễn Gia Phong.  I'm a Vietnamese graduate student
+and a [free software] enthusiast.  My areas of interest surround
+programming languages, concurrency, reproducibility and decentralization.
+In meatspace I also like cooking, dogs[^culture] and urban music.
 
 You can find me under my Internet alias McSinyx (or CnX for short)
 in the [Fediverse][]:
diff --git a/utils.jl b/utils.jl
index f39dee5..8383740 100644
--- a/utils.jl
+++ b/utils.jl
@@ -17,10 +17,9 @@ hfun_comments() = @sprintf("https://lists.sr.ht/~cnx/site?search=%s:%s",
 
 function render_comments(template)
   prefix = joinpath(path(:libs), "formbox")
-  format = joinpath(prefix, "format")
   mbox = joinpath(prefix, "mbox")
   template_path = joinpath(prefix, template)
-  readchomp(`$format $mbox $(message_id()) $template_path`)
+  readchomp(`formbox $mbox $(message_id()) $template_path`)
 end
 
 function hfun_comments_rendered()