From e788a51fe2516cd9382edf587f541998db81d873 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Mon, 20 Jul 2020 19:42:38 -0400 Subject: [PATCH 1/4] Updating and Generating R Package Files --- .gitignore | 1 + DESCRIPTION | 13 +++++ LICENSE | 1 + NAMESPACE | 3 ++ R/htmlDangerouslySetInnerHTML.R | 18 +++++++ R/internal.R | 9 ++++ .../DangerouslySetInnerHTML.py | 47 +++++++++++++++++++ dash_dangerously_set_inner_html/_imports_.py | 5 ++ .../package-info.json | 47 +++++++++++++++++++ inst/deps/bundle.js | 1 + man/htmlDangerouslySetInnerHTML.Rd | 21 +++++++++ package.json | 4 +- 12 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 DESCRIPTION create mode 120000 LICENSE create mode 100644 NAMESPACE create mode 100644 R/htmlDangerouslySetInnerHTML.R create mode 100644 R/internal.R create mode 100644 dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py create mode 100644 dash_dangerously_set_inner_html/_imports_.py create mode 100644 dash_dangerously_set_inner_html/package-info.json create mode 100644 inst/deps/bundle.js create mode 100644 man/htmlDangerouslySetInnerHTML.Rd diff --git a/.gitignore b/.gitignore index b1fd20c..04a6271 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ venv/ *.log .DS_Store .idea +.Rbuildignore diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..8b4ff32 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,13 @@ +Package: dashDangerouslySetInnerHtml +Title: A dash component for specifying raw HTML +Version: 0.0.2 +Description: A dash component for specifying raw HTML +Depends: R (>= 3.0.2) +Imports: +Suggests: dash, dashCoreComponents, dashHtmlComponents +License: MIT + file LICENSE +URL: https://github.com/plotly/dash-dangerously-set-inner-html +BugReports: https://github.com/plotly/dash-dangerously-set-inner-html/issues +Encoding: UTF-8 +LazyData: true +KeepSource: true diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..85de3d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +LICENSE.txt \ No newline at end of file diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..28d0cbf --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,3 @@ +# AUTO GENERATED FILE - DO NOT EDIT + +export(htmlDangerouslySetInnerHTML) diff --git a/R/htmlDangerouslySetInnerHTML.R b/R/htmlDangerouslySetInnerHTML.R new file mode 100644 index 0000000..c9e2fc9 --- /dev/null +++ b/R/htmlDangerouslySetInnerHTML.R @@ -0,0 +1,18 @@ +# AUTO GENERATED FILE - DO NOT EDIT + +htmlDangerouslySetInnerHTML <- function(children=NULL) { + + props <- list(children=children) + if (length(props) > 0) { + props <- props[!vapply(props, is.null, logical(1))] + } + component <- list( + props = props, + type = 'DangerouslySetInnerHTML', + namespace = 'dash_dangerously_set_inner_html', + propNames = c('children'), + package = 'dashDangerouslySetInnerHtml' + ) + + structure(component, class = c('dash_component', 'list')) +} diff --git a/R/internal.R b/R/internal.R new file mode 100644 index 0000000..8c73c56 --- /dev/null +++ b/R/internal.R @@ -0,0 +1,9 @@ +.dashDangerouslySetInnerHtml_js_metadata <- function() { +deps_metadata <- list(`dash_dangerously_set_inner_html` = structure(list(name = "dash_dangerously_set_inner_html", +version = "0.0.2", src = list(href = NULL, +file = "deps"), meta = NULL, +script = 'bundle.js', +stylesheet = NULL, head = NULL, attachment = NULL, package = "dashDangerouslySetInnerHtml", +all_files = FALSE), class = "html_dependency")) +return(deps_metadata) +} diff --git a/dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py b/dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py new file mode 100644 index 0000000..7bd1ae6 --- /dev/null +++ b/dash_dangerously_set_inner_html/DangerouslySetInnerHTML.py @@ -0,0 +1,47 @@ +# AUTO GENERATED FILE - DO NOT EDIT + +from dash.development.base_component import Component, _explicitize_args + + +class DangerouslySetInnerHTML(Component): + """A DangerouslySetInnerHTML component. +Render a string of raw, unescaped HTML. +This uses React.js's `dangerouslySetInnerHTML` method. +From React.js's documentation, note that: +> Setting HTML from code is risky because it's easy to +> inadvertently expose your users to a cross-site scripting (XSS) +> (https://en.wikipedia.org/wiki/Cross-site_scripting) +> attack. +So, you can set HTML directly in Dash through React.js, but you have +to type out dangerouslySetInnerHTML to remind yourself that it's dangerous. + +In most cases, you are safer using the Dash HTML component classes, +dash-html-components (https://github.com/plotly/dash-html-components). +You can also provide HTML in a sandboxed iframe using the +`dash_html_components.IFrame(srcDoc='raw html here')` component, +see , see https://community.plotly.com/t/rendering-html-similar-to-markdown/6232/2?u=chriddyp + +Note that the elements in the HTML block that is generated will can not +be targeted with Dash callbacks. + +Keyword arguments: +- children (string; optional): An string of raw, unescaped HTML that will be rendered directly""" + @_explicitize_args + def __init__(self, children=None, **kwargs): + self._prop_names = ['children'] + self._type = 'DangerouslySetInnerHTML' + self._namespace = 'dash_dangerously_set_inner_html' + self._valid_wildcard_attributes = [] + self.available_properties = ['children'] + self.available_wildcard_properties = [] + + _explicit_args = kwargs.pop('_explicit_args') + _locals = locals() + _locals.update(kwargs) # For wildcard attrs + args = {k: _locals[k] for k in _explicit_args if k != 'children'} + + for k in []: + if k not in args: + raise TypeError( + 'Required argument `' + k + '` was not specified.') + super(DangerouslySetInnerHTML, self).__init__(children=children, **args) diff --git a/dash_dangerously_set_inner_html/_imports_.py b/dash_dangerously_set_inner_html/_imports_.py new file mode 100644 index 0000000..bafd865 --- /dev/null +++ b/dash_dangerously_set_inner_html/_imports_.py @@ -0,0 +1,5 @@ +from .DangerouslySetInnerHTML import DangerouslySetInnerHTML + +__all__ = [ + "DangerouslySetInnerHTML" +] \ No newline at end of file diff --git a/dash_dangerously_set_inner_html/package-info.json b/dash_dangerously_set_inner_html/package-info.json new file mode 100644 index 0000000..b26deb1 --- /dev/null +++ b/dash_dangerously_set_inner_html/package-info.json @@ -0,0 +1,47 @@ +{ + "name": "dash-dangerously-set-inner-html", + "version": "0.0.2", + "description": "A dash component for specifying raw HTML", + "main": "lib/index.js", + "repository": { + "type": "git", + "url": "https://github.com/plotly/dash-dangerously-set-inner-html.git" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/plotly/dash-dangerously-set-inner-html/issues" + }, + "homepage": "https://github.com/plotly/dash-dangerously-set-inner-html", + "scripts": { + "copy-lib": "copyfiles -u 1 lib/* dash_dangerously_set_inner_html", + "demo": "builder run demo", + "install-local": "npm run copy-lib && python setup.py install", + "prepublish": "npm test && builder run build-dist && npm run copy-lib", + "publish-all": "npm publish && python setup.py sdist upload", + "publish-pypi": "npm run prepublish && python setup.py sdist upload", + "start": "builder run build-dev", + "test": "", + "test-watch": "builder run test-frontend-watch", + "test-debug": "builder run test-frontend-debug", + "uninstall-local": "pip uninstall dash-dangerously-set-inner-html -y", + "build:py_and_r": "dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json && dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json --r-prefix 'html' --r-suggests 'dash'" + }, + "author": "Chris Parmer ", + "dependencies": { + "builder": "3.2.2", + "copyfiles": "^1.2.0", + "dash-components-archetype": "^0.2.11", + "prop-types": "^15.6.2", + "react": "^15.5.4", + "react-dom": "^15.5.4" + }, + "devDependencies": { + "dash-components-archetype-dev": "^0.2.11", + "enzyme": "^2.8.2", + "react-test-renderer": "^15.5.4" + }, + "peerDependencies": { + "react": "^15.6.0 || ^16.0.0", + "react-dom": "^15.6.0 || ^16.0.0" + } +} diff --git a/inst/deps/bundle.js b/inst/deps/bundle.js new file mode 100644 index 0000000..a649d21 --- /dev/null +++ b/inst/deps/bundle.js @@ -0,0 +1 @@ +this.dash_dangerously_set_inner_html=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.DangerouslySetInnerHTML=void 0;var o=r(1),u=n(o);t.DangerouslySetInnerHTML=u.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){var t={__html:e.children};return s.default.createElement("div",{dangerouslySetInnerHTML:t})}Object.defineProperty(t,"__esModule",{value:!0});var u=r(5),s=n(u),a=r(3),i=n(a);o.propTypes={children:i.default.string},t.default=o},function(e,t,r){"use strict";function n(){}var o=r(4);e.exports=function(){function e(e,t,r,n,u,s){if(s!==o){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=n,r.PropTypes=r,r}},function(e,t,r){e.exports=r(2)()},function(e,t){"use strict";var r="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=r},function(e,t){!function(){e.exports=this.React}()}]); \ No newline at end of file diff --git a/man/htmlDangerouslySetInnerHTML.Rd b/man/htmlDangerouslySetInnerHTML.Rd new file mode 100644 index 0000000..37a9ba7 --- /dev/null +++ b/man/htmlDangerouslySetInnerHTML.Rd @@ -0,0 +1,21 @@ +% Auto-generated: do not edit by hand +\name{htmlDangerouslySetInnerHTML} + +\alias{htmlDangerouslySetInnerHTML} + +\title{DangerouslySetInnerHTML component} + +\description{ +Render a string of raw, unescaped HTML. This uses React.js's `dangerouslySetInnerHTML` method. From React.js's documentation, note that: > Setting HTML from code is risky because it's easy to > inadvertently expose your users to a cross-site scripting (XSS) > (https://en.wikipedia.org/wiki/Cross-site_scripting) > attack. So, you can set HTML directly in Dash through React.js, but you have to type out dangerouslySetInnerHTML to remind yourself that it's dangerous. In most cases, you are safer using the Dash HTML component classes, dash-html-components (https://github.com/plotly/dash-html-components). You can also provide HTML in a sandboxed iframe using the `dash_html_components.IFrame(srcDoc='raw html here')` component, see , see https://community.plotly.com/t/rendering-html-similar-to-markdown/6232/2?u=chriddyp Note that the elements in the HTML block that is generated will can not be targeted with Dash callbacks. +} + +\usage{ +htmlDangerouslySetInnerHTML(children=NULL) +} + +\arguments{ +\item{children}{Character. An string of raw, unescaped HTML that will be rendered directly} +} + +\value{named list of JSON elements corresponding to React.js properties and their values} + diff --git a/package.json b/package.json index 1a521cf..20d6b45 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,10 @@ "test": "", "test-watch": "builder run test-frontend-watch", "test-debug": "builder run test-frontend-debug", - "uninstall-local": "pip uninstall dash-dangerously-set-inner-html -y" + "uninstall-local": "pip uninstall dash-dangerously-set-inner-html -y", + "build:py_and_r": "dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json && dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json --r-prefix 'html' --r-suggests 'dash', 'dashCoreComponents'" }, + "author": "Chris Parmer ", "dependencies": { "builder": "3.2.2", "copyfiles": "^1.2.0", From e83f264d01caca1c70b32e700d2d5444e642bac3 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Mon, 20 Jul 2020 19:55:30 -0400 Subject: [PATCH 2/4] Updating gitignore --- .Rbuildignore | 34 ++++++++++++++++++++++++++++++++++ .gitignore | 1 - 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .Rbuildignore diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..5f714c9 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,34 @@ +# ignore JS config files/folders +node_modules/ +coverage/ +src/ +lib/ +.babelrc +.builderrc +.eslintrc +.npmignore +.editorconfig +.eslintignore +.prettierrc +.circleci +.github + +# demo folder has special meaning in R +# this should hopefully make it still +# allow for the possibility to make R demos +demo/.*\.js +demo/.*\.html +demo/.*\.css + +# ignore python files/folders +setup.py +usage.py +setup.py +requirements.txt +MANIFEST.in +CHANGELOG.md +test/ +# CRAN has weird LICENSE requirements +LICENSE.txt +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.gitignore b/.gitignore index 04a6271..b1fd20c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,3 @@ venv/ *.log .DS_Store .idea -.Rbuildignore From b465e7898cc3cd6f5e0ec9fe4f57dac1c71fdc4a Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Thu, 6 Aug 2020 03:24:23 -0400 Subject: [PATCH 3/4] Updated changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c1e7a..340c4db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 0.0.2 - 2020-07-29 +- Added initial release of R package + ## 0.0.2 - 2018-12-18 ### Changed - Use `prop-types` instead of React.PropTypes for React 15 & 16 support From 5feb8e093748b3f81fb70aa4db248c87c575e746 Mon Sep 17 00:00:00 2001 From: hammadtheone Date: Sat, 17 Oct 2020 14:17:54 -0400 Subject: [PATCH 4/4] Updating version number --- .Rbuildignore | 2 +- DESCRIPTION | 4 ++-- R/internal.R | 2 +- dash_dangerously_set_inner_html/package-info.json | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 5f714c9..0bb1753 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -20,7 +20,7 @@ demo/.*\.js demo/.*\.html demo/.*\.css -# ignore python files/folders +# ignore Python files/folders setup.py usage.py setup.py diff --git a/DESCRIPTION b/DESCRIPTION index 8b4ff32..7774f24 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,10 @@ Package: dashDangerouslySetInnerHtml Title: A dash component for specifying raw HTML -Version: 0.0.2 +Version: 0.0.3 Description: A dash component for specifying raw HTML Depends: R (>= 3.0.2) Imports: -Suggests: dash, dashCoreComponents, dashHtmlComponents +Suggests: dash License: MIT + file LICENSE URL: https://github.com/plotly/dash-dangerously-set-inner-html BugReports: https://github.com/plotly/dash-dangerously-set-inner-html/issues diff --git a/R/internal.R b/R/internal.R index 8c73c56..48619b8 100644 --- a/R/internal.R +++ b/R/internal.R @@ -1,6 +1,6 @@ .dashDangerouslySetInnerHtml_js_metadata <- function() { deps_metadata <- list(`dash_dangerously_set_inner_html` = structure(list(name = "dash_dangerously_set_inner_html", -version = "0.0.2", src = list(href = NULL, +version = "0.0.3", src = list(href = NULL, file = "deps"), meta = NULL, script = 'bundle.js', stylesheet = NULL, head = NULL, attachment = NULL, package = "dashDangerouslySetInnerHtml", diff --git a/dash_dangerously_set_inner_html/package-info.json b/dash_dangerously_set_inner_html/package-info.json index b26deb1..5471150 100644 --- a/dash_dangerously_set_inner_html/package-info.json +++ b/dash_dangerously_set_inner_html/package-info.json @@ -1,6 +1,6 @@ { "name": "dash-dangerously-set-inner-html", - "version": "0.0.2", + "version": "0.0.3", "description": "A dash component for specifying raw HTML", "main": "lib/index.js", "repository": { diff --git a/package.json b/package.json index 694dac5..5471150 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "test-watch": "builder run test-frontend-watch", "test-debug": "builder run test-frontend-debug", "uninstall-local": "pip uninstall dash-dangerously-set-inner-html -y", - "build:py_and_r": "dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json && dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json --r-prefix 'html' --r-suggests 'dash', 'dashCoreComponents'" + "build:py_and_r": "dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json && dash-generate-components ./src/components dash_dangerously_set_inner_html -p package-info.json --r-prefix 'html' --r-suggests 'dash'" }, "author": "Chris Parmer ", "dependencies": {