Skip to content

Commit

Permalink
Merge pull request #91 from JosephBARBIERDARNAL/path-issues
Browse files Browse the repository at this point in the history
fix path issues
  • Loading branch information
dgkeyes authored Dec 20, 2024
2 parents 0d75a85 + 40de914 commit b2133bb
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 42 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ inst/rmarkdown/templates/word_report/skeleton/~$eleton.docx
.Rprofile
test.Rmd
test.html
temp.*
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Author: c( person("Thomas", "Vroylandt", email =
Maintainer: Thomas Vroylandt <thomas@rfortherestofus.com>
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(omni_html_slidy)
export(omni_pdf_memo)
export(omni_pdf_report)
export(omni_pdf_report_new)
export(omni_rmarkdown)
export(omni_table)
export(omni_word_report)
export(omni_word_report_new)
Expand Down
46 changes: 33 additions & 13 deletions R/omni_formats.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,31 @@ omni_pdf_memo <-

# change CSS variables
if (!is.null(main_font)) {
main_font_css <- paste0("--main-font: ", main_font , ";")
} else{
main_font_css <- paste0("--main-font: ", main_font, ";")
} else {
main_font_css <- ""
}

if (!is.null(header_font)) {
header_font_css <- paste0("--header-font: ", header_font , ";")
} else{
header_font_css <- paste0("--header-font: ", header_font, ";")
} else {
header_font_css <- ""
}

if (!is.null(main_color)) {
main_color_css <- paste0("--main-color: ", main_color , ";")
} else{
main_color_css <- paste0("--main-color: ", main_color, ";")
} else {
main_color_css <- ""
}

additional_css <-
paste0(":root{",
main_font_css,
header_font_css,
main_color_css,
"}")
paste0(
":root{",
main_font_css,
header_font_css,
main_color_css,
"}"
)

# write tempfile
tempfile_name <- paste0(tempfile(), ".css")
Expand All @@ -103,7 +105,6 @@ omni_pdf_memo <-
css = c(css_style, tempfile_name),
...
)

}


Expand Down Expand Up @@ -140,7 +141,7 @@ omni_word_report <- function(number_sections = TRUE,
#' @export
#'
omni_word_report_new <- function(number_sections = TRUE,
...) {
...) {
# word template
word_template <-
pkg_resource("omni_word_report_new.docx")
Expand Down Expand Up @@ -226,3 +227,22 @@ omni_html_slidy <- function(hypothesis = FALSE, ...) {
...
)
}

#' Omni HTML Rmarkdown template
#'
#' @name omni_rmarkdown
#' @param ... Other params to rmarkdown::html_document
#'
#' @return An rmd format
#' @export
#'
omni_rmarkdown <- function(...) {
template <- pkg_resource("rmarkdown_template.html")
css <- pkg_resource("omni_rmarkdown.css")

rmarkdown::html_document(
template = template,
css = css,
...
)
}
110 changes: 110 additions & 0 deletions inst/assets/rmarkdown_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<html>
<head>
<title>$title$</title>
<style>
:root {
--black-color: black;
--main-font: "Calibri", sans-serif;
--base-font-size: 18px;
}

body {
font-family: var(--main-font);
font-size: var(--base-font-size);
margin: 0;
padding: 0;
}

h1,
h2,
h3 {
font-family: "Arial", sans-serif;
font-weight: bold;
color: var(--black-color);
}

h1 {
font-size: calc(15pt * 2);
}

h2 {
font-size: calc(14pt * 2);
}

h3 {
font-size: calc(13pt * 2);
}

#header {
background-color: #314160;
width: 100%;
padding: 40px 0;
position: relative;
border: 0;
}

.header-wrapper {
max-width: 940px;
margin: 0 auto;
padding: 0 20px;
}

.header-content {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}

.logo {
height: 40px;
width: auto;
}

.date {
font-family: var(--main-font);
font-size: 1.5em;
white-space: nowrap;
color: white;
}

.header-line {
height: 2px;
background-color: #7b7754;
/* margin: 15px 0; */
}

.title {
font-size: 2.5em;
color: white;
font-weight: bold;
font-family: var(--main-font);
text-align: left;
padding-top: 40px;
}

.content {
max-width: 940px;
margin: 0 auto;
}
</style>
</head>
<body>
<div id="header">
<div class="header-wrapper">
<div class="header-content">
<img
src="https://raw.githubusercontent.com/rfortherestofus/omni/refs/heads/main/inst/assets/logo/OMNI_Logo-White_Horizontal.png"
class="logo"
alt="Logo"
/>
<div class="date">$date$</div>
</div>
<div class="header-line"></div>
<div class="title">$title$</div>
</div>
</div>

<div class="content">$body$</div>
</body>
</html>
2 changes: 1 addition & 1 deletion inst/rmarkdown/templates/html_report/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Project title"
subtitle: "What you are doing"
author: "Who is doing it"
date: "`r Sys.Date()`"
date: "`r Sys.Date() |> format('%B %d, %Y')`"
output:
omni::omni_html_report:
hypothesis: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
title: "Here is where you write your title, and the aim of this document"
date: "`r Sys.Date() |> format('%B %d, %Y')`"
output:
html_document:
template: template.html
output: omni::omni_rmarkdown
---


Expand Down
24 changes: 0 additions & 24 deletions inst/rmarkdown/templates/html_rmarkdown/skeleton/template.html

This file was deleted.

17 changes: 17 additions & 0 deletions man/omni_rmarkdown.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b2133bb

Please sign in to comment.