Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A trac plugin to allow trac to serve static files

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 staticdocsplugin
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGES.rst
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 setup.py
Octocat-spinner-32 version.py
README.rst

Staticdocs Plugin for Trac

The staticdocs-plugin allows one to serve a directory of static web documents through trac. The motivation for writing this was to be able to control access to static files (e.g. project documentation) using trac’s authentication and authorization system.

Requirements

This has been tested under trac 0.12. It may well work in earlier versions. It probably requires python >= 2.6.

Installation

The package can be installed from PyPI, or you can get the raw source at github.

Configuration

Somewhere in your trac configs put a section like:

[staticdocs]

# (Optional) Set the required permission for viewing static docs
# The default is WIKI_VIEW
permission         = WIKI_VIEW

# Set up some aliases (you need at least one alias for this plugin
# to be worthwhile.)
alias./docs/       = /path/to/docs/
alias./docs/other/ = /path/to/other/docs/

# (Optional) Override the required permission for a specific alias
permission./docs/other/  = TICKET_VIEW

Also, you will want to enable the plugin. Probably like this:

[components]

staticdocsplugin.* = enabled

Now if you visit, e.g., http://example.com/yourtrac/docs/file.html, you will get served the file /path/to/docs/file.html.

Notes, Possible Buglets

Hidden and backup files

Any requests for URLs which have a path component starting with . or ending with ~ will result in a 404 Not Found response.

(Any request with a path component of .. will result in a 400 Bad Request response.)

Content Types

Currently, mimetype.guess_type is used to deduce the content type.

Directory Indexes

If the URL ends in a slash, index.html is added. This should probably be fixed so as to look for index.htm as well.

Other Hints

The NavAddPlugin (from trac-hacks) will let you add links to your static docs (or anywhere else) to the trac navigation bar.

The standard ExtraPermissionsProvider plugin can be used to add a new custom permission (say STATIC_DOCS_VIEW) if you would like one to control access to your static files.

Bugs

If you find any, file a ticket.

Author

Jeff Dairiki.

Something went wrong with that request. Please try again.