-
Notifications
You must be signed in to change notification settings - Fork 7
Update for R Package #8
base: master
Are you sure you want to change the base?
Changes from all commits
e788a51
e83f264
b465e78
b8967a7
5feb8e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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$ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Package: dashDangerouslySetInnerHtml | ||
| Title: A dash component for specifying raw HTML | ||
| Version: 0.0.3 | ||
| Description: A dash component for specifying raw HTML | ||
| Depends: R (>= 3.0.2) | ||
| Imports: | ||
| 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 | ||
| Encoding: UTF-8 | ||
| LazyData: true | ||
| KeepSource: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| LICENSE.txt |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # AUTO GENERATED FILE - DO NOT EDIT | ||
|
|
||
| export(htmlDangerouslySetInnerHTML) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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')) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.3", src = list(href = NULL, | ||
| file = "deps"), meta = NULL, | ||
| script = 'bundle.js', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At some point, I'd actually suggest that this package rename its bundle to something more descriptive, as we have with other projects, but it's not essential for this PR. |
||
| stylesheet = NULL, head = NULL, attachment = NULL, package = "dashDangerouslySetInnerHtml", | ||
| all_files = FALSE), class = "html_dependency")) | ||
| return(deps_metadata) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # AUTO GENERATED FILE - DO NOT EDIT | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we update the Python artifacts as part of this PR as well? If we're updating both Python and R, I imagine we'll need to make a new release on the 🐍 side also. |
||
|
|
||
| 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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from .DangerouslySetInnerHTML import DangerouslySetInnerHTML | ||
|
|
||
| __all__ = [ | ||
| "DangerouslySetInnerHTML" | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the past I've avoided contributing the |
||
| "name": "dash-dangerously-set-inner-html", | ||
| "version": "0.0.3", | ||
| "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 <chris@plotly.com>", | ||
| "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" | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll need to add an example within the package if we want to submit this to CRAN, and if that example requires
dashHtmlComponents, we'll have to add it to theSuggests:field here.