Demo OpenLab Debug off in manifold/static/js/manifold.js
[unfold.git] / plugins / messages / __init__.py
1 from unfold.plugin import Plugin
2
3 # lists levels and sets them to enabled or not at startup
4 default_levels = {'fatal': True, 'error': True, 'warning' : True, 'info' : True, 'debug' : False}
5 #default_levels = {'fatal': False, 'error': False, 'warning' : False, 'info' : False, 'debug' : False}
6
7 # there are two implementations available here
8 # one shows up in the main page like a regular part of the page,
9 # while the other one relies on transient popups
10 # by default we use the latter, but you can specify 
11 # transient=False if you want to use the former
12 # xxx
13 # also the pieces that go with this transient mode are
14 # under views/templates, it would make sense to move them over here
15 # however it turns out that views/templates/base.html unconditionnally
16 # includes messages-transient-header.html 
17 class Messages (Plugin):
18
19     def __init__ (self, transient=True, levels=None, **settings):
20         Plugin.__init__ (self, **settings)
21         if levels is None: levels=default_levels
22         # shortcut: 'ALL' turn everything on
23         elif levels=='ALL': levels=dict( [ (k,True) for k in default_levels ] )
24         elif levels=='NONE': levels=dict( [ (k,False) for k in default_levels ] )
25         self.transient=transient
26         self.levels=levels
27
28     def template_file (self):
29         return "messages.html" if not self.transient else "messages-transient.html"
30
31     def requirements (self):
32         return {
33             'js_files' :  [ "js/messages.js", "js/manifold.js", ],
34             'css_files' : "css/messages.css",
35             }
36
37     # although this has no query, we need a plugin instance to be created in the js output
38     def export_json_settings (self):
39         return True
40     # the js plugin expects a domid
41     def json_settings_list (self):
42         return [ 'plugin_uuid', 'levels' ]
43
44     # and we don't need a spin wheel 
45     def start_with_spin (self):
46         return False