Browse Source

several updates and tests

colombj 4 years ago
parent
commit
c317c3a3fd

+ 1 - 0
.Renviron

@@ -0,0 +1 @@
+ORCID_TOKEN = "b0d429f8-ddef-4f3d-83b5-21b6d99fa629

+ 1 - 0
.gitignore

@@ -3,3 +3,4 @@
 .RData
 .Ruserdata
 .Rproj
+.httr-oauth

+ 2 - 0
emails/sendmail.r

@@ -0,0 +1,2 @@
+email <- render_email('emails/test.Rmd')
+email 

+ 29 - 0
emails/test.Rmd

@@ -0,0 +1,29 @@
+---
+output: blastula::blastula_email 
+--- 
+
+```{r, echo=FALSE}
+
+profiles = rorcid::orcid_search(grant_number = 327654276)
+nrow(profiles)-1
+
+i=1
+info= rorcid::orcid_id(as.character(profiles [i,3]))
+
+```
+
+Dear SFB team,
+
+I am working on the creation of personal page for each of you in the next SFB1315-output.de website, working from your orcid profile. I am accessing the profiles automatically using the following code:
+
+
+```{r}
+
+profiles = rorcid::orcid_search(grant_number = 327654276)
+nrow(profiles)-1
+
+info
+a= as.character("0000-0002-3127-5520")
+HERETEXT = rorcid::orcid_id(a)$biography$content
+
+```

+ 140 - 0
emails/test.html

@@ -0,0 +1,140 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<style>
+@media only screen and (max-width: 620px) {
+table[class=body] h1 {
+font-size: 28px !important;
+margin-bottom: 10px !important;
+}
+table[class=body] p,
+table[class=body] ul,
+table[class=body] ol,
+table[class=body] td,
+table[class=body] span,
+table[class=body] a {
+font-size: 16px !important;
+}
+table[class=body] .wrapper,
+table[class=body] .article {
+padding: 10px !important;
+}
+table[class=body] .content {
+padding: 0 !important;
+}
+table[class=body] .container {
+padding: 0 !important;
+width: 100% !important;
+}
+table[class=body] .main {
+border-left-width: 0 !important;
+border-radius: 0 !important;
+border-right-width: 0 !important;
+}
+table[class=body] .btn table {
+width: 100% !important;
+}
+table[class=body] .btn a {
+width: 100% !important;
+}
+table[class=body] .img-responsive {
+height: auto !important;
+max-width: 100% !important;
+width: auto !important;
+}
+}
+
+/* -------------------------------------
+PRESERVE THESE STYLES IN THE HEAD
+------------------------------------- */
+@media all {
+
+img {
+max-width: 100% !important;
+}
+
+.ExternalClass {
+width: 100%;
+}
+.ExternalClass,
+.ExternalClass p,
+.ExternalClass span,
+.ExternalClass font,
+.ExternalClass td,
+.ExternalClass div {
+line-height: 100%;
+}
+.apple-link a {
+color: inherit !important;
+font-family: inherit !important;
+font-size: inherit !important;
+font-weight: inherit !important;
+line-height: inherit !important;
+text-decoration: none !important;
+}
+.btn-primary table td:hover {
+background-color: #34495e !important;
+}
+.btn-primary a:hover {
+background-color: #34495e !important;
+border-color: #34495e !important;
+}
+}
+</style>
+</head>
+<body class style="background-color: #f6f6f6; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">
+<table border="0" cellpadding="0" cellspacing="0" class="body" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background-color: #f6f6f6;">
+<tr>
+<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;"><br /></td>
+<td class="container" style="font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; Margin: 0 auto; max-width: 580px; padding: 10px; width: 580px;">
+<div class="content" style="box-sizing: border-box; display: block; Margin: 0 auto; max-width: 580px; padding: 10px;">
+
+<!-- START CENTERED WHITE CONTAINER -->
+<span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;"></span>
+<table class="main" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; background: #ffffff; border-radius: 3px;">
+
+<!-- START MAIN CONTENT AREA -->
+<tr>
+<td class="wrapper" style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;">
+<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
+<tr>
+<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;">
+<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;"><p>Hi Team,</p>
+<p>This <em>important</em> forecast needs to go out today.</p>
+<pre><code>## $pred
+##          Qtr1     Qtr2     Qtr3
+## 1975 29.65318 34.31234 38.15225
+## 
+## $se
+##           Qtr1      Qtr2      Qtr3
+## 1975  9.244921 11.980103 13.526128</code></pre></p>
+</td>
+</tr>
+</table>
+</td>
+</tr>
+
+<!-- END MAIN CONTENT AREA -->
+</table>
+
+<!-- START FOOTER -->
+<div class="footer" style="clear: both; Margin-top: 10px; text-align: left; width: 100%;">
+<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;">
+<tr>
+<td class="content-block powered-by" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; font-size: 12px; color: #999999; text-align: left;">
+</td>
+</tr>
+</table>
+</div>
+<!-- END FOOTER -->
+
+<!-- END CENTERED WHITE CONTAINER -->
+</div>
+</td>
+<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;"><br /></td>
+</tr>
+</table>
+</body>
+</html>

