Skip to content

Commit

Permalink
added an argument initpath to server_config() so you can open a s…
Browse files Browse the repository at this point in the history
…pecific path initially in the web browser
  • Loading branch information
yihui committed Nov 29, 2016
1 parent 004a821 commit 0258632
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions NEWS
@@ -1,3 +1,10 @@
CHANGES IN servr VERSION 0.5

NEW FEATURES

- added an argument `initpath` to `server_config()` so you can open a specific
path initially in the web browser

CHANGES IN servr VERSION 0.4.1

NEW FEATURES
Expand Down
6 changes: 5 additions & 1 deletion R/static.R
Expand Up @@ -92,11 +92,14 @@ watch_dir = function(dir = '.', pattern = NULL, all_files = FALSE, handler = NUL
#' the future
#' @param baseurl the base URL (the full URL will be
#' \code{http://host:port/baseurl})
#' @param initpath the initial path in the URL (e.g. you can open a specific
#' HTML file initially)
#' @inheritParams httpuv::startServer
#' @return A list of configuration information of the form \code{list(host,
#' port, start_server = function(app) {}, ...)}.
server_config = function(
dir, host = '127.0.0.1', port, browser, daemon, interval = 1, baseurl = ''
dir, host = '127.0.0.1', port, browser, daemon, interval = 1, baseurl = '',
initpath = ''
) {
cargs = commandArgs(TRUE)
if (missing(browser)) browser = interactive() || '-b' %in% cargs || is_rstudio()
Expand All @@ -107,6 +110,7 @@ server_config = function(
damn_library('methods')
url = sprintf('http://%s:%d', host, port)
if (baseurl != '') url = paste(url, baseurl, sep = '')
url = paste0(url, if (initpath != '' && !grepl('^/', initpath)) '/', initpath)
list(
host = host,
port = port,
Expand Down

0 comments on commit 0258632

Please sign in to comment.