miniblog

Miniblog: A command-line static blog system in Common Lisp
Log | Files | Refs | README | LICENSE

template.lhtml (4762B)


      1 <!DOCTYPE html>
      2 <html>
      3   <head>
      4     <title>
      5       <%= (or (getf env :title) "Miniblog") %>
      6       <% @if year %>
      7         - <% @var year %>/<% @var month %>
      8       <% @endif %>
      9     </title>
     10     <style>
     11       header#miniblog-header { width: 100%; }
     12       section#miniblog-left { float: left; width: 15%; }
     13       section#miniblog-main { float: left; width: <%= (if (getf env :links) "65%" "80%") %>; }
     14       nav#miniblog-nav { float: left; width: 20%; }
     15       div#miniblog-rss { clear: both; }
     16       table.calendar { padding: 10px; float: left; }
     17       table.calendar td { width: 25%; }
     18       @media screen and (max-aspect-ratio: 1/1) {
     19         section#miniblog-left { float: none; width: 100%; }
     20         section#miniblog-main { float: none; width: 100%; }
     21         nav#miniblog-nav { float: none; width: 100%; }
     22       }
     23     </style>
     24     <% @if stylesheet %>
     25       <link rel="stylesheet" type="text/css" href="<% @var stylesheet %>">
     26     <% @endif %>
     27     <% @if enable-rss %>
     28       <link rel="alternate" type="application/rss+xml"
     29         title="RSS feed for <%= (or (getf env :title) "Miniblog") %>"
     30         href="<% @var root-uri %>rss.xml">
     31     <% @endif %>
     32   </head>
     33   <body>
     34     <header id="miniblog-header">
     35       <% @if header %>
     36         <% @includevar header %>
     37       <% @endif %>
     38     </header>
     39     <section id="miniblog-left">
     40       <% @if links %>
     41         <% @loop links %>
     42           <a href="<% @var link %>"><% @var text %></a><br>
     43         <% @endloop %>
     44       <% @endif %>
     45     </section>
     46     <section id="miniblog-main">
     47       <% @if posts %>
     48         <% (let ((short-date) (render-hr nil)) %>
     49           <% (loop for post in (getf env :posts) do %>
     50             <% (destructuring-bind (&key id created-at last-updated-at title content created-by last-updated-by) post %>
     51               <% (let ((curr-short-date (funcall (getf env :short-date-formatter) created-at))) %>
     52                 <% (if render-hr %>
     53                   <hr>
     54                 <% ) %>
     55                 <% (setf render-hr t) %>
     56                 <% (if (string/= short-date curr-short-date)
     57                      (progn
     58                        (setf short-date curr-short-date)
     59                        (format t "<h1>~A</h1>~%" short-date)))) %>
     60               <a name="<%= id %>"></a>
     61               <h2><%= title %></h2>
     62               <article>
     63                 <%= (funcall (getf env :content-formatter) content) %>
     64               </article>
     65               <p>
     66                 <small>
     67                   Posted by <%= created-by %> on
     68                   <%= (funcall (getf env :long-date-formatter) created-at) %>
     69                   <% (if (local-time:timestamp/= created-at last-updated-at)
     70                        (format t "<br>~%Last updated by ~A on ~A~%"
     71                                last-updated-by
     72                                (funcall (getf env :long-date-formatter) last-updated-at))) %>
     73                 </small>
     74               </p>
     75             <% ) %>
     76           <% ) %>
     77         <% ) %>
     78       <% @else %>
     79         No posts found.
     80       <% @endif %>
     81     </section>
     82     <nav id="miniblog-nav">
     83       <% @if archive-date-list %>
     84         <%
     85           (let ((arc (copy-list (getf env :archive-date-list))))
     86             (loop while arc do
     87               (format t "<table class=\"calendar\"><tr><th colspan=\"4\">~a</th></tr>~%" (caar arc))
     88               (let ((month-entries '())
     89                     (month-names '("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")))
     90                 (loop for cal-month downfrom 12 to 1 do
     91                   (if (and arc (= cal-month (cdar arc)))
     92                     (progn
     93                       (push (format nil "~d/~2,'0d/index.html" (caar arc) (cdar arc)) month-entries)
     94                       (pop arc))
     95                     (push nil month-entries)))
     96                 (loop for row from 0 to 2 do
     97                   (format t "<tr>~%")
     98                   (loop for cal-month from (* row 4) to (+ (* row 4) 3) do
     99                     (format t "<td>")
    100                     (if (nth cal-month month-entries)
    101                       (format t "<a href=\"~a~a\">~a</a>"
    102                                     (or (getf env :root-uri) "")
    103                                     (nth cal-month month-entries)
    104                                     (nth cal-month month-names))
    105                       (format t "~A" (nth cal-month month-names)))
    106                     (format t "</td>~%"))
    107                   (format t "</tr>~%")))
    108                 (format t "</table>~%"))) %>
    109       <% @endif %>
    110       <% @if enable-rss %>
    111         <div id="miniblog-rss">
    112           <a href="<% @var root-uri %>rss.xml" target="_blank">
    113             Subscribe to <%= (or (getf env :title) "Miniblog") %>
    114           </a>
    115         </div>
    116       <% @endif %>
    117     </nav>
    118   </body>
    119 </html>