Skip to content

Managing links and urls

GennadyK edited this page Dec 6, 2016 · 15 revisions

Links in Baker can be divided in three distinct categories: internal, external and book.

 

Internal Links

Internal links target a single HTML/PDF file inside the book folder, for example:

<a href="new-page.html#anchor">Link to new page</a>
<a href="reference1.pdf?referrer=Baker">Link to PDF document</a>

There are three different behaviors associated to internal links, based upon the type of the linked file:

  • the file is a book page: Baker will scroll the book to the linked page and load its content. If the linked page is the current page, Baker will reload the page content.
  • the file is not a book page: Baker will load the content of the linked file inside the current page, replacing its content with the new one.
  • the file is not a book page and doesn't have a way to return back to the book, e.g. referenced PDF document: use "?referrer=Baker" query parameter (see external links below) to open it in the modal internal browser, that has "Back" link in the top bar.

If an #anchor is specified, the content of the page will scroll down (or up) to the first element with an id or name attribute that matches the anchor.

 

External links

External links target an external HTML page, for example:

<a href="http://www.external-site.com?referrer=Baker">Link to external site</a>

There are two different behaviors associated with external links, based upon the referrer query parameter:

  • the referrer attribute is specified and it is equal to Baker: Baker will open the linked page in the modal internal browser.
  • the referrer attribute is specified and it is equal to Safari: Baker will open the link directly in Safari Mobile. Please however be sure that this is really what you need to do, since it will create an inconvenience for most of the users.
  • the referrer attribute is not specified or it is different from Baker or Safari: Baker will load the content of the linked page inside the current page, replacing its content with the new one.

NOTE: the parameter is used in Baker and will not be used in the URL to contact the server. In the example above the server will receive only http://www.external-site.com.

 

Mail links

Baker supports the in-app sending of mails using mailto-links like the following ones:

<a href="mailto:user@example.com">Send mail</a>
<a href="mailto:user@example.com?subject=Hello%20World">Send mail with subject</a>
<a href="mailto:user@example.com?subject=Hello%20World&body=Foo%20Bar">Send mail with subject and body</a>

When one of these links is clicked, the app will open a modal sheet showing the standard iOS mail composer window.

 

Book links (4.3)

https://github.com/bakerframework/baker/issues/548

 

Book links (3.2 and below only)

Book links target an external book, for example:

<a href="book://www.mysite.com/books/new-book.hpub/page.html#anchor">Link to new book</a>

These links are defined by the special book:// protocol. When a book link is clicked, Baker will download and open the linked book, replacing the current one.

If page.html is specified and it's a valid page of the new book, Baker will automatically open the new book at that page.
If an #anchor is specified, the content of the page will scroll down (or up) to the first element with an id or name attribute that matches the anchor.

Other than standards book links, with the format described above, Baker supports a special book URL:

<a href="book://local">Link to bundle book</a>

When clicked in a book different than the bundled one, Baker will discard the current book and revert to the original one.