define-blog-post

A domain-specific language for writing blog posts

Arthur A. Gleckler

talks@speechcode.com

BALISP
Sat 2 Feb 2019

Why?

  • Org mode

    Powerful, but controlling layout and appearance is too much work.
  • Power

    Full power of Scheme to produce HTML.

Example blog post definition


(define-blog-post (push-pin-maps "Push-pin Maps" (1 9 2019) ())
    ((states '("AK" "AZ" "CA" "CO" "CT" "DE" "FL" "GA" "HI" "KY" "MA"
	       "MD" "ME" "MN" "MO" "NH" "NJ" "NM" "NV" "NY" "OH" "OK"
	       "OR" "PA" "RI" "TN" "TX" "UT" "VA" "VT" "WA" "WI"))
     (selectors (string-join ", #" states "#"))
     (svg (make-raw-xml (load-states-svg))))
  (hero
   ((style) selectors " { fill: black; }\n.state { fill: #d3d3d3; }\nsvg { width: 100%; }")
   svg)
  (blurb
   ((p)
    "Use these interactive maps to visualize where you've been "
    ((a href "/maps/usa") "in the USA")
    " and "
    ((a href "/maps/world") "in the world")
    "."))
  ((p) "My mother has a wall map that is covered with push pins marking the many countries she has visited.  Her map inspired me to make two web pages, one for the US and one for the world, that anyone can use to visualize all the places they've visited.")
  ((ul)
   ((li) ((a href "/maps/usa") "USA"))
   ((li) ((a href "/maps/world") "World")))
  ((p) "Both are written using simple JavaScript, without frameworks, in a direct style that might not be practical for larger projects, but that works well for these small pages.")
  ((p) "Thanks to those who made the excellent SVG maps used here available through Wikipedia."))

define-blog-post produces a card…


(define-blog-post (push-pin-maps "Push-pin Maps" (1 9 2019) ())
    ((states …)
     (selectors …)
     (svg …))
  (hero
   ((style) …)
   svg)
  (blurb
   ((p)
    "Use these interactive maps to visualize where you've been "
    ((a href "/maps/usa") "in the USA")
    " and "
    ((a href "/maps/world") "in the world")
    "."))
  ((p) "My mother has a wall map that is covered with push pins marking the many countries she has visited.  Her map inspired me to make two web pages, one for the US and one for the world, that anyone can use to visualize all the places they've visited.")
  …)

… and a separate page for the post itself…

… as well as RSS feeds for the blog and for each label


<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Speechcode.com</title>
    <link>https://speechcode.com/</link>
    <description>Blog posts on Miscellaneous by Arthur A. Gleckler</description>
    <language>en-US</language>
    <webMaster>webmaster@speechcode.com (Arthur A. Gleckler)</webMaster>
    <atom:link href="https://speechcode.com/blog/label/miscellaneous/rss" rel="self" type="application/rss+xml"></atom:link>
    …
    <item>
      <title>Push-pin Maps</title>
      <link>https://speechcode.com/blog/push-pin-maps</link>
      <guid>https://speechcode.com/blog/push-pin-maps</guid>
      <description>
&lt;p&gt;Use these interactive maps to visualize where you've been &lt;a href=&quot;/maps/usa&quot;&gt;in the USA&lt;/a&gt; and &lt;a href=&quot;/maps/world&quot;&gt;in the world&lt;/a&gt;.&lt;/p&gt;&lt;a href=&quot;https://speechcode.com/blog/push-pin-maps&quot;&gt;more&lt;/a&gt;</description>
      <dc:creator>Arthur A. Gleckler</dc:creator>
      <pubDate>Wed, 9 Jan 2019 12:00:00 +0000</pubDate></item></channel></rss>

Thanks.

I haven't yet published this code, but plan to do so eventually. In the meantime, I'm trying to spread the idea of the power of DSLs by giving this talk.

Arthur A. Gleckler <talks@speechcode.com>