-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathironviz_build_html.R
47 lines (35 loc) · 1.21 KB
/
ironviz_build_html.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Read submissions data
ironviz_df <- read.csv("data/ironviz_2020_twitter_submissions.csv", stringsAsFactors = F)
# randomise vizzes
ironviz_links <- sample(ironviz_df$img_and_tweet_link
,length(ironviz_df$img_and_tweet_link))
number_of_vizzes <- length(ironviz_df$img_and_tweet_link)
# Update html files
# Write list of images to a text file for now
fileConn <- file("html/img_list.txt")
writeLines(ironviz_links, fileConn)
close(fileConn)
blurb_temp_file <- file("html/blurb_template.txt")
blurb <- readLines(blurb_temp_file)
blurb <- gsub('NUM_OF_VIZZES',number_of_vizzes,blurb)
blurb_file <- file("html/blurb.txt")
writeLines(blurb, blurb_file)
close(blurb_file)
close(blurb_temp_file)
# create full html
header_file <- file("html/header.txt")
blurb_file <- file("html/blurb.txt")
images_file <- file("html/img_list.txt")
footer_file <- file("html/footer.txt")
header <- readLines(header_file)
blurb <- readLines(blurb_file)
images <- readLines(images_file)
footer <- readLines(footer_file)
full_html <- c(header,blurb,images,footer)
html_file <- file("gallery/ironviz.html")
writeLines(full_html, html_file)
close(html_file)
close(header_file)
close(blurb_file)
close(images_file)
close(footer_file)