Skip to content

Commit 35e4f4b

Browse files
committed
feat: add support for ROR IDs
1 parent e23c4d1 commit 35e4f4b

File tree

12 files changed

+73
-19
lines changed

12 files changed

+73
-19
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,5 @@ Config/testthat/parallel: true
7474
Config/testthat/start-first: build-article, build-quarto-article, build-reference
7575
Encoding: UTF-8
7676
Roxygen: list(markdown = TRUE)
77-
RoxygenNote: 7.3.2
77+
RoxygenNote: 7.3.2.9000
7878
SystemRequirements: pandoc

R/build-home-authors.R

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ data_home_sidebar_authors <- function(pkg = ".", call = caller_env()) {
8484
)
8585
data <- data_authors(pkg, roles)
8686
authors <- purrr::map_chr(data$main, author_desc, comment = FALSE)
87-
87+
8888
before <- config_pluck_markdown_inline(pkg, "authors.sidebar.before", call = call)
8989
after <- config_pluck_markdown_inline(pkg, "authors.sidebar.after", call = call)
90-
90+
9191
bullets <- c(before, authors, after)
9292
if (data$needs_page) {
9393
bullets <- c(bullets, a(tr_("More about authors..."), "authors.html"))
@@ -136,11 +136,15 @@ author_list <- function(x, authors_info = NULL, comment = FALSE, pkg = ".") {
136136
orcid <- purrr::pluck(x$comment, "ORCID")
137137
x$comment <- remove_orcid(x$comment)
138138

139+
ror <- purrr::pluck(x$comment, "ROR")
140+
x$comment <- remove_ror(x$comment)
141+
139142
list(
140143
name = name,
141144
roles = roles,
142145
comment = linkify(x$comment),
143-
orcid = orcid_link(orcid)
146+
# can't have both ORCID and ROR
147+
uniqueid = orcid_link(orcid) %||% ror_link(ror)
144148
)
145149
}
146150

@@ -151,6 +155,9 @@ author_desc <- function(x, comment = TRUE) {
151155
if (!is.null(x$orcid)) {
152156
x$orcid
153157
},
158+
if (!is.null(x$ror)) {
159+
x$ror
160+
},
154161
if (comment && !is.null(x$comment) && length(x$comment) != 0) {
155162
paste0("<br/>\n<small>(", linkify(x$comment), ")</small>")
156163
}
@@ -168,6 +175,17 @@ orcid_link <- function(orcid) {
168175
)
169176
}
170177

178+
ror_link <- function(ror) {
179+
if (is.null(ror)) {
180+
return(NULL)
181+
}
182+
183+
paste0(
184+
"<a href='https://ror.org/", ror, "'>",
185+
"<img src='https://raw.githubusercontent.com/ror-community/ror-logos/main/ror-icon-rgb.svg' class='ror' alt='ROR'></a>"
186+
)
187+
}
188+
171189
# Derived from:
172190
# db <- utils:::MARC_relator_db
173191
# db <- db[db$usage != "",]
@@ -300,3 +318,10 @@ remove_orcid <- function(x) {
300318
}
301319
out
302320
}
321+
remove_ror <- function(x) {
322+
out <- x[names2(x) != "ROR"]
323+
if (all(names(out) == "")) {
324+
names(out) <- NULL
325+
}
326+
out
327+
}

R/build-home.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@
119119
#' See `?build_home` and `?build_site` for details about changing the location
120120
#' of the authors information within the home sidebar and the site footer.
121121
#'
122-
#' ## Authors ORCID and bio
122+
#' ## Authors ORCID, ROR and bio
123123
#'
124124
#' Author ORCID identification numbers in the `DESCRIPTION` are linked using
125-
#' the ORCID logo:
125+
#' the ORCID logo,
126+
#' author ROR identification numbers are linked using the ROR logo:
126127
#'
127128
#' ```r
128129
#' Authors@R: c(
@@ -131,7 +132,9 @@
131132
#' ),
132133
#' person("Jay", "Hesselberth", role = "aut",
133134
#' comment = c(ORCID = "0000-0002-6299-179X")
134-
#' )
135+
#' ),
136+
#' person("Posit Software, PBC", role = c("cph", "fnd"),
137+
#' comment = c(ROR = "03wc8by49"))
135138
#' )
136139
#' ```
137140
#'

inst/BS5/assets/pkgdown.scss

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $pkgdown-navbar-bg-dark: if($navbar-dark-bg, $navbar-dark-bg, null) !default;
5151
}
5252

5353
// make both the active nav and the hovered nav more clear by mixing the
54-
// background colour with the body and primary colours respectively
54+
// background colour with the body and primary colours respectively
5555
.nav-item .nav-link {
5656
@include border-radius($border-radius);
5757
}
@@ -312,6 +312,11 @@ dt:target + dd {
312312
color: #A6CE39;
313313
margin-right: 4px;
314314
}
315+
// ror badge
316+
.ror {
317+
height: 16px;
318+
margin-right: 4px;
319+
}
315320
// activate font awesome
316321
.fab {
317322
font-family: "Font Awesome 5 Brands" !important;
@@ -372,7 +377,7 @@ a[href='#main'] {
372377
}
373378
.lifecycle-stable { background-color: rgb(16, 128, 1); color: var(--bs-white);}
374379
.lifecycle-superseded { background-color: rgb(7, 64, 128); color: var(--bs-white);}
375-
.lifecycle-experimental,
380+
.lifecycle-experimental,
376381
.lifecycle-deprecated { background-color: rgb(253, 128, 8); color: var(--bs-black);}
377382

378383
/* Footnotes ---------------------------------------------------------------- */
@@ -452,7 +457,7 @@ pre, pre code {
452457
// Default dark mode styling does not look good for code
453458
[data-bs-theme="dark"] {
454459
pre, code {
455-
background-color: RGBA(var(--bs-body-color-rgb), 0.1);
460+
background-color: RGBA(var(--bs-body-color-rgb), 0.1);
456461
}
457462
// don't double apply transparency
458463
pre code {
@@ -594,7 +599,7 @@ span.smallcaps {font-variant: small-caps;}
594599
ul.task-list{list-style: none;}
595600
ul.task-list li input[type="checkbox"] {
596601
width: 0.8em;
597-
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
602+
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
598603
vertical-align: middle;
599604
}
600605

inst/BS5/templates/content-authors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h1>{{{pagetitle}}}</h1>
1010
<ul class="list-unstyled">
1111
{{#authors}}
1212
<li>
13-
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{orcid}}}
13+
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{uniqueid}}}
1414
{{#comment}}<br /><small>{{{.}}}</small>{{/comment}}</p>
1515
</li>
1616
{{/authors}}

inst/BS5/templates/content-citation-authors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h2>{{#translate}}{{authors}}{{/translate}}</h2>
1111
<ul class="list-unstyled">
1212
{{#authors}}
1313
<li>
14-
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{orcid}}}
14+
<p><strong>{{{name}}}</strong>. {{{roles}}}. {{{uniqueid}}}
1515
{{#comment}}<br /><small>{{{.}}}</small>{{/comment}}</p>
1616
</li>
1717
{{/authors}}

man/deploy_site_github.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/deploy_to_branch.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/init_site.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/pkgdown-package.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)