├── .gitignore ├── LICENSE ├── .Rbuildignore ├── inst └── rstudio │ └── addins.dcf ├── NAMESPACE ├── genbib.Rproj ├── .github └── workflows │ └── R-CMD-check.yaml ├── man ├── gen_bib_addin.Rd └── gen_bib_url.Rd ├── R ├── gen-bib-pkg.R ├── gen-bib.R └── gen-bib-addin.R ├── DESCRIPTION ├── README.md ├── README.Rmd └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2019 2 | COPYRIGHT HOLDER: Nicholas Tierney 3 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^genbib\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^README\.Rmd$ 4 | ^LICENSE\.md$ 5 | ^\.github/workflows/R-CMD-check\.yaml$ 6 | -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | Name: Run genbib 2 | Description:Run 'genbib' interactively 3 | Binding: gen_bib_addin 4 | Interactive: true 5 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(gen_bib_addin) 4 | export(gen_bib_url) 5 | import(miniUI) 6 | import(shiny) 7 | -------------------------------------------------------------------------------- /genbib.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | 3 | name: R-CMD-check 4 | 5 | jobs: 6 | R-CMD-check: 7 | runs-on: macOS-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - uses: r-lib/actions/setup-r@master 11 | - name: Install dependencies 12 | run: Rscript -e "install.packages(c('remotes', 'rcmdcheck'))" -e "remotes::install_deps(dependencies = TRUE)" 13 | - name: Check 14 | run: Rscript -e "rcmdcheck::rcmdcheck(args = '--no-manual', error_on = 'error')" 15 | -------------------------------------------------------------------------------- /man/gen_bib_addin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gen-bib-addin.R 3 | \name{gen_bib_addin} 4 | \alias{gen_bib_addin} 5 | \title{Make it easier to cite web addresses 6 | Based on 'Twitter Rant!' Addin UI from Bob Rudis; see 7 | \url{https://github.com/hrbrmstr/hrbraddins}} 8 | \usage{ 9 | gen_bib_addin() 10 | } 11 | \description{ 12 | Make it easier to cite web addresses 13 | Based on 'Twitter Rant!' Addin UI from Bob Rudis; see 14 | \url{https://github.com/hrbrmstr/hrbraddins} 15 | } 16 | -------------------------------------------------------------------------------- /R/gen-bib-pkg.R: -------------------------------------------------------------------------------- 1 | #' @examples 2 | #' \dontrun{ 3 | #' # in an ideal world: 4 | #' gen_bib_pkg(dplyr) 5 | #' #> writing to clipboard 6 | #' # @Manual{dplyr, 7 | #' # title = {dplyr: A Grammar of Data Manipulation}, 8 | #' # author = {Hadley Wickham and Romain François and Lionel Henry and Kirill Müller}, 9 | #' # year = {2019}, 10 | #' # note = {R package version 0.8.1}, 11 | #' # url = {https://CRAN.R-project.org/package=dplyr}, 12 | #' # } 13 | #' # } 14 | #' @import shiny miniUI 15 | gen_bib_pkg <- function(pkg, 16 | handle = pkg, 17 | clipboard = FALSE){ 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: genbib 2 | Title: Generate Bibliography Stubs on the Fly 3 | Version: 0.0.0.9000 4 | Authors@R: c( 5 | person("Nicholas", 6 | "Tierney", 7 | email = "nicholas.tierney@gmail.com", 8 | role = c("aut", "cre"), 9 | comment = c(ORCID = "0000-0003-1460-8722")), 10 | person("Michael", 11 | "DeWitt", 12 | email = "me.dewitt.jr@gmail.com", 13 | role = c("aut"), 14 | comment = c(ORCID = "0000-0001-8940-1967")) 15 | ) 16 | Description: Short utility functions to generate bibliography stubs on the fly. 17 | Depends: R (>= 3.5.0) 18 | License: MIT + file LICENSE 19 | Encoding: UTF-8 20 | LazyData: true 21 | Imports: 22 | glue, 23 | clipr, 24 | miniUI, 25 | shiny 26 | RoxygenNote: 7.0.2 27 | URL: https://github.com/njtierney/genbib 28 | BugReports: https://github.com/njtierney/genbib/issues 29 | -------------------------------------------------------------------------------- /man/gen_bib_url.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/gen-bib.R 3 | \name{gen_bib_url} 4 | \alias{gen_bib_url} 5 | \title{Generate bib citations for URLs for some given strings} 6 | \usage{ 7 | gen_bib_url(handle, url, title = handle, date = Sys.Date(), clipboard = FALSE) 8 | } 9 | \arguments{ 10 | \item{handle}{character - the name of the handle} 11 | 12 | \item{url}{character - the URL} 13 | 14 | \item{title}{character - the title for the bib reference. Default is to use 15 | the handle} 16 | 17 | \item{date}{character - the date accessed. Default is current date} 18 | 19 | \item{clipboard}{logical - do you want to use the clipboard? Default to FALSE} 20 | } 21 | \value{ 22 | string of the bib handle 23 | } 24 | \description{ 25 | Generate bib citations for URLs for some given strings 26 | } 27 | \examples{ 28 | gen_bib_url(handle = "wikipedia", 29 | url = "https://en.wikipedia.org/wiki/Main_Page") 30 | } 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # genbib 5 | 6 | 7 | 8 | [![R build 9 | status](https://github.com/njtierney/genbib/workflows/R-CMD-check/badge.svg)](https://github.com/njtierney/genbib) 10 | [![Lifecycle: 11 | experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) 12 | 13 | 14 | The goal of genbib is to make it easier for me to generate bib files. 15 | 16 | ## Installation 17 | 18 | Install the development version from [GitHub](https://github.com/) with: 19 | 20 | ``` r 21 | # install.packages("remotes") 22 | remotes::install_github("njtierney/genbib") 23 | ``` 24 | 25 | ## Example 26 | 27 | ``` r 28 | library(genbib) 29 | gen_bib_url(handle = "wikipedia", 30 | url = "https://en.wikipedia.org/wiki/Main_Page") 31 | #> @misc{wikipedia, 32 | #> title = {wikipedia}, 33 | #> howpublished = {https://en.wikipedia.org/wiki/Main_Page}, 34 | #> note = {Accessed: 2020-01-03} 35 | #> } 36 | ``` 37 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | out.width = "100%" 13 | ) 14 | ``` 15 | # genbib 16 | 17 | 18 | [![R build status](https://github.com/njtierney/genbib/workflows/R-CMD-check/badge.svg)](https://github.com/njtierney/genbib) 19 | [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental) 20 | 21 | 22 | The goal of genbib is to make it easier for me to generate bib files. 23 | 24 | ## Installation 25 | 26 | Install the development version from [GitHub](https://github.com/) with: 27 | 28 | ``` r 29 | # install.packages("remotes") 30 | remotes::install_github("njtierney/genbib") 31 | ``` 32 | ## Example 33 | 34 | ```{r example} 35 | library(genbib) 36 | gen_bib_url(handle = "wikipedia", 37 | url = "https://en.wikipedia.org/wiki/Main_Page") 38 | ``` 39 | 40 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Nicholas Tierney 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /R/gen-bib.R: -------------------------------------------------------------------------------- 1 | #' Generate bib citations for URLs for some given strings 2 | #' 3 | #' @param handle character - the name of the handle 4 | #' @param url character - the URL 5 | #' @param title character - the title for the bib reference. Default is to use 6 | #' the handle 7 | #' @param date character - the date accessed. Default is current date 8 | #' @param clipboard logical - do you want to use the clipboard? Default to FALSE 9 | #' 10 | #' @return string of the bib handle 11 | #' @export 12 | #' 13 | #' @examples 14 | #' gen_bib_url(handle = "wikipedia", 15 | #' url = "https://en.wikipedia.org/wiki/Main_Page") 16 | gen_bib_url <- function(handle, 17 | url, 18 | title = handle, 19 | date = Sys.Date(), 20 | clipboard = FALSE) { 21 | 22 | bib <- 23 | glue::glue("@misc{[[handle]], 24 | title = {[[title]]}, 25 | howpublished = {[[url]]}, 26 | note = {Accessed: [[date]]} 27 | }", 28 | .open = "[[", 29 | .close = "]]") 30 | 31 | if (clipboard){ 32 | message("writing bib to clip board") 33 | clipr::write_clip(bib) 34 | return(bib) 35 | } 36 | 37 | if (!clipboard){ 38 | return(bib) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /R/gen-bib-addin.R: -------------------------------------------------------------------------------- 1 | #' Make it easier to cite web addresses 2 | #' Based on 'Twitter Rant!' Addin UI from Bob Rudis; see 3 | #' \url{https://github.com/hrbrmstr/hrbraddins} 4 | #' 5 | #' @export 6 | #' 7 | 8 | gen_bib_addin <- function(){ 9 | ui <- miniPage( 10 | gadgetTitleBar("Generate a Website BibTeX Entry!"), 11 | miniContentPanel( 12 | textAreaInput("inHandle", "Handle for Website", cols = 120, rows = 5), 13 | textAreaInput("inUrl", "Website URL", cols = 120, rows = 5), 14 | checkboxInput("inClipboard", 15 | "Copy to Clipboard?", value = FALSE), 16 | htmlOutput("output") 17 | ) 18 | ) 19 | 20 | server <- function(input, output, session) { 21 | 22 | reactiveData <- reactive({ 23 | dataHandle <- input$inHandle 24 | dataUrl <- input$inUrl 25 | dataClipboard <- input$inClipboard 26 | list(dataHandle,dataUrl, dataClipboard) 27 | }) 28 | 29 | output$output <- renderText({ 30 | gen_bib_url(handle = reactiveData()[[1]], 31 | url = reactiveData()[[2]], clipboard = reactiveData()[[3]]) 32 | }) 33 | 34 | # Listen for 'done'. 35 | observeEvent(input$done, { 36 | invisible(stopApp()) 37 | }) 38 | } 39 | 40 | # Use a modal dialog as a viewer 41 | viewer <- dialogViewer("BibTeX on the Fly!", width = 1000, height = 800) 42 | runGadget(ui, server, viewer = viewer) 43 | } 44 | --------------------------------------------------------------------------------