Relative URLs done right.
This commit is contained in:
parent
3c0b0a05c1
commit
492a36e781
3 changed files with 14 additions and 12 deletions
|
@ -13,14 +13,12 @@
|
|||
(defun taglinks (&optional tags)
|
||||
"Generate links to all the tag indices or those in TAGS."
|
||||
(loop for tag in (or tags (sort (all-tags) #'string<))
|
||||
collect (list :url (format nil "~a/tag/~a.html" (domain *config*) tag)
|
||||
:name tag)))
|
||||
collect (list :url (format nil "tag/~a.html" tag) :name tag)))
|
||||
|
||||
(defun monthlinks ()
|
||||
"Generate links to all the month indices."
|
||||
(loop for month in (sort (all-months) #'string<)
|
||||
collect (list :url (format nil "~a/date/~a.html" (domain *config*) month)
|
||||
:name month)))
|
||||
collect (list :url (format nil "date/~a.html" month) :name month)))
|
||||
|
||||
(defun get-month (timestamp)
|
||||
"Extract the YYYY-MM portion of TIMESTAMP."
|
||||
|
@ -30,11 +28,13 @@
|
|||
"Sort POSTS in reverse chronological order."
|
||||
(sort posts #'string> :key #'post-date))
|
||||
|
||||
(defun write-index (posts filename title &optional prev next)
|
||||
(defun write-index (posts filename title &key prev next (relative t))
|
||||
"Write out the HTML for POSTS to FILENAME.html."
|
||||
(let ((content (loop for post in posts
|
||||
collect (list :url (format nil "~a/posts/~a"
|
||||
(domain *config*) (post-url post))
|
||||
collect (list :url (if relative
|
||||
(format nil "../posts/~a" (post-url post))
|
||||
(format nil "~a/posts/~a"
|
||||
(domain *config*) (post-url post)))
|
||||
:title (post-title post)
|
||||
:date (post-date post)
|
||||
:content (render-content (post-content post)
|
||||
|
@ -43,6 +43,7 @@
|
|||
(funcall (theme-fn "INDEX")
|
||||
(list :taglinks (taglinks)
|
||||
:monthlinks (monthlinks)
|
||||
:siteroot (domain *config*)
|
||||
:title title
|
||||
:posts content
|
||||
:prev (and prev (format nil "~d.html" prev))
|
||||
|
@ -56,8 +57,9 @@
|
|||
(let ((posts (by-date (hash-table-values *posts*))))
|
||||
(loop for i = 1 then (1+ i)
|
||||
do (write-index (by-20 posts i) (format nil "~d.html" i) "Recent Posts"
|
||||
(and (plusp (1- i)) (1- i))
|
||||
(and (< (* i 20) (length posts)) (1+ i)))
|
||||
:prev (and (plusp (1- i)) (1- i))
|
||||
:next (and (< (* i 20) (length posts)) (1+ i))
|
||||
:relative nil)
|
||||
until (> (* i 20) (length posts))))))
|
||||
|
||||
(defun render-by-tag ()
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div id="tagsoup">
|
||||
<p>This blog covers
|
||||
{foreach $taglink in $taglinks}
|
||||
<a href="{$taglink.url |noAutoescape}">{$taglink.name}</a>
|
||||
<a href="{$siteroot}/{$taglink.url |noAutoescape}">{$taglink.name}</a>
|
||||
{if not isLast($taglink)}, {/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<div id="monthsoup">
|
||||
<p>View posts from
|
||||
{foreach $monthlink in $monthlinks}
|
||||
<a href="{$monthlink.url |noAutoescape}">{$monthlink.name}</a>
|
||||
<a href="{$siteroot}/{$monthlink.url |noAutoescape}">{$monthlink.name}</a>
|
||||
{if not isLast($monthlink)}, {/if}
|
||||
{/foreach}
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<h1 class="title">{$title}</h1>{\n}
|
||||
<div class="tags">{\n}
|
||||
Tagged as {foreach $tag in $tags}
|
||||
<a href="{$tag.url |noAutoescape}">{$tag.name}</a>
|
||||
<a href="../{$tag.url |noAutoescape}">{$tag.name}</a>
|
||||
{if not isLast($tag)}, {/if}
|
||||
{/foreach}
|
||||
</div>{\n}
|
||||
|
|
Loading…
Add table
Reference in a new issue