From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: why prepend "file://" to abs paths in html output? Date: Mon, 10 Jul 2017 19:54:58 +0000 Message-ID: References: <87lgnz43qk.fsf@nicolasgoaziou.fr> <87h8yn3tsa.fsf@nicolasgoaziou.fr> <87bmou4u8a.fsf@nicolasgoaziou.fr> <874lumfqk7.fsf@gmail.com> <877ezh51ns.fsf@nicolasgoaziou.fr> <86y3rw2y1y.fsf@hierocles.phy.bnl.gov> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114b13b4ca86080553fbf5ad" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUem2-0002vO-1i for emacs-orgmode@gnu.org; Mon, 10 Jul 2017 15:55:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUem0-0006QQ-Jv for emacs-orgmode@gnu.org; Mon, 10 Jul 2017 15:55:14 -0400 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:33704) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUem0-0006ND-6W for emacs-orgmode@gnu.org; Mon, 10 Jul 2017 15:55:12 -0400 Received: by mail-lf0-x22b.google.com with SMTP id z78so70422742lff.0 for ; Mon, 10 Jul 2017 12:55:10 -0700 (PDT) In-Reply-To: <86y3rw2y1y.fsf@hierocles.phy.bnl.gov> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Brett Viren , Nicolas Goaziou Cc: Carsten Dominik , Tim Cross , Org Mode --001a114b13b4ca86080553fbf5ad Content-Type: text/plain; charset="UTF-8" Hi Nicolas, I tried out the patch, and my comments are in the MWE below. On Mon, Jul 10, 2017 at 9:59 AM Brett Viren wrote: > Is this saying "subtract the value of 'html_link_root' from the Org link > to make its URL"? > > If so, I think this would not be general enough to help some cases. For > example, with Nikola+orgmode and with Nikola's "pretty URLs" option the > relative location between either the Org source or its generated HTML > and an image that they both link will differ. > Good point. I overlooked that. I have this MWE that explains the "would like to have" vs "what this patch gives us": ===== #+TITLE: ox-html root dir #+OPTIONS: toc:nil #+STARTUP: inlineimages #+HTML_LINK_ROOT: /tmp/site/static/ An =image.png= exists as =/tmp/site/static/images/image.png=. * This is how the image links should have worked with the link root already specified [[/images/image.png]] - The =HTML_LINK_ROOT= should to appended to the front of the above link if that concatenated path is a valid one. - Would also like =C-x C-o=, inline image display, etc. to work. - So a thought.. should the link root specification be made exporter agnostic? * This works after adding support for =HTML_LINK_ROOT= .. .. but - The link path becomes too long. - Need to hard-code the full path to the site/blog root directory before each of such links. [[file:/tmp/site/static/images/image.png]] ===== > Some details: > > Nikola source wants this layout: > > /path/to/my/nikola/posts/my-blog-post.org > /path/to/my/nikola/images/unicorn.jpg > > The Org source generates to HTML which will be found at this URL path: > > /mysiteroot/posts/my-blog-post/index.html > The organization for Hugo posts is something similar. So hopefully we can have a solution that works for such blogging platforms in general. In comparsion, the hugo paths would be: /path/to/my/hugo/content/posts/my-blog-post.org /path/to/my/hugo/static/images/unicorn.jpg So, right now, either the Org link to the image must be written to be > invalid (for Org): > > [[../../images/unicorn.jpg]] > Yeah, this is a problem and can probably be fixed if a support for something like "#+LINK_ROOT" can be made in Org and not specific to an exporter backend. Or, some mechanism needs to turn the valid Org link: > > [[../images/unicorn.jpg]] > > into either: > > > > or: > > > > I guess I could use html_link_root set to "/path/to/my/nikola" but then > my Org source loses portability. > > I think better would be able to explicitly state the desired URL path > for the HTML like: > > #+html_url_path: /mysiteroot/images/unicorn.jpg > [[../images/unicorn.jpg]] > As I mention in my MWE, I am actually looking for a solution so that we do not need to specify the "mysiteroot" for each link.. may be just one as a "#+LINK_ROOT". -- Kaushal Modi --001a114b13b4ca86080553fbf5ad Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Nicolas,

=
I tried out the patch, and my comments are in the MWE below.

On Mon, Jul 10, 2017 at 9:59 AM Brett Vir= en <bv@bnl.gov> wrote:
Is this saying "subtract the value of '= ;html_link_root' from the Org link
to make its URL"?

If so, I think this would not be general enough to help some cases.=C2=A0 F= or
example, with Nikola+orgmode and with Nikola's "pretty URLs" = option the
relative location between either the Org source or its generated HTML
and an image that they both link will differ.

Good point. I overlooked that.

I have this = MWE that explains the "would like to have" vs "what this pat= ch gives us":

=3D=3D=3D=3D=3D
= #+TITLE: ox-html root dir
#+OPTIONS: toc:nil
#+STARTUP:= inlineimages
#+HTML_LINK_ROOT: /tmp/site/static/

<= /div>
An =3Dimage.png=3D exists as =3D/tmp/site/static/images/image.png= =3D.

* This is how the image links should have wor= ked with the link root already specified
[[/images/image.png]]
- The =3DHTML_LINK_ROOT=3D should to appended to the front of the a= bove link if that
=C2=A0 concatenated path is a valid one.
<= div>- Would also like =3DC-x C-o=3D, inline image display, etc. to work.
- So a thought.. should the link root specification be made exporte= r agnostic?
* This works after adding support for =3DHTML_LINK_RO= OT=3D ..
.. but
- The link path becomes too long.
=
- Need to hard-code the full path to the site/blog root directory befo= re each of
=C2=A0 such links.
[[file:/tmp/site/static/i= mages/image.png]]
=3D=3D=3D=3D=3D

= =C2=A0
Some details:

Nikola source wants this layout:

=C2=A0 /path/to/my/nikola/posts/my-blog-post.org
=C2=A0 /path/to/my/nikola/images/unicorn.jpg

The Org source generates to HTML which will be found at this URL path:

=C2=A0 /mysiteroot/posts/my-blog-post/index.html

<= /div>
The organization for Hugo posts is something similar. So hopefull= y we can have a solution that works for such blogging platforms in general.=
=C2=A0
In comparsion, the hugo paths would be:

=C2=A0 /path/to/my/hugo/content/posts/my-blog-post.org=
=C2=A0 /path/to/my/hugo/static/images/unicorn.jpg

So, right now, either the Org link to the= image must be written to be
invalid (for Org):

=C2=A0 [[../../images/unicorn.jpg]]

=C2= =A0Yeah, this is a problem and can probably be fixed if a support for somet= hing like "#+LINK_ROOT" can be made in Org and not specific to an= exporter backend.

Or, s= ome mechanism needs to turn the valid Org link:

=C2=A0 [[../images/unicorn.jpg]]

into either:

=C2=A0 <img src=3D"/mysiteroot/images/unicorn.jpg" ...>

or:

=C2=A0 <img src=3D"../../images/unicorn.jpg" ...>

I guess I could use html_link_root set to "/path/to/my/nikola" bu= t then
my Org source loses portability.

I think better would be able to explicitly state the desired URL path
for the HTML <img> like:

=C2=A0 #+html_url_path: /mysiteroot/images/unicorn.jpg
=C2=A0 [[../images/unicorn.jpg]]

As I m= ention in my MWE, I am actually looking for a solution so that we do not ne= ed to specify the "mysiteroot" for each link.. may be just one as= a "#+LINK_ROOT".
--
=

Kaushal Modi

--001a114b13b4ca86080553fbf5ad--