From dafbaf6c602809fb6f513b4c4ac348b4ba2cbf79 Mon Sep 17 00:00:00 2001 From: Nick Uhorchak Date: Fri, 29 May 2020 14:30:14 -0400 Subject: [PATCH 1/7] removed first forward slash to test for linux compatability --- R/dscoemarkdown_function.R | 20 ++++++++++---------- dscoemarkdown.Rproj | 5 +++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/R/dscoemarkdown_function.R b/R/dscoemarkdown_function.R index 495ef29..1415143 100644 --- a/R/dscoemarkdown_function.R +++ b/R/dscoemarkdown_function.R @@ -1,26 +1,26 @@ #' Run Markdown #' -#' +#' #' #' @export -#' -#' +#' +#' dscoe <- function(logo=TRUE, disclaimer=TRUE) { system <- system.file('',package='dscoemarkdown') - + if(disclaimer == TRUE){ - footer <- paste(system,'/style/disclaimer.html',sep='') + footer <- paste(system,'style/disclaimer.html',sep='') } else if(disclaimer == FALSE){ - footer <- paste(system,'/style/noDisclaimer.html',sep='') + footer <- paste(system,'style/noDisclaimer.html',sep='') } - + if(logo == TRUE){ - css <- paste(system,'/style/dscoemarkdownLogo.css',sep='') + css <- paste(system,'style/dscoemarkdownLogo.css',sep='') } else if(logo == FALSE){ - css <- paste(system,'/style/dscoemarkdownNoLogo.css',sep='') + css <- paste(system,'style/dscoemarkdownNoLogo.css',sep='') } - + rmarkdown::html_document(css=css, includes=rmarkdown::includes(after_body=footer)) } diff --git a/dscoemarkdown.Rproj b/dscoemarkdown.Rproj index d848a9f..cba1b6b 100644 --- a/dscoemarkdown.Rproj +++ b/dscoemarkdown.Rproj @@ -5,8 +5,13 @@ SaveWorkspace: No AlwaysSaveHistory: Default EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 Encoding: UTF-8 +RnwWeave: Sweave +LaTeX: pdfLaTeX + AutoAppendNewline: Yes StripTrailingWhitespace: Yes From 6360ed448dc81bc57c58915cbb3ffc66d2e9d13b Mon Sep 17 00:00:00 2001 From: Nick Uhorchak Date: Fri, 29 May 2020 14:45:48 -0400 Subject: [PATCH 2/7] messing with the .css --- inst/style/dscoeMarkdownLogo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/style/dscoeMarkdownLogo.css b/inst/style/dscoeMarkdownLogo.css index ac74487..4acb630 100644 --- a/inst/style/dscoeMarkdownLogo.css +++ b/inst/style/dscoeMarkdownLogo.css @@ -1,5 +1,5 @@ body { - background-image: url(logo-png.png); + background-image: url('logo-png.png'); background-repeat: no-repeat; background-position: 85% 60px; margin-bottom: 50px; From e50943c1ee5d6ae49a2c7e3038b802af36372eaf Mon Sep 17 00:00:00 2001 From: Nick Uhorchak Date: Fri, 29 May 2020 14:51:27 -0400 Subject: [PATCH 3/7] undo last fix --- inst/style/dscoeMarkdownLogo.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/style/dscoeMarkdownLogo.css b/inst/style/dscoeMarkdownLogo.css index 4acb630..ac74487 100644 --- a/inst/style/dscoeMarkdownLogo.css +++ b/inst/style/dscoeMarkdownLogo.css @@ -1,5 +1,5 @@ body { - background-image: url('logo-png.png'); + background-image: url(logo-png.png); background-repeat: no-repeat; background-position: 85% 60px; margin-bottom: 50px; From cf6feb87874dfd46f8ce1ad740d0de862b9dea97 Mon Sep 17 00:00:00 2001 From: Nick Uhorchak Date: Fri, 29 May 2020 15:10:07 -0400 Subject: [PATCH 4/7] changed relative path of css files --- R/dscoemarkdown_function.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/dscoemarkdown_function.R b/R/dscoemarkdown_function.R index 1415143..5ea48e7 100644 --- a/R/dscoemarkdown_function.R +++ b/R/dscoemarkdown_function.R @@ -10,15 +10,15 @@ dscoe <- function(logo=TRUE, disclaimer=TRUE) { system <- system.file('',package='dscoemarkdown') if(disclaimer == TRUE){ - footer <- paste(system,'style/disclaimer.html',sep='') + footer <- paste(system,'inst/style/disclaimer.html',sep='') } else if(disclaimer == FALSE){ - footer <- paste(system,'style/noDisclaimer.html',sep='') + footer <- paste(system,'inst/style/noDisclaimer.html',sep='') } if(logo == TRUE){ - css <- paste(system,'style/dscoemarkdownLogo.css',sep='') + css <- paste(system,'inst/style/dscoemarkdownLogo.css',sep='') } else if(logo == FALSE){ - css <- paste(system,'style/dscoemarkdownNoLogo.css',sep='') + css <- paste(system,'inst/style/dscoemarkdownNoLogo.css',sep='') } rmarkdown::html_document(css=css, includes=rmarkdown::includes(after_body=footer)) From 6b2d7800d93f336653a65d0d33165383d314d058 Mon Sep 17 00:00:00 2001 From: Nick Uhorchak Date: Mon, 1 Jun 2020 16:44:07 -0400 Subject: [PATCH 5/7] modified package --- .gitignore | 2 + DESCRIPTION | 8 +- R/dscoemarkdown_function.R | 31 +++++-- README.md | 9 +- dscoemarkdown.Rproj => dscoemarkdown2.Rproj | 5 +- inst/{style => }/disclaimer.html | 0 .../dscoeMarkdownExample.png | Bin inst/{style => }/dscoeMarkdownLogo.css | 0 inst/{style => }/dscoeMarkdownNoLogo.css | 0 inst/{style => }/logo-png.png | Bin inst/{style => }/noDisclaimer.html | 0 man/dscoe.Rd | 29 +++++- vignettes/.gitignore | 2 + vignettes/DSCOE-Markdown.Rmd | 83 ++++++++++++++++++ 14 files changed, 146 insertions(+), 23 deletions(-) rename dscoemarkdown.Rproj => dscoemarkdown2.Rproj (79%) rename inst/{style => }/disclaimer.html (100%) rename dscoeMarkdownExample.png => inst/dscoeMarkdownExample.png (100%) rename inst/{style => }/dscoeMarkdownLogo.css (100%) rename inst/{style => }/dscoeMarkdownNoLogo.css (100%) rename inst/{style => }/logo-png.png (100%) rename inst/{style => }/noDisclaimer.html (100%) create mode 100644 vignettes/.gitignore create mode 100644 vignettes/DSCOE-Markdown.Rmd diff --git a/.gitignore b/.gitignore index 807ea25..d71de39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +inst/doc .Rproj.user .Rhistory .RData +.txt \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 1d7dbc7..4c67383 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,16 @@ Package: dscoemarkdown Title: R Markdown for DSCOE Submissions -Version: 0.0.0.9000 +Version: 0.0.1.0 Authors@R: person("Ian", "Kloo", email = "ian.p.kloo.civ@mail.mil", role = c("aut", "cre")) Description: Create R Markdown documents in the prefered format for the DSCOE website. Depends: - R (>= 2.0.0) + R (>= 3.5.0) License: None Encoding: UTF-8 LazyData: true -RoxygenNote: 5.0.1 +RoxygenNote: 7.1.0 Imports: knitr, rmarkdown +VignetteBuilder: knitr + diff --git a/R/dscoemarkdown_function.R b/R/dscoemarkdown_function.R index 5ea48e7..da8da90 100644 --- a/R/dscoemarkdown_function.R +++ b/R/dscoemarkdown_function.R @@ -1,24 +1,43 @@ -#' Run Markdown +#' @title Generate DSCOE markdown #' +#' @description Apply css and footer and build a DSCOE formatted markdown document #' +#' @param logo a boolean representing whether or not to inclue the DSCOE logo +#' @param disclaimer a boolean representing whether or not to include the disclaimer footer #' -#' @export +#' @examples +#' --- +#' #title: "Demo Header" +#' #author: "Ian Kloo" +#' #date: "September 2016" +#' #output: dscoemarkdown::dscoe +#' --- #' +#' --- +#' #title: "Demo Header" +#' #author: "Ian Kloo" +#' #date: "September 2016" +#' #output: +#' # dscoemarkdown::dscoe: +#' # logo: FALSE +#' # disclaimer: FALSE +#' --- #' +#' @export dscoe <- function(logo=TRUE, disclaimer=TRUE) { system <- system.file('',package='dscoemarkdown') if(disclaimer == TRUE){ - footer <- paste(system,'inst/style/disclaimer.html',sep='') + footer <- paste(system,'./inst/disclaimer.html',sep='') } else if(disclaimer == FALSE){ - footer <- paste(system,'inst/style/noDisclaimer.html',sep='') + footer <- paste(system,'./inst/noDisclaimer.html',sep='') } if(logo == TRUE){ - css <- paste(system,'inst/style/dscoemarkdownLogo.css',sep='') + css <- paste(system,'./inst/dscoemarkdownLogo.css',sep='') } else if(logo == FALSE){ - css <- paste(system,'inst/style/dscoemarkdownNoLogo.css',sep='') + css <- paste(system,'./inst/dscoemarkdownNoLogo.css',sep='') } rmarkdown::html_document(css=css, includes=rmarkdown::includes(after_body=footer)) diff --git a/README.md b/README.md index 7cc20df..2856636 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,6 @@ require(devtools) devtools::install_github("iankloo/dscoemarkdown") ``` -***There is a known issue with linux users. Until I can get a more elgant fix, you can use the following lines to install the package on linux: - -```{r} -require(devtools) -devtools::install_github("iankloo/dscoemarkdown", ref = 'linux') -``` - If that goes smoothly, you can now include this line in the header of your R Markdown Documents: ```{r} @@ -67,5 +60,5 @@ As it stands, the styling in this package is very basic. If you want to propose ## Example -![alt tag](https://github.com/iankloo/dscoemarkdown/blob/master/dscoeMarkdownExample.png) +![alt tag](./inst/dscoeMarkdownExample.png) diff --git a/dscoemarkdown.Rproj b/dscoemarkdown2.Rproj similarity index 79% rename from dscoemarkdown.Rproj rename to dscoemarkdown2.Rproj index cba1b6b..497f8bf 100644 --- a/dscoemarkdown.Rproj +++ b/dscoemarkdown2.Rproj @@ -1,7 +1,7 @@ Version: 1.0 -RestoreWorkspace: No -SaveWorkspace: No +RestoreWorkspace: Default +SaveWorkspace: Default AlwaysSaveHistory: Default EnableCodeIndexing: Yes @@ -18,4 +18,3 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace diff --git a/inst/style/disclaimer.html b/inst/disclaimer.html similarity index 100% rename from inst/style/disclaimer.html rename to inst/disclaimer.html diff --git a/dscoeMarkdownExample.png b/inst/dscoeMarkdownExample.png similarity index 100% rename from dscoeMarkdownExample.png rename to inst/dscoeMarkdownExample.png diff --git a/inst/style/dscoeMarkdownLogo.css b/inst/dscoeMarkdownLogo.css similarity index 100% rename from inst/style/dscoeMarkdownLogo.css rename to inst/dscoeMarkdownLogo.css diff --git a/inst/style/dscoeMarkdownNoLogo.css b/inst/dscoeMarkdownNoLogo.css similarity index 100% rename from inst/style/dscoeMarkdownNoLogo.css rename to inst/dscoeMarkdownNoLogo.css diff --git a/inst/style/logo-png.png b/inst/logo-png.png similarity index 100% rename from inst/style/logo-png.png rename to inst/logo-png.png diff --git a/inst/style/noDisclaimer.html b/inst/noDisclaimer.html similarity index 100% rename from inst/style/noDisclaimer.html rename to inst/noDisclaimer.html diff --git a/man/dscoe.Rd b/man/dscoe.Rd index f8dcfb1..87d05b4 100644 --- a/man/dscoe.Rd +++ b/man/dscoe.Rd @@ -2,11 +2,34 @@ % Please edit documentation in R/dscoemarkdown_function.R \name{dscoe} \alias{dscoe} -\title{Run Markdown} +\title{Generate DSCOE markdown} \usage{ -dscoe() +dscoe(logo = TRUE, disclaimer = TRUE) +} +\arguments{ +\item{logo}{a boolean representing whether or not to inclue the DSCOE logo} + +\item{disclaimer}{a boolean representing whether or not to include the disclaimer footer} } \description{ -Run Markdown +Apply css and footer and build a DSCOE formatted markdown document } +\examples{ +--- +#title: "Demo Header" +#author: "Ian Kloo" +#date: "September 2016" +#output: dscoemarkdown::dscoe +--- +--- +#title: "Demo Header" +#author: "Ian Kloo" +#date: "September 2016" +#output: + # dscoemarkdown::dscoe: + # logo: FALSE + # disclaimer: FALSE +--- + +} diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/DSCOE-Markdown.Rmd b/vignettes/DSCOE-Markdown.Rmd new file mode 100644 index 0000000..c1f1872 --- /dev/null +++ b/vignettes/DSCOE-Markdown.Rmd @@ -0,0 +1,83 @@ +--- +title: "DSCOE-Markdown" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{DSCOE-Markdown} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup} +library(dscoemarkdown) +``` + +# DSCOE Markdown Package + +This package was created for DSCOE products in order to unify formatting. + +Using this package, you can extend knitr to automatically use the DSCOE format. + +## Usage + +You can install this package using the devtools github installer: + +```{r eval=FALSE} +require(devtools) +devtools::install_github("iankloo/dscoemarkdown") +``` + +If that goes smoothly, you can now include this line in the header of your R Markdown Documents: + +```{r eval=FALSE} +output: dscoemarkdown::dscoe +``` + +An example full header is: + +```{r eval=FALSE} +--- +title: "Demo Header" +author: "Ian Kloo" +date: "September 2016" +output: dscoemarkdown::dscoe +--- +``` + +## Styling + +The base styling comes from Edward Tufte's github page. Tufte is known for simple and readable aesthetics, so this was a good place to start. + +This styling is very simple, in that it does not require any javascript libraries (such as jQuery) to do the styling. These libraries make it much more difficult to share/post documents. You may still need to include javascript libraries as part of your work, but at least there won't be any additional libraries needed for styling alone. + +## Options + +You have the option to remove the DSCOE logo and/or the disclaimer. We ask that you leave these on for DSCOE posts, but if you want to use the framework elsewhere, please feel free to remove them. + +By default, both the logo and disclaimer are included. To change this you can specify options like this: + +```{r eval=FALSE} +--- +title: "DSCOE Markdown Example" +author: "Ian Kloo" +date: "September 2016" +output: + dscoemarkdown::dscoe: + logo: FALSE + disclaimer: FALSE +--- +``` + +## Development + +As it stands, the styling in this package is very basic. If you want to propose any changes, make an "issue" or clone the repo and push your own branch. + +## Example + +![alt tag](../inst/dscoeMarkdownExample.png) From 7445905c513249fe6da4a280cf405250326f86ba Mon Sep 17 00:00:00 2001 From: Nick Uhorchak Date: Mon, 1 Jun 2020 19:17:48 -0400 Subject: [PATCH 6/7] updated for OS --- R/dscoemarkdown_function.R | 38 +++++++++++++++++------ inst/{ => style}/disclaimer.html | 0 inst/{ => style}/dscoeMarkdownLogo.css | 0 inst/{ => style}/dscoeMarkdownNoLogo.css | 0 inst/{ => style}/logo-png.png | Bin inst/{ => style}/noDisclaimer.html | 0 6 files changed, 29 insertions(+), 9 deletions(-) rename inst/{ => style}/disclaimer.html (100%) rename inst/{ => style}/dscoeMarkdownLogo.css (100%) rename inst/{ => style}/dscoeMarkdownNoLogo.css (100%) rename inst/{ => style}/logo-png.png (100%) rename inst/{ => style}/noDisclaimer.html (100%) diff --git a/R/dscoemarkdown_function.R b/R/dscoemarkdown_function.R index da8da90..c4ebf0e 100644 --- a/R/dscoemarkdown_function.R +++ b/R/dscoemarkdown_function.R @@ -28,18 +28,38 @@ dscoe <- function(logo=TRUE, disclaimer=TRUE) { system <- system.file('',package='dscoemarkdown') - if(disclaimer == TRUE){ - footer <- paste(system,'./inst/disclaimer.html',sep='') - } else if(disclaimer == FALSE){ - footer <- paste(system,'./inst/noDisclaimer.html',sep='') - } + if(.Platform$OS.type == 'windows'){ + + if(disclaimer == TRUE){ + footer <- paste(system,'/style/disclaimer.html',sep='') + } else if(disclaimer == FALSE){ + footer <- paste(system,'/style/noDisclaimer.html',sep='') + } + + if(logo == TRUE){ + css <- paste(system,'/style/dscoemarkdownLogo.css',sep='') + } else if(logo == FALSE){ + css <- paste(system,'/style/dscoemarkdownNoLogo.css',sep='') + } + + } else if (.Platform$OS.type == "unix") { + + if(disclaimer == TRUE){ + footer <- paste(system,'inst/disclaimer.html',sep='') + } else if(disclaimer == FALSE){ + footer <- paste(system,'inst/noDisclaimer.html',sep='') + } + + if(logo == TRUE){ + css <- paste(system,'inst/dscoeMarkdownLogo.css',sep='') + } else if(logo == FALSE){ + css <- paste(system,'inst/dscoeMarkdownNoLogo.css',sep='') + } - if(logo == TRUE){ - css <- paste(system,'./inst/dscoemarkdownLogo.css',sep='') - } else if(logo == FALSE){ - css <- paste(system,'./inst/dscoemarkdownNoLogo.css',sep='') } + + rmarkdown::html_document(css=css, includes=rmarkdown::includes(after_body=footer)) } diff --git a/inst/disclaimer.html b/inst/style/disclaimer.html similarity index 100% rename from inst/disclaimer.html rename to inst/style/disclaimer.html diff --git a/inst/dscoeMarkdownLogo.css b/inst/style/dscoeMarkdownLogo.css similarity index 100% rename from inst/dscoeMarkdownLogo.css rename to inst/style/dscoeMarkdownLogo.css diff --git a/inst/dscoeMarkdownNoLogo.css b/inst/style/dscoeMarkdownNoLogo.css similarity index 100% rename from inst/dscoeMarkdownNoLogo.css rename to inst/style/dscoeMarkdownNoLogo.css diff --git a/inst/logo-png.png b/inst/style/logo-png.png similarity index 100% rename from inst/logo-png.png rename to inst/style/logo-png.png diff --git a/inst/noDisclaimer.html b/inst/style/noDisclaimer.html similarity index 100% rename from inst/noDisclaimer.html rename to inst/style/noDisclaimer.html From d6f2071dd95ad8534dc58964492ee616bcb381d5 Mon Sep 17 00:00:00 2001 From: Nick Uhorchak Date: Mon, 1 Jun 2020 19:23:56 -0400 Subject: [PATCH 7/7] fixed linux file path error --- R/dscoemarkdown_function.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/dscoemarkdown_function.R b/R/dscoemarkdown_function.R index c4ebf0e..28b3e15 100644 --- a/R/dscoemarkdown_function.R +++ b/R/dscoemarkdown_function.R @@ -45,15 +45,15 @@ dscoe <- function(logo=TRUE, disclaimer=TRUE) { } else if (.Platform$OS.type == "unix") { if(disclaimer == TRUE){ - footer <- paste(system,'inst/disclaimer.html',sep='') + footer <- paste(system,'style/disclaimer.html',sep='') } else if(disclaimer == FALSE){ - footer <- paste(system,'inst/noDisclaimer.html',sep='') + footer <- paste(system,'style/noDisclaimer.html',sep='') } if(logo == TRUE){ - css <- paste(system,'inst/dscoeMarkdownLogo.css',sep='') + css <- paste(system,'style/dscoeMarkdownLogo.css',sep='') } else if(logo == FALSE){ - css <- paste(system,'inst/dscoeMarkdownNoLogo.css',sep='') + css <- paste(system,'style/dscoeMarkdownNoLogo.css',sep='') } }