-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout fonction use_favicon_dsfr #131
- Loading branch information
1 parent
ae7bfd5
commit 1675dbc
Showing
8 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ $run_dev.* | |
docs | ||
^inst/test.convert.dsfr/\.Rbuildignore$ | ||
^deliverables$ | ||
^dev/tools/$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# WARNING - Generated by {fusen} from dev/tools/flat_favicon.Rmd: do not edit by hand | ||
|
||
#' use_favicon_dsfr | ||
#' | ||
#' @description | ||
#' use_favicon_dsfr() est une fonction a lancer dans la console pour enregistrer le fichier de favicon marianne dans votre projet shiny. | ||
#' | ||
#' | ||
#' @param path_app chaine de texte indiquant le chemin vers votre application shiny | ||
#' @param golem_app booleen, TRUE pour une app golem, FALSE sinon | ||
#' @importFrom golem use_favicon | ||
#' | ||
#' @return NULL | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # A lancer dans la console pour rapatrier le fichier dans votre repertoire de travail | ||
#' use_favicon_dsfr(path_app = "", golem_app = TRUE) | ||
#' } | ||
|
||
use_favicon_dsfr <- function(path_app = '', golem_app = TRUE) { | ||
path_favicon_dsfr <- system.file(paste0("dsfr-v", get_dsfr_version(), "/dist/favicon/favicon.ico"), package = "shinygouv") | ||
if(golem_app) { | ||
golem::use_favicon(path = path_favicon_dsfr, pkg = path_app) | ||
} else { | ||
dest_favic = paste0(path_app, "/www") | ||
dir.create(path = dest_favic, showWarnings = TRUE) | ||
file.copy(from = path_favicon_dsfr, to = dest_favic, overwrite = TRUE, recursive = FALSE) | ||
cat("La favicon Marianne est dans `", dest_favic, "`.", sep = "", fill = TRUE) | ||
cat("Il vous reste a l'introduire dans votre corps de page UI, par exemple avec", fill = TRUE) | ||
cat('tags$head(tags$link(rel = "shortcut icon", type = "image/x-icon", href = "favicon.ico")\n') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
title: "favicon" | ||
output: html_document | ||
editor_options: | ||
chunk_output_type: console | ||
--- | ||
|
||
```{r development, include=FALSE} | ||
library(testthat) | ||
``` | ||
|
||
```{r development-load} | ||
# Load already included functions if relevant | ||
pkgload::load_all(export_all = FALSE) | ||
``` | ||
|
||
# flat_favicon_rmd | ||
|
||
```{r function-flat_favicon_rmd} | ||
#' use_favicon_dsfr | ||
#' | ||
#' @description | ||
#' use_favicon_dsfr() est une fonction a lancer dans la console pour enregistrer le fichier de favicon marianne dans votre projet shiny. | ||
#' | ||
#' | ||
#' @param path_app chaine de texte indiquant le chemin vers votre application shiny | ||
#' @param golem_app booleen, TRUE pour une app golem, FALSE sinon | ||
#' @importFrom golem use_favicon | ||
#' | ||
#' @return NULL | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' # A lancer dans la console pour rapatrier le fichier dans votre repertoire de travail | ||
#' use_favicon_dsfr(path_app = "", golem_app = TRUE) | ||
#' } | ||
use_favicon_dsfr <- function(path_app = '', golem_app = TRUE) { | ||
path_favicon_dsfr <- system.file(paste0("dsfr-v", get_dsfr_version(), "/dist/favicon/favicon.ico"), package = "shinygouv") | ||
if(golem_app) { | ||
golem::use_favicon(path = path_favicon_dsfr, pkg = path_app) | ||
} else { | ||
dest_favic = paste0(path_app, "/www") | ||
dir.create(path = dest_favic, showWarnings = TRUE) | ||
file.copy(from = path_favicon_dsfr, to = dest_favic, overwrite = TRUE, recursive = FALSE) | ||
cat("La favicon Marianne est dans `", dest_favic, "`.", sep = "", fill = TRUE) | ||
cat("Il vous reste a l'introduire dans votre corps de page UI, par exemple avec", fill = TRUE) | ||
cat('tags$head(tags$link(rel = "shortcut icon", type = "image/x-icon", href = "favicon.ico")\n') | ||
} | ||
} | ||
``` | ||
|
||
|
||
```{r tests-flat_favicon_rmd} | ||
test_that("use_favicon_dsfr works", { | ||
# version shiny basique | ||
path_shiny_base <- paste0(app, "/www/favicon.ico") | ||
use_favicon_dsfr(path_app = app, golem_app = FALSE) | ||
expect_true(file.exists(path_shiny_base)) | ||
}) | ||
``` | ||
|
||
|
||
```{r development-inflate, eval=FALSE} | ||
# Run but keep eval=FALSE to avoid infinite loop | ||
# Execute in the console directly | ||
fusen::inflate(flat_file = "dev/tools/flat_favicon.Rmd", vignette_name = NA, check = FALSE) | ||
``` | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# WARNING - Generated by {fusen} from dev/tools/flat_favicon.Rmd: do not edit by hand | ||
|
||
test_that("use_favicon_dsfr works", { | ||
|
||
# version shiny basique | ||
path_shiny_base <- paste0(app, "/www/favicon.ico") | ||
use_favicon_dsfr(path_app = app, golem_app = FALSE) | ||
expect_true(file.exists(path_shiny_base)) | ||
|
||
}) |