Skip to content

Commit

Permalink
Refactor: HUGO_EXPORT_DIR -> HUGO_BASE_DIR
Browse files Browse the repository at this point in the history
Found the earlier name confusing as the value actually represents the
base directory for the Hugo site development. The posts are actually
exported to a content/ subdir under that.
  • Loading branch information
kaushalmodi committed Jul 6, 2017
1 parent 3e58ef9 commit 7e5248f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/ox-hugo-manual.org
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Markdown]] flavor.
[[http://gohugo.io/content/sections/][here]] for more information on Hugo sections. It is
common for this property to be set to =posts= or
=blog=.
- HUGO_EXPORT_DIR :: Root directory of the source for the Hugo site.
- HUGO_BASE_DIR :: Root directory of the source for the Hugo site.
If this is set to =~/hugo/=, the exported Markdown files will be
saved to =~/hugo/content/<HUGO_SECTION>/= directory. By [[http://gohugo.io/content/organization/][default]],
the Markdown files reside in a hierarchy under the =content/=
Expand Down
14 changes: 7 additions & 7 deletions ox-hugo.el
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ directory where all Hugo posts should go by default."
(:hugo-url "HUGO_URL" nil nil)
;; Non-front-matter options
(:hugo-section "HUGO_SECTION" nil org-hugo-default-section-directory)
(:hugo-export-dir "HUGO_EXPORT_DIR" nil nil)
(:hugo-base-dir "HUGO_BASE_DIR" nil nil)
(:hugo-static-images "HUGO_STATIC_IMAGES" nil "images")))


Expand Down Expand Up @@ -222,13 +222,13 @@ PATH is the path to the image or pdf attachment.
INFO is a plist used as a communication channel."
(message "[ox-hugo DBG] The Hugo sectioimage dir is: %s" (plist-get info :hugo-static-images) )
(message "[ox-hugo DBG] The Hugo section is: %s" (plist-get info :hugo-section) )
(message "[ox-hugo DBG] The Hugo export dir is: %s" (plist-get info :hugo-export-dir) )
(message "[ox-hugo DBG] The Hugo base dir is: %s" (plist-get info :hugo-base-dir) )

(let* ((full-path (file-truename path))
(exportables '("jpg" "jpeg" "tiff" "png" "pdf" "odt" ))
(file-name (file-name-nondirectory path))
(image-export-dir (concat
(file-name-as-directory (plist-get info :hugo-export-dir))
(file-name-as-directory (plist-get info :hugo-base-dir))
"static/"
(file-name-as-directory (plist-get info :hugo-static-images))
))
Expand Down Expand Up @@ -413,14 +413,14 @@ Return output file's name."
'hugo subtreep visible-only)
(org-export--get-buffer-attributes)
(org-export-get-environment 'hugo subtreep)))
(export-dir-path (if (null (plist-get info :hugo-export-dir))
(user-error "It is mandatory to set the HUGO_EXPORT_DIR property")
(file-name-as-directory (plist-get info :hugo-export-dir))))
(base-dir (if (null (plist-get info :hugo-base-dir))
(user-error "It is mandatory to set the HUGO_BASE_DIR property")
(file-name-as-directory (plist-get info :hugo-base-dir))))
(content-dir "content/")
(section-dir (if (null (plist-get info :hugo-section))
(user-error "It is mandatory to set the HUGO_SECTION property")
(file-name-as-directory (plist-get info :hugo-section))))
(pub-dir (let ((dir (concat export-dir-path content-dir section-dir)))
(pub-dir (let ((dir (concat base-dir content-dir section-dir)))
(make-directory dir :parents) ;Create the directory if it does not exist
dir))
(outfile (org-export-output-file-name ".md" subtreep pub-dir)))
Expand Down
2 changes: 1 addition & 1 deletion tests/org/prop-drawer-parsing/prop-drawer-parsing.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#+TITLE: My Blog
#+HUGO_EXPORT_DIR: ../../md/
#+HUGO_BASE_DIR: ../../md/
#+HUGO_SECTION: posts

# 1. Load `ox-hugo'
Expand Down
2 changes: 1 addition & 1 deletion tests/org/small1/small1.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#+TITLE: My Blog
#+HUGO_EXPORT_DIR: ../../md/
#+HUGO_BASE_DIR: ../../md/
#+HUGO_SECTION: posts

# 1. Load `ox-hugo'
Expand Down
2 changes: 1 addition & 1 deletion tests/org/tags-and-keywords/tags-and-keywords.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#+TITLE: My Blog
#+HUGO_EXPORT_DIR: ../../md/
#+HUGO_BASE_DIR: ../../md/
#+KEYWORDS: alpha beta

# 1. Load `ox-hugo'
Expand Down

1 comment on commit 7e5248f

@kaushalmodi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@titaniumbones Please note this backward-incompatible change.

Please sign in to comment.