5 changed files with 160 additions and 48 deletions
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
;;; Buid --- The builder for FG42 -*- lexical-binding: t; -*- |
||||
;; |
||||
;; Copyright (c) 2010-2022 Sameer Rahmani & Contributors |
||||
;; |
||||
;; Author: Sameer Rahmani <lxsameer@gnu.org> |
||||
;; URL: https://gitlab.com/FG42/FG42 |
||||
;; Version: 3.0.0 |
||||
;; |
||||
;; 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 thnis program. If not, see <http://www.gnu.org/licenses/>. |
||||
;; |
||||
;;; Commentary: |
||||
;; Cubes are the building blocks of any `FG42' editor. Each `cube' is a |
||||
;; unit which defines different abilities in a deterministic and idempotent |
||||
;; way. Cubes are composable and a composition of cubes creates an editor. |
||||
;; |
||||
;;; Code: |
||||
(require 'seq) |
||||
(require 'fg42/build/core) |
||||
|
||||
(defun fg42/rss-map-items (file-and-props link) |
||||
"Create a RSS item from the given org FILE with the give http LINK" |
||||
(let* ((file (car file-and-props)) |
||||
(values (cadr file-and-props))) |
||||
(format |
||||
(concat |
||||
" <item>\n" |
||||
" <title>%s</title>\n" |
||||
" <link>%s</link>\n" |
||||
" <author>%s</author>\n" |
||||
" <guid isPermaLink=\"false\">%s</guid>\n" |
||||
" <pubDate>%s</pubDate>\n" |
||||
" <description><![CDATA[%s]]></description>\n" |
||||
" </item>\n") |
||||
(cadr (assoc "TITLE" values)) |
||||
link |
||||
(or |
||||
(cadr (assoc "AUTHOR" values)) |
||||
fg42/build-author-name) |
||||
link |
||||
(or |
||||
(cadr (assoc "DATE" values)) |
||||
(error "'DATE' is missing from '%s'" file)) |
||||
(or |
||||
(cadr (assoc "DESC" values)) |
||||
(error "'DESC' is missing from '%s'" file))))) |
||||
|
||||
|
||||
(defun fg42/rss-create-item (post base-url) |
||||
(fg42/rss-map-items |
||||
(car (last post)) |
||||
(format "%s%s/%s" |
||||
base-url |
||||
fg42/build-docs-pages-dir |
||||
;; Path |
||||
(nth 2 post)))) |
||||
|
||||
(defun fg42/rss-create (posts base-url dest) |
||||
"Create a RSS xml file via POSTS for the give BASE-URL and save to DEST" |
||||
(with-temp-file dest |
||||
(insert |
||||
(format |
||||
(concat |
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" |
||||
"<rss version=\"2.0\">\n" |
||||
"<channel>\n" |
||||
" <title>%s</title>\n" |
||||
" <link>%s</link>\n" |
||||
" <description>%s</description>\n" |
||||
"%s\n" |
||||
"</channel>\n" |
||||
"</rss>\n") |
||||
fg42/build-docs-title |
||||
base-url |
||||
fg42/build-docs-desc |
||||
(mapconcat |
||||
(lambda (post) |
||||
(fg42/rss-create-item post base-url)) |
||||
posts))))) |
||||
|
||||
|
||||
(provide 'fg42/build/rss) |
||||
;;; docs.el ends here |
Loading…
Reference in new issue