1 from unfold.plugin import Plugin
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}
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
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):
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
28 def template_file (self):
29 return "messages.html" if not self.transient else "messages-transient.html"
31 def requirements (self):
33 'js_files' : [ "js/messages.js", "js/manifold.js", ],
34 'css_files' : "css/messages.css",
37 # although this has no query, we need a plugin instance to be created in the js output
38 def export_json_settings (self):
40 # the js plugin expects a domid
41 def json_settings_list (self):
42 return [ 'plugin_uuid', 'levels' ]