Skip to content

Commit

Permalink
first working version
Browse files Browse the repository at this point in the history
  • Loading branch information
timelyportfolio committed Jun 24, 2016
0 parents commit cd5ed49
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
^.*\.Rproj$
^\.Rproj\.user$
^\build
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
28 changes: 28 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Package: reactR
Type: Package
Title: React Dependencies for R
Version: 0.1.0
Authors@R: c(
person(
"Facebook", "Inc"
, role = c("aut", "cph")
, comment = "react library in lib, https://facebook.github.io/react"
),
person(
"Kent", "Russell"
, role = c("aut", "cre")
, comment = "R interface"
, email = "[email protected]"
)
)
Maintainer: Kent Russell <[email protected]>
Description: Make it easy .
License: MIT + file LICENSE
LazyData: TRUE
Imports:
htmltools
Suggests:
htmlwidgets (>= 0.6.0),
rmarkdown,
shiny
RoxygenNote: 5.0.1
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2016
COPYRIGHT HOLDER: Your name goes here
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(html_dependency_react)
importFrom(htmltools,htmlDependency)
42 changes: 42 additions & 0 deletions R/dependencies.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#' Dependencies for React
#'
#' @param offline \code{logical} to use local file dependencies. If \code{FALSE},
#' then the dependencies use the Facebook cdn as its \code{src}.
#'
#' @return \code{\link[htmltools]{htmlDependency}}
#' @importFrom htmltools htmlDependency
#' @export
#'
#' @examples
#' library(reactR)
#' library(htmltools)
#'
#' browsable(attachDependencies(
#' tags$script(
#' "
#' ReactDOM.render(
#' React.createElement(
#' 'h1',
#' null,
#' 'Powered by React'
#' ),
#' document.body
#' )
#' "
#' ),
#' html_dependency_react()
#' ))
html_dependency_react <- function(offline=TRUE){
hd <- htmltools::htmlDependency(
name = "react",
version = react_version(),
src = system.file("www/react",package="reactR"),
script = c("react.min.js", "react-dom.min.js")
)

if(!offline) {
hd$src = c(href="https://fb.me")
}

hd
}
2 changes: 2 additions & 0 deletions R/meta.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#'@keywords internal
react_version <- function(){'15.1.0'}
35 changes: 35 additions & 0 deletions build/getreact.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# use the very nice rgithub
# devtools::install_github("cscheid/rgithub")

get_react_latest <- function(){
gsub(
x=github::get.latest.release("facebook", "react")$content$tag_name,
pattern="v",
replacement=""
)
}

# get newest react
download.file(
url=sprintf(
"https://fb.me/react-%s.min.js",
get_react_latest()
),
destfile="./inst/www/react/react.min.js"
)

# get newest react dom
download.file(
url=sprintf(
"https://fb.me/react-dom-%s.min.js",
get_react_latest()
),
destfile="./inst/www/react/react-dom.min.js"
)

# write function with newest version
# for use when creating dependencies
cat(
sprintf("#'@keywords internal\nreact_version <- function(){'%s'}", get_react_latest()),
file = "./R/meta.R"
)
12 changes: 12 additions & 0 deletions inst/www/react/react-dom.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* ReactDOM v15.1.0
*
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
!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});
16 changes: 16 additions & 0 deletions inst/www/react/react.min.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions man/hello.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
\name{hello}
\alias{hello}
\title{Hello, World!}
\usage{
hello()
}
\description{
Prints 'Hello, world!'.
}
\examples{
hello()
}
39 changes: 39 additions & 0 deletions man/html_dependency_react.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions reactR.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: XeLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace

0 comments on commit cd5ed49

Please sign in to comment.