When starting a new blog, or trying to run on some very old data, there is no
data available on any bogus or legitimate comments. When this happens Tekuti
will try to divide by 0 and divide 0 by other things in a few places, assuming
that there is at least _some_ data about bogus and legitimate comments.
I’m not 100% sure what the expectation is of these calculations, so I might have
chosen the wrong solution, but it seems to me that if there is no data
available, all we know is that there is nothing (0).
This fixes an issue with both trying to comment on a fresh new data set, or a
dataset that hasn’t been touched since 2014.
When setting up Tekuti for the first time the ‘compute-bogus-comments’ will get
the current commit passed in and try to get the parent. Since there is only the
“initial commit” at this stage it will get ‘#f’ as the parent commit and pass it
in to ‘fold-commits’. Trying to parse revision ‘#f’ will surely fail.
The ‘fold-commits’ function already expects that ‘rev’ might be empty, so this
should work out fine.
* tekuti/config.scm (*comments-open-window*): New config, indicating
seconds for which to keep comments open.
* tekuti/page-helpers.scm (post-editing-form): Expose comments closed
date feature.
* tekuti/page.scm (page-new-comment): Oops -- we were missing a
server-side comments-open check!
* tekuti/post.scm (*post-spec*): Serialize comments-closed-timestamp.
(post-comments-open?): Return false if we are after the
comments-closed-timestamp.
(post-comments-closed-timestamp): New accessor.
(munge-post): Write comments-closed-timestamp.
(parse-post-data): Parse comments-closed-timestamp from form data.
* tekuti/page-helpers.scm (html-doctype): Relax to HTML doctype.
(define-tag-set, void-element?, template-element?, raw-text-element?)
(escapable-raw-text-element?, foreign-element?, make-char-quotator)
(attribute-value-empty?, attribute-value-needs-quotes-chars)
(attribute-value-needs-quotes?, print-attribute-value/quoted)
(print-text/quoted, shtml->html): Emit HTML by default. This will
allow documents to contain <script> tags which themselves have &, <,
and so on.
As a side effect of this change, any pending posts in your repository
that are in "draft" status will effectively move into the new "draft"
state, which means they can be reached by their URL. That's not a big
deal though because those URLs are not trivial to guess.
* tekuti/page-helpers.scm (post-editing-form): Add radio button to
choose post status.
* tekuti/post.scm (post-public?, post-draft?, post-private?): New
accessors for post status.
(post-from-key): Add #:allow-draft? keyword argument.
* tekuti/page.scm (page-show-post): Allow direct access to draft posts.
* tekuti/page-helpers.scm (ensure-uri): Rename from ensure-public-uri.
A URI is absolute by definition.
(ensure-uri-reference): New helper. Requires git guile.
(respond): Use ensure-URI-reference to get the reference.
(atom-header, atom-entry): Use ensure-uri.
* tekuti/page.scm (atom-feed-from-posts): Pass the URI scheme from the
request-uri when reconstructing
* tekuti/config.scm (*public-scheme*): New config variable, defaulting
to http.
* tekuti/page.scm (make-post-key): Downcase, to cope with uri-encode
from Guile changing from lower-case hexidecimals to upper-case.
Otherwise older post keys wouldn't work...
* tekuti/git.scm (git-rev-parse): Try to read the ref ourselves, first.
Fall back to using git if that doesn't work (for example, if it's a
packed ref).
Inspired by a patch from Aleix Conchillo Flaqué. Thanks, Aleix!
* tekuti/index.scm (index-specs):
* tekuti/post.scm (reindex-posts, reindex-posts-by-date): Change to have
the "posts" index be a hash table mapping key -> post.
"posts-by-date" is a list of keys, from newest to oldest.
(post-from-git): This is what post-from-key was.
(post-from-key): New function, pulls out a post from the posts hash
table.
(munge-post): Use post-from-git.
(delete-post): Take the post directly.
(latest-posts): New awesome helper for fetching the lastest N posts
that match some predicates.
* tekuti/page-helpers.scm (find-posts-matching): Adapt to post-from-key
change.
(published-posts): Remove, replaced with latest-posts.
* tekuti/page.scm (page-admin, page-admin-posts, page-admin-post)
(page-archives, page-feed-atom): Use the new latest-posts helper.
(page-admin-delete-post, page-admin-delete-comment, page-show-post)
(page-new-comment, page-show-tag): Adapt to post-from-key change.
* tekuti/tags.scm (compute-related-posts, compute-related-tags): Adapt
to post-from-key change.
(reindex-tags): Use latest-posts.
* tekuti/page.scm (page-feed-atom): Reimplement Brian's thing with
"with" and "without" query args, to allow for multiple tags to be
included or excluded.
* tekuti/request.scm (request-query-ref-all): New helper.
* tekuti/util.scm (with-output-to-string*, with-input-from-string*): New
hacky helpers, which close the port before returning the string or
result. Hopefully reduce pressure on the GC.
(shell:quote):
* tekuti/git.scm (git-commit-reverse-operations, with-output-to-blob*)
(with-input-from-blob*):
* tekuti/filters.scm (wordpress->sxml): Use the string* procedures.