Commits

Ralph Bean committed 56fa202 Merge

Merge branch 'release/2.0.2'

Comments (0)

Files changed (8)

 include README.rst
 recursive-include tw2/jit/templates *
 recursive-include tw2/jit/static *
+recursive-include tests *

python-tw2-jit.spec

+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+
+%global modname tw2.jit
+
+Name:           python-tw2-jit
+Version:        2.0.2
+Release:        1%{?dist}
+Summary:        Javascript Infovis Toolkit (JIT) for ToscaWidgets2
+
+Group:          Development/Languages
+License:        MIT
+URL:            http://toscawidgets.org
+Source0:        http://pypi.python.org/packages/source/t/%{modname}/%{modname}-%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch:      noarch
+
+# For building
+BuildRequires:  python2-devel
+BuildRequires:  python-setuptools
+BuildRequires:  python-tw2-core
+BuildRequires:  python-tw2-jquery
+BuildRequires:  python-tw2-sqla
+BuildRequires:  python-sqlalchemy
+BuildRequires:  python-BeautifulSoup
+BuildRequires:  python-genshi
+BuildRequires:  python-mako
+
+# Runtime requirements
+Requires:  python-tw2-core
+Requires:  python-tw2-jquery
+Requires:  python-tw2-sqla
+Requires:  python-sqlalchemy
+Requires:  python-BeautifulSoup
+Requires:  python-genshi
+Requires:  python-mako
+
+%description
+toscawidgets2 (tw2) aims to be a practical and useful widgets framework
+that helps people build interactive websites with compelling features, faster
+and easier. Widgets are re-usable web components that can include a template,
+server-side code and JavaScripts/CSS resources. The library aims to be:
+flexible, reliable, documented, performant, and as simple as possible.
+
+The JavaScript InfoVis Toolkit (thejit) is a javascript library that
+provides web standard based tools to create interactive data visualizations
+for the Web.  It is pretty, interactive, and fast.
+
+This module, tw2.jit, provides toscawidgets2 (tw2) widgets that render
+thejit data visualizations.
+
+%prep
+%setup -q -n %{modname}-%{version}
+
+%build
+%{__python} setup.py build
+
+%install
+rm -rf %{buildroot}
+%{__python} setup.py install -O1 --skip-build \
+    --install-data=%{_datadir} --root %{buildroot}
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%doc README.rst
+%{python_sitelib}/*
+
+%changelog
+* Thu Apr 12 2012 Ralph Bean <rbean@redhat.com> - 2.0.2-1
+- Initial packaging for Fedora
 
 setup(
     name='tw2.jit',
-    version='2.0.1',
+    version='2.0.2',
     description='toscawidgets2 wrapper for the javascript infovis toolkit(jit)',
     long_description=long_description,
     author='Ralph Bean',
     author_email='rbean@redhat.com',
     url='http://github.com/toscawidgets/tw2.jit',
+    license='MIT',
     install_requires=[
         "tw2.core>=2.0.0",
         "tw2.jquery",
         "genshi",
         "mako",
         "tw2.sqla",
-        "elixir",
         "sqlalchemy",
-        "tw2.dynforms",
         "BeautifulSoup",
         ],
     packages=find_packages(exclude=['ez_setup']),
         'toscawidgets.widgets',
     ],
     classifiers = [
-        'Development Status :: 4 - Beta',
+        'Development Status :: 5 - Production/Stable',
+        'License :: OSI Approved :: MIT License',
         'Environment :: Web Environment',
         'Environment :: Web Environment :: ToscaWidgets',
         'Topic :: Software Development :: Libraries :: Python Modules',

tw2/jit/samples/graph.py

         (function(domElement, node){
             domElement.innerHTML = node.name;
             domElement.onclick = function(){
-                jitwidget.onClick(node.id);
+                $$jitwidget.onClick(node.id);
             };
         })""")
     onPlaceLabel = JSSymbol(src="""
             'enable' : True,
             'onMouseEnter' : JSSymbol(src="""
             (function() { 
-                jitwidget.canvas.getElement().style.cursor = \'move\';
+                $$jitwidget.canvas.getElement().style.cursor = \'move\';
             })"""),
             'onMouseLeave' : JSSymbol(src="""
             (function() {
-                jitwidget.canvas.getElement().style.cursor = \'\';
+                $$jitwidget.canvas.getElement().style.cursor = \'\';
             })"""),
             'onDragMove' : JSSymbol(src="""
             (function(node, eventInfo, e) {
                 var pos = eventInfo.getPos();
                 node.pos.setc(pos.x, pos.y);
-                jitwidget.plot();
+                $$jitwidget.plot();
             })"""),
             'onTouchMove' : JSSymbol(src="""
             (function(node, eventInfo, e) {

tw2/jit/samples/tree.py

         'onClick': JSSymbol(src="""
             (function(node) {  
                 if(!node) return;  
-                jitwidget.tips.hide();  
-                jitwidget.rotate(node, 'animate', {  
+                $$jitwidget.tips.hide();  
+                $$jitwidget.rotate(node, 'animate', {  
                     duration: 1000,  
                     transition: $jit.Trans.Quart.easeInOut  
                 });  
             ( function(domElement, node){
                   domElement.innerHTML = node.name;
                   $jit.util.addEvent(domElement, 'click', function () {
-                      jitwidget.onClick(node.id);
+                      $$jitwidget.onClick(node.id);
                   });
             })""")
 
             label.id = node.id;            
             label.innerHTML = node.name;
             label.onclick = function(){
-                jitwidget.onClick(node.id);
+                $$jitwidget.onClick(node.id);
             };
             var style = label.style;
             style.width = 60 + 'px';
         'onMouseEnter': JSSymbol(src="""
             (function(node) {
                 node.setData('border', '#33dddd');
-                jitwidget.fx.plotNode(node, jitwidget.canvas);
-                jitwidget.labels.plotLabel(
-                                 jitwidget.canvas,
+                $$jitwidget.fx.plotNode(node, $$jitwidget.canvas);
+                $$jitwidget.labels.plotLabel(
+                                 $$jitwidget.canvas,
                                  node,
-                                 jitwidget.controller);
+                                 $$jitwidget.controller);
             })"""),
         'onMouseLeave': JSSymbol(src="""
             (function(node) {
                 node.removeData('border');
-                jitwidget.fx.plot();
+                $$jitwidget.fx.plot();
             })"""),
         'onClick': JSSymbol(src="""
             (function(node){
                 if (node) {
-                    jitwidget.tips.hide();
-                    if(jitwidget.events.hoveredNode){
-                        this.onMouseLeave(jitwidget.events.hoveredNode);
+                    $$jitwidget.tips.hide();
+                    if($$jitwidget.events.hoveredNode){
+                        this.onMouseLeave($$jitwidget.events.hoveredNode);
                     }
-                    jitwidget.enter(node);
+                    $$jitwidget.enter(node);
                }
             })"""),
         'onRightClick': JSSymbol(src="""
             (function(){
-                jitwidget.tips.hide();
-                if(jitwidget.events.hoveredNode) {
-                    this.onMouseLeave(jitwidget.events.hoveredNode);
+                $$jitwidget.tips.hide();
+                if($$jitwidget.events.hoveredNode) {
+                    this.onMouseLeave($$jitwidget.events.hoveredNode);
                 }
-                jitwidget.out();
+                $$jitwidget.out();
             })"""),
     }
     onCreateLabel = JSSymbol(src="""

tw2/jit/widgets/ajax.py

                     }
 
                     var hover_id = 'ajaxRadialGraph_' + node.id + '_Tip';
-                    hover_id = hover_id.replace(/\./g,'_');
-                    hover_id = hover_id.replace(/\//g, '_');
-                    hover_id = hover_id.replace(/\(/g, '_');
-                    hover_id = hover_id.replace(/\)/g, '_');
+
+                    // TODO -- this needs some fixin'
+                    //hover_id = hover_id.replace(/\./g,'_');
+                    //hover_id = hover_id.replace(/\//g, '_');
+                    //hover_id = hover_id.replace(/\(/g, '_');
+                    //hover_id = hover_id.replace(/\)/g, '_');
+                    hover_id = hover_id.replace(new RegExp('\\.', 'g'),'_');
 
                     jQuery(domElement)
                       .mouseover(

tw2/jit/widgets/core.py

             q_str = urllib.urlencode(self.url_kw)
             self.url += '?' + q_str
 
+
+        def replacements(k, v):
+            """ Generator that yields key, value pairs where the value has had
+            all of its custom jsVariables replaced.
+
+            TODO - this could be wildly optimized.
+            """
+
+            src = v.src
+
+            for var, fun in self.jsVariables.iteritems():
+                if not var in src:
+                    continue
+                res = fun(self)
+                if not isinstance(res, basestring):
+                    res = twc.encoder.encode(res)
+
+                src = src.replace(var, res)
+
+            yield k, twc.JSSymbol(src=src)
+
         # TODO -- this should be overhauled to not use JSSymbol
         for k, v in self.attrs.iteritems():
             if type(v) in [twc.JSSymbol]:
-                for var, fun in self.jsVariables.iteritems():
-                    if not var in v.src:
-                        continue
-                    res = fun(self)
-                    if not isinstance(res, basestring):
-                        res = twc.encoder.encode(res)
+                for key_to_replace, new_value in replacements(k, v):
+                    self.attrs[key_to_replace] = new_value
 
-                    self.attrs[k] = twc.JSSymbol(
-                        src=self.attrs[k].src.replace(var, res))
+            if k == 'Events':
+                for _k, _v in v.items():
+                    if type(_v) in [twc.JSSymbol]:
+                        for key_to_replace, new_value in replacements(_k, _v):
+                            self.attrs['Events'][key_to_replace] = new_value
+
 
         setupcall = js_function('setupTW2JitWidget')(
             self.jitClassName,

tw2/jit/widgets/tree.py

         '(dict) Of the form Options.Events in the jit docs.',
         default={
             'enable': True,
-            'onClick': JSSymbol(src='(function(node) {if (node) {jitwidget.enter(node);}})'),
-            'onRightClick': JSSymbol(src='(function() {jitwidget.out();})'),
+            'onClick': JSSymbol(src='(function(node) {if (node) {$$jitwidget.enter(node);}})'),
+            'onRightClick': JSSymbol(src='(function() {$$jitwidget.out();})'),
         }, attribute=True)
 
     # TODO - Node.Type
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.