| @@ -1,3 +1,4 @@ | |||
| ^LICENSE\.md$ | |||
| ^ermoji\.Rproj$ | |||
| ^\.Rproj\.user$ | |||
| ^README\.Rmd$ | |||
| @@ -4,14 +4,13 @@ Title: RStudio Addin to Search and Copy Emoji | |||
| Description: RStudio addin to search through emoji and copy the emoji name, | |||
| unicode string or gliph to the clipboard. | |||
| Authors@R: "Garrrick Aden-Buie <g.adenbuie@gmail.com> [aut, cre]" | |||
| License: MIT | |||
| License: MIT + file LICENSE | |||
| Encoding: UTF-8 | |||
| LazyData: true | |||
| ByteCompile: true | |||
| Imports: | |||
| emo, | |||
| DT, | |||
| purrr, | |||
| clipr | |||
| Remotes: hadley/emo | |||
| Depends: | |||
| @@ -0,0 +1,2 @@ | |||
| YEAR: 2018 | |||
| COPYRIGHT HOLDER: Garrick Aden-Buie | |||
| @@ -0,0 +1,21 @@ | |||
| # MIT License | |||
| Copyright (c) 2018 Garrick Aden-Buie | |||
| Permission is hereby granted, free of charge, to any person obtaining a copy | |||
| of this software and associated documentation files (the "Software"), to deal | |||
| in the Software without restriction, including without limitation the rights | |||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
| copies of the Software, and to permit persons to whom the Software is | |||
| furnished to do so, subject to the following conditions: | |||
| The above copyright notice and this permission notice shall be included in all | |||
| copies or substantial portions of the Software. | |||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||
| SOFTWARE. | |||
| @@ -2,3 +2,5 @@ | |||
| export(ermoji_gadget) | |||
| export(ermoji_shiny) | |||
| import(miniUI) | |||
| import(shiny) | |||
| @@ -7,18 +7,16 @@ | |||
| #' @param ... Ignored at this time | |||
| #' @name ermoji | |||
| #' @return nothing | |||
| #' @import shiny | |||
| #' @import miniUI | |||
| #' @export | |||
| ermoji_gadget <- function(clipout = clipr::clipr_available(), ...) { | |||
| require(shiny) | |||
| require(miniUI) | |||
| runGadget(ermoji_ui, ermoji_server(clipout, ...), viewer = paneViewer(500), stopOnCancel = FALSE) | |||
| } | |||
| #' @rdname ermoji | |||
| #' @export | |||
| ermoji_shiny <- function(clipout = clipr::clipr_available(), ...) { | |||
| require(shiny) | |||
| require(miniUI) | |||
| shinyApp(ui = ermoji_ui, server = ermoji_server(clipout, ...)) | |||
| } | |||
| @@ -77,8 +75,8 @@ ermoji_server <- function(clipout = clipr::clipr_available()) { | |||
| output$emojis <- DT::renderDataTable({ | |||
| emojis <- emo::jis | |||
| emojis <- emojis[, c('emoji', 'name', "group", "keywords", "aliases")] | |||
| emojis$keywords <- purrr::map_chr(emojis$keywords, ~ paste(., collapse = ", ")) | |||
| emojis$aliases <- purrr::map_chr(emojis$aliases, ~ paste(., collapse = ", ")) | |||
| emojis$keywords <- vapply(emojis$keywords, function(x) paste(x, collapse = ", "), character(1)) | |||
| emojis$aliases <- vapply(emojis$aliases, function(x) paste(x, collapse = ", "), character(1)) | |||
| DT::datatable( | |||
| emojis, | |||
| rownames = FALSE, | |||
| @@ -117,7 +115,7 @@ ermoji_server <- function(clipout = clipr::clipr_available()) { | |||
| }) | |||
| this_emoji_html <- reactive({ | |||
| gsub("([0-9A-F]{4,8}) ?", "&#x\\1;", this_emoji()$runes) | |||
| rune2html(this_emoji()$runes) | |||
| }) | |||
| truncate <- function(x, n = 10) { | |||
| @@ -177,3 +175,7 @@ escape_html <- function(x) { | |||
| x = gsub('"', '"', x) | |||
| x | |||
| } | |||
| rune2html <- function(runes) { | |||
| gsub("([0-9A-F]{4,8}) ?", "&#x\\1;", runes) | |||
| } | |||