diff --git a/src/libprs500/trac/__init__.py b/src/libprs500/trac/__init__.py
new file mode 100644
index 0000000000..f2a5caf07b
--- /dev/null
+++ b/src/libprs500/trac/__init__.py
@@ -0,0 +1,18 @@
+## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with this program; if not, write to the Free Software Foundation, Inc.,
+## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+'''
+To test
+sudo tracd --port 8000 --auth libprs500,/var/www/localhost/htdocs/libprs500/passwd,libprs500 /var/www/localhost/htdocs/libprs500
+'''
diff --git a/src/libprs500/trac/download/__init__.py b/src/libprs500/trac/download/__init__.py
new file mode 100644
index 0000000000..b7d93c9623
--- /dev/null
+++ b/src/libprs500/trac/download/__init__.py
@@ -0,0 +1,16 @@
+## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with this program; if not, write to the Free Software Foundation, Inc.,
+## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+from download import *
\ No newline at end of file
diff --git a/src/libprs500/trac/download/download.py b/src/libprs500/trac/download/download.py
new file mode 100644
index 0000000000..3221b2c1cc
--- /dev/null
+++ b/src/libprs500/trac/download/download.py
@@ -0,0 +1,207 @@
+## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with this program; if not, write to the Free Software Foundation, Inc.,
+## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+import re
+from pkg_resources import resource_filename
+
+from trac.core import Component, implements
+from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet
+from trac.web.main import IRequestHandler
+from trac.util import Markup
+
+
+__appname__ = 'libprs500'
+
+class Distribution(object):
+
+ DEPENDENCIES = [
+ #(Generic, version, gentoo, ubuntu, fedora)
+ ('python', '2.5', None, None, None),
+ ('setuptools', '0.6c5', 'setuptools', 'python-setuptools', 'python-setuptools'),
+ ('Python Imaging Library', '1.1.6', 'imaging', 'python-imaging', 'python-imaging'),
+ ('libusb', '0.1.12', None, None, None),
+ ('Qt', '4.3.1', 'qt', 'libqt4-core libqt4-gui', 'qt4'),
+ ('PyQt', '4.3.1', 'PyQt4', 'python-qt4', 'PyQt4'),
+ ('fonttools', '2.0-beta1', 'fonttools', 'fonttools', 'fonttools'),
+ ('unrtf', '0.20.1', 'unrtf', 'unrtf', 'unrtf'),
+ ('mechanize for python', '0.1.7b', 'dev-python/mechanize', 'python-mechanize', 'python-mechanize'),
+ ('ImageMagick', '6.3.5', 'imagemagick', 'imagemagick', 'imagemagick'),
+ ('xdg-utils', '1.0.2', 'xdg-utils', 'xdg-utils', 'xdg-utils'),
+ ('dbus-python', '0.82.2', 'dbus-python', 'python-dbus', 'dbus-python'),
+ ('convertlit', '1.8', 'convertlit', None, None)
+ ]
+
+ DISTRO_MAP = {'gentoo':2, 'ubuntu':3, 'fedora':4, 'debian':3}
+
+ INSTALLERS = ('emerge -av', 'apt-get install', 'yum install')
+ AS_ROOT = (True, False, True)
+
+ TITLEMAP = {'gentoo':'Gentoo', 'ubuntu':'Ubuntu Gutsy Gibbon',
+ 'fedora':'Fedora 7', 'debian':'Debian Sid', 'generic': 'Generic Unix'}
+
+ MANUAL_MAP = {
+ 'ubuntu' : '
You will have to install convertlit manually to be able to convert LIT files.',
+ 'fedora' : '''You have to upgrade Qt to at least 4.3.1 and PyQt to at least 4.3.1'''\
+ '''You will have to install convertlit manually to be able to convert LIT files.''',
+ 'debian' : 'Add the following to /etc/apt/sources.listdeb http://www.debian-multimedia.org sid main
Thenapt-get install clit
',
+ }
+
+ def __init__(self, os):
+ self.os = os
+ self.title = self.TITLEMAP[os]
+ self.is_generic = os == 'generic'
+ offset = 0
+ if not self.is_generic:
+ index = self.DISTRO_MAP[self.os]
+ self.as_root = True if os == 'debian' else self.AS_ROOT[index-2]
+ prefix = '' if self.as_root else 'sudo '
+ cmd = prefix + self.INSTALLERS[index-2]
+ pre = ' \\\n '.ljust(len(cmd)+3)
+ for dep in self.DEPENDENCIES:
+ if len(cmd) > 70+offset:
+ offset += 70
+ cmd += pre
+ cmd += ' ' + dep[index] if dep[index] else ''
+ self.command = cmd.strip()
+ if os == 'debian':
+ self.command += '\n'+prefix + 'cp -R /usr/share/pycentral/fonttools/site-packages/FontTools* /usr/lib/python2.5/site-packages/'
+ self.command += '\n'+prefix+'easy_install -U TTFQuery libprs500 \nlibprs500_postinstall'
+ try:
+ self.manual = Markup(self.MANUAL_MAP[os])
+ except KeyError:
+ self.manual = None
+
+
+class Download(Component):
+ implements(INavigationContributor, IRequestHandler, ITemplateProvider)
+
+ request_pat = re.compile(r'\/download$|\/download_\S+')
+
+ # INavigationContributor methods
+ def get_active_navigation_item(self, req):
+ return 'download'
+
+ def get_navigation_items(self, req):
+ yield 'mainnav', 'download', Markup('Get %s'%(__appname__,))
+
+ def get_templates_dirs(self):
+ return [resource_filename(__name__, 'templates')]
+
+ def get_htdocs_dirs(self):
+ return [('dl', resource_filename(__name__, 'htdocs'))]
+
+ # IRequestHandler methods
+ def match_request(self, req):
+ return self.__class__.request_pat.match(req.path_info)
+
+ def process_request(self, req):
+ add_stylesheet(req, 'dl/css/download.css')
+ if req.path_info == '/download':
+ return self.top_level(req)
+ else:
+ match = re.match(r'\/download_(\S+)', req.path_info)
+ if match:
+ os = match.group(1)
+ if os == 'windows':
+ return self.windows(req)
+ elif os == 'osx':
+ return self.osx(req)
+ elif os == 'linux':
+ return self.linux(req)
+ else:
+ return self.linux_distro(req, os)
+
+ def linux_distro(self, req, os):
+ distro = Distribution(os)
+ data = dict(distro=distro,title=distro.title)
+ return 'distro.html', data, None
+
+ def top_level(self, req):
+ operating_systems = [
+ {'name' : 'windows', 'title' : 'Windows'},
+ {'name' : 'osx', 'title' : 'OS X'},
+ {'name' : 'linux', 'title' : 'Linux'},
+ ]
+ data = dict(title='Get ' + __appname__,
+ operating_systems=operating_systems, width=200,
+ font_size='xx-large')
+ return 'download.html', data, None
+
+ def version_from_filename(self, file):
+ return re.search(r'\S+-(\d+\.\d+\.\d+)\.', file).group(1)
+
+ def windows(self, req):
+ file = 'libprs500-0.4.14.exe'
+ version = self.version_from_filename(file)
+ data = dict(version = version, name='windows',
+ installer_name='Windows installer',
+ title='Download %s for windows'%(__appname__),
+ compatibility='%s works on Windows XP and Windows Vista.'%(__appname__,),
+ path='downloads/'+file,
+ note=Markup(\
+'''
+If you are using the SONY PRS-500 and %(appname)s does not detect your reader, read on:
+
+
+If you are using 64-bit windows, you're out of luck.
+
+
+There may be a conflict with the USB driver from SONY. In windows, you cannot install two drivers
+for one device. In order to resolve the conflict:
+
+- Start Device Manager by clicking Start->Run, typing devmgmt.msc and pressing enter.
+- Uninstall all PRS500 related drivers. You will find them in two locations:
+
+- Under "Libusb-Win32"
+- Under "Universal Serial ..." (... depends on the version of windows)
+
+You can uninstall a driver by right clicking on it and selecting uninstall.
+
+- Once the drivers have been uninstalled, uninstall %(appname)s. Reboot. Reinstall %(appname)s.
+
+
+
+'''%dict(appname=__appname__)))
+ return 'binary.html', data, None
+
+ def osx(self, req):
+ file = 'libprs500-0.4.14.dmg'
+ version = self.version_from_filename(file)
+ data = dict(version = version, name='osx',
+ installer_name='OS X universal dmg',
+ title='Download %s for OS X'%(__appname__),
+ compatibility='%s works on OS X Tiger and above.'%(__appname__,),
+ path='downloads/'+file,
+ note=Markup(\
+'''
+
+- Before trying to use the command line tools, you must run the app at least once. This will ask you for you password and then setup the symbolic links for the command line tools.
+- The app cannot be run from within the dmg. You must drag it to a folder on your filesystem (The Desktop, Applications, wherever).
+- In order for the conversion of RTF to LRF to support WMF images (common in older RTF files) you need to install ImageMagick.
+
+'''))
+ return 'binary.html', data, None
+
+ def linux(self, req):
+ operating_systems = [
+ {'name' : 'gentoo', 'title': 'Gentoo'},
+ {'name' : 'ubuntu', 'title': 'Ubuntu'},
+ {'name' : 'fedora', 'title': 'Fedora'},
+ {'name' : 'debian', 'title': 'Debian'},
+ {'name' : 'generic','title': 'Generic', 'img':'linux'},
+ ]
+ data = dict(title='Choose linux distribution', width=100,
+ operating_systems=operating_systems, font_size='x-large')
+ return 'download.html', data, None
+
\ No newline at end of file
diff --git a/src/libprs500/trac/download/htdocs/images/debian_logo.png b/src/libprs500/trac/download/htdocs/images/debian_logo.png
new file mode 100644
index 0000000000..1ed96d3a11
Binary files /dev/null and b/src/libprs500/trac/download/htdocs/images/debian_logo.png differ
diff --git a/src/libprs500/trac/download/htdocs/images/fedora_logo.png b/src/libprs500/trac/download/htdocs/images/fedora_logo.png
new file mode 100644
index 0000000000..fd5ee27a62
Binary files /dev/null and b/src/libprs500/trac/download/htdocs/images/fedora_logo.png differ
diff --git a/src/libprs500/trac/download/htdocs/images/gentoo_logo.png b/src/libprs500/trac/download/htdocs/images/gentoo_logo.png
new file mode 100644
index 0000000000..b0892849a9
Binary files /dev/null and b/src/libprs500/trac/download/htdocs/images/gentoo_logo.png differ
diff --git a/src/libprs500/trac/download/htdocs/images/linux_logo.png b/src/libprs500/trac/download/htdocs/images/linux_logo.png
new file mode 100644
index 0000000000..65ac36704f
Binary files /dev/null and b/src/libprs500/trac/download/htdocs/images/linux_logo.png differ
diff --git a/src/libprs500/trac/download/htdocs/images/osx_logo.png b/src/libprs500/trac/download/htdocs/images/osx_logo.png
new file mode 100644
index 0000000000..bff6deba70
Binary files /dev/null and b/src/libprs500/trac/download/htdocs/images/osx_logo.png differ
diff --git a/src/libprs500/trac/download/htdocs/images/ubuntu_logo.png b/src/libprs500/trac/download/htdocs/images/ubuntu_logo.png
new file mode 100644
index 0000000000..bfb8536550
Binary files /dev/null and b/src/libprs500/trac/download/htdocs/images/ubuntu_logo.png differ
diff --git a/src/libprs500/trac/download/htdocs/images/windows_logo.png b/src/libprs500/trac/download/htdocs/images/windows_logo.png
new file mode 100644
index 0000000000..99e4fc2e65
Binary files /dev/null and b/src/libprs500/trac/download/htdocs/images/windows_logo.png differ
diff --git a/src/libprs500/trac/download/htdocs/stylesheet/download.css b/src/libprs500/trac/download/htdocs/stylesheet/download.css
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/libprs500/trac/download/templates/binary.html b/src/libprs500/trac/download/templates/binary.html
new file mode 100644
index 0000000000..8f17e983be
--- /dev/null
+++ b/src/libprs500/trac/download/templates/binary.html
@@ -0,0 +1,24 @@
+
+
+
+
+ $title
+
+
+
+
+
+
+
$title
+
$compatibility
+
+
$installer_name (Version: $version)
+
Note
+
$note
+
+
+
\ No newline at end of file
diff --git a/src/libprs500/trac/download/templates/distro.html b/src/libprs500/trac/download/templates/distro.html
new file mode 100644
index 0000000000..0d4bc38996
--- /dev/null
+++ b/src/libprs500/trac/download/templates/distro.html
@@ -0,0 +1,47 @@
+
+
+
+
+ $title
+
+
+
+
+
+
+
$title
+
+ First verify that you have a sufficiently new installation of python
+
python --version
should return at least 2.5.1
+
+ Run the following commands in a terminal
as root
+
prefixed by sudo
+
${distro.command}
+
+
+
+
+ - Make sure that your system has
python >= 2.5
+ - Install the various dependencies listed below: Make sure that any python packages are installed into python2.5 (e.g. setuptools, python-imaging, PyQt4, fonttools, etc)
+ - As root run the command
easy_install-2.5 -U TTFQuery libprs500 && libprs500_postinstall
+
+
Dependencies
+
+ Name | Minimum version |
+
+ ${dep[0]} | ${dep[1]} |
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/libprs500/trac/download/templates/download.html b/src/libprs500/trac/download/templates/download.html
new file mode 100644
index 0000000000..bec8e5bfb7
--- /dev/null
+++ b/src/libprs500/trac/download/templates/download.html
@@ -0,0 +1,34 @@
+
+
+
+
+ $title
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/libprs500/trac/setup.py b/src/libprs500/trac/setup.py
new file mode 100644
index 0000000000..bc00fd6654
--- /dev/null
+++ b/src/libprs500/trac/setup.py
@@ -0,0 +1,32 @@
+## Copyright (C) 2007 Kovid Goyal kovid@kovidgoyal.net
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with this program; if not, write to the Free Software Foundation, Inc.,
+## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+from setuptools import find_packages, setup
+
+# name can be any name. This name will be used to create .egg file.
+# name that is used in packages is the one that is used in the trac.ini file.
+# use package name as entry_points
+setup(
+ name='TracLibprs500Plugins', version='0.1',
+ packages=find_packages(exclude=['*.tests*']),
+ entry_points = """
+ [trac.plugins]
+ download = libprs500.trac.download
+ """,
+ package_data={'download': ['templates/*.html',
+ 'htdocs/css/*.css',
+ 'htdocs/images/*']},
+)
+