Skip to content

Commit

Permalink
Only build favicons locally (r-lib#2563)
Browse files Browse the repository at this point in the history
And fix bug introduced by use of fs everywhere. Fixes r-lib#2553.

Tested by re-buidling pkgdown's favicons.
  • Loading branch information
hadley authored and SebKrantz committed Jun 1, 2024
1 parent 7790cd2 commit 81445a9
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pkgdown (development version)

* `init_site()` will no longer automatically build favicons on CI systems (e.g. GHA). This is an expensive operation that uses an external service so it should only be run locally (#2553).
* `build_home_index()` now reports when rendering the home page (#2544).
* Bootstrap 3 has been deprecated. It was superseded in December 2021, and now we're starting to more directly encourage folks to move away from it.
* Improve HTML5 compliance (#2369):
Expand Down
4 changes: 2 additions & 2 deletions R/build-favicons.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ build_favicons <- function(pkg = ".", overwrite = FALSE) {
cli::cli_abort("API request failed.", .internal = TRUE)
}

tmp <- withr::local_tempdir()
tmp <- withr::local_tempfile()
result <- httr::RETRY(
"GET",
result$favicon$package_url,
httr::write_disk(tmp),
httr::write_disk(tmp, overwrite = TRUE),
quiet = TRUE
)

Expand Down
4 changes: 2 additions & 2 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ init_site <- function(pkg = ".") {
build_bslib(pkg)
}

if (has_logo(pkg) && !has_favicons(pkg)) {
# Building favicons is expensive, so we hopefully only do it once.
# Building favicons is expensive, so we hopefully only do it once, locally
if (has_logo(pkg) && !has_favicons(pkg) && !on_ci()) {
build_favicons(pkg)
}
copy_favicons(pkg)
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ section_id <- function(section) {
xml2::xml_attr(h, "id")
}

on_ci <- function() {
isTRUE(as.logical(Sys.getenv("CI", "false")))
}

# yaml ------------------------------------------------------------

print_yaml <- function(x) {
Expand Down
Binary file modified pkgdown/favicon/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 81445a9

Please sign in to comment.