From 64739c31e2e4c63efc4191a2aaa26c254d9ecdc5 Mon Sep 17 00:00:00 2001 From: sbalci Date: Sat, 29 Jun 2024 20:27:13 +0300 Subject: [PATCH] fixed links --- app.R | 4 +++- generate_qmd.R | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app.R b/app.R index 01da210..fcae1fa 100644 --- a/app.R +++ b/app.R @@ -40,6 +40,7 @@ ui <- fluidPage( checkboxInput("diagnosis", "Diagnosis", value = TRUE), checkboxInput("use_youtube", "Use YouTube", value = FALSE), textInput("youtube_link", "YouTube Link", value = "youtube_link"), + checkboxInput("end_template", "End Template", value = FALSE), actionButton("generate", "Generate Code"), br(), downloadButton('downloadFile_qmd', 'Download qmd file'), @@ -95,7 +96,8 @@ server <- function(input, output) { stain = stain, diagnosis = input$diagnosis, use_youtube = input$use_youtube, - youtube_link = input$youtube_link + youtube_link = input$youtube_link, + end_template = input$end_template ) }) diff --git a/generate_qmd.R b/generate_qmd.R index f08a350..7db6ab5 100644 --- a/generate_qmd.R +++ b/generate_qmd.R @@ -470,7 +470,8 @@ readme_text <- function( stain = c("HE1", "HE2"), diagnosis = FALSE, use_youtube = FALSE, - youtube_link = "youtube_link" + youtube_link = "youtube_link", + end_template = FALSE ) { @@ -530,6 +531,7 @@ update html file heading: ## yaml string ---- + yaml_string <- paste0(" ```yaml - stainname: {{template}}-{{stain}} @@ -565,7 +567,7 @@ yaml_string <- paste0(" screenshot: https://www.patolojiatlasi.com/screenshots/thumbnail_{{template}}-{{stain}}.png github: https:///github.com/pathologyatlas/{{template}} githubpage: https://pathologyatlas.github.io/{{template}} - youtube: https://www.youtube.com/watch?v={{youtube_link}} + youtube:" , ifelse(use_youtube, paste0("https://www.youtube.com/watch?v=", youtube_link), "''"), " ``` " ) @@ -797,12 +799,24 @@ for (s in stain) { } +if (!use_youtube) { + readme_text <- gsub(pattern = "youtube: https://www.youtube.com/watch\\?v=.+", replacement = "youtube: ''", x = readme_text, perl = TRUE) + } + ## end render ---- -readme_text <- paste(readme_text, end_string, sep = "\n\n") + + +if (end_template) { + + readme_text <- paste(readme_text, end_string, sep = "\n\n") + +} + + readme_text <- gsub(pattern = "((<", replacement = "{{<", x = readme_text, fixed = TRUE)