Fix the issue with changing the working directory on rss generator

This commit is contained in:
Sameer Rahmani 2023-01-26 20:44:49 +00:00
parent 640ed5b8e4
commit fa32c4d416
6 changed files with 35 additions and 22 deletions

View File

@ -92,6 +92,7 @@ The build system will consum these details for various purposes."
(defmacro command-> (command-var args-var &rest body)
(declare (indent defun))
`(defun main ()
"The entry point to the build script."

View File

@ -65,7 +65,7 @@
(defun fg42/build-prepare-docs (build-dir host)
"Prepare the documents and the website in the given BUILD-DIR."
"Prepare the documents and the website in the given BUILD-DIR and HOST."
;; Build the org files for each cube
(message "Processing the docs for all the cubes")

View File

@ -121,7 +121,7 @@ call `org-html-render-tag-template' otherwise will call ORIG-FN."
("base-url" (plist-get info :base-url))
("preamble" (org-html--build-pre/postamble 'preamble info))
("title" (get-file-global-props (plist-get info :input-file) "TITLE"))
("version" (fg42/version))
("version" (fg42/project-version))
("description" (or (get-file-global-props (plist-get info :input-file) "DESC")
""))
("postamble" (org-html--build-pre/postamble 'postamble info)))))

View File

@ -29,7 +29,7 @@
(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"
"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
@ -66,7 +66,7 @@
(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"
"Create a RSS xml file via POSTS for the give BASE-URL and save to DEST."
(with-temp-file dest
(insert
(format
@ -86,8 +86,9 @@
(mapconcat
(lambda (post)
(fg42/rss-create-item post base-url))
posts)))))
posts
"")))))
(provide 'fg42/build/rss)
;;; docs.el ends here
;;; rss.el ends here

View File

@ -59,17 +59,21 @@
(insert-file-contents file)
(get-buffer-global-props prop)))
(defmacro with-cwd (path &rest body)
"Run the BODY with PATH as the current working dir."
`(let ((cwd (getenv "PWD"))
(default-directory ,path))
(cd default-directory)
(prog1
,@body
(cd cwd))))
(defun fg42/exctract-keywords (file keys)
"Create a RSS item from the given org FILE"
(let ((cwd (getenv "PWD"))
(old-org-directory org-directory))
(cd fg42/build-project-root)
(prog1
(with-temp-buffer
(insert-file-contents file)
(org-collect-keywords keys))
(cd cwd))))
"Create a RSS item from the given org FILE for the give KEYS."
(with-cwd (file-name-directory file)
(with-temp-buffer
(insert-file-contents file)
(org-collect-keywords keys))))
(defun pair-file-with-date (file)
@ -87,15 +91,20 @@
(defun fg42/git-branch ()
(cd fg42/build-project-root)
(shell-command-to-string "git branch --show-current"))
"Return the branch name of the project."
(let ((default-directory fg42/build-project-root))
(shell-command-to-string "git branch --show-current")))
(defun fg42/project-version ()
"Return the current version of the project."
(let ((default-directory fg42/build-project-root))
(shell-command-to-string (format "git describe %s" (fg42/git-branch)))))
(defun fg42/version ()
"Returns the current version of FG42."
(cd fg42/build-project-root)
(shell-command-to-string (format "git describe %s" (fg42/git-branch))))
"Return the current version of the project."
(let ((default-directory (getenv "FG42_HOME")))
(shell-command-to-string (format "git describe %s" (fg42/git-branch)))))
(provide 'fg42/build/utils)
;;; utils.el ends here

View File

@ -705,7 +705,8 @@ Never evaluate the arguments of a macro manually. E.g. with =eval=
More info: https://www.gnu.org/software/emacs/manual/html_node/elisp/Eval-During-Expansion.html
** What's next?
* Episode 12 - Features & Load Paths
* DONE Episode 12 - Features & Load Paths
CLOSED: [2023-01-14 Sat 11:44]
** Emacs Lisp files
Write elisp code in files with =.el= suffix.
@ -777,3 +778,4 @@ We can clone a library somewhere on the disk and add the path to it to the =load
and load the library files.
But that would be tedious to do so for all the libraries. That's why we use a package manager
* Episode 13 - Hooks