cfdc

CFDC Citation Generator

https://github.com/nutrientinstitute/cfdc

Science Score: 18.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (2.3%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

CFDC Citation Generator

Basic Info
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 3 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

Comprehensive Food Data Citation (CFDC): Citation Generator

This app is intended to create comprehensive citations for food and nutrient data sources.

The app is hosted on a Shiny server and can be accessed here. The code used to create this application can be found in the citation.rmd file above.

Owner

  • Name: Nutrient Institute
  • Login: NutrientInstitute
  • Kind: user

Elevating nutrition science through data

Citation (citation.Rmd)

---
title: "Comprehensive Food Data Citation (CFDC): Citation Generator"
runtime: shiny
output: html_document
self_contained: true
header-includes:
- \usepackage{setspace}
- \doublespacing
- \usepackage{titlesec}
editor_options: 
  markdown: 
    wrap: 90
---

```{=html}
<style type="text/css">
.main-container {
    width: 95%;
    max-width: unset;
}
body, td {
   font-size: 16px;
   font-family: Arial,Helvetica,sans-serif;
}
code.r{
  font-size: 12px;
}
pre {
  font-size: 12px
}
pre code {
  white-space: pre-wrap;
}
h1.title {
  padding: 30px;
  text-align: left;
  font-size: 35px;
  font-weight: bold;
  color: white;
  background: #F1592A;
  margin: 0;
  font-family: Arial,Helvetica,sans-serif;
  outline: 2px solid #F1592A;
}
.icon-bar {
  background-color: white;
  height: 5%;
  bottom: 0;
  width: 100%;
}
/* pretty radio */
label > input[type='radio'] {
    opacity: 0;
    position: absolute;
}
label > input[type='radio'] + *::before {
    content: '';
    margin: 4px 0 0;
    width: 13px;
    height: 13px;
    position: absolute;
    margin-left: -20px;
    border-radius: 50%;
    border-style: solid;
    border-width: 0.1rem;
    border-color: #F1592A;
}
label > input[type='radio']:checked + *::before {
    background: radial-gradient(white 0%, white 30%, #F1592A 30%, #F1592A);
    border-color: #F1592A;
}

.accordion {
  background-color: #eee;
  color: #444;
  cursor: pointer;
  padding: 10px;
  width: 100%;
  border: none;
  text-align: left;
  font-size: 20px;
  transition: 0.4s;
  font-weight: bold;
}

.active, .accordion:hover {
  background-color: #ccc;
}

.accordion:after {
  content: '\002B';
  color: #777;
  font-weight: bold;
  float: right;
  margin-left: 5px;
}

.active:after {
  content: "\2212";
}

.panel {
  padding: 0 15px;
  background-color: white;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out;
  margin-top: 0px;
  margin-bottom: 0px;
}

</style>

<script>
function CopyToClipboard(id)
{
var r = document.createRange();
r.selectNode(document.getElementById(id));
window.getSelection().removeAllRanges();
window.getSelection().addRange(r);
document.execCommand('copy');
window.getSelection().removeAllRanges();
}
</script>

<script>
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var panel = this.nextElementSibling;
    if (panel.style.maxHeight) {
      panel.style.maxHeight = null;
    } else {
      panel.style.maxHeight = panel.scrollHeight + "px";
    } 
  });
}
</script>
```




```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
                      message = FALSE, 
                      warning = FALSE, 
                      cache = FALSE)
```

```{r}
library(tidyverse)
library(shiny)
library(shinyBS)
```




```{=HTML}
<button class="accordion">More Information</button>
<div class="panel">
  <br>
  <p>Fill out the form below to generate a comprehensive food and nutrient data citation. Generated citations incorporate all applicable components of the CFDC standard and are formatted per NLM Citing Medicine guidelines<sup>1</sup>.</a>
     <br>
     <br>
     Further docummentation of this app can be found at https://github.com/NutrientInstitute/cfdc.</p>
     <p style = "font-size:10px">1. Patrias K, author; Wendling D, editor. Citing Medicine: The NLM Style Guide for Authors, Editors, and Publishers [Internet]. 2nd edition. Bethesda (MD): National Library of Medicine (US); 2007-. Chapter 24, Databases/Retrieval Systems/Datasets on the Internet. 2007 Oct 10 [Updated 2018 May 18]. Available from: https://www.ncbi.nlm.nih.gov/books/NBK7273/<br></p>
</div>
<button class="accordion">NHANES Example</button>
<div class="panel" style = 'min-height: 0px;'>
  <br>
  <b>Formal Citation:</b>
  <p>Centers for Disease Control and Prevention, National Center for Health Statistics. In: National Health and Nutrition Examination Survey: 2017-2018 Dietary Data [Internet dataset]. Hyattsville, MD: U.S. Department of Health & Human Services; 2020 Jun [accessed 2023 Apr 10]. Available from: https://wwwn.cdc.gov/nchs/nhanes/search/datapage.aspx?Component=Dietary&CycleBeginYear=2017
</p>
  <br>
  <b>Descriptive Citation:</b>
  <p>The following subset of food data from NHANES 2017-2018 Dietary Data was included in this analysis: Dietary Interview - Individual Foods, First Day (file name DR1IFF_J). Food data was transformed or altered for use in this analysis. The following edits were made: foods with no dietary fiber were excluded. The Comprehensive Food Data Citation (CFDC) guideline was used to facilitate replicability.
</p>
  <br>
  <b>Codebook Citation:</b>
  <p>Centers for Disease Control and Prevention, National Center for Health Statistics. 2017-2018 Data Documentation, Codebook, and Frequencies: Dietary Interview - Individual Foods, First Day (DR1IFF_J)[Internet].Hyattsville, MD: U.S. Department of Health & Human Services; 2020 Jun [accessed 2023 Apr 10].Available from: https://wwwn.cdc.gov/Nchs/Nhanes/2017-2018/DR1IFF_J.htm</p>
  <br>
</div>
```



<br>

## **Formal Citation Components**

***

```{r}
# Input citation elements
# formal elements first, followed by descriptive

div(style = "justify-content: left;display: flex;flex-wrap: wrap;",
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "author", 
              label = tags$span(
                "Author(s)", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "author_tooltip")),  
              width = '400px', 
              placeholder = "ex) Haytowitz DB, Ahuja JKC, Wu X, Somanchi M, Nickle M, Nguyen QA, Roseland JM, Williams JR, Patterson KY, Li Y, et al.")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "title", 
              label = tags$span(
                "Tile/Name", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "title_tooltip")),   
              width = '400px', 
              placeholder = "ex) USDA National Nutrient Database for Standard Reference")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "version", 
              label = tags$span(
                "Version", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "version_tooltip")),  
              width = '400px', 
              placeholder = "ex) Version 1.5.0")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "edition", 
              label = tags$span(
                "Edition", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "edition_tooltip")), 
              width = '400px', 
              placeholder =  "ex) 5th Edition")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "parent", 
              label = tags$span(
                "Name of Parent/Series", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "parent_tooltip")), 
              width = '400px', 
              placeholder = "ex) FoodData Central")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "type", 
              label = tags$span(
                "Resource Type", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "type_tooltip")),  
              width = '400px', 
              placeholder = "ex) Internet dataset")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "place", 
              label = tags$span(
                "Place of Publication", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "place_tooltip")),
              width = '400px', 
              placeholder = "ex) Wishington (DC)")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "publisher", 
              label = tags$span(
                "Publisher", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "publisher_tooltip")), 
              width = '400px', 
              placeholder = "ex) Nutrient Data Laboratory, Beltsville Human Nutrition Research Center, ARS, USDA")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "pubdate", 
              label = tags$span(
                "Date of Publication", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "pubdate_tooltip")),  
              width = '400px', 
              placeholder = "ex) 2019 May 2")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "revdate", 
              label = tags$span(
                "Most Recent Date of Revision/Modification", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "revdate_tooltip")),  
              width = '400px', 
              placeholder = "ex) 2019 May 2")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "accessdate", 
              label = tags$span(
                "Date Accessed", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "accessdate_tooltip")),
              width = '400px', 
              placeholder = "ex) 2019 May 2")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "URL", 
              label = tags$span(
                "URL(s)", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "url_tooltip")),  
              width = '400px', 
              placeholder = "ex) https://data.nal.usda.gov/dataset/usda-national-nutrient-database-standard-reference-legacy-release")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "identifier", 
              label = tags$span(
                "Additional Idenitifier(s)", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "identifier_tooltip")), 
              width = '400px', 
              placeholder = "ex) identifier: 69ebc253-1869-4bf0-8471-b0c2fb5742f5")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "funder", 
              label = tags$span(
                "Funding Person(s) or Organization(s)", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "funder_tooltip")), 
              width = '400px', 
              placeholder = "ex) Agricultural Research Service")))
```

<br>

```{r}
# Create formal citation
div(style = "justify-content: center;display: flex;flex-wrap: wrap;padding-bottom:10px;",
div(style="font-size:30px;font-weight:bold;padding-top:10px;padding-bottom:10px;background:#F1592A;color: white;width: 100%;text-align: left;outline: 2px solid #F1592A;padding: 10px;", 
    renderText(paste0("Formal Citation"))),

div(style="width: 100%; outline: 2px solid #F1592A; font-size: 20px;  min-height: 100px; background: #fdece7;padding: 10px;",
    id = "formal",
    span(style = "color:gray;", renderText(ifelse(input$author == "" & input$parent == "" & input$title == "" & input$publisher == "" & input$URL == "" &input$accessdate == "" & input$revdate == "" & input$type == "" & input$edition == "" & input$version == "" & input$identifier == "", paste("EXAMPLE:", "Haytowitz DB, Ahuja JKC, Wu X, Somanchi M, Nickle M, Nguyen QA, Roseland JM, Williams JR, Patterson KY, Li Y, et al. USDA National Nutrient Database for Standard Reference, Legacy Release [Internet dataset]. Nutrient Data Laboratory, Beltsville Human Nutrition Research Center, ARS, USDA; 2019 May 7 [modified 2022 Jan 7; accessed 2022 Nov 7]. Available from: https://data.nal.usda.gov/dataset/usda-national-nutrient-database-standard-reference-legacy-release identifier: 69ebc253-1869-4bf0-8471-b0c2fb5742f5"),paste0("")))),
    renderText(ifelse(input$author == "" & input$parent == "" & input$title == "" & input$publisher == "" & input$URL == "" &input$accessdate == "" & input$revdate == "" & input$type == "" & input$edition == "" & input$version == "" & input$identifier == "", paste0(""), paste0(input$author, 
                      ifelse(input$author == "", "", ". "), 
                      input$title, 
                      ifelse(input$title != "" & (input$version != "" | input$edition != ""),", ", ""), 
                      input$version, 
                      ifelse(input$version != "" & input$edition != "", ", ", ""),
                      input$edition, 
                      ifelse(input$version != "" | input$edition != "", ".", ""),
                      ifelse(input$parent != "", paste0(" In: ", input$parent, ifelse(input$title != "","", "")), ""),
                      ifelse(input$type != ""," [", ""), 
                      input$type, 
                      ifelse(input$type != "","]. ", ""), 
                      input$place, 
                      ifelse(input$place == "" | input$publisher == "","" , ": "), 
                      input$publisher, 
                      ifelse(input$publisher != "" &  input$pubdate != "", "; ", ""), 
                      input$pubdate, 
                      ifelse(input$accessdate != "" | input$revdate != "", " [", ""),
                      ifelse(input$revdate != "","modified ", ""), 
                      input$revdate, 
                      ifelse(input$revdate == "" | input$accessdate == "" ,"" ,";"),
                      ifelse(input$accessdate != "", "accessed ", ""),
                      input$accessdate, 
                      ifelse(input$accessdate != "" | input$revdate != "", "]. ", ""), 
                      ifelse(input$URL != "", "Available from: ", ""), 
                      input$URL,
                      ifelse(input$URL != "" & input$identifier != "", " ", ""),
                      input$identifier,
                      ifelse(input$funder != "", paste0(" Funded by ", input$funder), "")
                      )
               ))
    )
)



```


<div style="justify-content: left;display: flex;flex-wrap: wrap;">
<button type='button' class='btn' style = 'outline: 2px solid #F1592A;' onclick="CopyToClipboard('formal');return false;">Copy Formal Citation</button>
</div>
<br>

## **Descriptive Citation Components**

***

```{r}
div(style = "justify-content: left;display: flex;flex-wrap: wrap;",
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "subset", 
              label = tags$span(
                "Subset of Data Used", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "subset_tooltip")), 
              width = '90vw', 
              placeholder = "ex) foods in the food group Dairy and Egg Products, as specified by the FD_GROUP file")),
div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "edits", 
              label = tags$span(
                "Modifications and Transformations", 
                tags$i(class = "glyphicon glyphicon-info-sign",
                       style = "color:gray;font-size:20px;",
                       id = "edits_tooltip")), 
              width = '90vw', 
              placeholder = "ex) All units were transformed from milligrams to grams; missing nutrient measure values were inputted from scientific literature, source identified in supplemental tables.")))
```

<br>

```{r}
# Suggest in-text/descriptive citation
div(style = "justify-content: left;display: flex;flex-wrap: wrap;padding-bottom:10px;",
    div(style="font-size:30px;font-weight:bold;background:#F1592A;color: white;width: 100%;text-align: left;outline: 2px solid #F1592A;padding: 10px;", 
        renderText(paste0("Suggested Descriptive Citation"))
        ),
    div(style="width: 100%; outline: 2px solid #F1592A; font-size: 20px;  min-height: 100px; background: #fdece7;padding: 10px;",
    id = "descriptive",
    renderText(paste0(ifelse(input$subset != "" & input$title != "", 
                             paste0("The following subset of food data from ", ifelse(input$title == "", "[dataset title]", input$title), " was included in this analysis: ", input$subset, ". " ), 
                             paste0("All food data from ", ifelse(input$title == "", "[dataset title]", input$title), " was included in analysis. ")), 
                      ifelse(input$edits != "", 
                             paste0("Food data was transformed or altered for use in this analysis. The following edits were made: ", input$edits, ". "), 
                             paste0("Food data was used as published, with no edits or transformations.")),
                             paste0(" The Comprehensive Food Data Citation (CFDC) guideline was used to facilitate replicability.")))
    )
    )
```

<div style="justify-content: left;display: flex;flex-wrap: wrap;">
<button type='button' class='btn' style = 'outline: 2px solid #F1592A;' onclick="CopyToClipboard('descriptive');return false;">Copy Descriptive Citation</button>
</div>
<br>

## **Codebook Citation Components**

***

```{r}
# Check if codebook was used
div(style = "justify-content: left;display: flex;flex-wrap: wrap;",
div(style="display:inline-block; margin:0px 5px 0px;width: 95%;",
    radioButtons(inputId = "codebook",
                 width = '100%',
                 label = tags$span(
                   "Does this food data source have a codebook?",
                   tags$i(class = "glyphicon glyphicon-info-sign",
                          style = "color:gray;font-size:20px;",
                          id = "codebook_tooltip")),
                 choices = c("Yes, it is provided with the dataset", "Yes, it must be accessed seperately from the dataset", "No")
                )
))
```
```{r}
# Add tooltips with shinyBS

bsPopover(id = "author_tooltip",
          title ="",
          content = "List each author (if applicable). Format as surname followed by first initial and middle initial. Seperate names with commas", 
          placement = "top",
          trigger = "click")

bsPopover(id = "parent_tooltip", 
          title ="",
          content = "Full unabbreviated name of parent-series containing data cited (if applicable)", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "title_tooltip", 
          title ="",
          content = "Full unabbreviated name of the dataset", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "version_tooltip", 
          title ="",
          content = "Release number, Volume number, and/or Version subtitle (if applicable); If multiple versions of the data were used, all versions must be provided (seperated by semicolons). <br>NOTE: Data version and edition can be used to mean the same thing. Provide any and all information.", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "edition_tooltip", 
          title ="",
          content = "Edition of the data release (if applicable). <br>NOTE: Data edition and version can be used to mean the same thing. Provide any and all information.", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "type_tooltip", 
          title ="",
          content = "The type or format of the data resource. Most common options include: Internet dataset, pdf, Microsoft Excel, CSV, TSV, RDF, JSON, Microsoft Access, SAS executable file, STATA, application, and book.", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "place_tooltip", 
          title ="",
          content = "Physical location where the data was published (if applicable).<br> NOTE: May be difficult to find", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "publisher_tooltip", 
          title ="",
          content = "Full name of the person(s) or organization(s) responsible for publishing the data", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "pubdate_tooltip", 
          title ="",
          content = "The date the data was published. Formatted as YYYY MMM DD", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "revdate_tooltip", 
          title ="",
          content = "The most recent date the data was modified or revised. Formatted as YYYY MMM DD (if applicable)", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "accessdate_tooltip", 
          title ="",
          content = "The date the data was retrieved from the publisher. Formatted as YYYY MMM DD", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "url_tooltip", 
          title ="",
          content = "The digital location of the data, if multiple are provided list URLs seperated by semicolons", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "identifier_tooltip", 
          title ="",
          content = "Additional identifiers that can be used to locate the data. Common examples include but are not limited to: DOI, PMID, ISSN, and ISBN.", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "funder_tooltip", 
          title ="",
          content = "Person(s) or organization(s) responsible for funding the collection of the data (if applicable)", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "subset_tooltip", 
          title ="",
          content = "Specifics of what data from this dataset was used; Include all data identifiers, methods of joining data, and filters used. If all data was used in analysis leave this blank.", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "edits_tooltip", 
          title ="",
          content = "All deviations from original data must be specified, this includes but is not limited to additions, modifications, exclusions, unit transformations, and calculations.", 
          placement = "top", 
          trigger = "click")

bsPopover(id = "codebook_tooltip", 
          title ="",
          content = "A codebook is a resource for understanding or interpreting the data and can include information such as variable definitions and file descriptions.", 
          placement = "top", 
          trigger = "click")

```
```{r}
# Optionally input citation elements of codebook

code_book <- reactive(input$codebook)

renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
  div(style = "justify-content: left;display: flex;flex-wrap: wrap;",
      div(style = "display:inline-block; margin:0px 5px 0px;",
          textInput(inputId = "cbauthor",
                    label = tags$span(
                      "Codebook Author",
                      tags$i(class = "glyphicon glyphicon-info-sign",
                             style = "color:gray;font-size:20px;",
                             id = "cbauthor_tooltip")),
                    width = '400px',
                    placeholder = "ex) Rhodes DG, Morton S, Hymes MA, Friday JE, Martin CL, Steinfeldt LC, Moshfegh AJ")),
  div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "cbtitle",
              label = tags$span(
                      "Codebook Title",
                      tags$i(class = "glyphicon glyphicon-info-sign",
                             style = "color:gray;font-size:20px;",
                             id = "cbtitle_tooltip")),
                    width = '400px',
                    placeholder = "ex) 2017-2018 Food and Nutrient Database
for Dietary Studies: Documentation")),
  div(style = "display:inline-block; margin:0px 5px 0px;",
      textInput(inputId = "cbplace",
                label = tags$span(
                       "Codebook Place of Publication",
                        tags$i(class = "glyphicon glyphicon-info-sign",
                               style = "color:gray;font-size:20px;",
                               id = "cbplace_tooltip")),
                    width = '400px',
                    placeholder = "ex) Beltsville, MD")),
  div(style = "display:inline-block; margin:0px 5px 0px;",
    textInput(inputId = "cbpub",
               label = tags$span(
                       "Codebook Publisher",
                       tags$i(class = "glyphicon glyphicon-info-sign",
                              style = "color:gray;font-size:20px;",
                              id = "cbpub_tooltip")),
                    width = '400px',
                    placeholder = "ex) U.S. Department of Agriculture, Agricultural Research Service, Beltsville Human Nutrition Research Center, Food Surveys Research Group")),
  div(style = "display:inline-block; margin:0px 5px 0px;",
  textInput(inputId = "cbpubdate",
            label = tags$span(
                   "Codebook Date of Publication",
                   tags$i(class = "glyphicon glyphicon-info-sign",
                          style = "color:gray;font-size:20px;",
                          id = "cbpubdate_tooltip")),
                    width = '400px',
                    placeholder = "ex) 2020 Jul 1")),
  div(style = "display:inline-block; margin:0px 5px 0px;",
  textInput(inputId = "cbaccess",
            label = tags$span(
                   "Codebook Date Accessed",
                   tags$i(class = "glyphicon glyphicon-info-sign",
                          style = "color:gray;font-size:20px;",
                          id = "cbaccess_tooltip")),
                    width = '400px',
                    placeholder = "ex) 2023 Mar 31")),
  div(style = "display:inline-block; margin:0px 5px 0px;",
  textInput(inputId = "cbURL",
            label = tags$span(
                   "Codebook URL",
                   tags$i(class = "glyphicon glyphicon-info-sign",
                          style = "color:gray;font-size:20px;",
                          id = "cburl_tooltip")),
                    width = '400px',
                    placeholder = "ex) https://www.ars.usda.gov/ARSUserFiles/80400530/pdf/fndds/2017_2018_FNDDS_Doc.pdf")))
  
})

#codebook input tooltips
renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
bsPopover(id = "cbauthor_tooltip", 
          title = "",
          content =  "List each author (if applicable). Format as surname followed by first initial and middle initial. Seperate names with commas", 
          placement = "top", 
          trigger = "click")})

renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
bsPopover(id = "cbtitle_tooltip", 
          title = "",
          content =  "Full unabbreviated name of the codebook", 
          placement = "top", 
          trigger = "click")})

renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
bsPopover(id = "cbplace_tooltip", 
          title = "",
          content =  "Physical location where the data was published (if applicable). <br>NOTE: May be difficult to find", 
          placement = "top", 
          trigger = "click")})

renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
bsPopover(id = "cbpub_tooltip", 
          title = "",
          content =  "Full name of the person(s) or organization(s) responsible for publishing the codebook", 
          placement = "top", 
          trigger = "click")})

renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
bsPopover(id = "cbpubdate_tooltip", 
          title = "",
          content =  "Date the codebook was published. Formatted as YYYY MMM DD", 
          placement = "top", 
          trigger = "click")})

renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
bsPopover(id = "cbaccess_tooltip", 
          title = "",
          content =  "Date codebook was accessed. Formatted as YYYY MMM DD", 
          placement = "top", 
          trigger = "click")})

renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
bsPopover(id = "cburl_tooltip", 
          title = "",
          content =  "The digital location of the codebook, if multiple are provided list URLs seperated by semicolons", 
          placement = "top", 
          trigger = "click")})


```

<br>


```{r}
# Create optional codebook citation
renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
div(style = "justify-content: left;display: flex;flex-wrap: wrap;padding-bottom:10px;",
    div(style="font-size:30px;font-weight:bold;background:#F1592A;color: white;width: 100%;text-align: left;outline: 2px solid #F1592A;padding: 10px;", 
        renderText(paste0("Codebook Citation"))
        ),
    div(style="width: 100%; outline: 2px solid #F1592A; font-size: 20px;  min-height: 100px; background: #fdece7;padding: 10px;",
    id = "copycodebook",
    span(style = "color:gray;",
         renderText(ifelse(input$cbauthor == "" & input$cbtitle == "" & input$cbplace == "" & input$cbpub == "" & input$cbpubdate == "" & input$cbaccess == "" & input$cbURL == "", paste0("EXAMPLE: Rhodes DG, Morton S, Hymes MA, Friday JE, Martin CL, Steinfeldt LC, Moshfegh AJ. 2017-2018 Food and Nutrient Database for Dietary Studies: Documentation[Internet].Beltsville, MD: U.S. Department of Agriculture, Agricultural Research Service, Beltsville Human Nutrition Research Center, Food Surveys Research Group; 2020 Jul 1 [accessed 2023 Mar 31].Available from: https://www.ars.usda.gov/ARSUserFiles/80400530/pdf/fndds/2017_2018_FNDDS_Doc.pdf"), paste0("")))),
    renderText(ifelse(input$cbauthor == "" & input$cbtitle == "" & input$cbplace == "" & input$cbpub == "" & input$cbpubdate == "" & input$cbaccess == "" & input$cbURL == "", paste0(""), paste0(input$cbauthor,
                      ifelse(input$cbauthor != "", ". ", ""), 
                      input$cbtitle,
                      "[Internet].",
                      input$cbplace,
                      ifelse(input$cbtitle != "" | input$cbauthor != "",ifelse(input$cbplace != "" & input$cbpub != "", ": ","[place unknown]: " ), ""),
                      input$cbpub,
                      ifelse(input$cbpubdate != "", "; ", ""),
                      input$cbpubdate,
                      ifelse(input$cbpubdate != "", " ", ""),
                      ifelse(input$cbaccess != "", "[accessed ", ""),
                      input$cbaccess,
                      ifelse(input$cbaccess != "", "].", ""),
                      ifelse(input$cbURL != "", "Available from: ", ""),
                      input$cbURL)))
    )
    )
})
renderUI(if(code_book() == "Yes, it must be accessed seperately from the dataset"){
  HTML("<div style='justify-content: left;display: flex;flex-wrap: wrap;'>
<button type='button' class='btn' style = 'outline: 2px solid #F1592A;' onclick=\"CopyToClipboard('copycodebook');return false;\">Copy Codebook Citation</button>
</div>
<br>")
})

```



***

<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> -->
<!-- <div class="icon-bar"> -->
<!--   <a href="https://nutrientinstitute.org"><img src="NI_LOGO.png" style="width:50px;height:75px;float: right;margin:10px;"></a> -->
<!--   <p style="float:right;padding-top:30px;"> Brought to you by </p> -->
<!--   <a href = "https://github.com/NutrientInstitute/cfdc" class="fa fa-github" style="font-size:55px;color:gray;float: left;margin:10px;"></a> -->
<!-- </div> -->

GitHub Events

Total
Last Year