+ 91 - 1
orcidwork.R

@@ -1 +1,91 @@
-rorcid::orcid_search(grant_number = 327654276)
+library(readr)
+library (dplyr)
+
+#additional libraries for images stuff
+library (magick)
+library (data.table)
+
+## create list
+seafilefolder= "/Users/colombj/Documents/Seafile/SFB1315info/"
+orcidlist1= rorcid::orcid_search(grant_number = 327654276)
+
+people_sfb <- read_delim(paste0(seafilefolder,"sfb1315_people.csv"),
+                         "\t", trim_ws = TRUE, skip = 0, na=character())
+
+left_join(orcidlist1, people_sfb, by = c("name" = "artist"))
+p_template =  readLines("automation_websiteelementscreation/authors_template.md")
+
+
+a= as.character("0000-0002-3127-5520")
+b=rorcid::orcid_id(a)[[1]]
+
+##---  links
+urlname=b$`researcher-urls`$`researcher-url`$`url-name`
+url=b$`researcher-urls`$`researcher-url`$url.value
+
+
+
+for (i in c(1: nrow(orcidlist))){
+  a= as.character("0000-0002-3127-5520")
+  # a= as.character(orcidlist[i])
+  b=rorcid::orcid_id(a)[[1]]
+  
+  ## specific
+  code = tolower(paste0(b$name$`given-names`, "-", b$name$`family-name`))
+  
+  ## from external sfb list
+  role= people_sfb$role_group[people_sfb$people_code == code]
+  
+  ## usual
+  name = paste0(b$name$`given-names`, " ", b$name$`family-name`)
+  bio = b$biography$content
+  
+  ## links
+  githublink= url[grepl("github", url)][1]
+  twitterlink = url[grepl("twitter", url)][1]
+  picturelink = url[grepl("picture", urlname)][1]
+  lablink = url[grepl("lab", urlname)][1]
+  
+  SOCIAL = paste0("- icon: orcid \n  icon_pack: ai \n  link: ",a)
+  SOCIAL = paste0("\n- icon: globe \n  icon_pack: fas \n  link: ",lablink)
+  SOCIAL = paste0(SOCIAL,"\n- icon: twitter \n  icon_pack: fab \n  link: ",twitterlink)
+  SOCIAL = paste0(SOCIAL,"\n- icon: github \n  icon_pack: fab \n  link: ",githublink)
+  
+  tweetname = substring(twitterlink,21)
+  a=rtweet::lookup_users(tweetname)
+  HERESHORTBIO = a$description
+  
+  ## set from template
+  
+  pdirectory =paste0("content/authors/",code)
+  dir.create(pdirectory, recursive = TRUE)
+  
+  templatenew = p_template
+  templatenew =sub ("DISPLAYNAME", name,templatenew)
+  templatenew =sub ("USERNAME", code,templatenew)
+  templatenew =sub ("HEREROLE", orcidlist$role_group[i],templatenew) ## not an orcid info
+  templatenew =sub ("HERESHORTBIO", HERESHORTBIO,templatenew) ## from twitter
+  templatenew =sub ("HERESOCIAL", SOCIAL,templatenew)
+  templatenew =sub ("HERETEXT", bio,templatenew)
+  
+  writeLines(templatenew, paste0(pdirectory,"/_index.md") )
+  
+  # add default avatar image if none present:
+  
+  
+  
+  if (!file.exists(paste0(pdirectory,"/avatar.jpg")) && !is.na(picturelink)){
+    
+    download.file(sub("_normal.", ".",picturelink),paste0(pdirectory,"/avatar.jpg"), mode ="wb")
+  }
+  if (!file.exists(paste0(pdirectory,"/avatar.jpg"))){
+    file.copy ("automation_websiteelementscreation/avatar.jpg",
+               paste0(pdirectory,"/avatar.jpg"))
+  }
+  
+  
+}
+
+# for tests
+#writeLines(templatenew, "test.md" )
+

BIN
orcidwork/walkthrough.key


BIN
orcidwork/walkthrough/walkthrough.001.jpeg


BIN
orcidwork/walkthrough/walkthrough.002.jpeg


BIN
orcidwork/walkthrough/walkthrough.003.jpeg


BIN
trainingvideos/images/openresearchdata-covid.png


BIN
trainingvideos/images/openresearchdata-covid2.jpg


BIN
trainingvideos/images/openresearchdata-covid3.png


BIN
trainingvideos/images/presentation-why.key