Commit aae014ff authored by Stefan Göbel's avatar Stefan Göbel

Initial commit

* Version 0.1.2
parents
This diff is collapsed.
# Copyright 2010-2011, 2014 Stefan Goebel - <tracsecdl -at- subtype -dot- de>
#
# This file is part of TracSecDl.
#
# TracSecDl 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 3 of the License, or (at your option) any later
# version.
#
# TracSecDl 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
# TracSecDl. If not, see <http://www.gnu.org/licenses/>.
from setuptools import setup
setup (
name = 'TracSecDl',
version = '0.1.2',
description = "File download plugin for Trac.",
keywords = 'trac lighttpd mod_secdownload files upload download',
author = 'Stefan Göbel',
author_email = 'tracsecdl@subtype.de',
url = 'https://bitbucket.org/goeb/tracsecdl',
license = 'GPLv3',
zip_safe = True,
classifiers = ['Framework :: Trac'],
packages = [
'tracsecdl',
'tracsecdl.database',
'tracsecdl.model',
'tracsecdl.model.enum',
],
package_data = {
'tracsecdl': [
'templates/*.html', 'htdocs/css/*.css', 'htdocs/js/*.js'
]
},
entry_points = {
'trac.plugins': [
'TracSecDl.AdminUI = tracsecdl.admin_ui',
'TracSecDl.Config = tracsecdl.config',
'TracSecDl.Env = tracsecdl.env',
'TracSecDl.Extension = tracsecdl.extension',
'TracSecDl.Perm = tracsecdl.perm',
'TracSecDl.Redirect = tracsecdl.redirect',
'TracSecDl.Timeline = tracsecdl.timeline',
'TracSecDl.Upload = tracsecdl.upload',
'TracSecDl.WebUI = tracsecdl.web_ui',
'TracSecDl.Wiki = tracsecdl.wiki',
]
},
)
# :indentSize=4:tabSize=4:noTabs=true:mode=python:maxLineLen=79:
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
# Copyright 2010-2011, 2014 Stefan Goebel - <tracsecdl -at- subtype -dot- de>
#
# This file is part of TracSecDl.
#
# TracSecDl 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 3 of the License, or (at your option) any later
# version.
#
# TracSecDl 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
# TracSecDl. If not, see <http://www.gnu.org/licenses/>.
from trac.db import Table, Column, Index, DatabaseManager
"""Performs a database upgrade.
The do_upgrade() function will upgrade the environment's TracSecDl specific
database stuff to version 1. This is the initial version. Do not change this
script on database updates, create a new one according to the new database
version that performs an incremental update instead.
"""
# Prefix to use for the table names to avoid name clashes with other plugins.
# If you change the prefix here you also need to change it in model/base.py!
prefix = 'sdl_'
# The tables used by TracSecDl, one for the downloads, and one for each of the
# architectures, platforms and types. The components, milestones and versions
# are provided by Trac's ticket system:
tables = [
Table (prefix + 'download', key = 'id') [
Column ('id', type = 'integer', auto_increment = True),
Column ('name' ),
Column ('url', ),
Column ('description' ),
Column ('size', type = 'integer' ),
Column ('time', type = 'integer' ),
Column ('last_request', type = 'integer' ),
Column ('count', type = 'integer' ),
Column ('author' ),
Column ('ip', type = 'bigint' ),
Column ('component' ),
Column ('milestone' ),
Column ('version' ),
Column ('architecture', type = 'integer' ),
Column ('platform', type = 'integer' ),
Column ('type', type = 'integer' ),
Column ('hidden', type = 'integer' ),
Column ('checksum_md5', ),
Column ('checksum_sha' ),
],
Table (prefix + 'architecture', key = 'id') [
Column ('id', type = 'integer', auto_increment = True),
Column ('name' ),
Column ('description' ),
Index (['name'], unique = True ),
],
Table (prefix + 'platform', key = 'id') [
Column ('id', type = 'integer', auto_increment = True),
Column ('name' ),
Column ('description' ),
Index (['name'], unique = True ),
],
Table (prefix + 'type', key = 'id') [
Column ('id', type = 'integer', auto_increment = True),
Column ('name' ),
Column ('description' ),
Index (['name'], unique = True ),
]
]
def do_upgrade (env, db, cursor):
"""Upgrade TracSecDl specific database stuff to this script's version.
DB version 1: * create all required tables
* insert the db version into the system table
* store a default description in the system table
"""
db_backend, _ = DatabaseManager (env)._get_connector ()
try:
for table in tables:
for statement in db_backend.to_sql (table):
cursor.execute (statement)
cursor.execute (
'INSERT INTO system (name, value) VALUES (%s, %s)',
('secdl_version', '1')
)
cursor.execute (
'INSERT INTO system (name, value) VALUES (%s, %s)',
('secdl_description', 'Available downloads:')
)
db.commit ()
except:
raise
# :indentSize=4:tabSize=4:noTabs=true:mode=python:maxLineLen=79:
\ No newline at end of file
# Copyright 2010-2011, 2014 Stefan Goebel - <tracsecdl -at- subtype -dot- de>
#
# This file is part of TracSecDl.
#
# TracSecDl 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 3 of the License, or (at your option) any later
# version.
#
# TracSecDl 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
# TracSecDl. If not, see <http://www.gnu.org/licenses/>.
from trac.core import Component, implements
from trac.env import IEnvironmentSetupParticipant
class SecDlEnv (Component):
"""Environment setup stuff."""
implements (IEnvironmentSetupParticipant)
# This needs to be incremented on every database update:
_secdl_db_version = 1
# IEnvironmentSetupParticipant methods:
def environment_created (self):
"""Performs a database initialization on environment creation."""
db = self.env.get_db_cnx ()
return self._upgrade_environment (db)
def environment_needs_upgrade (self, db):
"""Returns True if the database is out of date."""
return self._get_version (db) != self._secdl_db_version
def upgrade_environment (self, db):
"""Called when an environment is upgraded."""
return self._upgrade_environment (db)
def _upgrade_environment (self, db):
"""Perform the environment upgrade for TracSecDl.
The database setup scripts are located in the database folder, named
'database_<version>.py', <version> being the (two digit) version number
for the script (eg. the setup script for the first version of the
database is called 'database_01.py'). On version updates new scripts
must be provided - named accordingly - that perform all necessary
actions to update the database from the previous version. All scripts
will be run in correct order, but skipping all scripts for previous
database versions. All scripts must make sure that no data is lost!
"""
version = self._get_version (db)
cursor = db.cursor ()
for i in range (version + 1, self._secdl_db_version + 1):
script_name = 'database_%02i' % i
module = __import__ (
'tracsecdl.database.%s' % script_name,
globals (),
locals (),
['do_upgrade']
)
module.do_upgrade (self.env, db, cursor)
def _get_version (self, db):
"""Returns the current TracSecDl database version.
The current version is stored in the 'system' table, the key being
'secdl_version'. Exceptions will not be handled but passed on to the
caller instead.
"""
cursor = db.cursor ()
try:
query = 'SELECT value FROM system WHERE name=%s'
cursor.execute (query, ['secdl_version'])
for row in cursor:
return int (row [0])
return 0
except:
raise
# :indentSize=4:tabSize=4:noTabs=true:mode=python:maxLineLen=79:
\ No newline at end of file
# Copyright 2010-2011, 2014 Stefan Goebel - <tracsecdl -at- subtype -dot- de>
#
# This file is part of TracSecDl.
#
# TracSecDl 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 3 of the License, or (at your option) any later
# version.
#
# TracSecDl 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
# TracSecDl. If not, see <http://www.gnu.org/licenses/>.
from trac.core import Interface
class ISecDlDownload (Interface):
"""Provides an extension point for plugins."""
def created (id):
"""Called when a new download has been created.
The only argument is the ID of the new download. The return value of
this method is ignored.
"""
# Called in SecDlAdminPanelDownload._render_admin_panel() in
# admin_ui.py.
def removed ():
"""Called when a download has been removed.
No parameters, return value is ignored. There is not much you can do in
this method, since the download data has been deleted from the database
already if there was a download to delete, for technical reasons, you
can not be sure that this is the case (ie. trying to delete a
non-existing download will also cause this method to be called). Note
that if multiple downloads are deleted at once this method will be
called only once after the downloads are removed.
"""
# Called in SecDlAdminPanelDownload._render_admin_panel() in
# admin_ui.py.
def requested (req, id):
"""Called when a download is requested.
This method is called when a download is requested by a client, before
the redirect is sent to the client. The parameters are a request
instance and the ID of the requested download. The return value of this
method is ignored.
"""
# Called in SecDlWebUI.process_request() in web_ui.py.
# :indentSize=4:tabSize=4:noTabs=true:mode=python:maxLineLen=79:
\ No newline at end of file
/*
Copyright 2010-2011, 2014 Stefan Goebel - <tracsecdl -at- subtype -dot- de>
This file is part of TracSecDl.
TracSecDl 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 3 of the License, or (at your option) any later
version.
TracSecDl 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
TracSecDl. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
TracSecDl admin page specific CSS rules. These are used in addition to
those defined in htdocs/css/secdl.css.
*/
form#addenum
{
max-width: 20em;
}
form#addenum input[type="text"]
{
min-width: 19em;
width: 90%;
}
form#addenum input[type="submit"],
form#addenum input[type="button"],
form#addenum input[type="reset"],
form#modenum input[type="submit"],
form#modenum input[type="reset"],
form#moddesc input[type="reset"],
form#moddesc input[type="submit"]
{
float: left;
margin-left: 2px;
margin-right: 1px;
margin-top: 0px;
}
form#addenum input[type="reset"]
{
float: right;
margin-right: 0px;
}
form#addenum input#moreinputs
{
display: none;
}
form#modenum fieldset.outer
{
padding-right: 30px;
}
form#moddesc fieldset.outer
{
padding-right: 20px;
}
form#modenum input[type="text"],
form#modenum textarea,
form#moddesc textarea
{
width: 100%;
}
form#modenum textarea
{
padding: 0.5em;
}
form#addenum label,
form#modenum label,
form#moddesc label
{
padding-left: 0.1em;
}
form#addenum p.help
{
clear: both;
padding-top: 1em;
text-align: justify;
}
form#enums_table table#enums_list tr.created,
form#downloads_table table#downloads_list tr.created
{
background-color: #e7ffe7;
}
form#enums_table table#enums_list tr.created:hover,
form#downloads_table table#downloads_list tr.created:hover
{
background-color: #d7eed7 !important;
}
form#enums_table td.sel
{
font-size: 0.5em;
line-height: 0.7em;
padding: 0px;
vertical-align: middle;
}
form#enums_table td.name
{
padding: 0.2em;
}
form#enums_table td.sel,
form#enums_table td.name
{
padding-left: 0.5em;
padding-right: 0.5em;
}
form table#downloads_list
{
font-size: 0.9em !important;
margin-bottom: 0px;
}
form table#downloads_list th.hidden,
form table#downloads_list th.local,
form table#downloads_list th.ext-header
{
text-align: center;
}
form table#downloads_list td.hidden,
form table#downloads_list td.local,
form table#downloads_list td.edit,
form table#downloads_list td.ext-link
{
font-size: 1.2em;
line-height: 0.9em;
padding-left: 0px;
padding-right: 0px;
text-align: center;
vertical-align: middle;
width: 1.5em;
}
form table#downloads_list td.sel
{
font-size: 0.5em;
line-height: 0.7em;
padding: 0px;
padding-left: 0.5em;
padding-right: 0.5em;
text-align: center;
vertical-align: middle;
}
form table#downloads_list td.edit a
{
border: none;
}
blockquote.description
{
border-bottom: 1px #ddd solid;
border-top: 1px #ddd solid;
margin-left: 1em;
margin-right: 1em;
margin-top: 2em;
padding-left: 3em;
}
blockquote.description p.edit
{
margin-top: -10px;
margin-left: -30px;
}
blockquote.description p.edit a
{
background-color: #fff;
border: none;
padding-left: 0.3em;
padding-right: 0.3em;
}
form#newdownload label,
form#moddownload label
{
float: left;
padding-top: 0.2em;
width: 8em;
}
form#newdownload div.field div.input,
form#moddownload div.field div.input
{
float: left;
}
form#newdownload input[type="text"],
form#moddownload input[type="text"],
form#newdownload textarea,
form#moddownload textarea
{
width: 400px;
}
form#newdownload select,
form#moddownload select
{
width: 410px;
}
form#newdownload textarea,
form#moddownload textarea
{
padding: 0.5em;
}
form#newdownload option.empty,
form#moddownload option.empty
{
font-style: italic;
}
form#newdownload p.help,
form#moddownload p.help
{
margin-top: 0px;
width: 410px;
}
form#newdownload br,
form#moddownload br
{
clear: both;
}
form#newdownload label.submit,
form#newdownload div.submit,
form#moddownload label.submit,
form#moddownload div.submit
{
margin-top: 1em;
}
form#moddownload fieldset
{
padding-bottom: 1em;
}
form#moddownload fieldset label.noinput
{
clear: both;
padding-top: 0px;
}
form#moddownload div.checksum
{
font-family: monospace;
}
form#moddownload div.readonly
{
padding-left: 5em;
margin-bottom: 1em;
}
form#moddownload p.bottom
{
width: auto;
}
form#downloads_table div.buttons,
form#moddesc div.buttons
{
margin-top: 0px;
}
form#downloads_table p.table-help
{
margin-bottom: 30px;
}
ul.limits
{
margin-bottom: 2em;
}
ul.limits li.reached
{
color: #c00;
}
ul.limits div.progress
{
border: 1px solid #ddd;
font-size: 0.7em;
margin-bottom: 1em;
margin-top: 3px;
width: 100%;
}
ul.limits div.progress div.bar
{
background-color: #eee;
text-align: center;
}
ul.limits li.reached div.progress div.bar
{
background-color: #fee;
}
form fieldset ul.uploadrules
{
color: #666;
font-size: 0.9em;
margin-left: 8em;
margin-top: -0.5em;
}
.wikitoolbar
{
margin-left: 2px;
margin-top: 4px;
}
/* :indentSize=4:tabSize=4:noTabs=true:mode=css:maxLineLen=79: */
\ No newline at end of file
/*
Copyright 2010-2011, 2014 Stefan Goebel - <tracsecdl -at- subtype -dot- de>
This file is part of TracSecDl.
TracSecDl 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 3 of the License, or (at your option) any later
version.
TracSecDl 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
TracSecDl. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************
CSS for the TracSecDl download page.
*/
table#downloads_list
{
margin-bottom: 15px;
width: 100%;
}
table#downloads_list th
{
white-space: nowrap;
}
table#downloads_list td.ext
{
border-bottom: none;
padding: 0px;
vertical-align: middle;
width: 0.5em;
}
table#downloads_list td.ext a
{
border: none;
display: block;
font-size: 1.1em;
text-align: center;
}
table#downloads_list td.name,
table#downloads_list td.info
{
font-size: 0.9em;
}
table#downloads_list td.info,
table#downloads_list th.size
{
width: 1em;
}
table#downloads_list td.name a.checksum
{
border: none;
float: right;