aboutsummaryrefslogtreecommitdiff
path: root/structure/book/en/00-preamble.md
blob: cc6a3cbb313178dae24c0a57cff5ae85057f2754 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!-- Bookdown before-body file -->

<!-- Hack to generate a proper cover and fix the missing index.html file -->
<!-- See https://stackoverflow.com/questions/58340924/bookdown-generates-index-file-with-a-chapter-title-instead-of-index-html-when -->
<!-- See https://bookdown.org/yihui/rmarkdown-cookbook/document-metadata.html -->
```{r echo=FALSE, results='asis'}
if (knitr::is_html_output()) {
  cat('# Start {#index .unnumbered}')
  cat("\n")
  cat('<img src="images/cover.png">')
  cat("\n")
  cat("<h2>About</h2>")
  cat("\n")
  cat('<em>')
  cat(readLines('DISCLAIMER'), sep='\n')
  cat('</em>')
  cat('<br/><br/>')
  cat('Living Book - Version <strong><em>')
  cat(readLines('.metadata/revision.txt'), sep='\n')
  cat('</em></strong> - compiled at <strong><em>')
  cat(readLines('.metadata/date.txt'), sep='\n')
  cat('</em></strong>.')
  cat('<br/>')
  cat('Older versions available in the <a href="/archive">archive</a>.')
  cat('<br/>')
  cat('Notebook available <a href="/notes">here</a>.')
  cat('<br/><br/>')
  cat(readLines('snippets/project.txt'))
  cat(' - ')
  cat(readLines('snippets/volume.txt'))
  cat('<br/>')
  cat('Published by ')
  #cat(rmarkdown::metadata$publisher)
  cat(readLines('snippets/publisher.txt'))
  cat('<br/>')
  cat('Published at ')
  cat(readLines('snippets/url.txt'), sep='\n')
  cat('<br/><br/>')
  cat(readLines('snippets/keywords.txt'), sep='\n')
  cat("\n")
  cat("<h2>Credits</h2>")
  cat("\n")
  cat(paste(rmarkdown::metadata$title, "<br/>", "Copyleft &copy;", readLines('.metadata/year.txt'), rmarkdown::metadata$author, readLines('snippets/contact.txt'), sep=' '))
  cat('<br/><br/>')
  cat(readLines('LICENSE'), sep='\n')
  cat('<br/><br/>')
  cat(readLines('snippets/cover.txt'), sep='\n')
  cat("<h2>PDF version</h2>")
  cat("\n")
  cat('Download the PDF <a href="book.pdf">here</a>, or browse it below:')
  cat("\n")
  cat('<br/><br/>')
  cat('<embed src="book.pdf" width="100%" height="375" type="application/pdf">')
  cat('<br/><br/>')
}
```

<!-- Sample block for the LaTeX output -->
```{r echo=FALSE, results='asis'}
if (knitr::is_latex_output()) {
  # By default, it outputs nothing.
  # An empty code block would return the string 'NULL' to LaTeX, which would then be printed.
  cat('')
}
```