Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 480 - Add .map file extension support to dash #478

Merged
merged 8 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.31.2 - 2018-12-06
## Added
- Support for .map file extension [#478](https://github.com/plotly/dash/pull/478)

## 0.31.1 - 2018-11-29
## Fixed
- Fix `_imports_.py` indentation generation. [#473](https://github.com/plotly/dash/pull/473/files)
Expand Down Expand Up @@ -101,7 +105,7 @@
- Take configs values from init or environ variables (Prefixed with `DASH_`). [#322](https://github.com/plotly/dash/pull/322)

## Fixed
- Take `requests_pathname_prefix` config when creating scripts tags.
- Take `requests_pathname_prefix` config when creating scripts tags.
- `requests/routes_pathname_prefix` must starts and end with `/`.
- `requests_pathname_prefix` must ends with `routes_pathname_prefix`. If you supplied both `requests` and `routes` pathname before this update, make sure `requests_pathname_prefix` ends with the same value as `routes_pathname_prefix`.
- `url_base_pathname` set both `requests/routes` pathname, cannot supply it with either `requests` or `routes` pathname prefixes.
Expand Down
20 changes: 16 additions & 4 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def serve_routes(self):
mimetype='application/json'
)

# pylint: disable=too-many-branches
def _collect_and_register_resources(self, resources):
# now needs the app context.
# template in the necessary component suite JS bundles
Expand All @@ -378,15 +379,25 @@ def _relative_url_path(relative_package_path='', namespace=''):

srcs = []
for resource in resources:
is_dynamic_resource = 'dynamic' in resource and \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps resource.get('dynamic', False) so it is not split

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dictionary entry with default I guess?

resource.get('dynamic')

if 'relative_package_path' in resource:
if isinstance(resource['relative_package_path'], str):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternate way might solve the too-many-branches 🐫

paths = resource['relative_package_path']
paths = [paths] if isinstance(paths, str) else paths
for rel_path in paths:
   ... the logic that is repeated twice ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.. I'm in, if only because it makes me learn the language haha!

srcs.append(_relative_url_path(**resource))
path = _relative_url_path(
resource['relative_package_path'],
resource['namespace']
)
if not is_dynamic_resource:
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved Hide resolved
srcs.append(path)
else:
for rel_path in resource['relative_package_path']:
srcs.append(_relative_url_path(
path = _relative_url_path(
relative_package_path=rel_path,
namespace=resource['namespace']
))
)
if not is_dynamic_resource:
srcs.append(path)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here..

elif 'external_url' in resource:
if isinstance(resource['external_url'], str):
srcs.append(resource['external_url'])
Expand Down Expand Up @@ -492,7 +503,8 @@ def serve_component_suites(self, package_name, path_in_package_dist):

mimetype = ({
'js': 'application/JavaScript',
'css': 'text/css'
'css': 'text/css',
'map': 'application/json'
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved Hide resolved
})[path_in_package_dist.split('.')[-1]]
Marc-Andre-Rivet marked this conversation as resolved.
Show resolved Hide resolved

headers = {
Expand Down
2 changes: 2 additions & 0 deletions dash/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def _filter_resources(self, all_resources, dev_bundles=False):
filtered_resources = []
for s in all_resources:
filtered_resource = {}
if 'dynamic' in s:
filtered_resource['dynamic'] = s['dynamic']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dynamic property needs to survive the sanitation process -- adding it to the list

if 'namespace' in s:
filtered_resource['namespace'] = s['namespace']
if 'external_url' in s and not self.config.serve_locally:
Expand Down
2 changes: 1 addition & 1 deletion dash/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.31.1'
__version__ = '0.31.2'