keithsalisbury-subtrac 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +56 -0
- data/VERSION.yml +4 -0
- data/bin/subtrac +40 -0
- data/lib/subtrac.rb +245 -0
- data/lib/subtrac/common/clients/index.wsgi +89 -0
- data/lib/subtrac/common/favicon.ico +0 -0
- data/lib/subtrac/common/images/trac/banner_bg.jpg +0 -0
- data/lib/subtrac/common/images/trac/bar_bg.gif +0 -0
- data/lib/subtrac/common/images/trac/footer_back.png +0 -0
- data/lib/subtrac/common/images/trac/main_bg.gif +0 -0
- data/lib/subtrac/common/images/trac/saint_logo_small.png +0 -0
- data/lib/subtrac/common/static/404.html +14 -0
- data/lib/subtrac/common/styles/trac.css +222 -0
- data/lib/subtrac/common/trac.ini +178 -0
- data/lib/subtrac/config/config.yml +54 -0
- data/lib/subtrac/passwords +1 -0
- data/lib/subtrac/shared/trac.ini +178 -0
- data/lib/subtrac/templates/location.erb +16 -0
- data/lib/subtrac/templates/projects/blank/svn/branches/README +0 -0
- data/lib/subtrac/templates/projects/blank/svn/tags/README +0 -0
- data/lib/subtrac/templates/projects/blank/svn/trunk/README +0 -0
- data/lib/subtrac/templates/projects/blank/trac/wiki/WikiStart +57 -0
- data/lib/subtrac/templates/projects/new/svn/trunk/trac/wiki/WikiStart +46 -0
- data/lib/subtrac/templates/projects/new/trac/wiki/WikiStart +23 -0
- data/lib/subtrac/templates/projects/trac_theme/svn/trunk/index/index.html +22 -0
- data/lib/subtrac/templates/projects/trac_theme/svn/trunk/templates/layout.html +56 -0
- data/lib/subtrac/templates/projects/trac_theme/svn/trunk/templates/site.html +27 -0
- data/lib/subtrac/templates/projects/trac_theme/svn/trunk/templates/theme.html +86 -0
- data/lib/subtrac/templates/projects/trac_theme/trac/wiki/WikiStart +4 -0
- data/lib/subtrac/templates/trac.erb +25 -0
- data/lib/subtrac/templates/vhost.erb +35 -0
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/advancedworkflow/__init__.py +0 -0
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/advancedworkflow/controller.py +419 -0
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/setup.cfg +3 -0
- data/lib/subtrac/trac-plugins/advancedticketworkflowplugin/setup.py +20 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/__init__.py +0 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/action.py +28 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/action_email.py +168 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/action_zendesk_forum.py +137 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/admin.py +91 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/api.py +199 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/client.py +105 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/events.py +287 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/eventsadmin.py +71 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/htdocs/clients.css +4 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/model.py +135 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/processor.py +70 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/reportmanager.py +142 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/reports.py +231 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/summary.py +27 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/summary_milestone.py +152 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/summary_ticketchanges.py +160 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/templates/admin_client_events.html +124 -0
- data/lib/subtrac/trac-plugins/clientsplugin/clients/templates/admin_clients.html +134 -0
- data/lib/subtrac/trac-plugins/clientsplugin/cron/changes.xslt +132 -0
- data/lib/subtrac/trac-plugins/clientsplugin/cron/run-client-event +97 -0
- data/lib/subtrac/trac-plugins/clientsplugin/cron/summary.xslt +161 -0
- data/lib/subtrac/trac-plugins/clientsplugin/setup.py +43 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/__init__.py +4 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/burndownchart.py +273 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/hoursinplaceeditor.py +44 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/hoursremaining.py +36 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/htdocs/jquery-1.2.3.min.js +32 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/htdocs/jquery.jeditable.js +409 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/htdocs/jquery.jeditable.mini.js +30 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/templates/edithours.html +53 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/tests/burndownchart.py +181 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/tests/hoursremaining.py +66 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/tests/workloadchart.py +47 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/utils.py +93 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/estimationtools/workloadchart.py +86 -0
- data/lib/subtrac/trac-plugins/estimationtoolsplugin/setup.py +20 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/SumRollups.js +23 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/adw_tracdb.py +128 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/git-post-receive +40 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/trac-post-commit.py +285 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/trac_billing.py +173 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/utils/__init__.py +0 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/scripts/utils/mail.py +164 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/setup.py +69 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/__init__.py +1 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/api.py +292 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/blackmagic.py +172 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/dbhelper.py +178 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/billingplugin.css +25 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/field_disabler.js +6 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/formatDate.js +356 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/js/tip_centerwindow.js +100 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/js/tip_followscroll.js +84 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/js/wz_tooltip.js +1149 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/linkifyer.js +119 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/query.js +73 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/htdocs/ticket.js +165 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/query_webui.py +28 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/reportmanager.py +221 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/reports.py +675 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/reports_filter.py +150 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/statuses.py +25 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/tande_filters.py +131 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/templates/billing.cs +84 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/templates/billing.html +104 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/ticket_daemon.py +194 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/ticket_policy.py +62 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/ticket_webui.py +28 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/usermanual.py +127 -0
- data/lib/subtrac/trac-plugins/timingandestimationplugin/timingandestimationplugin/webui.py +129 -0
- data/lib/subtrac/trac-plugins/worklogplugin/setup.py +29 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/__init__.py +1 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/api.py +187 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jqModal.css +40 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jqModal.js +67 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jquery.mousewheel.pack.js +12 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/jquery.timeentry.pack.js +7 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/tracWorklog.js +40 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/ui.datepicker.css +208 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/ui.datepicker.js +1439 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/work.png +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/work.xcf +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/worklogplugin.css +80 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/workstart.png +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/htdocs/workstop.png +0 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/manager.py +336 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/reports.py +598 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog.html +45 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog_stop.html +70 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog_user.html +40 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/templates/worklog_webadminui.html +59 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/ticket_daemon.py +33 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/ticket_filter.py +153 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/timeline_hook.py +96 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/usermanual.py +29 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/util.py +31 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/webadminui.py +47 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/webui.py +174 -0
- data/lib/subtrac/trac-plugins/worklogplugin/worklog/xmlrpc.py +73 -0
- data/lib/subtrac/version.rb +4 -0
- metadata +191 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 =
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "subtrac"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "keithsalisbury@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/keithsalisbury/subtrac"
|
11
|
+
gem.authors = ["="]
|
12
|
+
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/*_test.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |test|
|
29
|
+
test.libs << 'test'
|
30
|
+
test.pattern = 'test/**/*_test.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "subtrac #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
data/VERSION.yml
ADDED
data/bin/subtrac
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander'
|
5
|
+
require 'subtrac'
|
6
|
+
|
7
|
+
program :name, 'subtrac'
|
8
|
+
program :version, Subtrac::VERSION
|
9
|
+
program :description, 'subtrac will install and manage a collection of subversion respositories and associated trac sites'
|
10
|
+
|
11
|
+
command :install do |c|
|
12
|
+
c.syntax = 'subtrac install [options]'
|
13
|
+
c.summary = ''
|
14
|
+
c.description = 'Installation of default files required to host multipe development projects.'
|
15
|
+
c.example 'description', 'installs the default trac and svn setup'
|
16
|
+
c.option '-c','--clean', 'Performs a clean install'
|
17
|
+
c.when_called Subtrac::Commands::Install
|
18
|
+
end
|
19
|
+
|
20
|
+
command :create do |c|
|
21
|
+
c.syntax = 'subtrac create [options]'
|
22
|
+
c.summary = ''
|
23
|
+
c.description = ''
|
24
|
+
c.example 'description', 'creates a new project'
|
25
|
+
c.option '-p','--project PROJECT', 'Name of project to create'
|
26
|
+
c.option '-c','--client CLIENT', 'Name of client to create the project for'
|
27
|
+
c.when_called Subtrac::Commands::Create
|
28
|
+
end
|
29
|
+
|
30
|
+
=begin
|
31
|
+
command :delete do |c|
|
32
|
+
c.syntax = 'subtrac delete [options]'
|
33
|
+
c.summary = ''
|
34
|
+
c.description = ''
|
35
|
+
c.example 'description', 'deletes an existing project'
|
36
|
+
c.option '--project', 'Name of project to delete'
|
37
|
+
c.option '--client', 'Name of client the project was for'
|
38
|
+
c.when_called Devserver::Commands::Create
|
39
|
+
end
|
40
|
+
=end
|
data/lib/subtrac.rb
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright (c) 2009, Keith Salisbury (www.globalkeith.com)
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
6
|
+
# are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# Redistributions in binary form must reproduce the above copyright notice,
|
12
|
+
# this list of conditions and the following disclaimer in the documentation
|
13
|
+
# and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# Neither the name of the original author nor the names of contributors
|
16
|
+
# may be used to endorse or promote products derived from this software
|
17
|
+
# without specific prior written permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
#
|
30
|
+
# You may need these...
|
31
|
+
#
|
32
|
+
# sudo apt-get install ruby rubygems
|
33
|
+
# sudo gem sources -a http://gems.github.com
|
34
|
+
# sudo gem install visionmedia-commander
|
35
|
+
# sudo gem install yaml erb fileutils
|
36
|
+
#
|
37
|
+
|
38
|
+
require 'yaml'
|
39
|
+
require 'erb'
|
40
|
+
require 'fileutils'
|
41
|
+
require 'subtrac/version'
|
42
|
+
|
43
|
+
module Subtrac
|
44
|
+
DEV_ENV = 'test' # should be a system environment var
|
45
|
+
module Commands
|
46
|
+
class Install
|
47
|
+
def initialize(args, options)
|
48
|
+
Subtrac.load_config()
|
49
|
+
Subtrac.install(args,options)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
class Create
|
53
|
+
def initialize(args, options)
|
54
|
+
project = ask("What is the name of the project you would like to create?") if !options.project
|
55
|
+
client = ask("Which client is this project for?") if !options.client
|
56
|
+
Subtrac.load_config()
|
57
|
+
Subtrac.create_project(options.project,options.client)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Install
|
63
|
+
def self.install(args,options)
|
64
|
+
# Ask if the user agrees (yes or no)
|
65
|
+
confirm = agree("Are you sure?") if options.clean
|
66
|
+
if confirm
|
67
|
+
# clear previous data
|
68
|
+
clean()
|
69
|
+
create_environment_directories()
|
70
|
+
else
|
71
|
+
puts "\nAttempt install without overwrites"
|
72
|
+
end
|
73
|
+
install_common_files()
|
74
|
+
create_virtual_host()
|
75
|
+
# create default project and client
|
76
|
+
#create_client(@APP_CONFIG[:default_client])
|
77
|
+
create_project(@APP_CONFIG[:default_project],@APP_CONFIG[:default_client])
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# Loads the configuration YML file
|
83
|
+
def self.load_config
|
84
|
+
puts "\n==== Loading configuration file ===="
|
85
|
+
# load configuration file
|
86
|
+
begin
|
87
|
+
file_path = File.join(File.dirname(__FILE__), "subtrac/config/config.yml")
|
88
|
+
yamlFile = YAML.load_file(file_path)
|
89
|
+
rescue Exception => e
|
90
|
+
raise StandardError, "Config #{file_path} could not be loaded."
|
91
|
+
end
|
92
|
+
if yamlFile
|
93
|
+
if yamlFile[DEV_ENV]
|
94
|
+
@APP_CONFIG = yamlFile[DEV_ENV]
|
95
|
+
else
|
96
|
+
raise StandardError, "config/config.yml exists, but doesn't have a configuration for DEV_ENV=#{DEV_ENV}."
|
97
|
+
end
|
98
|
+
else
|
99
|
+
raise StandardError, "config/config.yml does not exist."
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# creates a directory if it does not exist
|
104
|
+
def self.create_if_missing *names
|
105
|
+
puts "\n==== Creating directory #{names} ===="
|
106
|
+
names.each do |name| FileUtils.mkdir_p(name) unless File.directory?(name) end
|
107
|
+
end
|
108
|
+
|
109
|
+
# publishes an erb template
|
110
|
+
def self.parse_template(infile,outfile,binding)
|
111
|
+
file = File.open(outfile, 'w+')
|
112
|
+
if file
|
113
|
+
template = ERB.new(IO.read(infile))
|
114
|
+
if template
|
115
|
+
file.syswrite(template.result(binding))
|
116
|
+
else
|
117
|
+
raise "Could not read template. file #{infile}"
|
118
|
+
end
|
119
|
+
else
|
120
|
+
raise "Unable to open file for writing. file #{outfile}"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# creates a new virtual host and reloads apache and enables the new virtual host
|
125
|
+
def self.create_virtual_host
|
126
|
+
puts "\n==== Creating new virtual host ===="
|
127
|
+
vhost_template = File.join(File.dirname(__FILE__), @APP_CONFIG[:templates][:virtual_host])
|
128
|
+
new_vhost = "#{@APP_CONFIG[:dirs][:conf]}/#{@APP_CONFIG[:server][:hostname]}"
|
129
|
+
puts new_vhost
|
130
|
+
parse_template(vhost_template,new_vhost,binding)
|
131
|
+
# reload apache configuration
|
132
|
+
`/etc/init.d/apache2 force-reload` if DEV_ENV != 'test'
|
133
|
+
`a2ensite #{@APP_CONFIG[:server][:hostname]}` if DEV_ENV != 'test'
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.install_common_files
|
137
|
+
puts "\n==== Installing common files ===="
|
138
|
+
# TODO: implement a mash for .svn folders
|
139
|
+
# TODO: refactor /common to the app config
|
140
|
+
common_dir = File.join(File.dirname(__FILE__), "subtrac/common")
|
141
|
+
puts common_dir
|
142
|
+
source = Dir.glob("#{common_dir}/.")
|
143
|
+
puts source
|
144
|
+
dest = @APP_CONFIG[:dirs][:document]
|
145
|
+
FileUtils.cp_r(source,dest)
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.create_environment_directories
|
149
|
+
puts "\n==== Creating new environment directories ===="
|
150
|
+
# create the environment directories
|
151
|
+
@APP_CONFIG[:dirs].each do |key, value|
|
152
|
+
create_if_missing value
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def self.clean
|
157
|
+
puts "\n==== Remove old data if exists ===="
|
158
|
+
@APP_CONFIG[:dirs].each do |key, value|
|
159
|
+
unless [@APP_CONFIG[:dirs][:install]].include? value
|
160
|
+
#TODO: Ask for confirmation - yes,no,All
|
161
|
+
puts "Deleting #{value}"
|
162
|
+
FileUtils.rm_rf value
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def self.create_client(name)
|
168
|
+
puts "\n==== Create a new client #{name} ===="
|
169
|
+
client_name = name.downcase
|
170
|
+
# create apache configuration
|
171
|
+
# create apache template
|
172
|
+
location_template = File.join(File.dirname(__FILE__), @APP_CONFIG[:templates][:location])
|
173
|
+
location_conf = "#{@APP_CONFIG[:dirs][:conf_locations]}/#{client_name}.conf"
|
174
|
+
parse_template(location_template,location_conf,binding)
|
175
|
+
`/etc/init.d/apache2 force-reload` if DEV_ENV != 'test'
|
176
|
+
|
177
|
+
# create svn+trac directory
|
178
|
+
create_if_missing "#{@APP_CONFIG[:dirs][:svn]}/#{client_name}"
|
179
|
+
create_if_missing "#{@APP_CONFIG[:dirs][:trac]}/#{client_name}"
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.create_project(project, client)
|
183
|
+
puts "\n==== Create a new project #{project} for #{client} ===="
|
184
|
+
|
185
|
+
client_name = client.downcase
|
186
|
+
project_name = project.downcase
|
187
|
+
|
188
|
+
# create client directory if needed
|
189
|
+
create_client(client_name) if (!File.directory? "#{@APP_CONFIG[:dirs][:svn]}/#{client_name}")
|
190
|
+
|
191
|
+
svn_dir = "#{@APP_CONFIG[:dirs][:svn]}/#{client_name}/#{project_name}"
|
192
|
+
trac_dir = "#{@APP_CONFIG[:dirs][:trac]}/#{client_name}/#{project_name}"
|
193
|
+
if (File.directory? svn_dir) then
|
194
|
+
raise StandardError, "A project called #{project} already exists in the #{client} repository. Would you like to replace it?"
|
195
|
+
end
|
196
|
+
|
197
|
+
project_template = File.join(File.dirname(__FILE__), "#{@APP_CONFIG[:templates][:projects]}/#{@APP_CONFIG[:default_project_template]}")
|
198
|
+
|
199
|
+
# copy template svn project to a temp folder, then svn import it into the repo
|
200
|
+
svn_template_dir = "#{project_template}/svn"
|
201
|
+
temp_dir = "#{@APP_CONFIG[:dirs][:temp]}/#{project_name}"
|
202
|
+
FileUtils.cp_r(svn_template_dir,temp_dir)
|
203
|
+
|
204
|
+
# create a new subversion repository
|
205
|
+
`svnadmin create #{svn_dir}` if DEV_ENV != 'test'
|
206
|
+
|
207
|
+
# import into svn and delete the temporary directory
|
208
|
+
`svn import #{temp_dir} file:///#{svn_dir} --message "initial import"` if DEV_ENV != 'test'
|
209
|
+
FileUtils.rm_r(temp_dir, :force => true)
|
210
|
+
|
211
|
+
# create a new trac site
|
212
|
+
`trac-admin #{trac_dir} initenv #{project_name} sqlite:#{trac_dir}/db/trac.db svn #{svn_dir}` if DEV_ENV != 'test'
|
213
|
+
FileUtils.chown_R('www-data', 'www-data', trac_dir, :verbose => true) if DEV_ENV != 'test'
|
214
|
+
FileUtils.mkdir_p("#{trac_dir}/conf") if DEV_ENV == 'test' # fake the folder for tests
|
215
|
+
|
216
|
+
# install shared trac.ini
|
217
|
+
trac_ini_template = File.join(File.dirname(__FILE__), @APP_CONFIG[:templates][:trac])
|
218
|
+
parse_template(trac_ini_template,"#{trac_dir}/conf/trac.ini",binding)
|
219
|
+
|
220
|
+
# remove custom templates directory so trac uses the shared location (while we wait for trac patch)
|
221
|
+
FileUtils.rm_rf("#{trac_dir}/templates")
|
222
|
+
|
223
|
+
puts "Setting up default trac permission..."
|
224
|
+
# set up trac permissions
|
225
|
+
@APP_CONFIG[:trac][:permissions].each do |key, value|
|
226
|
+
`trac-admin #{trac_dir} permission add #{key} #{value}` if DEV_ENV != 'test'
|
227
|
+
end
|
228
|
+
|
229
|
+
puts "Adding default trac wiki pages..."
|
230
|
+
# this needs to loop through the directory and import all pages
|
231
|
+
Dir.foreach("#{project_template}/trac/wiki/.") do |file|
|
232
|
+
# do something with the file here
|
233
|
+
unless ['.', '..','.svn'].include? file
|
234
|
+
temp_file = "#{@APP_CONFIG[:dirs][:temp]}/#{file}"
|
235
|
+
parse_template("#{project_template}/trac/wiki/#{file}", temp_file, binding)
|
236
|
+
`trac-admin #{trac_dir} wiki import #{file} #{temp_file}` if DEV_ENV != 'test'
|
237
|
+
FileUtils.rm(temp_file)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
|
245
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
"""
|
3
|
+
A simple WSGI test application.
|
4
|
+
|
5
|
+
Its main purpose is to show that WSGI support works (meaning that the
|
6
|
+
web server and the WSGI adaptor / support module are configured correctly).
|
7
|
+
|
8
|
+
As a nice plus, it outputs some interesting system / WSGI values as a nice
|
9
|
+
HTML table.
|
10
|
+
|
11
|
+
The main use of this script will be using the WSGI "application" defined
|
12
|
+
below within your production WSGI environment. You will use some code similar
|
13
|
+
to what you see at the end of this script to use the application from that
|
14
|
+
environment. For the special case of apache2/mod_wsgi, it shoud be possible
|
15
|
+
to directly use this file.
|
16
|
+
|
17
|
+
If you start this script from the commandline either with python2.5 or with
|
18
|
+
and older python + wsgiref module installed, it will serve the content on
|
19
|
+
http://localhost:8000/ - this is mainly for debugging THIS script.
|
20
|
+
|
21
|
+
@copyright: 2008 by MoinMoin:ThomasWaldmann
|
22
|
+
@license: Python License, see LICENSE.Python for details.
|
23
|
+
"""
|
24
|
+
import os.path
|
25
|
+
import os
|
26
|
+
import sys
|
27
|
+
|
28
|
+
try:
|
29
|
+
__file__
|
30
|
+
except NameError:
|
31
|
+
__file__ = '?'
|
32
|
+
|
33
|
+
html_template = """\
|
34
|
+
<html>
|
35
|
+
<head>
|
36
|
+
<title>WSGI Test Script</title>
|
37
|
+
</head>
|
38
|
+
<body>
|
39
|
+
<h1>WSGI test script is working!</h1>
|
40
|
+
<table border=1>
|
41
|
+
<tr><th colspan=2>1. System Information</th></tr>
|
42
|
+
<tr><td>Python</td><td>%(python_version)s</td></tr>
|
43
|
+
<tr><td>Python Path</td><td>%(python_path)s</td></tr>
|
44
|
+
<tr><td>Platform</td><td>%(platform)s</td></tr>
|
45
|
+
<tr><td>Absolute path of this script</td><td>%(abs_path)s</td></tr>
|
46
|
+
<tr><td>Filename</td><td>%(filename)s</td></tr>
|
47
|
+
<tr><th colspan=2>2. WSGI Environment</th></tr>
|
48
|
+
%(wsgi_env)s
|
49
|
+
</table>
|
50
|
+
</body>
|
51
|
+
</html>
|
52
|
+
"""
|
53
|
+
|
54
|
+
row_template = " <tr><td>%s</td><td>%r</td></tr>"
|
55
|
+
|
56
|
+
|
57
|
+
def application(environ, start_response):
|
58
|
+
""" The WSGI test application """
|
59
|
+
# emit status / headers
|
60
|
+
status = "200 OK"
|
61
|
+
headers = [('Content-Type', 'text/html'), ]
|
62
|
+
start_response(status, headers)
|
63
|
+
|
64
|
+
# assemble and return content
|
65
|
+
content = html_template % {
|
66
|
+
'python_version': sys.version,
|
67
|
+
'platform': sys.platform,
|
68
|
+
'abs_path': os.path.abspath('.'),
|
69
|
+
'filename': __file__,
|
70
|
+
'python_path': repr(sys.path),
|
71
|
+
'wsgi_env': '\n'.join([row_template % item for item in environ.items()]),
|
72
|
+
}
|
73
|
+
return [content]
|
74
|
+
|
75
|
+
|
76
|
+
if __name__ == '__main__':
|
77
|
+
# this runs when script is started directly from commandline
|
78
|
+
try:
|
79
|
+
# create a simple WSGI server and run the application
|
80
|
+
from wsgiref import simple_server
|
81
|
+
print "Running test application - point your browser at http://localhost:8000/ ..."
|
82
|
+
httpd = simple_server.WSGIServer(('', 8000), simple_server.WSGIRequestHandler)
|
83
|
+
httpd.set_app(application)
|
84
|
+
httpd.serve_forever()
|
85
|
+
except ImportError:
|
86
|
+
# wsgiref not installed, just output html to stdout
|
87
|
+
for content in application({}, lambda status, headers: None):
|
88
|
+
print content
|
89
|
+
|