##// END OF EJS Templates
Moving direct view widget to docs/examples.
Brian Granger -
Show More
@@ -0,0 +1,20 b''
1 {
2 "metadata": {
3 "name": "directview"
4 },
5 "nbformat": 3,
6 "worksheets": [
7 {
8 "cells": [
9 {
10 "cell_type": "code",
11 "input": [
12 ""
13 ],
14 "language": "python",
15 "outputs": []
16 }
17 ]
18 }
19 ]
20 } No newline at end of file
1 NO CONTENT: file renamed from IPython/frontend/html/notebook/widgets/directview.js to docs/examples/widgets/directview/directview.js
NO CONTENT: file renamed from IPython/frontend/html/notebook/widgets/directview.js to docs/examples/widgets/directview/directview.js
@@ -31,7 +31,7 b' from IPython.core.displaypub import publish_pretty'
31 import os, sys
31 import os, sys
32 from IPython.core.display import Javascript
32 from IPython.core.display import Javascript
33
33
34 from .widget import JavascriptWidget
34 from widget import JavascriptWidget
35
35
36
36
37 class DirectViewWidget(JavascriptWidget):
37 class DirectViewWidget(JavascriptWidget):
@@ -42,7 +42,9 b' class DirectViewWidget(JavascriptWidget):'
42 super(DirectViewWidget,self).__init__()
42 super(DirectViewWidget,self).__init__()
43
43
44 def render(self):
44 def render(self):
45 jscode = self.load_file(u'directview.js')
45 fname = os.path.join(os.path.dirname(__file__), u'directview.js')
46 with open(fname, 'r') as f:
47 jscode = f.read()
46 data = {
48 data = {
47 'widget_var': self.widget_var,
49 'widget_var': self.widget_var,
48 'targets' : self.encode_json(self.targets)
50 'targets' : self.encode_json(self.targets)
@@ -39,19 +39,6 b' class JavascriptWidget(object):'
39 ns = get_ipython().user_ns
39 ns = get_ipython().user_ns
40 ns[self.widget_var] = self
40 ns[self.widget_var] = self
41
41
42 def load_file(self, fname):
43 """Read a file in the same directory as this module.
44
45 This exists to make it easy for developers of widget to put Javascript
46 source files and templates in the same directory as their Python
47 widget code. This is much better than writing the JavaScript code in
48 Python strings.
49 """
50 fname = os.path.join(os.path.dirname(__file__), fname)
51 with open(fname) as f:
52 data = f.read()
53 return data
54
55 def encode_json(self, o):
42 def encode_json(self, o):
56 return jsonapi.dumps(o)
43 return jsonapi.dumps(o)
57
44
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now