0

So I have currently made several different monthly calendars. Here is one for example. Calendar_1858_9.png They range from the years of 1858 to 1944 all with every individual month in a year. What I also have is several different HTML files with titles like 18580907-18580908-website.html where 1858-09-07 is the start year-month-day and 1858-09-08 is the end year-month-day. The contents of the HTML files are not relevant as those work and are not an issue. The issue I am facing and trying to accomplish is to make the PNG calendars I have created correctly associate with the HTML files.

So the question I am asking is whether there is a way to script the calendar PNGs to image map the files to their correct days. Basically, I am trying to image map the files so that if you were to click on a particular day of a calendar, it will open the file associated with that. And as mentioned, each file does have the appropriate start/end dates in the file name. With that being said, I honestly have no clue how to go about scripting it since every monthly calendar will be different, but if anyone has an idea on how to go about doing it, it would be greatly appreciated!

Obviously measuring the size of a day on the calendar would be the start as all the boxes in the calendar have the same size. So doing something like

fnames_html <- str_subset(files, "html")
# coords <-   # Get the coordinates 

cat('<map name="calendar">', "\n")

for(i in 1:length(fnames_html)) {

  cat(paste0('<area shape="rect" coords=', coords[i], 'href="', fnames_html[i], '">'), "\n")

}

cat('</map>')


> fnames_html[1:10]
 [1] "18580907-18580908-website.html" "18580908-18580909-website.html" "18580910-18580911-website.html"
 [4] "18580913-18580914-website.html" "18580914-18580915-website.html" "18580915-18580916-website.html"
 [7] "18580916-18580917-website.html" "18580917-18580918-website.html" "18580920-18580921-website.html"
[10] "18580921-18580922-website.html"

after getting the coordinates is the way to go about it, but I don't know how to script the coordinates in without manually hard coding each one (but that's not feasible as there are thousands of HTML files).

  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Jul 30 '21 at 22:55
  • I included some sample code there though. Would you like me to include the code on how to make the calendar as well? – Nathan Drake Aug 02 '21 at 15:01
  • I also included edited what fnames_html's first 10 elements are to give an idea of what it looks like. – Nathan Drake Aug 02 '21 at 15:03

0 Answers0