blob: e1ae464a5439bba76d0ef1200e4c46916b68a5e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
define get-wordpress-article-url
;; Copyright (C) 2023-2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
;;
;; 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 <https://www.gnu.org/licenses/>.
;; 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/
(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
|