Attachment 'easier_RecentChanges-1.5.5a.patch'

Download

   1 --- MoinMoin/macro/RecentChanges.py.155a.old	Sun Oct 22 16:17:52 2006
   2 +++ MoinMoin/macro/RecentChanges.py	Sun Oct 15 23:04:18 2006
   3 @@ -44,6 +44,7 @@
   4  
   5      return wikiutil.make_breakable(comment, _MAX_COMMENT_LENGTH)
   6  
   7 +# Format a single page's day's worth of page edits.
   8  def format_page_edits(macro, lines, bookmark_usecs):
   9      request = macro.request
  10      _ = request.getText
  11 @@ -51,34 +52,67 @@
  12      line = lines[0]
  13      pagename = line.pagename
  14      tnow = time.time()
  15 -    is_new = lines[-1].action == 'SAVENEW'
  16 -    # check whether this page is newer than the user's bookmark
  17 -    hilite = line.ed_time_usecs > (bookmark_usecs or line.ed_time_usecs)
  18 +
  19      page = Page(request, line.pagename)
  20  
  21 -    html_link = ''
  22 -    if not page.exists():
  23 +#    request.write("pagename=%s<br>\n " % line.pagename)
  24 +    
  25 +    latestrev = None
  26 +    oldestrevline = None
  27 +    for line in lines:
  28 +#        request.write("- rev=%s<br>\n" % line.rev)
  29 +        # Determine the first & last _real_ page revision
  30 +        # (i.e. attachnew/del == 999999; we don't care about these)
  31 +        lrev = int(line.rev)
  32 +        if lrev != 99999999:
  33 +            if latestrev == None:
  34 +                latestrev = lrev
  35 +            oldestrevline = line
  36 +
  37 +    if latestrev and not page.get_rev(-1, latestrev)[2]:
  38 +        # If the latest page revision was a delete, 
  39          # indicate page was deleted
  40          html_link = request.theme.make_icon('deleted')
  41 -    elif is_new:
  42 -        # show "NEW" icon if page was created after the user's bookmark
  43 -        if hilite:
  44 -            img = request.theme.make_icon('new')
  45 -            html_link = wikiutil.link_tag(request, wikiutil.quoteWikinameURL(pagename),
  46 -                                          img, formatter=macro.formatter)
  47 -    elif hilite:
  48 -        # show "UPDATED" icon if page was edited after the user's bookmark
  49 -        img = request.theme.make_icon('updated')
  50 -        html_link = wikiutil.link_tag(request,
  51 -                                      wikiutil.quoteWikinameURL(pagename) + "?action=diff&date=%d" % bookmark_usecs,
  52 +#        request.write("- DELETED<br>\n")
  53 +    elif oldestrevline and oldestrevline.action == 'SAVENEW':
  54 +        # the oldest change was a create, show it as "new"
  55 +        img = request.theme.make_icon('new')
  56 +        html_link = wikiutil.link_tag(request, wikiutil.quoteWikinameURL(pagename),
  57                                        img, formatter=macro.formatter)
  58 +#        request.write("- NEW<br>\n")
  59      else:
  60 -        # show "DIFF" icon else
  61 -        img = request.theme.make_icon('diffrc')
  62 -        html_link = wikiutil.link_tag(request,
  63 -                                      wikiutil.quoteWikinameURL(line.pagename) + "?action=diff",
  64 -                                      img, formatter=macro.formatter)
  65 +        # else call it modified.
  66 +        img = request.theme.make_icon('updated')
  67 +        html_link = ''
  68 +
  69 +        if latestrev:
  70 +            # Try to link from the latest rev to one-before the oldest rev.
  71 +            # Need to figure out what the next-oldest revision is.
  72 +            oldestrev = int(oldestrevline.rev)
  73 +            found = False
  74 +            prehistoric_rev = None
  75 +            for rev in page.getRevList():
  76 +                if found:
  77 +                    prehistoric_rev = rev
  78 +                    break
  79 +                elif rev == oldestrev:
  80 +                    found = True
  81 +
  82 +            if prehistoric_rev:
  83 +                html_link = wikiutil.link_tag(request,
  84 +                                  wikiutil.quoteWikinameURL(pagename) 
  85 +                                  + "?action=diff&rev1=%d&rev2=%d" % (prehistoric_rev, latestrev),
  86 +                                  img, formatter=macro.formatter)
  87 +#                request.write("- DIFF between %d and %d<br>\n" % (prehistoric_rev, latestrev))
  88  
  89 +        if not html_link:
  90 +            # There wasn't anything to diff (probably just attachment changes)
  91 +            # so just link to the page.
  92 +            html_link = wikiutil.link_tag(request, wikiutil.quoteWikinameURL(pagename),
  93 +                                          img, formatter=macro.formatter)
  94 +            
  95 +#        request.write("- MOD<br>\n")
  96 +#    request.write("<br>\n")
  97      # print name of page, with a link to it
  98      force_split = len(page.page_name) > _MAX_PAGENAME_LENGTH
  99      
 100 @@ -278,7 +312,6 @@
 101      request.write(request.theme.recentchanges_header(d))
 102      
 103      pages = {}
 104 -    ignore_pages = {}
 105  
 106      today = request.user.getTime(tnow)[0:3]
 107      this_day = today
 108 @@ -296,8 +329,6 @@
 109          if ((this_day != day or (not hilite and not max_days))) and len(pages) > 0:
 110              # new day or bookmark reached: print out stuff 
 111              this_day = day
 112 -            for page in pages:
 113 -                ignore_pages[page] = None
 114              pages = pages.values()
 115              pages.sort(cmp_lines)
 116              pages.reverse()
 117 @@ -324,10 +355,7 @@
 118          elif this_day != day:
 119              # new day but no changes
 120              this_day = day
 121 -
 122 -        if line.pagename in ignore_pages:
 123 -            continue
 124 -        
 125 +       
 126          # end listing by default if user has a bookmark and we reached it
 127          if not max_days and not hilite:
 128              msg = _('[Bookmark reached]')
 129 @@ -342,8 +370,6 @@
 130              # end of loop reached: print out stuff 
 131              # XXX duplicated code from above
 132              # but above does not trigger if we have the first day in wiki history
 133 -            for page in pages:
 134 -                ignore_pages[page] = None
 135              pages = pages.values()
 136              pages.sort(cmp_lines)
 137              pages.reverse()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-03-16 20:31:26, 4.4 KB) [[attachment:easier_RecentChanges-1.3.1.patch]]
  • [get | view] (2006-10-24 05:28:50, 5.5 KB) [[attachment:easier_RecentChanges-1.5.5a.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.