reminders.R 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. library(blastula)
  2. blastula::create_smtp_creds_file(
  3. file = "mailtrap_file",
  4. host = "mailhost.cms.hu-berlin.de",
  5. port = 25,
  6. use_ssl = TRUE,
  7. user = "colombju"
  8. )
  9. # #email reminder app
  10. #
  11. # #1 survey analysis
  12. #
  13. # #read google doc
  14. #
  15. # library (googlesheets)
  16. # gs_auth()
  17. #
  18. # PIlist = gs_url ("https://docs.google.com/spreadsheets/d/1jVBj0RBZ4zFwtL1dcy-D9UA_QRvkGhX8s5_sWI8toEk/edit#gid=390395480")
  19. #
  20. # data= googlesheets::gs_read_csv(PIlist, skip =2)
  21. #
  22. # remind = data[data$`Data Survey`== "0",]
  23. #
  24. # text2= ""
  25. # for (i in c(1:15)) {
  26. # text =paste0("<a href='mailto:", remind$Email[i], "?subject=SFB1315-data&body=Dear Prof. ",remind$`Last name`[i],", '> ",i,remind$`Last name`[i]," </a>")
  27. # text2 = paste0 (text2, text, collapse = "<br>")
  28. # }
  29. #
  30. #
  31. #
  32. #
  33. # 2 image and orcid
  34. library (readr)
  35. library(dplyr)
  36. people_sfb <- read_delim("/Users/colombj/github_repo/01_sfb1315/WEBSITE_SFB1315_academictheme/automation_websiteelementscreation/SFBpeopel_current.csv",
  37. "\t", trim_ws = TRUE, skip = 0, na=c(""))
  38. newlist<- read_csv("/Users/colombj/github_repo/01_sfb1315/WEBSITE_SFB1315_academictheme/automation_websiteelementscreation/newlistfromgoogle.csv")
  39. peoplelist_respori <- read_delim("~/Documents/Seafile/SFB1315info/allpeople.csv",
  40. "\t", escape_double = FALSE, trim_ws = TRUE)
  41. peoplelist= right_join( peoplelist_respori, newlist, by=c("email"= "Email"))
  42. peoplelist_sub = peoplelist[!is.na(peoplelist$SFBgroup),]
  43. peoplelist_sub$project_responsible[is.na(peoplelist_sub$project_responsible)] <- "FALSE"
  44. groups = unique(peoplelist_sub$SFBgroup)
  45. ## this one is sent only to the responsible person
  46. text2 = ""
  47. peoplelist_resp <- subset(peoplelist_sub, peoplelist_sub$project_responsible == TRUE)
  48. for (group in groups){
  49. #group = "Z"
  50. footer = ""
  51. peoplelist_group <- peoplelist_resp[peoplelist_resp$SFBgroup == group,]
  52. if (nrow(peoplelist_group) == 0){
  53. #peoplelist_group <- peoplelist_sub[peoplelist_sub$SFBgroup == group,]
  54. peoplelist_group <- peoplelist_sub %>% filter(grepl (group, Project))
  55. footer= "PS: I would only need to send this email to one person, if you indicate a person of contact for the creation of the project page for your group."
  56. }
  57. emails = paste0(peoplelist_group$email, collapse = ",")
  58. text_mail = paste0("
  59. The website will soon go live, I extended the
  60. ", footer)
  61. text =paste0("<a href='mailto:", emails,
  62. "?subject=making SFB1315-output.de awesome&body=Dear members of project ",group,",", gsub('&NewLine;','%0D%0A',textutils::HTMLencode(text_mail))
  63. ," '> ",
  64. group," </a>")
  65. text2 = paste0 (text2, text, sep = "<br>")
  66. }
  67. # ## this one sent to everyone !
  68. # text2 = ""
  69. # peoplelist_resp <- peoplelist_sub
  70. # for (group in groups){
  71. # #group = "Z"
  72. # footer = "Best regards,"
  73. # peoplelist_group <- peoplelist_resp[peoplelist_resp$SFBgroup == group,]
  74. # if (nrow(peoplelist_group) == 0){
  75. # peoplelist_group <- peoplelist_sub[peoplelist_sub$SFBgroup == group,]
  76. # footer= "Best regards,"
  77. # }
  78. #
  79. # emails = paste0(peoplelist_group$email, collapse = ",")
  80. # text_mail = paste0("
  81. #
  82. # Please visit https://deploy-preview-3--adoring-tereshkova-f0b719.netlify.app/project/",group," .
  83. #
  84. # This page will present you and your project, including (after login) the SmartFigures related to your project. This new version of the website will go live on JUNE 1st, contact me if you are not happy with the project page or the personal page design.
  85. #
  86. # The new version of the smartfigure gallery went live this week. You are now able to create your own group (for example for your lab), and each figure can be shared with different groups.
  87. # I will be creating new accounts for PIs (I did it already for phds and postdocs last year) with access to the 'sfb1315 Members' sharing group. You will be able to sign in with this email address, the default password is 'resultgallery' (if you do not have access by tomorrow, drop me an email).
  88. #
  89. #
  90. # Walkthrough to add content for:
  91. # - your project smartfigure gallery: https://www.sfb1315-output.de/post/smartfigure-preview/
  92. # - your personal page: https://www.sfb1315-output.de/post/using-orcid/
  93. #
  94. # ", footer)
  95. #
  96. # text =paste0("<a href='mailto:", emails,
  97. # "?subject=DEADLINE, awesome SFB1315-output.de in June&body=Dear members of project ",group,",", gsub('&NewLine;','%0D%0A',textutils::HTMLencode(text_mail))
  98. # ," '> ",
  99. # group," </a>")
  100. #
  101. # text2 = paste0 (text2, text, sep = "<br>")
  102. #
  103. #
  104. # }
  105. # text2 = ""
  106. # peoplelist_resp <- subset(peoplelist_sub, peoplelist_sub$project_responsible == TRUE)
  107. # for (group in groups){
  108. # #group = "Z"
  109. # footer = ""
  110. # peoplelist_group <- data.frame()
  111. #
  112. #
  113. #
  114. # if (nrow(peoplelist_group) == 0){
  115. # #peoplelist_group <- peoplelist_sub[peoplelist_sub$SFBgroup == group,]
  116. # peoplelist_group <- peoplelist_sub %>% filter(grepl (group, Project))
  117. # #footer= "PS: I would only need to send this email to one person, if you indicate a person of contact for the creation of the project page for your group."
  118. # }
  119. #
  120. # emails = paste0(peoplelist_group$email, collapse = ",")
  121. # text_mail = paste0("
  122. #
  123. # Please accept my apologies for having used an outdated personel list.
  124. # I updated the website according to the latest spreadsheet curated by Marylu : https://deploy-preview-3--adoring-tereshkova-f0b719.netlify.app/project/",group," .
  125. #
  126. # The website lauch was reported to give you time to check it, maybe you want to sent me a figure for the project thumbnail.
  127. #
  128. # NB you can add content for:
  129. # - your project smartfigure gallery: https://www.sfb1315-output.de/post/smartfigure-preview/
  130. # - your personal page (including image): https://www.sfb1315-output.de/post/using-orcid/
  131. #
  132. # ", footer)
  133. #
  134. # text =paste0("<a href='mailto:", emails,
  135. # "?subject=making SFB1315-output.de awesome&body=Dear members of project ",group,",", gsub('&NewLine;','%0D%0A',textutils::HTMLencode(text_mail))
  136. # ," '> ",
  137. # group," </a>")
  138. #
  139. # text2 = paste0 (text2, text, sep = "<br>")
  140. #
  141. #
  142. # }
  143. fileConn<-file("remind.html")
  144. writeLines(c(text2), fileConn)
  145. close(fileConn)
  146. browseURL("remind.html")
  147. if (FALSE){
  148. text2 = ""
  149. peoplelist_resp <- peoplelist_sub %>% filter (role.x != "PI")
  150. #for (group in peoplelist_resp$peoplecode){
  151. for (group in peoplelist_resp$peoplecode[-c(1:j)]){
  152. #group = "julien-colomb"
  153. footer = "Best regards,"
  154. peoplelist_group <- peoplelist_resp[peoplelist_resp$peoplecode == group,]
  155. emails = paste0(peoplelist_group$email, collapse = ",")
  156. thetitle = "thank you for your help, dear SFB member"
  157. text_mail = paste0(",
  158. I really appreciate the fact you took 10 minutes of your time to take our survey and think about file organisation for your project(s),
  159. I wish you a wonderful day.
  160. Julien
  161. *PS: This message was sent the 27.09.2020: in order to prevent a time paradox, please take the survey if you did not do so yet:*
  162. https://umfrage.hu-berlin.de/index.php/622476?newtest=Y
  163. ")
  164. img_string <- add_image(file = "~/github_repo/05_old_rdm/rdm_promotion/website_build/static/material/CC-BY-NC/futureself.png", width = 300)
  165. #img_string <- add_image(file = "~/github_repo/05_old_rdm/rdm_promotion/website_build/static/material/CC-BY-NC/datafile_naming_xkcd.png", width = 300)
  166. email <- compose_email(
  167. title = "SFB1315, GIN-tonic survey",
  168. body = md( paste0("Dear " , peoplelist_group$`First name`,
  169. text_mail,"
  170. "))
  171. ,footer = md(paste0("Dr. Julien Colomb, SFB1315 project Z,
  172. (Email created with the *R blastula package*),",
  173. img_string
  174. ))
  175. )
  176. #email
  177. print(group)
  178. smtp_send(
  179. email = email,
  180. subject = thetitle,
  181. from = "julien.colomb@hu-berlin.de",
  182. to = emails,
  183. credentials = creds_file("mailtrap_file")
  184. )
  185. }
  186. }
  187. ## this one sent to phds, directly ! NB only works in look with VPN to HU Berlin on!