wiki:DownloadsPlugin

Version 12 (modified by anonymous, 5 years ago) (diff)

--

Adds downloads section

Description

This plugin provides downloads section which may contain releases or other files. It is administrated via WebAdminPlugin and there is an interface to the trac-admin tool that may help during automatic server maintenance. The Downloads section of Trac displays a table with information about the uploaded files such as description, component, version, size, architecture, type and optionally assigned tags which the download is related to. It also collects information about number of downloads which can be displayed on wiki page together with direct links to the specified download.

Bugs/Feature Requests

Existing bugs and feature requests for DownloadsPlugin are here.

If you have any issues, create a new ticket but read BugReporting page first, please.

Download

Download the zipped source from here.

Source

You can check out DownloadsPlugin using Subversion, or browse the source with Trac.

Dependencies

DownloadsPlugin for Trac 0.10 depends on WebAdminPlugin since many configuration options are avaiable only on apropriate WebAdminPlugin's pages. On Trac 0.11 this is supported by Trac itself. Optionally DownloadsPlugin uses TagsPlugin for tags support.

Plugin Versions

As many other plugins in this site even this plugin names its branches according to Trac versions. Here is a simple table explaining this convention for DownloadsPlugin:

Plugin Branch Trac Branch Plugin Version
0.10 0.10-stable 0.1
0.11 0.11-stable 0.2
0.12 trunk, 0.11-stable* 0.3

Main difference between 0.1 and 0.2 version is that 0.2 uses Genshi templates and 0.1 ClearSilver ones. 0.12 branch is the one where new features are introduced so you may experience some regressions with this branch.

* So far 0.12 branch of the plugin works with Trac 0.11 except of interface to trac-admin command. If you want to use this full-featured but testing branch, just disable DownloadsConsoleAdmin component.

Installation

After installing plugin's egg you can set up few configuration variables in trac.ini. Their default values are displayed bellow:

[downloads]

title = Downloads
path = /var/lib/trac/downloads
ext = zip gz bz2 rar # For 0.10 and 0.11 branch.
ext = zip,gz,bz2,rar # For 0.12 branch.
visible_fields = id file description size time count author tags component version \
  architecture platform type # For 0.10 and 0.11 branch.
visible_fields = id,file,description,size,time,count,author,tags,component,version, \
  architecture,platform,type # For 0.12 branch.
unique_filename = False
consoleadmin_user = anonymous # Branch 0.12 only.

Variable title sets text of main navigation bar button. path is location where uploaded downloads are stored. It has to be accessible for writing to web server. Setting ext variable restricts allowed extensions of uploaded files. If unique_filename is enabled, plugin checks if file name of download file is not already occupied by any other download file. visibled_field variable controls appearance of downloads table columns in Downloads section. Finally, consoleadmin_user option serves for permission checks when listing, adding or removing downlads using trac-admin. This option is available only in 0.12 branch.

Note: Don't miss that ext and visible_fields options has changed to comma separated lists in 0.12 branch of the plugin.

If you run Trac in environment which needs to enable plugins explicitly put in trac.ini these lines:

[components]
tracdownloads.api.DownloadsApi = enabled
tracdownloads.core.DownloadsCore = enabled
tracdownloads.init.DownloadsInit = enabled
tracdownloads.timeline.DownloadsTimeline = enabled
tracdownloads.wiki.DownloadsWiki = enabled
tracdownloads.admin.DownloadsWebAdmin = enabled # Branch 0.10 and 0.11.
tracdownloads.webadmin.DownloadsWebAdmin = enabled # Branch 0.12 only.
tracdownloads.consoleadmin.DownloadsConsoleAdmin = enabled # Branch 0.12 only.
tracdownloads.core.DownloadsDownloads = enabled # Branch 0.12 only.
tracdownloads.tags.DownloadsTags = enabled # With TagsPlugin installed.

In 0.12 branch, the DownloadsCore component was splited into the DownloadsDownloads component, which handles Downloads section of Trac, and the DownloadsCore component that serves file download requests and other core features. This means that you can disable the DownloadsDownloads component to hide Downloads section from users. admin module was renamed to consoleadmin.

The next step is to upgrade your environment:

# trac-admin <path_to_environment> upgrade

Permissions

DownloadsPlugin defines three permissions: DOWNLOADS_VIEW for normal users and DOWNLOADS_ADD and DOWNLOADS_ADMIN for people who uploads and administrates downloads. DOWNLOADS_ADD permission is implemented since 0.12 branch and allows user to upload downloads without access to WebAdmin interface.

You can grant them using these commands:

# trac-admin <path_to_environment> permission add <user> DOWNLOADS_VIEW
# trac-admin <path_to_environment> permission add <user> DOWNLOADS_ADD # Branch 0.12 only.
# trac-admin <path_to_environment> permission add <user> DOWNLOADS_ADMIN

Macros

There are few wiki macros available:

[download:<download_id> <text>] or
[download:<download_filename> <text>]

Displays link to download identified by ID <download_id> or filename <download_filename> with text <text>.

[[DownloadsCount(1)]]
[[DownloadsCount(1, 2, 3)]]
[[DownloadsCount(foo.zip)]]
[[DownloadsCount(1, foo.zip, bar.rar, 3)]]
[[DownloadsCount()]]
[[DownloadsCount(0)]]

Displays sum of number of downloads for downloads identified by comma separated list of IDs or filenames. If there is empty list or any zero (last two examples), sum of all number of downloads for all downloads is returned. Non-existing downloads silently counts as zero. Works with branch 0.12 only.

[[ListDownloads()]]

Displays same table that is displayed in Downloads section of the Trac on a wiki page. Works with branch 0.12 only.

Inteface to trac-admin

There is ability to list, insert or delete downloads from server's console/script with following commands:

# trac-admin <path_to_environment> download list
# trac-admin <path_to_environment> download add <path_to_file> description=<description> \
    author=<author> tags="<tag1> <tag2> ..." component=<component> version=<version> \
    architecture=<architecture> platform=<platform> type=<type>
# trac-admin <path_to_environment> download remove <download_filename>
# trac-admin <path_to_environment> download remove <download_id>

All download attributes of download add command are optional only the file must be specified. console_admin trac.ini option must be setted to any user who has permission to do apropriate action.

Notes

  • Branch 0.10 of the plugin is considered as deprecated and not developed anymore.
  • Branch 0.11 is bug-fix only unless requested otherwise.

Recent Changes

[12139] by rjollos on 2012-10-10 03:54:13
Fixed incorrect source code encoding (http://www.python.org/dev/peps/pep-0263/).
[12067] by rjollos on 2012-09-27 06:16:44
Fixes #10280: FIX: specifying a sort direction in trac.ini had no effect. Thanks to sdegrande for the patch.

Removed egg accidentally committed in [12064].

[12066] by rjollos on 2012-09-27 05:59:34
Tagged version 0.1

Author/Contributors

Author: Blackhex
Contributors: