Skip to content

Commit 5af661d

Browse files
authored
Merge pull request UofTCoders#1 from lwjohnst86/SaraMati-gh-pages
Fix problems in announcements.
2 parents 94784e8 + 6b20588 commit 5af661d

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ ByteCompile: true
88
Imports:
99
yaml,
1010
here,
11-
tidyverse,
11+
purrr,
12+
dplyr,
13+
stringr,
1214
lubridate,
1315
glue,
1416
fs,

scripts/announcements.R

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020

2121
if (!require(devtools)) install.packages("devtools")
2222
devtools::install_dev_deps()
23-
library(tidyverse)
23+
library(stringr)
24+
library(dplyr)
25+
library(purrr)
2426
library(lubridate)
2527
library(glue)
2628
library(assertr)
@@ -30,7 +32,7 @@ library(yaml)
3032

3133
session_details <-
3234
yaml.load_file(here::here("_data", "events.yml")) %>%
33-
map_dfr(as.tibble) %>%
35+
map_dfr(as_tibble) %>%
3436
arrange(date) %>%
3537
# drop sessions that are not set (NA in date)
3638
filter(!is.na(date)) %>%
@@ -41,7 +43,7 @@ session_details <-
4143
location_url = na_if(location_url, ""),
4244
location_string = case_when(
4345
# if both location and url are included!is.na(location) &
44-
!is.na(location_url) ~ glue::glue("[{location}]({location_url})"),
46+
!is.na(location_url) ~ glue("[{location}]({location_url})"),
4547
# if only location is included!is.na(location) &
4648
is.na(location_url) ~ location,
4749
# if neither location nor url are included
@@ -50,7 +52,7 @@ session_details <-
5052

5153
coffee_code_details <-
5254
yaml.load_file(here::here("_data", "coffee-code.yml")) %>%
53-
map_dfr(as.tibble) %>%
55+
map_dfr(as_tibble) %>%
5456
arrange(date) %>%
5557
# drop sessions that are not set (NA in date)
5658
filter(!is.na(date)) %>%
@@ -87,6 +89,13 @@ new_coffee_code <- keep_only_new(coffee_code_details)
8789
# Create files in _posts/ -------------------------------------------------
8890
# Adds the new sessions/events to the _posts folder.
8991

92+
# Format as eg August 23
93+
day_month <- function(.date, add_name = TRUE) {
94+
date_format <- "%B %e" # as August 23
95+
if (add_name) date_format <- "%A, %B %e" # as Monday, August 23
96+
trimws(format(as.Date(.date), format = date_format))
97+
}
98+
9099
create_new_posts_with_content <- function(.data) {
91100
new_post_filenames <-
92101
glue_data(.data, "{here::here('_posts')}/{date}-{key}.md")
@@ -124,17 +133,12 @@ create_new_posts_with_content <- function(.data) {
124133
create_new_posts_with_content(new_sessions)
125134
create_new_posts_with_content(new_coffee_code)
126135

127-
128-
129-
130-
131136
# Create a GitHub Issue of the session ------------------------------------
132137

133138
post_gh_issue <- function(title, body, labels) {
134139
# Will need to set up a GitHub PAT via (I think) the function
135140
# devtools::github_pat() in the console.
136-
# devtools:::rule("Posting GitHub Issues")
137-
cat("Posting `", title, "`\n\n")
141+
cat("\n\nPosting `", title, "`\n\n")
138142
if (!devtools:::yesno("Are you sure you want to post this event as an Issue?")) {
139143
gh::gh(
140144
"POST /repos/:owner/:repo/issues",
@@ -152,13 +156,6 @@ post_gh_issue <- function(title, body, labels) {
152156
}
153157
}
154158

155-
# Format as eg August 23
156-
day_month <- function(.date, add_name = TRUE) {
157-
date_format <- "%B %e" # as August 23
158-
if (add_name) date_format <- "%A, %B %e" # as Monday, August 23
159-
trimws(format(as.Date(.date), format = date_format))
160-
}
161-
162159
gh_issue_info_event <- function(.data) {
163160
content <- .data %>%
164161
mutate(needs_packages = ifelse(
@@ -214,7 +211,6 @@ gh_issue_info_coffee_code <- function(.data) {
214211
select(title, content, gh_labels)
215212
}
216213

217-
218214
create_gh_issues_coffee_code <- function(.data) {
219215
.data %>%
220216
gh_issue_info_coffee_code() %>%
@@ -229,5 +225,3 @@ create_gh_issues_events <- function(.data) {
229225

230226
create_gh_issues_coffee_code(new_coffee_code)
231227
create_gh_issues_events(new_sessions)
232-
233-

0 commit comments

Comments
 (0)