# Copyright (C) 2023-2024 Denis 'GNUtoo' Carikli # # This program 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. # # This program 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 this program. If not, see . CURL ?= curl BLOG_URL ?= https://blog.replicant.us/page GUILE_PATCH = 0001-SRFI-19-Add-support-for-ISO-8601-zones-with-a-colon.patch GUIX_COMMIT ?= b25b94335a3ee8d68d2145da8e5ea0325ecea451 GUIX_SHELL ?= guix time-machine --commit=$(GUIX_COMMIT) -- shell -C GUIX_PYTHON_PACKAGES ?= python python-beautifulsoup4 python-html2text python-sh CONVERT ?= $(GUIX_SHELL) $(GUIX_PYTHON_PACKAGES) -- python3 convert.py HAUNT ?= $(GUIX_SHELL) --with-patch=guile=patches/$(GUILE_PATCH) haunt -- haunt VENDOR_REPLICANT_ARTWORK_REV ?= fc213d2ca94cef9047d1e4a71c21c4c4c87f349d VENDOR_REPLICANT_ARTWORK_PATH ?= external/vendor_replicant_artwork SENTINEL = .PHONY: \ all \ build \ deploy \ generate-wordpress-articles \ help \ posts \ serve \ update-makefile \ $(SENTINEL) # Input: wordpress/articles/2015_07_replicant-source-code-hosting-and-rmll-2015.html # Output: https://blog.replicant.us/2015/07/replicant-source-code-hosting-and-rmll-2015/ define get-wordpress-article-url (use-modules (ice-9 regex)) ;; Input: wordpress/articles/2015_07_replicant-source-code-hosting-and-rmll-2015.html ;; Output: 2015_07_replicant-source-code-hosting-and-rmll-2015.html (define (local-filename name) (list-ref (string-split name #\/) 2)) ;; Output: 2015 (define year (car (string-split (local-filename "$@") #\_))) ;; Output: 07 (define month (cadr (string-split (local-filename "$@") #\_))) ;; Output: replicant-source-code-hosting-and-rmll-2015.html (define html-page (regexp-substitute #f (string-match "[0-9]{4}_[0-9]{2}_" "$@") 'post)) ;; Output: replicant-source-code-hosting-and-rmll-2015 (define page-path (regexp-substitute #f (string-match ".html" html-page) 'pre)) (string-append "https://blog.replicant.us/" year "/" month "/" page-path "/") endef WORDPRESS_PAGES = \ wordpress/pages/replicant_blog_page_8.html \ wordpress/pages/replicant_blog_page_7.html \ wordpress/pages/replicant_blog_page_6.html \ wordpress/pages/replicant_blog_page_5.html \ wordpress/pages/replicant_blog_page_4.html \ wordpress/pages/replicant_blog_page_3.html \ wordpress/pages/replicant_blog_page_2.html \ wordpress/pages/replicant_blog_page_1.html \ wordpress/pages/replicant_blog_page_0.html \ $(SENTINEL) all: help wordpress/articles: mkdir -p $@ wordpress/pages: mkdir -p $@ wordpress/pages/replicant_blog_page_%.html: wordpress/pages $(CURL) $(BLOG_URL)/$(subst replicant_blog_page_,,$*)/ -o $@ generate-wordpress-articles: build $(GUIX_SHELL) $(GUIX_PYTHON_PACKAGES) \ -- \ python3 haunthtml2wordpress.py \ ./site/replicant-status-and-report-of-the-37c3-and-fosdem-2024-conferences.html links.txt: $(WORDPRESS_PAGES) @echo -n '' > $@ @for f in $(WORDPRESS_PAGES) ; do \ echo "Processing $$f" > /dev/stderr ; \ guix shell -C python python-beautifulsoup4 -- \ python3 get_links.py $$f | sort -u >> $@ ; \ done # do not depend on links.txt as a human is supposed to review it manually update-makefile: guile build/update-makefile-markdown-articles.scm wordpress/articles/%.html: curl "$(guile $(get-wordpress-article-url))" -o $@ posts/%.md: wordpress/articles/%.html mkdir -p posts $(CONVERT) $^ $@ posts: $(POSTS) $(VENDOR_REPLICANT_ARTWORK_PATH): git clone \ https://git.replicant.us/replicant/vendor_replicant_artwork \ $(VENDOR_REPLICANT_ARTWORK_PATH) static/replicant_banner_white.png: vendor_replicant_artwork_revision.txt install -m 644 \ $(VENDOR_REPLICANT_ARTWORK_PATH)/replicant_banner_white.png \ $@ vendor_replicant_artwork_revision.txt: $(VENDOR_REPLICANT_ARTWORK_PATH) Makefile if [ ! -f $@ ] || [ "`cat $@`" != "$(VENDOR_REPLICANT_ARTWORK_REV)" ] ; \ then \ rm -f $@ ; \ git -C $(VENDOR_REPLICANT_ARTWORK_PATH) fetch origin ; \ git -C $(VENDOR_REPLICANT_ARTWORK_PATH) \ checkout -f $(VENDOR_REPLICANT_ARTWORK_REV) ; \ git -C $(VENDOR_REPLICANT_ARTWORK_PATH) reset --hard ; \ git -C $(VENDOR_REPLICANT_ARTWORK_PATH) clean -dfx ; \ echo $(VENDOR_REPLICANT_ARTWORK_REV) > $@ ; \ fi build: static/replicant_banner_white.png $(HAUNT) build deploy: build rsync -av site/ root@git.replicant.us:/var/www/blog.test.replicant.us/ help: @printf "%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n" \ "Available commands:" \ "make build # Generate the HTML files with haunt." \ "make deploy # Copy the html files to https://blog.test.replicant.us" \ "make links.txt # Create links.txt file with blog post links." \ " # For security reasons This file needs to be manually" \ " # reviewed manually before usage." \ "make posts # create blog posts markdown pages. To be done after reviewing links.txt." \ "make check # Run tests." \ serve: $(HAUNT) serve -w -p $(HAUNT_PORT) website.tar.gz: build tar \ --exclude-vcs \ --format=gnu \ --owner=0 --group=0 --numeric-owner \ --sort=name \ -czf \ website.tar.gz \ site \ pages/img \ index.html \ --transform="s#^site#web#" \ --transform="s#^pages/img/#web/img/#" check: build ./tests.sh