createRedirects: Create redirection pages

View source: R/createRedirects.R

createRedirectsR Documentation

Create redirection pages

Description

Create HTML pages to redirect users to the latest version of the relevant Bioconductor book. This is useful for preserving compatibility with old links when reorganizing the contents of a book.

Usage

createRedirects(
  name,
  pkg,
  page,
  dir = "../inst/doc/book",
  file = NULL,
  check = FALSE,
  include.gif = TRUE
)

Arguments

name

Character vector containing the name of each HTML.

pkg

Character vector containing the name of the Bioconductor book package to redirect to.

page

Character vector containing the name of the new chapter to redirect to.

dir

String containing the path to the output directory for the HTMLs.

file

String containing the name of a comma-separate file with three unnamed columns, from which to derive name, pkg and page.

check

Logical scalar indicating whether to check if the destination URL exists.

include.gif

Logical scalar indicating whether a GIF should be included in the redirection notice.

Details

This function is intended to be called inside the Makefile generated by configureBook, which will create the necessary HTMLs at package build time. The expectation is that there is a file like redirect.txt that can be passed in as the file argument. The default dir is the same as the final destination for all HTMLs that is defined in the Makefile.

In file, the last column can be left empty for any row. This will instruct createRedirects to re-use name as page, which is convenient when a chapter is simply moved to another package without a change in the HTML file name.

It is probably a good idea to run with check=TRUE on occasion, to verify that the redirections are working. This is not done by default to avoid a chicken-and-egg situation where two books cannot build because they redirect to each other.

Value

HTMLs of the specified name are created in dir, redirected to the sites defined by their respective pkg and page entries. A NULL is invisibly returned.

Author(s)

Aaron Lun

Examples

tmp <- tempfile()
dir.create(tmp)
createRedirects("BLAH.html", pkg="OSCA.intro", page="installation.html", dir=tmp)

if (interactive()) {
    browseURL(file.path(tmp, "BLAH.html"))
}


LTLA/rebook documentation built on June 5, 2023, 6:24 p.m.