R/generateEmail.R

emailHeader <- readLines("~/JournalWatchPBPath/_emailHeader.Rmd")

newPancreas <- if (length(newPMIDList_pancreas$X1) > 0) {
    readLines("~/JournalWatchPBPath/_newpancreas.Rmd")  
} else {
    "Today there is no new Pancreas Article."
}

newGallbladder <- if (length(newPMIDList_gallbladder$X1) > 0) {
    readLines("~/JournalWatchPBPath/_newgallbladder.Rmd")
} else {
    "Today there is no new Gallbladder Article."
}


newBileDucts <- if (length(newPMIDList_bileducts$X1) > 0) {
    readLines("~/JournalWatchPBPath/_newbileducts.Rmd")
} else {
    "Today there is no new Bile Duct Article."
}


# newAmpulla <- readLines("~/JournalWatchPBPath/_ampullaRecent.Rmd")

newAmpulla <- if (length(newPMIDList_ampulla$X1) > 0) {
    readLines("~/JournalWatchPBPath/_newampulla.Rmd")
} else {
    "Today there is no new Ampulla Article."
}



cat(emailHeader,
    "For all candidate articles please visit: http://pbpath.org/journal-watch-upcoming-issue/", "\n",
    "### New Pancreas Articles", "\n",
    newPancreas, "\n",
    "### New GallBladder Articles", "\n",
    newGallbladder, "\n",
    "### New BileDuct Articles", "\n",
    newBileDucts, "\n",
    "### New Ampulla Articles", "\n",
    newAmpulla, "\n","\n",
    "For all candidate articles please visit: http://pbpath.org/journal-watch-upcoming-issue/", "\n",
    file = "~/JournalWatchPBPath/candidates/email.Rmd",
    sep = "\n")


# Sys.setenv(RSTUDIO_PANDOC= "/Applications/RStudio.app/Contents/MacOS/pandoc")
# email <- blastula::render_email(input = "~/JournalWatchPBPath/candidates/email.Rmd", quiet = TRUE)


Sys.setenv(RSTUDIO_PANDOC = "/Applications/RStudio.app/Contents/MacOS/pandoc")
email <-
    blastula::render_email(input = "~/JournalWatchPBPath/candidates/email.Rmd",
                           quiet = TRUE)


rmarkdown::render('/Users/serdarbalciold/JournalWatchPBPath/candidates/email.Rmd',  encoding = 'UTF-8', knit_root_dir = '~/AutoJournalWatch', quiet = TRUE)


print(paste0("Generate email at: ", Sys.time()))


Sys.sleep(10)
sbalci/AutoJournalWatch documentation built on Aug. 13, 2020, 4:18 p.m.