Skip to content

Commit d04d347

Browse files
committed
Show message when inline JavaScript is disabled
1 parent ad576c9 commit d04d347

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/nyaplot/exportable.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def raise_display_failed
1313
# @return [String] generated html
1414
def generate_html(temp_path)
1515
path = File.expand_path(temp_path, __FILE__)
16+
url = Nyaplot.get_url
1617
id = SecureRandom.uuid
1718
model = to_json
1819
template = File.read(path)
@@ -48,4 +49,14 @@ def show
4849
IRuby.display(self)
4950
end
5051
end
52+
53+
@@url = "http://http://nbviewer.ipython.org/"
54+
55+
def self.set_url(url)
56+
@@url = url
57+
end
58+
59+
def self.get_url
60+
@@url
61+
end
5162
end

lib/nyaplot/templates/iruby.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
<div id="msg-<%= id %>" style="background-color: #555; width: 100%; color: #fff; padding: 5px; border-radius: 8px">
2+
<img src="https://dl.dropboxusercontent.com/u/47978121/cat.png" style="display: inline; margin: 0px 5px;">
3+
<span>Inline JavaScript is disabled for some reason. Use <a href="<%= url %>" target="_blank" style="color: rgb(58, 171, 210)">nbviewer</a> to see plots.</span>
4+
</div>
15
<div id='vis-<%= id %>'></div>
26
<script>
7+
var dom = document.getElementById('msg-<%= id %>');
8+
dom.parentElement.removeChild(dom);
9+
310
require.config({paths: {
411
Nyaplot: "<%= PATH_NYAPLOT %>"
512
}});

0 commit comments

Comments
 (0)