Skip to content

Commit cd5ed49

Browse files
first working version
0 parents  commit cd5ed49

File tree

13 files changed

+220
-0
lines changed

13 files changed

+220
-0
lines changed

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
^.*\.Rproj$
2+
^\.Rproj\.user$
3+
^\build

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.Rproj.user
2+
.Rhistory
3+
.RData
4+
.Ruserdata

DESCRIPTION

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Package: reactR
2+
Type: Package
3+
Title: React Dependencies for R
4+
Version: 0.1.0
5+
Authors@R: c(
6+
person(
7+
"Facebook", "Inc"
8+
, role = c("aut", "cph")
9+
, comment = "react library in lib, https://facebook.github.io/react"
10+
),
11+
person(
12+
"Kent", "Russell"
13+
, role = c("aut", "cre")
14+
, comment = "R interface"
15+
, email = "[email protected]"
16+
)
17+
)
18+
Maintainer: Kent Russell <[email protected]>
19+
Description: Make it easy .
20+
License: MIT + file LICENSE
21+
LazyData: TRUE
22+
Imports:
23+
htmltools
24+
Suggests:
25+
htmlwidgets (>= 0.6.0),
26+
rmarkdown,
27+
shiny
28+
RoxygenNote: 5.0.1

LICENSE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
YEAR: 2016
2+
COPYRIGHT HOLDER: Your name goes here

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(html_dependency_react)
4+
importFrom(htmltools,htmlDependency)

R/dependencies.R

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#' Dependencies for React
2+
#'
3+
#' @param offline \code{logical} to use local file dependencies. If \code{FALSE},
4+
#' then the dependencies use the Facebook cdn as its \code{src}.
5+
#'
6+
#' @return \code{\link[htmltools]{htmlDependency}}
7+
#' @importFrom htmltools htmlDependency
8+
#' @export
9+
#'
10+
#' @examples
11+
#' library(reactR)
12+
#' library(htmltools)
13+
#'
14+
#' browsable(attachDependencies(
15+
#' tags$script(
16+
#' "
17+
#' ReactDOM.render(
18+
#' React.createElement(
19+
#' 'h1',
20+
#' null,
21+
#' 'Powered by React'
22+
#' ),
23+
#' document.body
24+
#' )
25+
#' "
26+
#' ),
27+
#' html_dependency_react()
28+
#' ))
29+
html_dependency_react <- function(offline=TRUE){
30+
hd <- htmltools::htmlDependency(
31+
name = "react",
32+
version = react_version(),
33+
src = system.file("www/react",package="reactR"),
34+
script = c("react.min.js", "react-dom.min.js")
35+
)
36+
37+
if(!offline) {
38+
hd$src = c(href="https://fb.me")
39+
}
40+
41+
hd
42+
}

R/meta.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#'@keywords internal
2+
react_version <- function(){'15.1.0'}

build/getreact.R

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# use the very nice rgithub
2+
# devtools::install_github("cscheid/rgithub")
3+
4+
get_react_latest <- function(){
5+
gsub(
6+
x=github::get.latest.release("facebook", "react")$content$tag_name,
7+
pattern="v",
8+
replacement=""
9+
)
10+
}
11+
12+
# get newest react
13+
download.file(
14+
url=sprintf(
15+
"https://fb.me/react-%s.min.js",
16+
get_react_latest()
17+
),
18+
destfile="./inst/www/react/react.min.js"
19+
)
20+
21+
# get newest react dom
22+
download.file(
23+
url=sprintf(
24+
"https://fb.me/react-dom-%s.min.js",
25+
get_react_latest()
26+
),
27+
destfile="./inst/www/react/react-dom.min.js"
28+
)
29+
30+
# write function with newest version
31+
# for use when creating dependencies
32+
cat(
33+
sprintf("#'@keywords internal\nreact_version <- function(){'%s'}", get_react_latest()),
34+
file = "./R/meta.R"
35+
)

inst/www/react/react-dom.min.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* ReactDOM v15.1.0
3+
*
4+
* Copyright 2013-present, Facebook, Inc.
5+
* All rights reserved.
6+
*
7+
* This source code is licensed under the BSD-style license found in the
8+
* LICENSE file in the root directory of this source tree. An additional grant
9+
* of patent rights can be found in the PATENTS file in the same directory.
10+
*
11+
*/
12+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e(require("react"));else if("function"==typeof define&&define.amd)define(["react"],e);else{var f;f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,f.ReactDOM=e(f.React)}}(function(e){return e.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED});

inst/www/react/react.min.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)