diff options
| author | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2024-04-11 00:23:43 +0200 |
|---|---|---|
| committer | Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> | 2025-06-15 01:30:29 +0200 |
| commit | 1210904b52a02cdec4153bd744a6b14cd032e4b0 (patch) | |
| tree | 75cb0078f8d71385c5542140c7ad5760ab8c6580 /website/builders/replicant-blog-search.scm | |
| parent | 6be1837a59920ca0ba94f2454c597d64218dfb4e (diff) | |
| download | haunt-blog-1210904b52a02cdec4153bd744a6b14cd032e4b0.tar.gz haunt-blog-1210904b52a02cdec4153bd744a6b14cd032e4b0.tar.bz2 haunt-blog-1210904b52a02cdec4153bd744a6b14cd032e4b0.zip | |
Add search page with instruction on how to search.
While the search could be implemented with things like Xapian which is
available in most GNU/Linux distributions, not only this could be a
lot of work, but it also makes the site not static anymore, which
increase the attack surface of the server that runs the search.
And finally it teach users the bad practice of relying on SAASS
(service as a software substitute) or equivalent instead of doing the
work themselves on their computers with the tools they want.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'website/builders/replicant-blog-search.scm')
| -rw-r--r-- | website/builders/replicant-blog-search.scm | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/website/builders/replicant-blog-search.scm b/website/builders/replicant-blog-search.scm new file mode 100644 index 0000000..d19607a --- /dev/null +++ b/website/builders/replicant-blog-search.scm @@ -0,0 +1,92 @@ +;;; Copyright © 2015 David Thompson <davet@gnu.org> +;;; Copyright © 2016 Christopher Allan Webber <cwebber@dustycloud.org> +;;; Copyright © 2023-2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +;;; +;;; This file is based on haunt/builder/blog.scm, +;;; haunt/reader/commonmark.scm and tests/post.scm and from Haunt +;;; 2.6.0. +;;; +;;; This file is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published +;;; by the Free Software Foundation; either version 3 of the License, +;;; or (at your option) any later version. +;;; +;;; Haunt 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 +;;; General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with Haunt. If not, see <http://www.gnu.org/licenses/>. + +(define-module (website builders replicant-blog-search) + #:use-module (commonmark) + #:use-module (haunt artifact) + #:use-module (haunt builder assets) + #:use-module (haunt html) + #:use-module (haunt post) + #:use-module (haunt site) + #:use-module (haunt utils) + #:use-module (ice-9 match) + #:use-module (ice-9 rdelim) + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-19) + #:use-module (website builders replicant-blog) + #:export (replicant-blog-search-page)) + +(fluid-set! %default-port-encoding "UTF-8") + +(define (guix-package name) + `(a + (@ (href ,(string-append "https://packages.guix.gnu.org/packages/" name))) + ,name)) + +(define (replicant-default-collection-template site title posts prefix) + (define (post-uri post) + (string-append (or prefix "") "/" + (site-post-slug site post) ".html")) + + `((h1 (@ (id "title")) "Search") + + (p "This blog has no built-in search functionality. Instead users are +supposed to download the full blog source code and search inside +it. This way they are fully in control of the search and in most cases +it should not leak the search to a third party.") + + (p "Here is an example that works under a terminal in GNU/Linux with git installed:") + (p (@ (class "command")) "git clone https://git.replicant.us/contrib/GNUtoo/infrastructure/haunt-blog") + (p "And then you can search in it. For instance if you want to search for +FOSDEM in the blog articles, you can use the following commands:") + (p (@ (class "command")) "cd haunt-blog") + (p (@ (class "command")) "git grep -i fosdem -- markdown") + + (p (string-append + "It is also possible to download the source code with graphical " + "software such as " + ,(guix-package "gitg") + " and then search inside the files with file managers such as " + ,(guix-package "nautilus") + ". " + "If you want to search inside the files, be sure to select the " + "\"Full text\" search as by default these file managers usually only " + "search the file names only.")))) + +(define* (replicant-blog-search-page #:key (theme replicant-theme) prefix + (collections + `(("" "search.html" ,posts/reverse-chronological)))) + "Return a procedure that transforms a list of posts into pages +decorated by THEME, whose URLs start with PREFIX." + (define (make-file-name base-name) + (if prefix + (string-append prefix "/" base-name) + base-name)) + + (lambda (site posts) + (define collection->page + (match-lambda + ((title file-name filter) + (serialized-artifact (make-file-name file-name) + (render-collection theme site title (filter posts) prefix) + sxml->html)))) + + (append (map collection->page collections)))) |
