Commits

ejucovy  committed da23b9c

wiki history and diff views

  • Participants
  • Parent commits 31a7902

Comments (0)

Files changed (3)

 1. Add pictures for:
  * /attachment/
- * /wiki/ diff ("last modified") - should be like ticket-comment-diff and browser-changeset
- * /wiki/ history ("history")
  
 2. Replace hardcoded gravatar with an OrderedExtensionPoint implementing IUserPicturesProvider
 

File userpictures/__init__.py

     browser_filesource_size = Option("userpictures", "browser_filesource_size", default="40")
     browser_lineitem_size = Option("userpictures", "browser_lineitem_size", default="20")
     search_results_size = Option("userpictures", "search_results_size", default="20")
+    wiki_diff_size = Option("userpictures", "wiki_diff_size", default="30")
+    wiki_history_lineitem_size = Option("userpictures", "wiki_history_lineitem_size", default="20")
 
     ## ITemplateProvider methods
 
             filter_.extend(self._search_filter(req, data))
         elif req.path_info.startswith("/report") or req.path_info.startswith("/query"):
             filter_.extend(self._report_filter(req, data))
+        elif req.path_info.startswith("/wiki"):
+            filter_.extend(self._wiki_filter(req, data))
 
         for f in filter_:
             if f is not None:
             return itertools.chain([stream[0]], tag, stream[1:])
 
         return [Transformer('//table[@class="listing tickets"]/tbody/tr/td[@class="owner"]|//table[@class="listing tickets"]/tbody/tr/td[@class="reporter"]').filter(find_change)]
+
+    def _wiki_filter(self, req, data):
+        if "action=diff" in req.query_string:
+            return self._wiki_diff_filter(req, data)
+        elif "action=history" in req.query_string:
+            return self._wiki_history_lineitem_filter(req, data)
+        return []
+
+    def _wiki_diff_filter(self, req, data):
+        author = data['change']['author']
+
+        return [lambda stream: Transformer('//dd[@class="author"]'
+                                           ).prepend(self._generate_avatar(
+                    req, author, 
+                    "wiki-diff", self.wiki_diff_size)
+                                                     )(stream)]
+    
+    def _wiki_history_lineitem_filter(self, req, data):
+        def find_change(stream):
+            author = stream[1][1]
+            tag = self._generate_avatar(req, author,
+                                        'wiki-history-lineitem', self.wiki_history_lineitem_size)
+            return itertools.chain([stream[0]], tag, stream[1:])
+
+        return [Transformer('//td[@class="author"]').filter(find_change)]
+
+    

File userpictures/htdocs/userpictures.css

   vertical-align: middle;
 }
 
-img.userpictures_avatar.browser-lineitem {
+img.userpictures_avatar.browser-lineitem,
+img.userpictures_avatar.wiki-history-lineitem {
   margin: 0 5px 0 0;
 }
 
 img.userpictures_avatar.browser-changeset,
-img.userpictures_avatar.ticket-comment-diff {
+img.userpictures_avatar.ticket-comment-diff,
+img.userpictures_avatar.wiki-diff {
   margin: 3px 10px 5px 0px;
   vertical-align: middle;
 }