From: Ihor Radchenko <yantar92@gmail.com>
To: lehi@tosk.in
Cc: Tim Cross <theophilusx@gmail.com>, emacs-orgmode@gnu.org
Subject: [PATCH] Re: Org Publish HTML and PDF With GPG Files
Date: Mon, 05 Sep 2022 19:44:33 +0800 [thread overview]
Message-ID: <87h71mvye6.fsf@localhost> (raw)
In-Reply-To: <dzDwQ5GafcCmToSUF86x45VKWpn78mXqOJ7sFdyTsAPn2-H0AXgDIk_7vZUhfpWd2WVhDB7DcbZy_z6375yW5e1p4H0HNTbPHn_3D2Z3Mk8=@tosk.in>
[-- 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
next prev parent reply other threads:[~2022-09-05 12:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Ihor Radchenko [this message]
2022-09-25 8:37 ` [PATCH] " Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h71mvye6.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=lehi@tosk.in \
--cc=theophilusx@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).