Skip to content

Commit e2f99e5

Browse files
Move hyperlinks to config.R
1 parent 1b63f11 commit e2f99e5

11 files changed

+47
-26
lines changed

R/codecheck.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ create_zenodo_record <- function(zen) {
286286
this_doi = myrec$metadata$prereserve_doi$doi
287287
cat("The following URL is your Zenodo DOI.\n")
288288
cat("Please add this to codecheck.yml in report: field\n")
289-
print(paste0("https://doi.org/", this_doi))
289+
print(paste0(CONFIG$HYPERLINKS[["doi"]], this_doi))
290290
cat("Remember to reload the yaml file after editing it.\n")
291291
get_zenodo_record(this_doi)
292292
}
@@ -351,7 +351,8 @@ set_zenodo_metadata <- function(zen, record, metadata) {
351351
draft$addRelatedIdentifier(relation = "isSupplementTo", identifier = metadata$paper$reference)
352352

353353
draft <- zen$depositRecord(draft)
354-
cat(paste0("Check your record online at https://zenodo.org/deposit/",
354+
cat(paste0("Check your record online at",
355+
CONFIG$HYPERLINKS[["zenodo_deposit"]],
355356
record,
356357
"\n"))
357358
}

R/configuration.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ get_codecheck_yml_osf <- function(x) {
7878
#' @importFrom httr GET content
7979
#' @importFrom yaml yaml.load
8080
get_codecheck_yml_gitlab <- function(x) {
81-
response <- httr::GET(paste0("https://gitlab.com/", x, "/-/raw/main/codecheck.yml?inline=false"))
81+
response <- httr::GET(paste0(CONFIG$HYPERLINKS[["gitlab"]], x, "/-/raw/main/codecheck.yml?inline=false"))
8282

8383
if (response$status == 200) {
8484
content <- httr::content(response, as = "text", encoding = "UTF-8")

R/utils_preprocess_register.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ add_issue_number_links <- function(register_table, register) {
4747
paste0(
4848
"[",
4949
issue_id,
50-
"](https://github.com/codecheckers/register/issues/",
50+
"](",
51+
CONFIG$HYPERLINKS[["codecheck_issue"]],
5152
issue_id, ")"
5253
)
5354
} else {

R/utils_register_check.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ check_issue_status <- function(entry) {
3939
)
4040
if (issue$state != "closed") {
4141
warning(
42-
entry$Certificate, " issue is still open: ",
43-
"<https://github.com/codecheckers/register/issues/",
42+
entry$Certificate, " issue is still open: <",
43+
CONFIG$HYPERLINKS[["codecheck_issue"]],
4444
entry$Issue, ">"
4545
)
4646
}

R/utils_render_register_htmls.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ add_repository_links_html <- function(register_table) {
77
X = register_table$Repository,
88
FUN = function(repository) {
99
spec <- parse_repository_spec(repository)
10+
# ! Needs refactoring
1011
if (!any(is.na(spec))) {
1112
urrl <- "#"
1213
if (spec[["type"]] == "github") {
13-
urrl <- paste0("https://github.com/", spec[["repo"]])
14+
urrl <- paste0(CONFIG$HYPERLINKS[["github"]], spec[["repo"]])
1415
paste0("<i class='fa fa-github'></i>&nbsp;[", spec[["repo"]], "](", urrl, ")")
1516
} else if (spec[["type"]] == "osf") {
16-
urrl <- paste0("https://osf.io/", spec[["repo"]])
17+
urrl <- paste0(CONFIG$HYPERLINKS[["osf"]], spec[["repo"]])
1718
paste0("<i class='ai ai-osf'></i>&nbsp;[", spec[["repo"]], "](", urrl, ")")
1819
} else if (spec[["type"]] == "gitlab") {
19-
urrl <- paste0("https://gitlab.com/", spec[["repo"]])
20+
urrl <- paste0(CONFIG$HYPERLINKS[["gitlab"]], spec[["repo"]])
2021
paste0("<i class='fa fa-gitlab'></i>&nbsp;[", spec[["repo"]], "](", urrl, ")")
2122
} else {
2223
repository

R/utils_render_register_json.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ add_repository_links_json <- function(register_table) {
66
register_table$`Repository Link` <- sapply(
77
X = register_table$Repository,
88
FUN = function(repository) {
9+
# ! Needs refactoring
910
spec <- parse_repository_spec(repository)
1011
if (spec[["type"]] == "github") {
11-
paste0("https://github.com/", spec[["repo"]])
12+
paste0(CONFIG$HYPERLINKS[["github"]], spec[["repo"]])
1213
} else if (spec[["type"]] == "osf") {
13-
paste0("https://osf.io/", spec[["repo"]])
14+
paste0(CONFIG$HYPERLINKS[["osf"]], spec[["repo"]])
1415
} else if (spec[["type"]] == "gitlab") {
15-
paste0("https://gitlab.com/", spec[["repo"]])
16+
paste0(CONFIG$HYPERLINKS[["gitlab"]], spec[["repo"]])
1617
} else {
1718
repository
1819
}

R/utils_render_register_mds.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ add_repository_links_md <- function(register_table) {
3434
spec <- parse_repository_spec(repository)
3535
if (!any(is.na(spec))) {
3636
urrl <- "#"
37-
37+
# ! Needs refactoring
3838
switch(spec["type"],
3939
"github" = {
40-
urrl <- paste0("https://github.com/", spec[["repo"]])
40+
urrl <- paste0(CONFIG$HYPERLINKS[["github"]], spec[["repo"]])
4141
paste0("[", spec[["repo"]], "](", urrl, ")")
4242
},
4343
"osf" = {
44-
urrl <- paste0("https://osf.io/", spec[["repo"]])
44+
urrl <- paste0(CONFIG$HYPERLINKS[["osf"]], spec[["repo"]])
4545
paste0("[", spec[["repo"]], "](", urrl, ")")
4646
},
4747
"gitlab" = {
48-
urrl <- paste0("https://gitlab.com/", spec[["repo"]])
48+
urrl <- paste0(CONFIG$HYPERLINKS[["gitlab"]], spec[["repo"]])
4949
paste0("[", spec[["repo"]], "](", urrl, ")")
5050
},
5151

R/utils_render_table_codecheckers.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,22 @@ add_all_codecheckers_hyperlink <- function(table){
6161
# Generate codechecker table hyperlink
6262
!!col_names[["codechecker_name"]] := paste0(
6363
"[", !!sym(col_names[["codechecker_name"]]),
64-
"](https://codecheck.org.uk/register/codecheckers/",
64+
"](", CONFIG$HYPERLINKS[["codecheckers"]],
6565
!!sym(col_names[["Codechecker"]]), "/)"
6666
),
6767

6868

6969
# Generate no. of codechecks hyperlink
7070
!!col_names[["no_codechecks"]] := paste0(
7171
!!sym(col_names[["no_codechecks"]]),
72-
" [(see all checks)](https://codecheck.org.uk/register/codecheckers/",
72+
" [(see all checks)](", CONFIG$HYPERLINKS[["codecheckers"]],
7373
!!sym(col_names[["Codechecker"]]), "/)"
7474
),
7575

7676
# Generate ORCID ID hyperlink
7777
!!col_names[["Codechecker"]] := paste0(
78-
"[", !!sym(col_names[["Codechecker"]]), "](https://orcid.org/",
78+
"[", !!sym(col_names[["Codechecker"]]), "](",
79+
CONFIG$HYPERLINKS[["orcid"]],
7980
!!sym(col_names[["Codechecker"]]), ")"
8081
)
8182
)

R/utils_render_table_non_registers.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ generate_html_postfix_hrefs_non_reg <- function(filter, table_details){
8787
if ("subcat" %in% names(table_details)){
8888
subcat <- table_details[["subcat"]]
8989
hrefs <- list(
90-
json_href = paste0("https://codecheck.org.uk/register/", filter, "/", subcat,"/index.json")
90+
json_href = paste0(CONFIG$HYPERLINKS[["register"]], filter, "/", subcat,"/index.json")
9191
)
9292
}
9393

9494
# Case with subcat
9595
else{
9696
hrefs <- list(
97-
json_href = paste0("https://codecheck.org.uk/register/", filter, "/index.json")
97+
json_href = paste0(CONFIG$HYPERLINKS[["register"]], filter, "/index.json")
9898
)
9999
}
100100

R/utils_render_table_venues.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,24 @@ add_all_venues_hyperlink <- function(table){
9393
# Generate venue name hyperlink
9494
!!col_names[["Venue"]] := paste0(
9595
"[", !!sym(col_names[["Venue"]]), "](",
96-
"https://codecheck.org.uk/register/venues/",
96+
CONFIG$HYPERLINKS[["venues"]],
9797
!!sym(col_names[["Type"]]), "/",
9898
venue_slug, "/)"
9999
),
100100

101101
# Generate no. of codechecks hyperlink
102102
!!col_names[["no_codechecks"]] := paste0(
103103
!!sym(col_names[["no_codechecks"]]),
104-
" [(see all checks)](https://codecheck.org.uk/register/venues/",
104+
" [(see all checks)](",
105+
CONFIG$HYPERLINKS[["venues"]],
105106
!!sym(col_names[["Type"]]), "/",
106107
venue_slug, "/)"
107108
),
108109

109110
# Generate venue type hyperlink
110111
!!col_names[["Type"]] := paste0(
111112
"[", stringr::str_to_title(!!sym(col_names[["Type"]])),
112-
"](https://codecheck.org.uk/register/venues/",
113+
"](", CONFIG$HYPERLINKS[["venues"]],
113114
!!sym(col_names[["Type"]]), "/)"
114115
)
115116
)
@@ -193,15 +194,16 @@ add_venue_type_hyperlink <- function(table, venue_type) {
193194
mutate(
194195
!!sym(venue_col_name) := paste0(
195196
"[", !!sym(venue_col_name), "](",
196-
"https://codecheck.org.uk/register/venues/",
197+
CONFIG$HYPERLINKS[["venues"]],
197198
venue_type, "/",
198199
venue_slug, "/)"
199200
),
200201

201202
# Generate no. of codechecks hyperlink
202203
!!sym(table_col_names[["no_codechecks"]]) := paste0(
203204
!!sym(table_col_names[["no_codechecks"]]),
204-
" [(see all checks)](https://codecheck.org.uk/register/venues/",
205+
" [(see all checks)](",
206+
CONFIG$HYPERLINKS[["venues"]],
205207
venue_type, "/",
206208
venue_slug, "/)"
207209
)

0 commit comments

Comments
 (0)