Short description

The edit warn message that some one else does already edit the page should become more noticable e.g. another color, blinking text or by playing a warning sound.

Patch for Moin1.9.0beta3

General aims

General aims of the given patch is to make following messages better noticable (since they could cause a lot of trouble to the user):

When trying to make something better noticable, this should adhere to basic accessibility guidelines. Therefore, blinking text cannot be used, see http://www-03.ibm.com/able/guidelines/java/javaavoidblnk.html and http://www.scsk12.org/SCS/webhelp/accessibility/blinking.htm. The given patch thus just styles the warning messages in another color, with bigger fonts and in bold. Blue font color is used for potential conflicts, red color is used for existing conflicts.

Explanation of the patch

Patch

   1 diff -r 5863854a6ccf PageEditor.py
   2 --- a/PageEditor.py	Sat Sep 05 22:28:08 2009 +0200
   3 +++ b/PageEditor.py	Mon Sep 07 18:01:07 2009 +0200
   4 @@ -155,8 +155,9 @@
   5  
   6          raw_body = ''
   7          msg = None
   8 -        conflict_msg = None
   9 +        conflict_message = None
  10          edit_lock_message = None
  11 +        edit_lock = 0
  12          preview = kw.get('preview', None)
  13          staytop = kw.get('staytop', 0)
  14  
  15 @@ -175,12 +176,13 @@
  16          else:
  17              try:
  18                  # try to acquire edit lock
  19 -                ok, edit_lock_message = self.lock.acquire()
  20 -                if not ok:
  21 +                edit_lock, edit_lock_message = self.lock.acquire()
  22 +                if not edit_lock:
  23                      # failed to get the lock
  24                      if preview is not None:
  25                          edit_lock_message = _('The lock you held timed out. Be prepared for editing conflicts!'
  26                              ) + "<br>" + edit_lock_message
  27 +                        edit_lock = 3 # we need to warn the user explicitely
  28                      else:
  29                          msg = edit_lock_message
  30              except OSError, err:
  31 @@ -244,14 +246,14 @@
  32              if not self.exists():
  33                  # page does not exist, are we creating it?
  34                  if rev:
  35 -                    conflict_msg = _('Someone else deleted this page while you were editing!')
  36 +                    conflict_message = _('Someone else deleted this page while you were editing!')
  37              elif rev != self.current_rev():
  38 -                conflict_msg = _('Someone else changed this page while you were editing!')
  39 +                conflict_message = _('Someone else changed this page while you were editing!')
  40                  if self.mergeEditConflict(rev):
  41 -                    conflict_msg = _("""Someone else saved this page while you were editing!
  42 +                    conflict_message = _("""Someone else saved this page while you were editing!
  43  Please review the page and save then. Do not save this page as it is!""")
  44                      rev = self.current_rev()
  45 -            if conflict_msg:
  46 +            if conflict_message:
  47                  # We don't show preview when in conflict
  48                  preview = None
  49  
  50 @@ -304,11 +306,18 @@
  51                      draft_message = _(u"'''<<BR>>Your draft based on revision %(draft_rev)d (saved %(draft_timestamp_str)s) can be loaded instead of the current revision %(page_rev)d by using the load draft button - in case you lost your last edit somehow without saving it.''' A draft gets saved for you when you do a preview, cancel an edit or unsuccessfully save.", wiki=True) % locals()
  52  
  53          # Setup status message
  54 -        status = [kw.get('msg', ''), conflict_msg, edit_lock_message, draft_message]
  55 -        status = [msg for msg in status if msg]
  56 -        status = ' '.join(status)
  57 -        status = Status(request, content=status)
  58 -        request.theme.add_msg(status, "dialog")
  59 +        miscellaneous_message = kw.get('msg', None)
  60 +        if miscellaneous_message:
  61 +            request.theme.add_msg(miscellaneous_message, "info_msg")
  62 +        if conflict_message:
  63 +            request.theme.add_msg(conflict_message, "conflict_msg")
  64 +        if edit_lock_message:   
  65 +            if edit_lock == 3:
  66 +                request.theme.add_msg(edit_lock_message, "edit_lock_potential_conflicts_msg")
  67 +            else:
  68 +                request.theme.add_msg(edit_lock_message, "edit_lock_msg")
  69 +        if draft_message:
  70 +            request.theme.add_msg(draft_message, "draft_msg")
  71  
  72          request.theme.send_title(
  73              title % {'pagename': self.split_title(), },
  74 @@ -1191,7 +1200,7 @@
  75  
  76          @rtype: tuple
  77          @return: tuple is returned containing 2 values:
  78 -              * a bool indicating successful acquiry
  79 +              * a value indicating successful acquiry (0=failed; 1=sucess; 3=succes but user needs to be warned)
  80                * a string giving a reason for failure or an informational msg
  81          """
  82          if not self.locktype:
  83 @@ -1242,7 +1251,7 @@
  84              else:
  85                  # warn user about existing lock
  86  
  87 -                result = 1, _(
  88 +                result = 3, _(
  89  """This page was opened for editing or last previewed at %(timestamp)s by %(owner)s.<<BR>>
  90  '''You should ''refrain from editing'' this page for at least another %(mins_valid)d minute(s),
  91  to avoid editing conflicts.'''<<BR>>
  92 diff -r 5863854a6ccf theme/__init__.py
  93 --- a/theme/__init__.py	Sat Sep 05 22:28:08 2009 +0200
  94 +++ b/theme/__init__.py	Mon Sep 07 18:01:07 2009 +0200
  95 @@ -562,36 +562,39 @@
  96              page = Page(self.request, page)
  97          return page.link_to_raw(self.request, text=img_src, querystr=qs, **attrs)
  98  
  99 -    def msg(self, d):
 100 +    def msg(self, d, link=1):
 101          """ Assemble the msg display
 102  
 103          Display a message with a widget or simple strings with a clear message link.
 104  
 105          @param d: parameter dictionary
 106 +        @param link: allows toggling of 'clear message"-link (defaults to 'show link')
 107          @rtype: unicode
 108          @return: msg display html
 109          """
 110          _ = self.request.getText
 111          msgs = d['msg']
 112  
 113 -        result = u""
 114 +        result = u''
 115          close = d['page'].link_to(self.request, text=_('Clear message'), css_class="clear-link")
 116          for msg, msg_class in msgs:
 117              try:
 118 -                result += u'<p>%s</p>' % msg.render()
 119 -                close = ''
 120 +                result += u'<p>%s</p>\n' % msg.render()
 121 +                link = 0
 122              except AttributeError:
 123                  if msg and msg_class:
 124 -                    result += u'<p><div class="%s">%s</div></p>' % (msg_class, msg)
 125 +                    result += u'<div class="%s"><p>%s</p></div>\n' % (msg_class, msg)
 126                  elif msg:
 127                      result += u'<p>%s</p>\n' % msg
 128 +
 129          if result:
 130 -            html = result + close
 131 -            return u'<div id="message">\n%s\n</div>\n' % html
 132 -        else:
 133 -            return u''
 134 +            if link:
 135 +                return u'<div id="message">\n%s%s\n</div>\n' % (result, close)
 136 +            else:
 137 +                return u'<div id="message">\n%s\n</div>\n' % result                    
 138  
 139 -        return u'<div id="message">\n%s\n</div>\n' % html
 140 +        return u''
 141 + 
 142  
 143      def trail(self, d):
 144          """ Assemble page trail
 145 diff -r 5863854a6ccf theme/modern.py
 146 --- a/theme/modern.py	Sat Sep 05 22:28:08 2009 +0200
 147 +++ b/theme/modern.py	Mon Sep 07 18:01:07 2009 +0200
 148 @@ -62,7 +62,7 @@
 149              # Header
 150              u'<div id="header">',
 151              self.title(d),
 152 -            self.msg(d),
 153 +            self.msg(d, 0),
 154              u'</div>',
 155  
 156              # Post header custom html (not recommended)
 157 diff -r 5863854a6ccf web/static/htdocs/modern/css/common.css
 158 --- a/web/static/htdocs/modern/css/common.css	Sat Sep 05 22:28:08 2009 +0200
 159 +++ b/web/static/htdocs/modern/css/common.css	Mon Sep 07 18:01:07 2009 +0200
 160 @@ -221,6 +221,20 @@
 161  .error
 162  {
 163  	color: red;
 164 +}
 165 +
 166 +.conflict_msg
 167 +{
 168 +    color: red;
 169 +    font-weight: bold;
 170 +    font-size: 1.2em;
 171 +}
 172 +
 173 +.edit_lock_potential_conflicts_msg
 174 +{
 175 +    color: blue;
 176 +    font-weight: bold;
 177 +    font-size: 1.2em;
 178  }
 179  
 180  strong.highlight

patch.diff

Discussion

Yes, this would be quite important in my eyes, however for conflict_msg, edit_lock_message, draft_message there are not seperate css-classes yet. All get wrapped into class "status" by the status widget -- -- OliverSiemoneit 2009-09-06 19:42:44

Related topics

MoinMoinBugs/NoMsgForEditConflict


CategoryFeatureRequest

MoinMoin: FeatureRequests/EditWarnMessageBetterNoticable (last edited 2010-09-21 12:31:35 by ThomasWaldmann)