You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/09/14 18:12:21 UTC
[whimsy] branch master updated: present task details
This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 9a6202d present task details
9a6202d is described below
commit 9a6202d9932ae001d6595ed717f5ac6a1182e6f8
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Wed Sep 14 14:11:58 2016 -0400
present task details
---
www/secmail/public/secmail.css | 4 +
www/secmail/public/tasklist.js | 6 +-
www/secmail/server.rb | 14 +---
www/secmail/tasks.rb | 64 +++++++++++++++
www/secmail/views/actions/icla.json.rb | 138 ++++++++++++++++++++-------------
www/secmail/views/tasklist.html.rb | 11 ++-
6 files changed, 166 insertions(+), 71 deletions(-)
diff --git a/www/secmail/public/secmail.css b/www/secmail/public/secmail.css
index 6ae5a0e..843556b 100644
--- a/www/secmail/public/secmail.css
+++ b/www/secmail/public/secmail.css
@@ -172,3 +172,7 @@ pre.bg-info {
white-space: pre-wrap;
word-break: normal;
}
+
+#tasklist input, #tasklist textarea {
+ width: 100%;
+}
diff --git a/www/secmail/public/tasklist.js b/www/secmail/public/tasklist.js
index 4072f0d..be7269a 100644
--- a/www/secmail/public/tasklist.js
+++ b/www/secmail/public/tasklist.js
@@ -34,6 +34,9 @@ function nexttask(proceed) {
fetch('', options).then(function(response) {
// display output
response.json().then(function(json) {
+ // remove all but the heading
+ task.parent().empty().append(task);
+
if (json.transcript) {
var pre = $('<pre>');
pre.text(json.transcript.join("\n"));
@@ -42,7 +45,8 @@ function nexttask(proceed) {
pre.html(("\n" + pre.html()).replace(/\n(\$ \w+ .*)/g,
"\n<b>$1</b>").trim());
- task.append(pre);
+ // append results
+ task.parent().append(pre);
}
if (json.message) {
diff --git a/www/secmail/server.rb b/www/secmail/server.rb
index 331d5ae..6a713c7 100644
--- a/www/secmail/server.rb
+++ b/www/secmail/server.rb
@@ -15,23 +15,11 @@ require_relative 'helpers'
require_relative 'models/mailbox'
require_relative 'models/safetemp'
require_relative 'models/events'
+require_relative 'tasks'
require 'whimsy/asf'
ASF::Mail.configure
-class Wunderbar::JsonBuilder
- def _task(title, &block)
- if not @task
- @_target[:tasklist] ||= []
- @_target[:tasklist] << title
- elsif @task == title
- block.call
- @task = nil
- else
- end
- end
-end
-
# list of messages
get '/' do
# determine latest month for which there are messages
diff --git a/www/secmail/tasks.rb b/www/secmail/tasks.rb
new file mode 100644
index 0000000..1203599
--- /dev/null
+++ b/www/secmail/tasks.rb
@@ -0,0 +1,64 @@
+
+class Wunderbar::JsonBuilder
+ def task(title, &block)
+ if not @task
+ # dry run: collect up a list of tasks
+ @_target[:tasklist] ||= []
+ @_target[:tasklist] << {title: title, form: []}
+
+ block.call
+ elsif @task == title
+ # actual run
+ block.call
+ @task = nil
+ end
+ end
+
+ def _input *args
+ return if @task
+ @_target[:tasklist].last[:form] << ['input', '', *args]
+ end
+
+ def _message mail
+ if @task
+ super
+ else
+ @_target[:tasklist].last[:form] << ['textarea', mail.to_s.strip, rows: 20]
+ end
+ end
+
+ def form &block
+ block.call
+ end
+
+ def complete &block
+ return unless @task
+
+ if block.arity == 1
+ Dir.mktmpdir do |dir|
+ block.call dir
+ end
+ else
+ block.call
+ end
+ end
+
+ def svn *args
+ args << svnauth if %(checkout update commit).include? args.first
+ _.system 'svn', *args
+ end
+
+ def svnauth
+ [
+ '--non-interactive',
+ '--no-auth-cache',
+ '--username', env.user.untaint,
+ '--password', env.password.untaint
+ ]
+ end
+
+ def template(name)
+ path = File.expand_path("../templates/#{name}", __FILE__.untaint)
+ ERB.new(File.read(path.untaint).untaint).result(binding)
+ end
+end
diff --git a/www/secmail/views/actions/icla.json.rb b/www/secmail/views/actions/icla.json.rb
index 0aee71f..d57cd90 100644
--- a/www/secmail/views/actions/icla.json.rb
+++ b/www/secmail/views/actions/icla.json.rb
@@ -2,7 +2,9 @@
# File an ICLA:
# - add files to documents/iclas
# - add entry to officers/iclas.txt
-# - send email
+# - respond to original email
+# - [optional] add entry to new-account-reqs.txt
+# - [optional] send email to root@
#
# extract message
@@ -28,33 +30,48 @@ if @project and not @project.empty?
end
end
+# obtain per-user information
+_personalize_email(env.user)
+
+########################################################################
+# document/iclas #
+########################################################################
+
# write attachment (+ signature, if present) to the documents/iclas directory
-_task "svn commit documents/iclas/#@filename#{fileext}" do
- Dir.mktmpdir do |dir|
+task "svn commit documents/iclas/#@filename#{fileext}" do
+ form do
+ _input value: @selected, name: 'selected'
+
+ if @signature and not @signature.empty?
+ _input value: @signature, name: 'signature'
+ end
+ end
+
+ complete do |dir|
# checkout empty directory
- _.system! 'svn', 'checkout', '--depth', 'empty',
- 'https://svn.apache.org/repos/private/documents/iclas', "#{dir}/iclas",
- ['--non-interactive', '--no-auth-cache'],
- ['--username', env.user.untaint, '--password', env.password.untaint]
+ svn 'checkout', '--depth', 'empty',
+ 'https://svn.apache.org/repos/private/documents/iclas', "#{dir}/iclas"
# create/add file(s)
dest = message.write_svn("#{dir}/iclas", @filename, @selected, @signature)
# Show files to be added
- _.system 'svn', 'status', "#{dir}/iclas"
+ svn 'status', "#{dir}/iclas"
# commit changes
- _.system! 'svn', 'commit', "#{dir}/iclas/#{@filename}#{fileext}",
- '-m', "ICLA from #{@pubname}",
- ['--non-interactive', '--no-auth-cache'],
- ['--username', env.user.untaint, '--password', env.password.untaint]
+ svn 'commit', "#{dir}/iclas/#{@filename}#{fileext}",
+ '-m', "ICLA from #{@pubname}"
end
end
+########################################################################
+# officers/iclas.txt #
+########################################################################
+
# insert line into iclas.txt
-_task "svn commit foundation/officers/iclas.txt" do
+task "svn commit foundation/officers/iclas.txt" do
# construct line to be inserted
- insert = [
+ @iclaline ||= [
'notinavail',
@realname.strip,
@pubname.strip,
@@ -62,42 +79,40 @@ _task "svn commit foundation/officers/iclas.txt" do
"Signed CLA;#{@filename}"
].join(':')
- Dir.mktmpdir do |dir|
+ form do
+ _input value: @iclaline, name: 'iclaline'
+ end
+
+ complete do |dir|
# checkout empty officers directory
- _.system! 'svn', 'checkout', '--depth', 'empty',
+ svn 'checkout', '--depth', 'empty',
'https://svn.apache.org/repos/private/foundation/officers',
- "#{dir}/officers",
- ['--non-interactive', '--no-auth-cache'],
- ['--username', env.user.untaint, '--password', env.password.untaint]
+ "#{dir}/officers"
# retrieve iclas.txt
dest = "#{dir}/officers/iclas.txt"
- _.system! 'svn', 'update', dest,
- ['--non-interactive', '--no-auth-cache'],
- ['--username', env.user.untaint, '--password', env.password.untaint]
+ svn 'update', dest
# update iclas.txt
- iclas_txt = ASF::ICLA.sort(File.read(dest) + insert + "\n")
+ iclas_txt = ASF::ICLA.sort(File.read(dest) + @iclaline + "\n")
File.write dest, iclas_txt
# show the changes
- _.system! 'svn', 'diff', dest
+ svn 'diff', dest
# commit changes
- _.system! 'svn', 'commit', dest, '-m', "ICLA from #{@pubname}",
- ['--non-interactive', '--no-auth-cache'],
- ['--username', env.user.untaint, '--password', env.password.untaint]
+ svn 'commit', dest, '-m', "ICLA from #{@pubname}"
end
end
-# send confirmation email
-_task "email #@email" do
- # obtain per-user information
- _personalize_email(env.user)
+########################################################################
+# email submitter #
+########################################################################
+# send confirmation email
+task "email #@email" do
# build mail from template
- template = File.expand_path('../../../templates/icla.erb', __FILE__).untaint
- mail = Mail.new(ERB.new(File.read(template).untaint).result(binding))
+ mail = Mail.new(template('icla.erb'))
# adjust copy lists
cc = mail.cc # from the template
@@ -117,15 +132,25 @@ _task "email #@email" do
end
# echo email
- _message mail.to_s
+ form do
+ _message mail.to_s
+ end
# deliver mail
- mail.deliver!
+ complete do
+ mail.deliver!
+ end
end
if @user and not @user.empty? and pmc and not @votelink.empty?
- _task "svn commit infra/acreq/new-account-reqs.txt" do
- line = [
+
+ ######################################################################
+ # acreq/new-account-reqs.txt #
+ ######################################################################
+
+ task "svn commit infra/acreq/new-account-reqs.txt" do
+ # construct account request line
+ @acreq ||= [
@user,
@pubname,
@email,
@@ -137,13 +162,15 @@ if @user and not @user.empty? and pmc and not @votelink.empty?
'no'
].join(';')
- Dir.mktmpdir do |dir|
+ form do
+ _input value: @acreq, name: 'acreq'
+ end
+
+ complete do |dir|
# checkout acreq directory
- _.system! 'svn', 'checkout', '--depth', 'files',
+ svn 'checkout', '--depth', 'files',
'https://svn.apache.org/repos/infra/infrastructure/trunk/acreq',
- "#{dir}/acreq",
- ['--non-interactive', '--no-auth-cache'],
- ['--username', env.user.untaint, '--password', env.password.untaint]
+ "#{dir}/acreq"
# update new-account-reqs.txt
dest = "#{dir}/acreq/new-account-reqs.txt"
@@ -152,24 +179,21 @@ if @user and not @user.empty? and pmc and not @votelink.empty?
File.write dest, File.read(dest) + line + "\n"
# show the changes
- _.system! 'svn', 'diff', dest
+ svn 'diff', dest
# commit changes
- _.system! 'svn', 'commit', dest, '-m',
- "#{@user} account request by #{env.user}",
- ['--non-interactive', '--no-auth-cache'],
- ['--username', env.user.untaint, '--password', env.password.untaint]
+ svn 'commit', dest, '-m',
+ "#{@user} account request by #{env.user}"
end
end
- # notify root@
- _task "email root@apache.org" do
- # obtain per-user information
- _personalize_email(env.user)
+ ######################################################################
+ # email root@ #
+ ######################################################################
+ task "email root@apache.org" do
# build mail from template
- template = File.expand_path('../../../templates/acreq.erb', __FILE__).untaint
- mail = Mail.new(ERB.new(File.read(template).untaint).result(binding))
+ mail = Mail.new(template('acreq.erb'))
# adjust copy lists
cc = mail.cc # from the template
@@ -178,9 +202,13 @@ if @user and not @user.empty? and pmc and not @votelink.empty?
mail.cc = cc.uniq
# echo email
- _message mail.to_s
+ form do
+ _message mail.to_s
+ end
# deliver mail
- mail.deliver!
+ complete do
+ mail.deliver!
+ end
end
end
diff --git a/www/secmail/views/tasklist.html.rb b/www/secmail/views/tasklist.html.rb
index 73df352..a2eba2b 100644
--- a/www/secmail/views/tasklist.html.rb
+++ b/www/secmail/views/tasklist.html.rb
@@ -10,9 +10,16 @@ _html do
_h1.bg_warning 'Operations to be performed'
- _ul do
+ _ul.tasklist! do
@dryrun['tasklist'].each do |task|
- _li {_h3 task}
+ _li do
+ _h3 task['title']
+
+ task['form'].each do |element|
+ element.last[:disabled] = true if Hash === element.last
+ tag! *element
+ end
+ end
end
end
--
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].