Code Monkey home page Code Monkey logo

trac-userpicturesplugin's Introduction

Adds user picture icons (avatars) to Trac.

Screenshots of the plugin in action can be found at https://github.com/boldprogressives/trac-UserPicturesPlugin/wiki/Screenshots

Credit goes to Michael Bayer for the idea -- and most of the code -- in https://bitbucket.org/zzzeek/tracvatar

A mirror is also available on Bitbucket: https://bitbucket.org/boldprogressives/trac-userpictures-plugin

The avatar engine is configurable, and two are provided in this package: a GravatarProvider that looks up the user's email address at Gravatar, and a UserManagerProvider that uses internally hosted images provided by the Trac UserManager Plugin if it is installed: http://trac-hacks.org/wiki/UserManagerPlugin

The approach of the plugin is to filter specific Trac views, gather all the authors found in the "data" hash being passed to Genshi, then using Genshi filters to insert additional avatar nodes with the proper img tags.

Currently supported views are:

  • Timeline
  • Ticket details: reporter, owner, comments, comment diffs
  • Attachment views (on tickets, wiki pages, etc)
  • Source control views (directory listings, file contents, changesets)
  • Report and custom query views
  • Wiki history, diffs and individual versions
  • Search results

This is, more or less, all the places where users show up in a standard Trac instance. If you find any other places where icons should also be inserted, whether in a standard Trac installation or in a view provided by your favorite plugin, please submit an issue or a patch.

Patches implementing additional avatar engines are also welcome.

Installation

Install the plugin in your favorite way (python setup.py develop, uploading an egg, etc) and then enable its components in trac.ini like so::

[components] userpictures.* = enabled

You should then choose your preferred avatar engine. For Gravatar::

[userpictures] pictures_provider = UserPicturesGravatarProvider

For UserManager, ensure that the UserManager plugin is installed, and then::

[userpictures] pictures_provider = UserPicturesUserManagerProvider

If you do not explicitly select either engine, a default provider is used which displays a blank silhouette for every user.

There are a number of optional "size" settings for each view; these are set to sensible defaults that are designed to look good with a standard Trac install and the stylesheet provided by this plugin, but look at the source in userpictures/init.py (and the CSS in userpictures/htdocs/userpictures.css) if you really want to change the way the icons are displayed.

trac-userpicturesplugin's People

Contributors

ejucovy avatar rjollos avatar tianmingxing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

trac-userpicturesplugin's Issues

Pictures shifted in search view

Hello,

I do a basic search by words in our Trac and I got a result referring to a milestone page so with no clear editor like a wiki page (no author picture to show). In this particular case, the following user pictures rendered in the web page were shifted comparing to the edition log by $author -- $date.
Probably the pictures list is not overload with dummy values because if I unchecked Milestone in searching option, the pictures are consistent with the editors.

Crash in file diff view between 2 changesets

Hello,

I installed this plugin recently (last revision 36), no problem with the different views (timeline, ticket or default changeset). But a user reported an issue on the very specific case of comparing 2 changesets of a given file. Here is the log:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 233, in dispatch
    content_type)
  File "/usr/lib/python2.7/site-packages/trac/web/chrome.py", line 983, in render_template
    stream |= self._filter_stream(req, method, filename, stream, data)
  File "/usr/lib64/python2.7/site-packages/genshi/core.py", line 132, in __or__
    return Stream(_ensure(function(self)), serializer=self.serializer)
  File "/usr/lib/python2.7/site-packages/trac/web/chrome.py", line 1162, in inner
    data)
  File "build/bdist.linux-x86_64/egg/userpictures/__init__.py", line 82, in filter_stream
    filter_.extend(self._browser_filter(req, data))
  File "build/bdist.linux-x86_64/egg/userpictures/__init__.py", line 188, in _browser_filter
    filter_.extend(self._browser_changeset_filter(req, data))
  File "build/bdist.linux-x86_64/egg/userpictures/__init__.py", line 197, in _browser_changeset_filter
    author = data['changeset'].author
AttributeError: 'bool' object has no attribute 'author'

My first guess is that where in a situation that has not been planned by the conditional loop:

    def _browser_changeset_filter(self, req, data):
        author = None
        if (data.get('file') or {}).get('changeset'):
            author = data['file']['changeset'].author
        elif 'changeset' in data:
            author = data['changeset'].author
        if author is None:
            return []

In particular, it is a changeset but in the default mode view (without UP plugin) no author information is published so probably not loaded (based on my little but growing knowledge of Trac).

KeyError: 'userpictures/htdocs'

I've just installed your plugin, and it seems to be working fine (using Gravatars). However, I am receiving the error KeyError: 'userpictures/htdocs' in my Trac log file on every page view.

I am using Trac 1.0.4 behind Apache2 + FastCGI. I downloaded the source of the plugin from here, ran python setup.py bdist_egg from the source directory, and moved it to my Trac installation's plugins directory. I do not have the UserManager plugin installed (as I don't need/want it).

Relevant portions of my trac.ini file:

[components]
userpictures.* = enabled

[userpictures]
pictures_provider = UserPicturesGravatarProvider

Here is the full stack trace:

Trac[main] ERROR: Internal Server Error: 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 513, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.7/dist-packages/trac/web/main.py", line 222, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/local/lib/python2.7/dist-packages/trac/web/chrome.py", line 674, in process_request
    in provider.get_htdocs_dirs() or []
  File "build/bdist.linux-x86_64/egg/userpictures/__init__.py", line 68, in get_htdocs_dirs
    yield 'userpictures', resource_filename(__name__, 'htdocs')
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1129, in resource_filename
    self, resource_name
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1826, in get_resource_filename
    return self._extract_resource(manager, zip_path)
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1847, in _extract_resource
    timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
KeyError: 'userpictures/htdocs'

Sorry if this isn't the right place to raise an issue. I wasn't sure whether to do it here, bitbucket, or Trac-Hacks.org.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.