* [Feature Request] Let publishing-function decide :output-file and whether publishing is needed
@ 2015-07-25 8:38 Ruben Maher
2015-07-28 13:21 ` Rasmus
2015-08-02 16:24 ` Nicolas Goaziou
0 siblings, 2 replies; 5+ messages in thread
From: Ruben Maher @ 2015-07-25 8:38 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1978 bytes --]
Hi list,
I've been working on a derived exporter to publish a static blog, and
I've run into some issues. Say that `:publishing-directory' is
"~/public_html" and I have `:base-directory' with an Org file foo.org.
foo.org has option keywords like this:
#+title: foo.org
#+date: <2015-07-25 Sat 17:21:41>
My derived exporter visits each Org file to get information from the
keywords, and would export foo.org like so: foo.org ->
~/public_html/2015/07/25/foo/index.html, using something like
#+begin_src elisp
(let ((pub-dir
(file-name-as-directory
(concat (expand-file-name pub-dir)
(format-time-string "%Y/%m/%d/" date)
(file-name-base filename)))))
(org-publish-org-to
'rkm-html filename
(concat "." (or (plist-get plist :html-extension)
org-html-extension "html"))
(org-combine-plists plist '(:output-file "index")) pub-dir))
#+end_src
I have achieved this using the attached diff, which tells
`org-export-output-file-name' to respect the property `:output-file' in
the communications channel.
This works pretty well, except that now `org-publish-needed-p' will
always return t when called by `org-publish-file' in ox-publish.el.
As far as I can tell this would be less trivial to change. The call to
org-publish-needed-p would have to move from here (in
`org-publish-file'):
#+begin_src elisp
;; Allow chain of publishing functions.
(dolist (f publishing-function)
(when (org-publish-needed-p filename pub-dir f tmp-pub-dir base-dir)
(let ((output (funcall f project-plist filename tmp-pub-dir)))
(org-publish-update-timestamp filename pub-dir f base-dir)
(run-hook-with-args 'org-publish-after-publishing-hook
filename
output))))
#+end_src
...to the actual publishing function.
I believe a change like this would go a ways to making publishing
backends more extensible for Org users.
Please tell me your thoughts.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-export-output-file-name-respect-output-file.patch --]
[-- Type: text/x-diff, Size: 2723 bytes --]
From 13c92b87b728da134a73ef173be8957453ef90a6 Mon Sep 17 00:00:00 2001
From: Ruben Maher <r@rkm.id.au>
Date: Sat, 25 Jul 2015 16:54:28 +0930
Subject: [PATCH] org-export-output-file-name: respect :output-file
There is a property :output-file defined in the communications channel
but it is ignored by `org-export-output-file-name'.
* lisp/ox.el (org-export-output-file-name): Add optional argument
EXT-PLIST, and try to get `base-name' from its property `:output-file'
if SUBTREEP is nil or there was no EXPORT_FILE_NAME at point.
* lisp/ox-publish.el (org-publish-org-to): Provide PLIST when calling
`org-export-output-file-name'.
---
---
lisp/ox-publish.el | 2 +-
lisp/ox.el | 10 +++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el
index 951f0fe..25086cd 100644
--- a/lisp/ox-publish.el
+++ b/lisp/ox-publish.el
@@ -579,7 +579,7 @@ Return output file name."
(work-buffer (or visitingp (find-file-noselect filename))))
(prog1 (with-current-buffer work-buffer
(let ((output-file
- (org-export-output-file-name extension nil pub-dir))
+ (org-export-output-file-name extension nil pub-dir plist))
(body-p (plist-get plist :body-only)))
(org-export-to-file backend output-file
nil nil nil body-p
diff --git a/lisp/ox.el b/lisp/ox.el
index b06211b..110094b 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -5892,7 +5892,8 @@ or FILE."
(or (and (functionp post-process) (funcall post-process file))
file))))))
-(defun org-export-output-file-name (extension &optional subtreep pub-dir)
+(defun org-export-output-file-name
+ (extension &optional subtreep pub-dir ext-plist)
"Return output file's name according to buffer specifications.
EXTENSION is a string representing the output file extension,
@@ -5905,6 +5906,9 @@ of subtree at point.
When optional argument PUB-DIR is set, use it as the publishing
directory.
+With optional argument SUBTREEP nil and EXT-PLIST non-nil, try to get
+the value of `:output-file' from EXT-PLIST.
+
Return file name as a string."
(let* ((visited-file (buffer-file-name (buffer-base-buffer)))
(base-name
@@ -5917,6 +5921,10 @@ Return file name as a string."
(save-excursion
(ignore-errors (org-back-to-heading) (point)))
"EXPORT_FILE_NAME" t))
+ ;; SUBTREEP is nil or there was no EXPORT_FILE_NAME at
+ ;; point. Try to get the file name from EXT-PLIST if
+ ;; it is there.
+ (plist-get ext-plist :output-file)
;; File name may be extracted from buffer's associated
;; file, if any.
(and visited-file (file-name-nondirectory visited-file))
--
2.4.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Feature Request] Let publishing-function decide :output-file and whether publishing is needed
2015-07-25 8:38 [Feature Request] Let publishing-function decide :output-file and whether publishing is needed Ruben Maher
@ 2015-07-28 13:21 ` Rasmus
2015-08-22 1:29 ` Ruben Maher
2015-08-02 16:24 ` Nicolas Goaziou
1 sibling, 1 reply; 5+ messages in thread
From: Rasmus @ 2015-07-28 13:21 UTC (permalink / raw)
To: emacs-orgmode
Hi Ruben,
Thanks for your patch.
Ruben Maher <r@rkm.id.au> writes:
> I've been working on a derived exporter to publish a static blog, and
> I've run into some issues. Say that `:publishing-directory' is
> "~/public_html" and I have `:base-directory' with an Org file foo.org.
>
> foo.org has option keywords like this:
>
> #+title: foo.org
> #+date: <2015-07-25 Sat 17:21:41>
OK. That's nice.
> I have achieved this using the attached diff, which tells
> `org-export-output-file-name' to respect the property `:output-file' in
> the communications channel.
OK. I did not test your patch, but can you please test and indicate
whether the following features work as expected with your patch:
- automatic sitemap.
- linking org files (foo.org links to bar.org).
- async export (since you change org-export-output-file-name)
Some quick thoughts. Perhaps it would be better to allow either a
user-supplied function that takes an org parse tree or an org file
location and returns an output name. Alternatively, maybe you could
provide a way to format file names in :publish-direction via a
format-string (e.g. keywords, date etc).
> From 13c92b87b728da134a73ef173be8957453ef90a6 Mon Sep 17 00:00:00 2001
> From: Ruben Maher <r@rkm.id.au>
> Date: Sat, 25 Jul 2015 16:54:28 +0930
> Subject: [PATCH] org-export-output-file-name: respect :output-file
>
> There is a property :output-file defined in the communications channel
> but it is ignored by `org-export-output-file-name'.
>
> * lisp/ox.el (org-export-output-file-name): Add optional argument
> EXT-PLIST, and try to get `base-name' from its property `:output-file'
> if SUBTREEP is nil or there was no EXPORT_FILE_NAME at point.
Nicolas would have to say whether this is OK. I don't know the details
here well enough.
Rasmus
--
May the Force be with you
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Feature Request] Let publishing-function decide :output-file and whether publishing is needed
2015-07-25 8:38 [Feature Request] Let publishing-function decide :output-file and whether publishing is needed Ruben Maher
2015-07-28 13:21 ` Rasmus
@ 2015-08-02 16:24 ` Nicolas Goaziou
2015-08-22 1:32 ` Ruben Maher
1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2015-08-02 16:24 UTC (permalink / raw)
To: Ruben Maher; +Cc: emacs-orgmode
Hello,
Ruben Maher <r@rkm.id.au> writes:
> I've been working on a derived exporter to publish a static blog, and
> I've run into some issues. Say that `:publishing-directory' is
> "~/public_html" and I have `:base-directory' with an Org file foo.org.
>
> foo.org has option keywords like this:
>
> #+title: foo.org
> #+date: <2015-07-25 Sat 17:21:41>
>
>
> My derived exporter visits each Org file to get information from the
> keywords, and would export foo.org like so: foo.org ->
> ~/public_html/2015/07/25/foo/index.html, using something like
>
>
> #+begin_src elisp
> (let ((pub-dir
> (file-name-as-directory
> (concat (expand-file-name pub-dir)
> (format-time-string "%Y/%m/%d/" date)
> (file-name-base filename)))))
> (org-publish-org-to
> 'rkm-html filename
> (concat "." (or (plist-get plist :html-extension)
> org-html-extension "html"))
> (org-combine-plists plist '(:output-file "index")) pub-dir))
> #+end_src
Can't you simply use org-publish-after-publishing-hook to copy the
published file elsewhere?
Or, if you write your own exporter, do it à la "ox-latex.el", i.e.,
publish in :base-directory and move it elsewhere with
`org-publish-attachment'?
>
> I have achieved this using the attached diff, which tells
> `org-export-output-file-name' to respect the property `:output-file' in
> the communications channel.
This doesn't sound right: if you know the file name beforehand, you
don't need to call `org-export-output-file-name' in the first place.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Feature Request] Let publishing-function decide :output-file and whether publishing is needed
2015-07-28 13:21 ` Rasmus
@ 2015-08-22 1:29 ` Ruben Maher
0 siblings, 0 replies; 5+ messages in thread
From: Ruben Maher @ 2015-08-22 1:29 UTC (permalink / raw)
To: emacs-orgmode
Rasmus <rasmus@gmx.us> writes:
> OK. I did not test your patch, but can you please test and indicate
> whether the following features work as expected with your patch:
>
> - automatic sitemap.
> - linking org files (foo.org links to bar.org).
> - async export (since you change org-export-output-file-name)
>
> Some quick thoughts. Perhaps it would be better to allow either a
> user-supplied function that takes an org parse tree or an org file
> location and returns an output name. Alternatively, maybe you could
> provide a way to format file names in :publish-direction via a
> format-string (e.g. keywords, date etc).
Thanks for your feedback! Regrettably I no longer have time to work on this right now (just started another semester at university) but I will investigate this option when I get back to it in the future.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Feature Request] Let publishing-function decide :output-file and whether publishing is needed
2015-08-02 16:24 ` Nicolas Goaziou
@ 2015-08-22 1:32 ` Ruben Maher
0 siblings, 0 replies; 5+ messages in thread
From: Ruben Maher @ 2015-08-22 1:32 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Can't you simply use org-publish-after-publishing-hook to copy the
> published file elsewhere?
>
> Or, if you write your own exporter, do it à la "ox-latex.el", i.e.,
> publish in :base-directory and move it elsewhere with
> `org-publish-attachment'?
>
>>
>> I have achieved this using the attached diff, which tells
>> `org-export-output-file-name' to respect the property `:output-file'
>> in the communications channel.
>
> This doesn't sound right: if you know the file name beforehand, you
> don't need to call `org-export-output-file-name' in the first place.
Thanks for taking the time to make suggestions! Unfortunately I have no longer have time to work on this at the moment (university), but as soon as I can get back to it I will investigate this option.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-08-22 1:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-25 8:38 [Feature Request] Let publishing-function decide :output-file and whether publishing is needed Ruben Maher
2015-07-28 13:21 ` Rasmus
2015-08-22 1:29 ` Ruben Maher
2015-08-02 16:24 ` Nicolas Goaziou
2015-08-22 1:32 ` Ruben Maher
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.