Commit cc1edd190167545d34eb93c7b86cd8b8e5202171:
Initial stab at a CMS request form
git-svn-id:
https://svn.apache.org/repos/infra/infrastructure/trunk/projects/whimsy@820852
90ea9780-b833-de11-8433-001ec94261de
Branch: refs/heads/master
Author: Sam Ruby <[email protected]>
Committer: Sam Ruby <[email protected]>
Pusher: rubys <[email protected]>
------------------------------------------------------------
asf/mail.rb | +++++++++++++
www/officers/cmsreq.cgi | +++++++++++++
www/officers/mlreq.cgi | ++ -----
------------------------------------------------------------
117 changes: 112 additions, 5 deletions.
------------------------------------------------------------
diff --git a/asf/mail.rb b/asf/mail.rb
index 085fb0a..c9a3a56 100644
--- a/asf/mail.rb
+++ b/asf/mail.rb
@@ -29,6 +29,12 @@ def self.list
@list = list
end
+
+ def self.lists
+ apmail_bin = ASF::SVN['infra/infrastructure/apmail/trunk/bin']
+ @lists ||= File.read(File.join(apmail_bin, '.archives')).
+ scan(/^\s+"(\w[-\w]+)", "\/home\/apmail\//).flatten
+ end
end
class Person < Base
@@ -58,4 +64,11 @@ def all_mail
active_emails + obsolete_emails
end
end
+
+ class Committee
+ def mail_list
+ return 'hc' if name == 'httpcomponents'
+ name
+ end
+ end
end
diff --git a/www/officers/cmsreq.cgi b/www/officers/cmsreq.cgi
new file mode 100755
index 0000000..13bf930
--- /dev/null
+++ b/www/officers/cmsreq.cgi
@@ -0,0 +1,97 @@
+#!/usr/bin/ruby1.9.1
+require 'wunderbar'
+require '/var/tools/asf'
+
+user = ASF::Person.new($USER)
+unless user.asf_member? or ASF.pmc_chairs.include? user or $USER=='ea'
+ print "Status: 401 Unauthorized\r\n"
+ print "WWW-Authenticate: Basic realm=\"ASF Members and Officers\"\r\n\r\n"
+ exit
+end
+
+BUILD_TYPES = %w(standard maven ant forrest shell)
+pmcs = ASF::Committee.list.map(&:mail_list)
+
+_html do
+
+ _head_ do
+ _title 'ASF CMS Request'
+ _style %{
+ textarea, .mod, label {display: block}
+ input[type=submit] {display: block; margin-top: 1em}
+ legend {background: #141; color: #DFD; padding: 0.4em}
+ input[type=text] {width: 6em}
+ input[type=url] {width: 30em}
+ }
+ end
+
+ _body? do
+ _form method: 'post' do
+ _fieldset do
+ _legend 'ASF CMS Request'
+
+ _h3_ 'CMS Name'
+ _input type: 'text', name: 'cms', required: true, pattern: '^\w+$',
+ value: @cms
+
+ _h3_ 'Source URL'
+ _input type: 'url', name: 'source', required: true,
+ value: @source || 'https://svn.apache.org/repos/asf/'
+
+ _h3_ 'Commits list'
+ _input type: 'text', name: 'list', value: @list || 'commits'
+ _ '@'
+ _select name: 'pmc' do
+ pmcs.sort.each do |pmc|
+ _option pmc, selected: (pmc == @pmc)
+ end
+ end
+ _ '.apache.org'
+
+ _h3_ 'Build Type'
+ _select name: 'build_type' do
+ BUILD_TYPES.each do |type|
+ _option type, selected: (type == @build_type)
+ end
+ end
+
+ _input_ type: 'submit', value: 'Submit Request'
+ end
+ end
+
+ if _.post?
+ error = nil
+ error ||= 'Invalid CMS name' unless @cms =~ /^\w+$/
+ error ||= 'Invalid build type' unless BUILD_TYPES.include? @build_type
+
+ unless ASF::Mail.lists.include? "#{@pmc}-#{@list}"
+ error ||= "Mail list doesn't exist"
+ end
+
+ begin
+ @source += '/' unless @source.end_with? '/'
+ if http_get(URI.parse(@source.untaint) + 'trunk/content/').code !=
'200'
+ error ||= "content directory not found in source URL"
+ end
+ rescue Exception => exception
+ error = "Exception processing URL: #{exception}"
+ end
+
+ if error
+ _h2_ 'Error'
+ _p error
+ else
+ _h2_ 'Request would be accepted if this application were complete'
+ end
+ end
+ end
+end
+
+require 'net/http'
+def http_get(uri)
+ uri = URI.parse(uri) if String === uri
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme=='https') do |http|
+ http.request Net::HTTP::Get.new uri.request_uri
+ end
+end
+
diff --git a/www/officers/mlreq.cgi b/www/officers/mlreq.cgi
index e694896..977d5d4 100755
--- a/www/officers/mlreq.cgi
+++ b/www/officers/mlreq.cgi
@@ -11,11 +11,8 @@ unless user.asf_member? or ASF.pmc_chairs.include? user or
$USER=='ea'
exit
end
-apmail_bin = ASF::SVN['infra/infrastructure/apmail/trunk/bin']
-lists = File.read(File.join(apmail_bin, '.archives')).
- scan(/^\s+"(\w[-\w]+)", "\/home\/apmail\//).flatten
-
-pmcs = ASF::Committee.list.map(&:name) - %w(httpcomponents) + %w(hc)
+lists = ASF::Mail.lists
+pmcs = ASF::Committee.list.map(&:mail_list)
pmcs.delete_if {|pmc| not lists.include? "#{pmc}-private"}
_html do