rough staticlist : you provide a list, no query/no asynchroneous
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 11 Mar 2013 16:26:17 +0000 (17:26 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Mon, 11 Mar 2013 16:26:17 +0000 (17:26 +0100)
probably not a high practical interest but for the sake of the design
and also the views we have so far

plugins/static/css/simplelist.css
plugins/static/css/staticlist.css [new file with mode: 0644]
plugins/staticlist.py [new file with mode: 0644]
plugins/templates/simplelist.html
plugins/templates/staticlist.html [new file with mode: 0644]
trash/pluginview.py

index 9ec9073..8bfe216 100644 (file)
@@ -1,9 +1,4 @@
-select { 
-    width: auto;
-}
-div.dataTables_filter input[type=text] {
-    width: 60;
-}
+/* ---------- */
 td.simplelist {
     padding: 0;
     list-style: none;
@@ -14,3 +9,11 @@ td.simplelist>a {
 th.simplelist {
     font-size: 150%;
 }
+/* ---------- */
+/* xxx this probably should be separated in something related to datatables */
+select { 
+    width: auto;
+}
+div.dataTables_filter input[type=text] {
+    width: 60;
+}
diff --git a/plugins/static/css/staticlist.css b/plugins/static/css/staticlist.css
new file mode 100644 (file)
index 0000000..226e189
--- /dev/null
@@ -0,0 +1,3 @@
+th.staticlist {
+    font-size: 150%;
+}
diff --git a/plugins/staticlist.py b/plugins/staticlist.py
new file mode 100644 (file)
index 0000000..b9c644b
--- /dev/null
@@ -0,0 +1,29 @@
+from engine.plugin import Plugin
+
+class StaticList (Plugin) :
+
+    # only deal with our own stuff here and let Plugin handle the rest
+    def __init__ (self, list=[], with_datatables=False, **settings):
+        Plugin.__init__ (self, **settings)
+        self.list=list
+        self.with_datatables = with_datatables
+
+    # SimpleList is useless per se anyways
+    def template_file (self): 
+        return "staticlist.html"
+    
+    def template_env (self, request):
+        env={}
+        header=getattr(self,'header',None)
+        if header: env['header']=header
+        env['list']=self.list
+        return env
+
+    def requirements (self):
+        reqs = { 'js_files' : [ ] ,
+                 'css_files': [ "css/staticlist.css" ],
+                 }
+        if self.with_datatables:
+            reqs['js_files'].append ("datatables/js/dataTables.js")
+            reqs['js_files'].append ("js/with-datatables.js")
+        return reqs
index 4132c4c..ca30c0c 100644 (file)
@@ -3,8 +3,5 @@
 <thead><tr><th class='simplelist'>{{ header }}</th></tr></thead>
 {% endif %}
 <tbody class='simplelist'>
-{% for item in list %}
-<tr><td>{{ item|safe }}</td></tr>
-{% endfor %}
 </tbody>
 </table>
diff --git a/plugins/templates/staticlist.html b/plugins/templates/staticlist.html
new file mode 100644 (file)
index 0000000..2e30eee
--- /dev/null
@@ -0,0 +1,10 @@
+<table class='staticlist{%if with_datatables %} with-datatables{% endif %}'>
+{% if header %}
+<thead><tr><th class='staticlist'>{{ header }}</th></tr></thead>
+{% endif %}
+<tbody class='staticlist'>
+{% for item in list %}
+<tr><td>{{ item|safe }}</td></tr>
+{% endfor %}
+</tbody>
+</table>
index e0bc218..fa3336f 100644 (file)
@@ -11,8 +11,7 @@ from engine.pluginset import PluginSet
 
 from plugins.verticallayout import VerticalLayout
 from plugins.tabs import Tabs
-from plugins.simplelist import SimpleList
-from plugins.slicelist import SliceList
+from plugins.staticlist import StaticList
 from plugins.quickfilter import QuickFilter
 from plugins.raw import Raw
 
@@ -30,10 +29,10 @@ def test_plugin_view (request):
     main_plugin = \
         VerticalLayout ( pluginset=pluginset,
                          title='title for the vertical layout',
-                         sons = [ SimpleList (pluginset=pluginset,
-                                              title='SimpleList and dataTables',
+                         sons = [ StaticList (pluginset=pluginset,
+                                              title='StaticList - with datatables - starts toggled off',
                                               list=hard_wired_list, 
-                                              header='Hard wired', 
+                                              header='Hard wired header', 
                                               foo='the value for foo',
                                               with_datatables=True,
                                               toggled=False),
@@ -45,14 +44,15 @@ def test_plugin_view (request):
                                                       title='a raw plugin',domid='raw1',
                                                       togglable=False,
                                                       html= 3*lorem_p),
-                                                 SliceList(pluginset=pluginset,
-                                                           title='a slice list',
-                                                           togglable=False,
-                                                           list=hard_wired_slice_names),
+                                                 StaticList(pluginset=pluginset,
+                                                            title='a slice list',
+                                                            togglable=False,
+                                                            header="static list but not togglable",
+                                                            list=hard_wired_slice_names),
                                                  Raw (pluginset=pluginset,
                                                       title='raw title',domid='raw2',
                                                       togglable=False,html=lorem) ]),
-                                  SimpleList (pluginset=pluginset,
+                                  StaticList (pluginset=pluginset,
                                               title='SimpleList with slice names', 
                                               list=hard_wired_slice_names,
                                               ),
@@ -64,11 +64,11 @@ def test_plugin_view (request):
 
     ##########
     # lacks a/href to /slice/%s
-    related_plugin = SliceList (pluginset=pluginset,
-                                title='SliceList plugin',domid='slicelist1',
-                                with_datatables='yes', 
-                                list=hard_wired_slice_names, 
-                                header='Slices')
+    related_plugin = StaticList (pluginset=pluginset,
+                                 title='SliceList plugin',domid='slicelist1',
+                                 with_datatables='yes', 
+                                 list=hard_wired_slice_names, 
+                                 header='Slices')
     # likewise but on the side view
     template_env [ 'content_related' ] = related_plugin.render (request)