* Org Publish HTML and PDF With GPG Files @ 2022-08-24 0:08 lehi 2022-08-27 3:15 ` Tim Cross 0 siblings, 1 reply; 14+ messages in thread From: lehi @ 2022-08-24 0:08 UTC (permalink / raw) To: emacs-orgmode@gnu.org [-- Attachment #1: Type: text/plain, Size: 839 bytes --] Good Afternoon, I have my org directory filled with encrypted files ending in ".org.gpg". The publish documentation says that org-mode will automatically replace references to ".org" files with ".html", but this is not an automatic action if the files are ".org.gpg". The resulting HTML files must then be edited (in batch with a call to sed) for the page links to work like expected. This happens when exporting to PDF as well. I have been looking over the org-mode documentation and I have found no real answer to this problem other than looking at the publishing source code and modifying it to additionally catch ".org.gpg" files. Is there some customization setting within Emacs that I could edit that would allow for this to work the way I expect? Or would this require changing the way the publishing works? v/r, MR. Lehi Toskin [-- Attachment #2: Type: text/html, Size: 1723 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-08-24 0:08 Org Publish HTML and PDF With GPG Files lehi @ 2022-08-27 3:15 ` Tim Cross 2022-09-01 7:03 ` Ihor Radchenko 0 siblings, 1 reply; 14+ messages in thread From: Tim Cross @ 2022-08-27 3:15 UTC (permalink / raw) To: lehi; +Cc: emacs-orgmode lehi@tosk.in writes: > Good Afternoon, > > I have my org directory filled with encrypted files ending in ".org.gpg". The publish documentation says that org-mode will > automatically replace references to ".org" files with ".html", but this is not an automatic action if the files are ".org.gpg". The > resulting HTML files must then be edited (in batch with a call to sed) for the page links to work like expected. This happens > when exporting to PDF as well. I have been looking over the org-mode documentation and I have found no real answer to > this problem other than looking at the publishing source code and modifying it to additionally catch ".org.gpg" files. > > Is there some customization setting within Emacs that I could edit that would allow for this to work the way I expect? Or > would this require changing the way the publishing works? > I was hoping someone who was more informed than me would respond here. I don't think there is an 'out of the box' solution for this issue. Part of the problem is likely because the handling of the gpg decryption is an Emacs function done outside of org mode i.e. org-mode is not really aware the original file was an encrypted gpg file, it only see the decrypted version. This makes it hard for org to know which links ending in .gpg should be translated and which ones should not (for example, a link to an encrypted gpg file to be served by the web server rather than a link to another org file). This makes it a little challenging to come up with a solution which will work for all use cases. The good news is that org-mode does support the ability to modify what happens during an export (publishing is really exporting as html). Have a look in the org manual at the "Advanced Export Configuration" section of the manual (under the Exporting section). In particular, you might be able to achieve the translation of links such that the .gpg are stripped using export filters. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-08-27 3:15 ` Tim Cross @ 2022-09-01 7:03 ` Ihor Radchenko 2022-09-04 5:59 ` lehi 0 siblings, 1 reply; 14+ messages in thread From: Ihor Radchenko @ 2022-09-01 7:03 UTC (permalink / raw) To: Tim Cross; +Cc: lehi, emacs-orgmode Tim Cross <theophilusx@gmail.com> writes: > I don't think there is an 'out of the box' solution for this issue. Part > of the problem is likely because the handling of the gpg decryption is > an Emacs function done outside of org mode i.e. org-mode is not really > aware the original file was an encrypted gpg file, it only see the > decrypted version. This makes it hard for org to know which links ending > in .gpg should be translated and which ones should not (for example, a > link to an encrypted gpg file to be served by the web server rather than > a link to another org file). This makes it a little challenging to come > up with a solution which will work for all use cases. I do not think that things are that difficult. org->html link conversion assumes that the linked .org file is also exported generating the .html file. If I understand correctly, .org.gpg files are also exported during publishing process. (Lehi Toskin, could you kindly confirm this?) Thus, we may simply extend `org-html-link' to work on .org.gpg files in addition to .org files. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-01 7:03 ` Ihor Radchenko @ 2022-09-04 5:59 ` lehi 2022-09-05 0:15 ` David Masterson 2022-09-05 11:44 ` [PATCH] " Ihor Radchenko 0 siblings, 2 replies; 14+ messages in thread From: lehi @ 2022-09-04 5:59 UTC (permalink / raw) To: Ihor Radchenko; +Cc: Tim Cross, emacs-orgmode > Tim Cross theophilusx@gmail.com writes: > I do not think that things are that difficult. org->html link conversion > > assumes that the linked .org file is also exported generating the > .html file. If I understand correctly, .org.gpg files are also exported > during publishing process. (Lehi Toskin, could you kindly confirm this?) > > Thus, we may simply extend `org-html-link' to work on .org.gpg files in > addition to .org files. Yes, this is it exactly. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-04 5:59 ` lehi @ 2022-09-05 0:15 ` David Masterson 2022-09-05 11:46 ` Ihor Radchenko 2022-09-05 11:44 ` [PATCH] " Ihor Radchenko 1 sibling, 1 reply; 14+ messages in thread From: David Masterson @ 2022-09-05 0:15 UTC (permalink / raw) To: lehi; +Cc: Ihor Radchenko, Tim Cross, emacs-orgmode lehi@tosk.in writes: >> Tim Cross theophilusx@gmail.com writes: >> I do not think that things are that difficult. org->html link conversion >> >> assumes that the linked .org file is also exported generating the >> .html file. If I understand correctly, .org.gpg files are also exported >> during publishing process. (Lehi Toskin, could you kindly confirm this?) >> >> Thus, we may simply extend `org-html-link' to work on .org.gpg files in >> addition to .org files. > > Yes, this is it exactly. > Does org-publish have options for files with org-crypt entries? -- David Masterson ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-05 0:15 ` David Masterson @ 2022-09-05 11:46 ` Ihor Radchenko 2022-09-05 20:29 ` David Masterson 0 siblings, 1 reply; 14+ messages in thread From: Ihor Radchenko @ 2022-09-05 11:46 UTC (permalink / raw) To: David Masterson; +Cc: lehi, Tim Cross, emacs-orgmode David Masterson <dsmasterson@gmail.com> writes: > Does org-publish have options for files with org-crypt entries? We do not have an explicit option, but you can add org-decrypt-entries to your org-export-before-processing-hook. -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-05 11:46 ` Ihor Radchenko @ 2022-09-05 20:29 ` David Masterson 2022-09-06 0:44 ` lehi 0 siblings, 1 reply; 14+ messages in thread From: David Masterson @ 2022-09-05 20:29 UTC (permalink / raw) To: Ihor Radchenko; +Cc: lehi, Tim Cross, emacs-orgmode Ihor Radchenko <yantar92@gmail.com> writes: > David Masterson <dsmasterson@gmail.com> writes: > >> Does org-publish have options for files with org-crypt entries? > > We do not have an explicit option, but you can add org-decrypt-entries > to your org-export-before-processing-hook. Thanks -- David Masterson ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-05 20:29 ` David Masterson @ 2022-09-06 0:44 ` lehi 2022-09-06 4:08 ` David Masterson 2022-09-06 13:47 ` Ihor Radchenko 0 siblings, 2 replies; 14+ messages in thread From: lehi @ 2022-09-06 0:44 UTC (permalink / raw) To: David Masterson; +Cc: Ihor Radchenko, Tim Cross, emacs-orgmode Ihor Radchenko yantar92@gmail.com writes: > > > David Masterson dsmasterson@gmail.com writes: > > > > > Does org-publish have options for files with org-crypt entries? > > > > We do not have an explicit option, but you can add org-decrypt-entries > > to your org-export-before-processing-hook. > > > Thanks > > -- > David Masterson Is there a specific way of setting this in the config? I tried adding `(add-hook 'org-export-before-processing-hook #'org-decrypt-entries)` to my init.el, but publishing fails with the error "run-hook-with-args: Wrong number of arguments: (0 . 0), 1" ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-06 0:44 ` lehi @ 2022-09-06 4:08 ` David Masterson 2022-09-06 4:37 ` tomas 2022-09-06 13:47 ` Ihor Radchenko 1 sibling, 1 reply; 14+ messages in thread From: David Masterson @ 2022-09-06 4:08 UTC (permalink / raw) To: lehi; +Cc: Ihor Radchenko, Tim Cross, emacs-orgmode lehi@tosk.in writes: > Ihor Radchenko yantar92@gmail.com writes: >> >> > David Masterson dsmasterson@gmail.com writes: >> > >> > > Does org-publish have options for files with org-crypt entries? >> > >> > We do not have an explicit option, but you can add org-decrypt-entries >> > to your org-export-before-processing-hook. >> >> Thanks > Is there a specific way of setting this in the config? > I tried adding `(add-hook 'org-export-before-processing-hook > #'org-decrypt-entries)` to my init.el, but publishing fails with the > error "run-hook-with-args: Wrong number of arguments: (0 . 0), 1" Been awhile -- what's the purpose of the '#' character? -- David Masterson ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-06 4:08 ` David Masterson @ 2022-09-06 4:37 ` tomas 2022-09-10 2:51 ` David Masterson 0 siblings, 1 reply; 14+ messages in thread From: tomas @ 2022-09-06 4:37 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1256 bytes --] On Mon, Sep 05, 2022 at 09:08:13PM -0700, David Masterson wrote: > lehi@tosk.in writes: > > > Ihor Radchenko yantar92@gmail.com writes: > >> > >> > David Masterson dsmasterson@gmail.com writes: > >> > > >> > > Does org-publish have options for files with org-crypt entries? > >> > > >> > We do not have an explicit option, but you can add org-decrypt-entries > >> > to your org-export-before-processing-hook. > >> > >> Thanks > > > Is there a specific way of setting this in the config? > > I tried adding `(add-hook 'org-export-before-processing-hook > > #'org-decrypt-entries)` to my init.el, but publishing fails with the > > error "run-hook-with-args: Wrong number of arguments: (0 . 0), 1" > > Been awhile -- what's the purpose of the '#' character? Its nickname is "sharp-quote" (actually the whole #' thingy is called like that). As ' is just a shorthand for 'quote' (i.e. 'foo is a shorthand for (quote foo), #' is a shorthand for 'function, i.e. #'foo stands for (function foo), meaning "the function the symbol foo refers to". Being Emacs Lisp, you could just have said 'foo, but this has quite a few downsides, one of them being that you blindside your compiler (And your human readers). Cheers -- t [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-06 4:37 ` tomas @ 2022-09-10 2:51 ` David Masterson 0 siblings, 0 replies; 14+ messages in thread From: David Masterson @ 2022-09-10 2:51 UTC (permalink / raw) To: tomas; +Cc: emacs-orgmode <tomas@tuxteam.de> writes: > On Mon, Sep 05, 2022 at 09:08:13PM -0700, David Masterson wrote: >> lehi@tosk.in writes: >> >> > Ihor Radchenko yantar92@gmail.com writes: >> >> >> >> > David Masterson dsmasterson@gmail.com writes: >> >> > >> >> > > Does org-publish have options for files with org-crypt entries? >> >> > >> >> > We do not have an explicit option, but you can add org-decrypt-entries >> >> > to your org-export-before-processing-hook. >> >> >> >> Thanks >> >> > Is there a specific way of setting this in the config? >> > I tried adding `(add-hook 'org-export-before-processing-hook >> > #'org-decrypt-entries)` to my init.el, but publishing fails with the >> > error "run-hook-with-args: Wrong number of arguments: (0 . 0), 1" >> >> Been awhile -- what's the purpose of the '#' character? > > Its nickname is "sharp-quote" (actually the whole #' thingy is called > like that). As ' is just a shorthand for 'quote' (i.e. 'foo is a > shorthand for (quote foo), #' is a shorthand for 'function, i.e. > #'foo stands for (function foo), meaning "the function the symbol > foo refers to". > > Being Emacs Lisp, you could just have said 'foo, but this has quite > a few downsides, one of them being that you blindside your compiler > (And your human readers). > > Cheers Ah ha! Thanks -- David Masterson ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Org Publish HTML and PDF With GPG Files 2022-09-06 0:44 ` lehi 2022-09-06 4:08 ` David Masterson @ 2022-09-06 13:47 ` Ihor Radchenko 1 sibling, 0 replies; 14+ messages in thread From: Ihor Radchenko @ 2022-09-06 13:47 UTC (permalink / raw) To: lehi; +Cc: David Masterson, Tim Cross, emacs-orgmode lehi@tosk.in writes: > Is there a specific way of setting this in the config? > I tried adding `(add-hook 'org-export-before-processing-hook #'org-decrypt-entries)` to my init.el, but publishing fails with the error "run-hook-with-args: Wrong number of arguments: (0 . 0), 1" This is abnormal hook and the added functions must accept a single argument - the export backend symbol (see the docstring). It is indeed confusing. On main, I changed `org-export-before-processing-hook' to `org-export-before-processing-functions' to indicate that it is abnormal hook. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fe90cab9564bd6fa08c9abe0882e0e06cc5626f9 -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] Re: Org Publish HTML and PDF With GPG Files 2022-09-04 5:59 ` lehi 2022-09-05 0:15 ` David Masterson @ 2022-09-05 11:44 ` Ihor Radchenko 2022-09-25 8:37 ` Ihor Radchenko 1 sibling, 1 reply; 14+ messages in thread From: Ihor Radchenko @ 2022-09-05 11:44 UTC (permalink / raw) To: lehi; +Cc: Tim Cross, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 393 bytes --] lehi@tosk.in writes: >> Thus, we may simply extend `org-html-link' to work on .org.gpg files in >> addition to .org files. > > Yes, this is it exactly. Can you try the attached patch? -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-publish-Allow-linking-to-encrypted-Org-files.patch --] [-- Type: text/x-patch, Size: 4298 bytes --] From dcbda721705ed54c378bcefa0ec9116b8203ecc8 Mon Sep 17 00:00:00 2001 Message-Id: <dcbda721705ed54c378bcefa0ec9116b8203ecc8.1662378219.git.yantar92@gmail.com> From: Ihor Radchenko <yantar92@gmail.com> Date: Mon, 5 Sep 2022 19:40:13 +0800 Subject: [PATCH] ox-publish: Allow linking to encrypted Org files * lisp/ox-html.el (org-html-link): Convert .org.gpg file links to .html, in addition to previously performed .org -> .html convertion. (org-html-link-org-files-as-html): Update the docstring. * doc/org-manual.org (Publishing links): * etc/ORG-NEWS (Publishing now supports links to encrypted Org files): Document the new feature. --- doc/org-manual.org | 17 ++++++++++------- etc/ORG-NEWS | 6 ++++++ lisp/ox-html.el | 15 +++++++++------ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 794682b49..fbd88aa68 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -16454,13 +16454,16 @@ *** Publishing links #+cindex: links, publishing To create a link from one Org file to another, you would use something -like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see [[*External Links]]). When -published, this link becomes a link to =foo.html=. You can thus -interlink the pages of your "Org web" project and the links will work -as expected when you publish them to HTML. If you also publish the -Org source file and want to link to it, use an =http= link instead of -a =file:= link, because =file= links are converted to link to the -corresponding =.html= file. +like =[[file:foo.org][The foo]]= or simply =[[file:foo.org]]= (see +[[*External Links]]). When published, this link becomes a link to +=foo.html=. You can thus interlink the pages of your "Org web" +project and the links will work as expected when you publish them to +HTML. If you also publish the Org source file and want to link to it, +use an =http= link instead of a =file:= link, because =file= links are +converted to link to the corresponding =.html= file. + +Links to encrypted Org files, like =[[file:foo.org.gpg]]= are also +supported. You may also link to related files, such as images. Provided you are careful with relative file names, and provided you have also diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 713a850f6..3f1c8f4c7 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -140,6 +140,12 @@ backend. From now on, using =outline-*= functions is strongly discouraged when working with Org files. ** New features +*** Publishing now supports links to encrypted Org files + +Links to other published Org files are automatically converted to the +corresponding html links. Now, this feature is also available when +links point to encrypted Org files, like +=[[file:foo.org.gpg::Heading]]=. *** Interactive commands now support escaping text inside comment blocks diff --git a/lisp/ox-html.el b/lisp/ox-html.el index b5aa868fe..8da180034 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -839,6 +839,8 @@ (defcustom org-html-link-org-files-as-html t (recognized by the extension \".org\") should become links to the corresponding HTML file, assuming that the linked Org file will also be converted to HTML. +Links to \"file.org.gpg\" are also converted. + When nil, the links still point to the plain \".org\" file." :group 'org-export-html :type 'boolean) @@ -3066,12 +3068,13 @@ (defun org-html-link (link desc info) (lambda (raw-path info) ;; Treat links to `file.org' as links to `file.html', if ;; needed. See `org-html-link-org-files-as-html'. - (cond - ((and (plist-get info :html-link-org-files-as-html) - (string= ".org" - (downcase (file-name-extension raw-path ".")))) - (concat (file-name-sans-extension raw-path) dot html-ext)) - (t raw-path)))) + (save-match-data + (cond + ((and (plist-get info :html-link-org-files-as-html) + (let ((case-fold-search t)) + (string-match "\\(.+\\)\\.org\\(?:\\.gpg\\)?$" raw-path))) + (concat (match-string 1 raw-path) dot html-ext)) + (t raw-path))))) (type (org-element-property :type link)) (raw-path (org-element-property :path link)) ;; Ensure DESC really exists, or set it to nil. -- 2.35.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] Re: Org Publish HTML and PDF With GPG Files 2022-09-05 11:44 ` [PATCH] " Ihor Radchenko @ 2022-09-25 8:37 ` Ihor Radchenko 0 siblings, 0 replies; 14+ messages in thread From: Ihor Radchenko @ 2022-09-25 8:37 UTC (permalink / raw) To: lehi; +Cc: Tim Cross, emacs-orgmode Ihor Radchenko <yantar92@gmail.com> writes: > Subject: [PATCH] ox-publish: Allow linking to encrypted Org files > Applied onto main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=f99902ecdfa4357035fb04f44b3baa8cec260530 -- Ihor Radchenko, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92 ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-09-25 8:37 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-08-24 0:08 Org Publish HTML and PDF With GPG Files lehi 2022-08-27 3:15 ` Tim Cross 2022-09-01 7:03 ` Ihor Radchenko 2022-09-04 5:59 ` lehi 2022-09-05 0:15 ` David Masterson 2022-09-05 11:46 ` Ihor Radchenko 2022-09-05 20:29 ` David Masterson 2022-09-06 0:44 ` lehi 2022-09-06 4:08 ` David Masterson 2022-09-06 4:37 ` tomas 2022-09-10 2:51 ` David Masterson 2022-09-06 13:47 ` Ihor Radchenko 2022-09-05 11:44 ` [PATCH] " Ihor Radchenko 2022-09-25 8:37 ` Ihor Radchenko
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.