reinstate the original messages mode in addition to the new popup-based one
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 11 Sep 2013 14:19:29 +0000 (16:19 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 11 Sep 2013 14:19:29 +0000 (16:19 +0200)
use plugin = Messages  (transient = True | False)
to select between both

plugins/messages/messages.py
views/templates/base.html
views/templates/messages-transient-header.html [moved from views/templates/messages-header.html with 100% similarity]
views/templates/messages-transient.html [moved from views/templates/messages.html with 100% similarity]

index 0faee93..65baea1 100644 (file)
@@ -3,18 +3,29 @@ from unfold.plugin import Plugin
 # lists levels and sets them to enabled or not at startup
 default_levels = {'fatal': True, 'error': True, 'warning' : True, 'info' : True, 'debug' : False}
 
 # lists levels and sets them to enabled or not at startup
 default_levels = {'fatal': True, 'error': True, 'warning' : True, 'info' : True, 'debug' : False}
 
+# there are two implementations available here
+# one shows up in the main page like a regular part of the page,
+# while the other one relies on transient popups
+# by default we use the latter, but you can specify 
+# transient=False if you want to use the former
+# xxx
+# also the pieces that go with this transient mode are
+# under views/templates, it would make sense to move them over here
+# however it turns out that views/templates/base.html unconditionnally
+# includes messages-transient-header.html 
 class Messages (Plugin):
 
 class Messages (Plugin):
 
-    def __init__ (self, levels=None, **settings):
+    def __init__ (self, transient=True, levels=None, **settings):
         Plugin.__init__ (self, **settings)
         if levels is None: levels=default_levels
         # shortcut: 'ALL' turn everything on
         elif levels=='ALL': levels=dict( [ (k,True) for k in default_levels ] )
         elif levels=='NONE': levels=dict( [ (k,False) for k in default_levels ] )
         Plugin.__init__ (self, **settings)
         if levels is None: levels=default_levels
         # shortcut: 'ALL' turn everything on
         elif levels=='ALL': levels=dict( [ (k,True) for k in default_levels ] )
         elif levels=='NONE': levels=dict( [ (k,False) for k in default_levels ] )
+        self.transient=transient
         self.levels=levels
 
     def template_file (self):
         self.levels=levels
 
     def template_file (self):
-        return "messages.html"
+        return "messages.html" if not self.transient else "messages-transient.html"
 
     def requirements (self):
         return {
 
     def requirements (self):
         return {
index db0d39f..ca7a969 100644 (file)
@@ -3,7 +3,7 @@
 <title> MySlice - {{ title }} </title>
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 {# This is where insert_str will end up #}{% media_container prelude %}
 <title> MySlice - {{ title }} </title>
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 {# This is where insert_str will end up #}{% media_container prelude %}
-{% include 'messages-header.html' %}
+{% include 'messages-transient-header.html' %}
 <script type="text/javascript"> {# raw js code - use {% insert prelude_js %} ... {% endinsert %} #} {% container prelude_js %}</script>
 <style type="text/css">{# In case we need to add raw css code #}{% container prelude_css %}</style>
 {{ header_prelude }}
 <script type="text/javascript"> {# raw js code - use {% insert prelude_js %} ... {% endinsert %} #} {% container prelude_js %}</script>
 <style type="text/css">{# In case we need to add raw css code #}{% container prelude_css %}</style>
 {{ header_prelude }}