Skip to content

Commit

Permalink
no need to specify the download configuration now: if not specified, …
Browse files Browse the repository at this point in the history
…we will check if [pdf, epub, mobi] exist, and add them to the download list automatically, otherwise just use whatever list of file extensions the author provided
  • Loading branch information
yihui committed Feb 22, 2016
1 parent b055d23 commit 00f3509
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ before_script:
- Rscript -e "if (packageVersion('htmltools') < '0.3.2') devtools::install_github('rstudio/htmltools')"
- R CMD INSTALL .
- cd inst/examples
- make gitbook
- "[ ! -z \"$BUILD_ALL\" ] && make all || true"
- make gitbook
- cd ../..

after_success:
Expand Down
13 changes: 12 additions & 1 deletion R/gitbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,18 @@ gitbook_page = function(
config$edit$link = sprintf(config$edit$link, rmd_cur)

if (length(exts <- load_config()[['download']]) == 0) exts = config$download
if (length(exts)) config$download = I(with_ext(opts$get('book_filename'), paste0('.', exts)))
if (identical(exts, FALSE)) {
downloads = NULL
} else if (isTRUE(exts) || length(exts) == 0) {
exts = c('pdf', 'epub', 'mobi')
downloads = with_ext(opts$get('book_filename'), exts)
in_dir(output_path('.'), {
downloads = downloads[file.exists(downloads)]
})
} else {
downloads = with_ext(opts$get('book_filename'), exts)
}
config$download = if (length(downloads)) I(downloads) else NULL

foot = sub('<!--bookdown:config-->', gitbook_config(config), foot)

Expand Down
1 change: 0 additions & 1 deletion inst/examples/_output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ bookdown::gitbook:
css: css/style.css
split_by: section
config:
download: ['pdf', 'epub', 'mobi']
toolbar:
position: fixed
toc:
Expand Down

0 comments on commit 00f3509

Please sign in to comment.