orcidwork.R 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. library(readr)
  2. library (dplyr)
  3. #additional libraries for images stuff
  4. library (magick)
  5. library (data.table)
  6. ## create list
  7. seafilefolder= "/Users/colombj/Documents/Seafile/SFB1315info/"
  8. orcidlist1= rorcid::orcid_search(grant_number = 327654276)
  9. people_sfb <- read_delim(paste0(seafilefolder,"sfb1315_people.csv"),
  10. "\t", trim_ws = TRUE, skip = 0, na=character())
  11. left_join(orcidlist1, people_sfb, by = c("name" = "artist"))
  12. p_template = readLines("automation_websiteelementscreation/authors_template.md")
  13. a= as.character("0000-0002-3127-5520")
  14. b=rorcid::orcid_id(a)[[1]]
  15. ##--- links
  16. urlname=b$`researcher-urls`$`researcher-url`$`url-name`
  17. url=b$`researcher-urls`$`researcher-url`$url.value
  18. for (i in c(1: nrow(orcidlist))){
  19. a= as.character("0000-0001-5307-1564")
  20. # a= as.character(orcidlist[i])
  21. b=rorcid::orcid_id(a)[[1]]
  22. ## specific
  23. code = gsub(" ", "-",tolower(paste0(b$name$`given-names`, "-", b$name$`family-name`)))
  24. ## from external sfb list
  25. role= people_sfb$role_group[people_sfb$people_code == code]
  26. ## usual
  27. name = paste0(b$name$`given-names`, " ", b$name$`family-name`)
  28. bio = b$biography$content
  29. ## links
  30. githublink= url[grepl("github", url)][1]
  31. twitterlink = url[grepl("twitter", url)][1]
  32. picturelink = url[grepl("picture", urlname)][1]
  33. lablink = url[grepl("lab", urlname)][1]
  34. SOCIAL = paste0("- icon: orcid \n icon_pack: ai \n link: ",a)
  35. SOCIAL = paste0("\n- icon: globe \n icon_pack: fas \n link: ",lablink)
  36. SOCIAL = paste0(SOCIAL,"\n- icon: twitter \n icon_pack: fab \n link: ",twitterlink)
  37. SOCIAL = paste0(SOCIAL,"\n- icon: github \n icon_pack: fab \n link: ",githublink)
  38. tweetname = substring(twitterlink,21)
  39. a=rtweet::lookup_users(tweetname)
  40. HERESHORTBIO = a$description
  41. ## set from template
  42. pdirectory =paste0("content/authors/",code)
  43. dir.create(pdirectory, recursive = TRUE)
  44. templatenew = p_template
  45. templatenew =sub ("DISPLAYNAME", name,templatenew)
  46. templatenew =sub ("USERNAME", code,templatenew)
  47. templatenew =sub ("HEREROLE", orcidlist$role_group[i],templatenew) ## not an orcid info
  48. templatenew =sub ("HERESHORTBIO", HERESHORTBIO,templatenew) ## from twitter
  49. templatenew =sub ("HERESOCIAL", SOCIAL,templatenew)
  50. templatenew =sub ("HERETEXT", bio,templatenew)
  51. writeLines(templatenew, paste0(pdirectory,"/_index.md") )
  52. # add default avatar image if none present:
  53. if (!file.exists(paste0(pdirectory,"/avatar.jpg")) && !is.na(picturelink)){
  54. download.file(sub("_normal.", ".",picturelink),paste0(pdirectory,"/avatar.jpg"), mode ="wb")
  55. }
  56. if (!file.exists(paste0(pdirectory,"/avatar.jpg"))){
  57. file.copy ("automation_websiteelementscreation/avatar.jpg",
  58. paste0(pdirectory,"/avatar.jpg"))
  59. }
  60. }
  61. # for tests
  62. #writeLines(templatenew, "test.md" )