aboutsummaryrefslogtreecommitdiffstats
path: root/website
diff options
context:
space:
mode:
Diffstat (limited to 'website')
-rw-r--r--website/builders/replicant-blog-search.scm92
-rw-r--r--website/builders/replicant-blog.scm16
2 files changed, 106 insertions, 2 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))))
diff --git a/website/builders/replicant-blog.scm b/website/builders/replicant-blog.scm
index 918bc5b..fb62de4 100644
--- a/website/builders/replicant-blog.scm
+++ b/website/builders/replicant-blog.scm
@@ -31,7 +31,17 @@
#:use-module (ice-9 rdelim)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-19)
- #:export (replicant-blog-website))
+ #:export (theme-collection-template)
+ #:export (make-theme)
+ #:export (render-collection)
+ #:export (replicant-blog-website)
+ #:export (replicant-layout)
+ #:export (replicant-theme)
+ #:export (theme)
+ #:export (theme-layout)
+ #:export (theme-name)
+ #:export (theme-post-template)
+ #:export (theme?))
(fluid-set! %default-port-encoding "UTF-8")
@@ -68,7 +78,9 @@
(li (a (@ (href "https://redmine.replicant.us/projects/replicant/issues"))
"Tracker"))
(li (a (@ (href "https://redmine.replicant.us/projects/replicant/boards"))
- "Forums")))))
+ "Forums"))
+ (li (a (@ (href "https://test.blog.replicant.us/search.html"))
+ "Blog: Search")))))
,body)))
(define (replicant-default-post-template post)