-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit allowed script tags, allow adding stylesheet for now
- Loading branch information
Showing
1 changed file
with
16 additions
and
6 deletions.
There are no files selected for viewing
22 changes: 16 additions & 6 deletions
22
config/plugins/visualizations/common/templates/script_entry_point.mako
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
<%inherit file="visualization_base.mako"/> | ||
|
||
## No stylesheets | ||
<%def name="stylesheets()"></%def> | ||
## Add stylesheet | ||
<%def name="stylesheets()"> | ||
<% css = script_attributes.get("css") %> | ||
%if css is not None: | ||
<link rel="stylesheet" href="${css}"> | ||
%endif | ||
</%def> | ||
|
||
## Create a container, attach data and import script file | ||
<%def name="late_javascripts()"> | ||
<% container = script_attributes.get("container") or "app" %> | ||
<%def name="get_body()"> | ||
## Collect incoming data | ||
<% data_incoming = { | ||
"visualization_id": visualization_id, | ||
"visualization_name": visualization_name, | ||
"visualization_plugin": visualization_plugin, | ||
"visualization_config": config } | ||
%> | ||
## Create a container with default identifier `app` | ||
<% container = script_attributes.get("container") or "app" %> | ||
<div id="${container}" data-incoming='${h.dumps(data_incoming)}'></div> | ||
<% tag_attrs = ' '.join([ '{0}="{1}"'.format( key, attr ) for key, attr in script_attributes.items() ]) %> | ||
<script type="text/javascript" ${tag_attrs}></script> | ||
## Add script tag | ||
<% src = script_attributes.get("src") %> | ||
<script type="text/javascript" src=${src}></script> | ||
</%def> |