-
Notifications
You must be signed in to change notification settings - Fork 0
/
cadGallery.Rmd
34 lines (27 loc) · 1.33 KB
/
cadGallery.Rmd
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
---
title: Gallery of Shareable Designs
---
## Technical Drawings
Click on a thumbnail to go to the full PDF.
```{r cadArray, echo=F, out.width = '33%'}
# grab the pathnames of the PDFs
cadNames <- list.files(path='img', pattern= '*.pdf', full.names=T, ignore.case=T)
cadNames <- gsub(" ", "%20", cadNames) # URL-escape spaces
# form the PDF pathnames into the corresponding thumbnail pathnames
cadNames_b <- basename(cadNames)
cadNames_bne <- sub(".pdf$", "", cadNames_b, perl=T, ignore.case=T)
thumbNames <- paste("img/thumbnail/", cadNames_bne, ".png", sep='')
# form linked thumbnails like: <a href="drawingPathname"><img src="thumbnailPathname" width="33%"></a>
# I do it this way because I really want to get more than one thumbnail on a line.
# AFAICT, Markdown doesn't have a way to specify image width. HTML does though.
links <- paste( '<a href=', cadNames, '><img src="', thumbNames, '" width="32%"></a>', sep='')
# Collapse that array of strings into a single string.
# This prevents pander from adding supurfluous commas and "and"s.
links <- paste(links, collapse='\n')
# display the linked thumbnails
pander::pander(links)
# This would be the way to do it in Markdown:
# output linked thumbnails like: [![](thumbnailPathname)](drawingPathname)
# links <- paste('[![](', thumbNames, ')](', cadNames, ') ', sep='')
# pander::pander(links)
```