Commit 7997692c396c165953fc89a1e21a977c8d1508bd:
    Remove unnecessary begin/end
    git-svn-id: 
https://svn.apache.org/repos/infra/infrastructure/trunk/projects/whimsy@819624 
90ea9780-b833-de11-8433-001ec94261de


Branch: refs/heads/master
Author: Sam Ruby <[email protected]>
Committer: Sam Ruby <[email protected]>
Pusher: rubys <[email protected]>

------------------------------------------------------------
www/secretary/workbench/file.cgi                             | +++++++ -------
------------------------------------------------------------
880 changes: 439 additions, 441 deletions.
------------------------------------------------------------


diff --git a/www/secretary/workbench/file.cgi b/www/secretary/workbench/file.cgi
index 829339b..8489e9c 100755
--- a/www/secretary/workbench/file.cgi
+++ b/www/secretary/workbench/file.cgi
@@ -445,540 +445,538 @@ _html do
       file.truncate file.pos
     end
 
-    begin
-      filename = [@filename, @cfilename, @gfilename, @mfilename, @nfilename].
-        find {|name| name and not name.empty?}
-      filename.untaint if filename and filename =~ /^[-.\w]+/
-      doctype = (@doctype == 'mem' ? 'member_apps' : @doctype.to_s+'s')
-      doctype.untaint if doctype =~ /^\w+$/
-      dest = File.join(DOCUMENTS, doctype, filename.to_s)
-      stem = ";#{filename.sub(/\.\w+$/,'').split('/').first}" if filename
-      alax = false
-      @source.untaint if Dir.chdir(RECEIVED) {Dir['*']}.include? @source
-
-      unless %w(clr rubys).include? $USER
-        @action = 'welcome' unless @action == 'view'
-      end
-
-      case (@action || @doctype).to_s.downcase
-      when 'welcome'
-        _h1 "Welcome!"
-        _p "This tools is for the Secretarial's team use only."
-        _p %{
-          Feel free to look around, but none of your actions will cause any
-          files to be moved, updated, or any emails to be sent.
-        }
+    filename = [@filename, @cfilename, @gfilename, @mfilename, @nfilename].
+      find {|name| name and not name.empty?}
+    filename.untaint if filename and filename =~ /^[-.\w]+/
+    doctype = (@doctype == 'mem' ? 'member_apps' : @doctype.to_s+'s')
+    doctype.untaint if doctype =~ /^\w+$/
+    dest = File.join(DOCUMENTS, doctype, filename.to_s)
+    stem = ";#{filename.sub(/\.\w+$/,'').split('/').first}" if filename
+    alax = false
+    @source.untaint if Dir.chdir(RECEIVED) {Dir['*']}.include? @source
+
+    unless %w(clr rubys).include? $USER
+      @action = 'welcome' unless @action == 'view'
+    end
 
-      when 'icla'
-        if @replaces != ''
-          remove_id, remove_email = @replaces.strip.split(':',2)
-        else
-          remove_id, remove_email = 'notinavail', nil
-        end
+    case (@action || @doctype).to_s.downcase
+    when 'welcome'
+      _h1 "Welcome!"
+      _p "This tools is for the Secretarial's team use only."
+      _p %{
+        Feel free to look around, but none of your actions will cause any
+        files to be moved, updated, or any emails to be sent.
+      }
+
+    when 'icla'
+      if @replaces != ''
+        remove_id, remove_email = @replaces.strip.split(':',2)
+      else
+        remove_id, remove_email = 'notinavail', nil
+      end
 
-        insert = [
-          remove_id, 
-          @realname.strip, 
-          @pubname.strip, 
-          @email.strip, 
-          "Signed CLA#{stem}\n"
-        ].join(':')
-
-        Dir.chdir(OFFICERS) do
-          input = open('iclas.txt') {|file| file.to_a}
-          open('iclas.txt','w') do |file|
-            input.each do |line|
-              if insert and icla_lname(line) >= icla_lname(insert)
-                if insert.split(':',2).last != line.split(':',2).last
-                  file.print insert
-                end
-                insert = nil
+      insert = [
+        remove_id, 
+        @realname.strip, 
+        @pubname.strip, 
+        @email.strip, 
+        "Signed CLA#{stem}\n"
+      ].join(':')
+
+      Dir.chdir(OFFICERS) do
+        input = open('iclas.txt') {|file| file.to_a}
+        open('iclas.txt','w') do |file|
+          input.each do |line|
+            if insert and icla_lname(line) >= icla_lname(insert)
+              if insert.split(':',2).last != line.split(':',2).last
+                file.print insert
               end
-              fields = line.split(':')
-              next if fields[0] == remove_id and fields[3] == remove_email
-              file.print line
+              insert = nil
             end
-            file.print insert if insert
-          end
-
-          _h1 @pubname
-          if @source=~/[^\x00-\x7F]/ and RUBY_PLATFORM=~/darwin/i
-            require 'unicode'
-            @source = Unicode.normalize_KC(@source)
+            fields = line.split(':')
+            next if fields[0] == remove_id and fields[3] == remove_email
+            file.print line
           end
-          _.move @source, dest
-          _.system "svn diff iclas.txt", hilite: @pubname
+          file.print insert if insert
         end
 
-        update_pending params, dest
+        _h1 @pubname
+        if @source=~/[^\x00-\x7F]/ and RUBY_PLATFORM=~/darwin/i
+          require 'unicode'
+          @source = Unicode.normalize_KC(@source)
+        end
+        _.move @source, dest
+        _.system "svn diff iclas.txt", hilite: @pubname
+      end
 
-      when 'grant'
-        insert = "#{@from.strip}" +
-          "\n  file: #{dest.split('/').last}" +
-          "\n  for: #{@description.strip.gsub(/\r?\n\s*/,"\n       ")}"
+      update_pending params, dest
 
-        Dir.chdir(OFFICERS) do
-          input = open('grants.txt') {|file| file.read}
-          marker = "\n# registering.  documents on way to Secretary.\n"
-          input = input.split(marker).insert(1,"\n#{insert}\n",marker)
-          open('grants.txt','w') do |file|
-            file.write(input.join)
-          end
+    when 'grant'
+      insert = "#{@from.strip}" +
+        "\n  file: #{dest.split('/').last}" +
+        "\n  for: #{@description.strip.gsub(/\r?\n\s*/,"\n       ")}"
 
-          _h1 "Grant"
-          _.move @source, dest
-          _.system "svn diff grants.txt", hilite: insert.split("\n")
+      Dir.chdir(OFFICERS) do
+        input = open('grants.txt') {|file| file.read}
+        marker = "\n# registering.  documents on way to Secretary.\n"
+        input = input.split(marker).insert(1,"\n#{insert}\n",marker)
+        open('grants.txt','w') do |file|
+          file.write(input.join)
         end
 
-        update_pending params, dest
+        _h1 "Grant"
+        _.move @source, dest
+        _.system "svn diff grants.txt", hilite: insert.split("\n")
+      end
 
-      when 'ccla'
-        insert = "notinavail:" + @company.strip
-         
-        unless @contact.empty?
-          insert += " - #{@contact.strip}"
-        end
+      update_pending params, dest
 
-        insert += ":#{@cemail.strip}:Signed Corp CLA"
+    when 'ccla'
+      insert = "notinavail:" + @company.strip
+       
+      unless @contact.empty?
+        insert += " - #{@contact.strip}"
+      end
 
-        unless @employees.empty?
-          insert += " for #{@employees.strip.gsub(/\s*\n\s*/, ', ')}"
-        end
+      insert += ":#{@cemail.strip}:Signed Corp CLA"
 
-        unless @product.empty?
-          insert += " for #{@product.strip}"
-        end
+      unless @employees.empty?
+        insert += " for #{@employees.strip.gsub(/\s*\n\s*/, ', ')}"
+      end
 
-        Dir.chdir(OFFICERS) do
-          open('cclas.txt','a') {|file| file.write(insert+"\n")}
+      unless @product.empty?
+        insert += " for #{@product.strip}"
+      end
 
-          _h1 @pubname
-          _.move @source, dest
-          _.system "svn diff cclas.txt", hilite: insert
-        end
+      Dir.chdir(OFFICERS) do
+        open('cclas.txt','a') {|file| file.write(insert+"\n")}
 
-        update_pending params, dest
+        _h1 @pubname
+        _.move @source, dest
+        _.system "svn diff cclas.txt", hilite: insert
+      end
 
-      when 'nda'
-        @realname ||= @nname
+      update_pending params, dest
 
-        _h1 "NDA for #{@realname}"
-        _move @source, dest
+    when 'nda'
+      @realname ||= @nname
 
-        Dir.chdir(FOUNDATION) do
-          ndalist = "Correspondence/JCP/tck-nda-list.txt"
-          _.system "svn update #{ndalist}"
-          text = open(ndalist).read
-          open(ndalist, 'w') do |fh|
-            fh.write(text)
-            line = "#{@nname.ljust(20)} #{@nid.ljust(13)} "
-            line += Date.today.strftime("%Y/%m/%d    ")
-            line += `id -un`.chomp.ljust(10) + ' No TCK access yet'
-            fh.write("#{line}\n")
-          end
-          _.system "svn diff #{ndalist}", hilite: @nid
+      _h1 "NDA for #{@realname}"
+      _move @source, dest
+
+      Dir.chdir(FOUNDATION) do
+        ndalist = "Correspondence/JCP/tck-nda-list.txt"
+        _.system "svn update #{ndalist}"
+        text = open(ndalist).read
+        open(ndalist, 'w') do |fh|
+          fh.write(text)
+          line = "#{@nname.ljust(20)} #{@nid.ljust(13)} "
+          line += Date.today.strftime("%Y/%m/%d    ")
+          line += `id -un`.chomp.ljust(10) + ' No TCK access yet'
+          fh.write("#{line}\n")
         end
+        _.system "svn diff #{ndalist}", hilite: @nid
+      end
 
-        update_pending params, dest
+      update_pending params, dest
 
-      when 'mem'
-        @realname ||= @mfname
-        dest.untaint if dest =~ /^[-.\w]+$/
+    when 'mem'
+      @realname ||= @mfname
+      dest.untaint if dest =~ /^[-.\w]+$/
 
-        _h1 "Membership Application for #{@realname}"
-        _.move @source, dest
+      _h1 "Membership Application for #{@realname}"
+      _.move @source, dest
 
-        if defined?(MEETING)
-          _.system "svn update #{MEETING}"
-          received = open("#{MEETING}/memapp-received.txt").read
-          begin
-            received[/(no )\s+\w+\s+\w+\s+#{@mavailid}/,1] = 'yes'
-          rescue
-            _pre.stderr $!
-          end
-          open("#{MEETING}/memapp-received.txt", 'w') do |fh| 
-            fh.write(received)
-          end
-          _.system "svn diff #{MEETING}/memapp-received.txt", hilite: @mavailid
+      if defined?(MEETING)
+        _.system "svn update #{MEETING}"
+        received = open("#{MEETING}/memapp-received.txt").read
+        begin
+          received[/(no )\s+\w+\s+\w+\s+#{@mavailid}/,1] = 'yes'
+        rescue
+          _pre.stderr $!
+        end
+        open("#{MEETING}/memapp-received.txt", 'w') do |fh| 
+          fh.write(received)
         end
+        _.system "svn diff #{MEETING}/memapp-received.txt", hilite: @mavailid
+      end
 
-        _.system "svn update #{FOUNDATION}/members.txt"
-        pattern = /^Active.*?^=+\n+(.*?)^Emeritus/m
-        members_txt = open("#{FOUNDATION}/members.txt").read
-        data = members_txt.scan(pattern).flatten.first
-        members = data.split(/^\s+\*\)\s+/)
-        members.shift
-
-        members.push [
-          "#{@mfname}",
-          "#{@maddr.gsub(/^/,'    ').gsub(/\r/,'')}",
-          ("    #{@mcountry}"     unless @mcountry.empty?),
-          "    Email: #{@memail}",
-          ("      Tel: #{@mtele}" unless @mtele.empty?),
-          ("      Fax: #{@mfax}"  unless @mfax.empty?),
-          " Forms on File: ASF Membership Application",
-          " Avail ID: #{@mavailid}"
-        ].compact.join("\n") + "\n"
-
-        sorted = members.sort_by {|member| lname(member.split("\n").first)}
-        members_txt[pattern,1] = " *) " + sorted.join("\n *) ")
-        members_txt[/We now number (\d+) active members\./,1] = 
-          members.length.to_s
-        open("#{FOUNDATION}/members.txt",'w') {|fh| fh.write(members_txt)}
-
-        _.system "svn diff #{FOUNDATION}/members.txt"
-
-        update_pending params, dest
-
-      when 'staple'
-        _h1 'Staple'
-        Dir.chdir(RECEIVED) do
-          @source.sub! /\/$/, ''
-          @source.untaint if Dir['*'].include? @source
-          selected = params.keys.grep(/include\d+/)
-          selected.map! {|key| "#{@source}/#{params[key].first}"}
-          selected=Dir["#{@source}/*"] if selected.empty?
-          cleanup = []
-
-          # convert to pdf, if necessary
-          sources = []
-          selected.sort.each do |file|
-            file.untaint if Dir["#{@source}/*"].include? file
-            ext = file.split('.').last
-            if ext.downcase == 'pdf'
-              sources << file
-            else
-              cleanup << file.sub(Regexp.new(ext+'$'),'pdf').sub(' ', '_')
-              sources << cleanup.last
-              _.system(['convert', file, cleanup.last])
-            end
+      _.system "svn update #{FOUNDATION}/members.txt"
+      pattern = /^Active.*?^=+\n+(.*?)^Emeritus/m
+      members_txt = open("#{FOUNDATION}/members.txt").read
+      data = members_txt.scan(pattern).flatten.first
+      members = data.split(/^\s+\*\)\s+/)
+      members.shift
+
+      members.push [
+        "#{@mfname}",
+        "#{@maddr.gsub(/^/,'    ').gsub(/\r/,'')}",
+        ("    #{@mcountry}"     unless @mcountry.empty?),
+        "    Email: #{@memail}",
+        ("      Tel: #{@mtele}" unless @mtele.empty?),
+        ("      Fax: #{@mfax}"  unless @mfax.empty?),
+        " Forms on File: ASF Membership Application",
+        " Avail ID: #{@mavailid}"
+      ].compact.join("\n") + "\n"
+
+      sorted = members.sort_by {|member| lname(member.split("\n").first)}
+      members_txt[pattern,1] = " *) " + sorted.join("\n *) ")
+      members_txt[/We now number (\d+) active members\./,1] = 
+        members.length.to_s
+      open("#{FOUNDATION}/members.txt",'w') {|fh| fh.write(members_txt)}
+
+      _.system "svn diff #{FOUNDATION}/members.txt"
+
+      update_pending params, dest
+
+    when 'staple'
+      _h1 'Staple'
+      Dir.chdir(RECEIVED) do
+        @source.sub! /\/$/, ''
+        @source.untaint if Dir['*'].include? @source
+        selected = params.keys.grep(/include\d+/)
+        selected.map! {|key| "#{@source}/#{params[key].first}"}
+        selected=Dir["#{@source}/*"] if selected.empty?
+        cleanup = []
+
+        # convert to pdf, if necessary
+        sources = []
+        selected.sort.each do |file|
+          file.untaint if Dir["#{@source}/*"].include? file
+          ext = file.split('.').last
+          if ext.downcase == 'pdf'
+            sources << file
+          else
+            cleanup << file.sub(Regexp.new(ext+'$'),'pdf').sub(' ', '_')
+            sources << cleanup.last
+            _.system(['convert', file, cleanup.last])
           end
+        end
 
-          dest,i = @source,0
-          dest = @source + (i+=1).to_s while File.exist?("#{dest}.pdf")
-          at = svn_at(@source)
+        dest,i = @source,0
+        dest = @source + (i+=1).to_s while File.exist?("#{dest}.pdf")
+        at = svn_at(@source)
 
-          # concatenate sources
-          if sources.length > 1
-            _.system "pdftk #{sources.sort.join(' ')} cat output #{dest}.pdf"
-            _.system "svn add #{dest}.pdf#{at}"
-          elsif selected.first =~ /\.pdf$/i
-            _.system "svn mv #{sources.first}#{at} #{dest}.pdf"
-          else
-            _.system "mv #{cleanup.shift} #{dest}.pdf"
-            _.system "svn add #{dest}.pdf#{at}"
-          end
+        # concatenate sources
+        if sources.length > 1
+          _.system "pdftk #{sources.sort.join(' ')} cat output #{dest}.pdf"
+          _.system "svn add #{dest}.pdf#{at}"
+        elsif selected.first =~ /\.pdf$/i
+          _.system "svn mv #{sources.first}#{at} #{dest}.pdf"
+        else
+          _.system "mv #{cleanup.shift} #{dest}.pdf"
+          _.system "svn add #{dest}.pdf#{at}"
+        end
 
-          # copy properties
-          sfx = at
-          `svn proplist #{@source}#{sfx}`.scan(/  \w+:[-\w]+/).each do |prop|
-            prop.untaint if prop.strip =~ /^\w+(:\w+)/
-            value = `svn propget #{prop} #{@source}#{sfx}`.chomp
-            _.system(['svn', 'propset', prop.strip, value, "#{dest}.pdf#{at}"])
-          end
-          _.system "svn propset svn:mime-type application/pdf #{dest}.pdf#{at}"
-
-          # remove temporary file and source directory
-          _.system "rm #{cleanup.join(' ')}" unless cleanup.empty?
-          if not (Dir["#{@source}/*"]-selected).empty?
-            selected.each do |file| 
-              if `svn st #{file}` !~ /^D/ and File.exist? file
-                _.system "svn rm --force #{file}" 
-              end
-            end
-            if Dir["#{@source}/*"].empty?
-              _.system "svn remove --force #{@source}#{at}"
+        # copy properties
+        sfx = at
+        `svn proplist #{@source}#{sfx}`.scan(/  \w+:[-\w]+/).each do |prop|
+          prop.untaint if prop.strip =~ /^\w+(:\w+)/
+          value = `svn propget #{prop} #{@source}#{sfx}`.chomp
+          _.system(['svn', 'propset', prop.strip, value, "#{dest}.pdf#{at}"])
+        end
+        _.system "svn propset svn:mime-type application/pdf #{dest}.pdf#{at}"
+
+        # remove temporary file and source directory
+        _.system "rm #{cleanup.join(' ')}" unless cleanup.empty?
+        if not (Dir["#{@source}/*"]-selected).empty?
+          selected.each do |file| 
+            if `svn st #{file}` !~ /^D/ and File.exist? file
+              _.system "svn rm --force #{file}" 
             end
-          elsif `svn st #{@source}#{at}` !~ /^D/ and File.exist? @source
+          end
+          if Dir["#{@source}/*"].empty?
             _.system "svn remove --force #{@source}#{at}"
           end
+        elsif `svn st #{@source}#{at}` !~ /^D/ and File.exist? @source
+          _.system "svn remove --force #{@source}#{at}"
         end
+      end
 
-      when 'cleanup'
-        _h1 'Revert all and cleanup'
+    when 'cleanup'
+      _h1 'Revert all and cleanup'
 
-        committable.each do |file|
-          status = `svn status #{file}`
-          unless status.empty?
-            status.scan(/^[?A]\s*\+?\s*(.*)/).flatten.each do |uncommitted|
-              _.system ['rm', '-rf', uncommitted]
-            end
-            if status =~ /^\w/
-              _pre.todo "svn revert -R #{file}", 'data-file' => file
-            end
+      committable.each do |file|
+        status = `svn status #{file}`
+        unless status.empty?
+          status.scan(/^[?A]\s*\+?\s*(.*)/).flatten.each do |uncommitted|
+            _.system ['rm', '-rf', uncommitted]
           end
-
-          if File.directory? file
-             _pre.todo "svn cleanup #{file}", 'data-file' => file
+          if status =~ /^\w/
+            _pre.todo "svn revert -R #{file}", 'data-file' => file
           end
         end
 
-        if File.exist?(PENDING_YML)
-          _.system "rm #{PENDING_YML}"
+        if File.directory? file
+           _pre.todo "svn cleanup #{file}", 'data-file' => file
         end
+      end
 
-        ajax=true
+      if File.exist?(PENDING_YML)
+        _.system "rm #{PENDING_YML}"
+      end
 
-      when 'commit'
-        _h1 'Commit'
-        log = Escape.shell_single_word(@message)
-        committable.each do |file|
-          unless `svn status #{file}`.empty?
-            _pre.todo "svn commit -m #{log} #{file}",
-              'data-message' => @message, 'data-file' => file
-          end
+      ajax=true
+
+    when 'commit'
+      _h1 'Commit'
+      log = Escape.shell_single_word(@message)
+      committable.each do |file|
+        unless `svn status #{file}`.empty?
+          _pre.todo "svn commit -m #{log} #{file}",
+            'data-message' => @message, 'data-file' => file
         end
+      end
 
-        if File.exist?(PENDING_YML)
-          pending = YAML.load(open(PENDING_YML))
+      if File.exist?(PENDING_YML)
+        pending = YAML.load(open(PENDING_YML))
 
-          pending.each do |vars|
-            _h2.todo "email #{vars['email']}", 'data-message' => @message
-          end
+        pending.each do |vars|
+          _h2.todo "email #{vars['email']}", 'data-message' => @message
         end
+      end
 
-        ajax = true
+      ajax = true
 
-      when 'other'
-        at = svn_at(@source)
-        Dir.chdir(RECEIVED) do
-          if @dest == 'burst'
-            _h1 'Burst'
-            dest = @source.sub(/\.\w+$/,'')
-
-            _.system "mkdir #{dest}"
-            _.system "pdftk #{@source} burst output #{dest}/%02d.pdf"
-            _.system "svn add #{dest}#{at}"
-            # copy properties
-            `svn proplist #{@source}#{at}`.scan(/ \w+:[-\w]+/).each do |prop|
-               prop.untaint if prop.strip =~ /^\w+(:\w+)/
-               next if prop.strip == 'svn:mime-type'
-               value = `svn propget #{prop} #{@source}#{at}`.chomp
-               _.system ['svn', 'propset', prop.strip, value, dest+at]
-            end
-            _.system "rm doc_data.txt" if File.exist? 'doc_data.txt'
-            _.system "svn rm #{@source}#{at}"
-          elsif @dest == 'flip'
-            _h1 'Flip'
-            _.system "pdftk #{@source} cat 1-endS output #{@source}.tmp"
-            _.system "mv #{@source}.tmp #{@source}"
-          elsif @dest == 'rotate right'
-            _h1 'Rotate Right'
-            _.system "pdftk #{@source} cat 1-endE output #{@source}.tmp"
-            _.system "mv #{@source}.tmp #{@source}"
-          elsif @dest == 'rotate left'
-            _h1 'Rotate Left'
-            _.system "pdftk #{@source} cat 1-endW output #{@source}.tmp"
-            _.system "mv #{@source}.tmp #{@source}"
-          elsif @dest == 'junk'
-            _.system(['svn', 'rm', '--force', "#{@source}#{at}"])
-          elsif DESTINATION.include? @dest
-            _.move @source, DESTINATION[@dest]
-          else
-            pre.stderr "Unknown destination: #{@dest}"
+    when 'other'
+      at = svn_at(@source)
+      Dir.chdir(RECEIVED) do
+        if @dest == 'burst'
+          _h1 'Burst'
+          dest = @source.sub(/\.\w+$/,'')
+
+          _.system "mkdir #{dest}"
+          _.system "pdftk #{@source} burst output #{dest}/%02d.pdf"
+          _.system "svn add #{dest}#{at}"
+          # copy properties
+          `svn proplist #{@source}#{at}`.scan(/ \w+:[-\w]+/).each do |prop|
+             prop.untaint if prop.strip =~ /^\w+(:\w+)/
+             next if prop.strip == 'svn:mime-type'
+             value = `svn propget #{prop} #{@source}#{at}`.chomp
+             _.system ['svn', 'propset', prop.strip, value, dest+at]
           end
+          _.system "rm doc_data.txt" if File.exist? 'doc_data.txt'
+          _.system "svn rm #{@source}#{at}"
+        elsif @dest == 'flip'
+          _h1 'Flip'
+          _.system "pdftk #{@source} cat 1-endS output #{@source}.tmp"
+          _.system "mv #{@source}.tmp #{@source}"
+        elsif @dest == 'rotate right'
+          _h1 'Rotate Right'
+          _.system "pdftk #{@source} cat 1-endE output #{@source}.tmp"
+          _.system "mv #{@source}.tmp #{@source}"
+        elsif @dest == 'rotate left'
+          _h1 'Rotate Left'
+          _.system "pdftk #{@source} cat 1-endW output #{@source}.tmp"
+          _.system "mv #{@source}.tmp #{@source}"
+        elsif @dest == 'junk'
+          _.system(['svn', 'rm', '--force', "#{@source}#{at}"])
+        elsif DESTINATION.include? @dest
+          _.move @source, DESTINATION[@dest]
+        else
+          pre.stderr "Unknown destination: #{@dest}"
         end
+      end
 
-      when 'update'
-        _h1 'Update'
-        _pre.todo "svn update #{OFFICERS}", 'data-file' => OFFICERS
-        _pre.todo "svn update #{DOCUMENTS}", 'data-file' => DOCUMENTS
-        _h3.todo 'icla.txt issues'
-        ajax = true
-        cleanup = Dir["#{DOCUMENTS}/members/received/*"].map(&:untaint).
-          select {|name| File.directory?(name) and Dir["#{name}/*"].empty?}.
-          reject {|name| name =~ /\/to_\w+$/}
-        unless cleanup.empty?
-          _h2 'Empty directories'
-          _ul do
-            cleanup.each { |name| _li name }
-          end
+    when 'update'
+      _h1 'Update'
+      _pre.todo "svn update #{OFFICERS}", 'data-file' => OFFICERS
+      _pre.todo "svn update #{DOCUMENTS}", 'data-file' => DOCUMENTS
+      _h3.todo 'icla.txt issues'
+      ajax = true
+      cleanup = Dir["#{DOCUMENTS}/members/received/*"].map(&:untaint).
+        select {|name| File.directory?(name) and Dir["#{name}/*"].empty?}.
+        reject {|name| name =~ /\/to_\w+$/}
+      unless cleanup.empty?
+        _h2 'Empty directories'
+        _ul do
+          cleanup.each { |name| _li name }
         end
+      end
 
-        _h2 'Recent Activity'
-        _table border: 1, cellpadding: 5, cellspacing: 0 do
-          _thead do
-            _tr do
-              _th 'Time'
-              _th 'User'
-              _th 'Action'
-              _th 'Parameters'
-            end
+      _h2 'Recent Activity'
+      _table border: 1, cellpadding: 5, cellspacing: 0 do
+        _thead do
+          _tr do
+            _th 'Time'
+            _th 'User'
+            _th 'Action'
+            _th 'Parameters'
           end
-          _tbody do
-            activity_log[1..-1].each do |entry|
-              collision = (entry['user'] != $USER and not entry['user'].empty?)
-              collision &&= (Time.now-entry['time'] < 600)
-              _tr_ class: ('collision' if collision) do
-                _td entry.delete('time')
-                _td entry.delete('user')
-                if entry['action']
-                  _td entry.delete('action')
-                elsif entry['doctype'] == 'other'
-                  _td entry['dest']
-                else
-                  _td entry['doctype']
-                end
-                entry.delete_if {|name, value| value.empty?}
-                _td entry.inspect
+        end
+        _tbody do
+          activity_log[1..-1].each do |entry|
+            collision = (entry['user'] != $USER and not entry['user'].empty?)
+            collision &&= (Time.now-entry['time'] < 600)
+            _tr_ class: ('collision' if collision) do
+              _td entry.delete('time')
+              _td entry.delete('user')
+              if entry['action']
+                _td entry.delete('action')
+              elsif entry['doctype'] == 'other'
+                _td entry['dest']
+              else
+                _td entry['doctype']
               end
+              entry.delete_if {|name, value| value.empty?}
+              _td entry.inspect
             end
           end
         end
+      end
 
-      when 'view'
-        @dir.untaint if Dir.chdir(RECEIVED) {Dir['*'].include? @dir.chomp('/')}
-        files = Dir["#{RECEIVED}/#{@dir}/*"].sort
-
-        if files.length == 2
-          if files.last == files.first + '.sig'
-            _pre `gpg --verify #{files.last} #{files.first} 2>&1`
-          elsif files.last == files.first + '.asc'
-            _pre `gpg --verify #{files.last} #{files.first} 2>&1`
-          elsif files.last =~ /\/signature.asc$/
-            _pre `gpg --verify #{files.last} #{files.first} 2>&1`
-          elsif files.first =~ /\/signature.asc$/
-            _pre `gpg --verify #{files.first} #{files.last} 2>&1`
-          end
+    when 'view'
+      @dir.untaint if Dir.chdir(RECEIVED) {Dir['*'].include? @dir.chomp('/')}
+      files = Dir["#{RECEIVED}/#{@dir}/*"].sort
+
+      if files.length == 2
+        if files.last == files.first + '.sig'
+          _pre `gpg --verify #{files.last} #{files.first} 2>&1`
+        elsif files.last == files.first + '.asc'
+          _pre `gpg --verify #{files.last} #{files.first} 2>&1`
+        elsif files.last =~ /\/signature.asc$/
+          _pre `gpg --verify #{files.last} #{files.first} 2>&1`
+        elsif files.first =~ /\/signature.asc$/
+          _pre `gpg --verify #{files.first} #{files.last} 2>&1`
         end
+      end
 
-        _form.buttons target: 'viewport', action: 'file.cgi', method: 'post' do
-          _ul style: 'list-style: none; padding: 0' do
-            files.each_with_index do |line,i|
-              file = line.split('/').last
-              _li do
-                _input type: :checkbox, name: "include#{i}", value: file
-                if %w(jpg).include?(file.split('.').last)
-                  _img src: "/members/received/#{@dir}/#{file}"
-                else
-                  _a file, href: "/members/received/#{@dir}/#{file}"
-                end
+      _form.buttons target: 'viewport', action: 'file.cgi', method: 'post' do
+        _ul style: 'list-style: none; padding: 0' do
+          files.each_with_index do |line,i|
+            file = line.split('/').last
+            _li do
+              _input type: :checkbox, name: "include#{i}", value: file
+              if %w(jpg).include?(file.split('.').last)
+                _img src: "/members/received/#{@dir}/#{file}"
+              else
+                _a file, href: "/members/received/#{@dir}/#{file}"
               end
             end
           end
+        end
 
-          _input name: 'source', id: 'source', type: 'hidden', value: @dir
+        _input name: 'source', id: 'source', type: 'hidden', value: @dir
 
-          if files.length > 0
-            _input type: 'submit', name: 'action', value: 'Staple'
-          else
-            file = "#{RECEIVED}/#{@dir}"
-            _pre `gpg --verify #{file} 2>&1`
-            open(file) {|fh| _pre fh.read} 
-          end
+        if files.length > 0
+          _input type: 'submit', name: 'action', value: 'Staple'
+        else
+          file = "#{RECEIVED}/#{@dir}"
+          _pre `gpg --verify #{file} 2>&1`
+          open(file) {|fh| _pre fh.read} 
+        end
 
-          _script src: "jquery-1.7.2.min.js"
-          _script %{
-            // first, check all of the checkboxes
-            $('input[@type=checkbox]').attr('checked', 'checked');
+        _script src: "jquery-1.7.2.min.js"
+        _script %{
+          // first, check all of the checkboxes
+          $('input[@type=checkbox]').attr('checked', 'checked');
 
-            // on click, unclick all if all are checked.
-            $('input[@type=checkbox]').mousedown(function() {
-              if (!$('input[type=checkbox]:not(:checked)').length) {
-                $('input[@type=checkbox]').removeAttr('checked');
-              }
-            });
-          }
-        end
+          // on click, unclick all if all are checked.
+          $('input[@type=checkbox]').mousedown(function() {
+            if (!$('input[type=checkbox]:not(:checked)').length) {
+              $('input[@type=checkbox]').removeAttr('checked');
+            }
+          });
+        }
+      end
 
-      when 'cancel', 'check'
-        _h1 @action
-        check
-    
-      when 'edit cc'
-        _h1 @action
+    when 'cancel', 'check'
+      _h1 @action
+      check
+  
+    when 'edit cc'
+      _h1 @action
 
-        if File.exist?(PENDING_YML)
-          pending = YAML.load(open(PENDING_YML))
+      if File.exist?(PENDING_YML)
+        pending = YAML.load(open(PENDING_YML))
 
-          if @email
-            pending.each do |vars|
-              if vars['email'] == @email
-                vars['email:cc'] = @cc.strip.gsub(/\r?\n/, ", ") 
-                vars['email:bcc'] = @bcc.strip.gsub(/\r?\n/, ", ") 
-                vars.delete('email:bcc') if vars['email:bcc'].empty?
+        if @email
+          pending.each do |vars|
+            if vars['email'] == @email
+              vars['email:cc'] = @cc.strip.gsub(/\r?\n/, ", ") 
+              vars['email:bcc'] = @bcc.strip.gsub(/\r?\n/, ", ") 
+              vars.delete('email:bcc') if vars['email:bcc'].empty?
 
-                open(PENDING_YML, 'w') {|file| file.write pending.to_yaml}
-                _p.notice! "cc list for #{@email} updated"
-              end
+              open(PENDING_YML, 'w') {|file| file.write pending.to_yaml}
+              _p.notice! "cc list for #{@email} updated"
             end
           end
+        end
 
-          pending.each do |vars|
-            vars = OpenStruct.new(vars.map {|k,v| [k.gsub(/\W/,'_'),v]})
-            _h2 "email #{vars.email}"
-            _form do
-              _input name: 'email', value: vars.email, type: 'hidden'
-              _table do
-                _tr do
-                  _td 'cc:'
-                  _td do
-                    _textarea vars.email_cc.to_s.gsub(/,\s+/,"\n"),
-                      name: 'cc', cols: 60
-                  end
+        pending.each do |vars|
+          vars = OpenStruct.new(vars.map {|k,v| [k.gsub(/\W/,'_'),v]})
+          _h2 "email #{vars.email}"
+          _form do
+            _input name: 'email', value: vars.email, type: 'hidden'
+            _table do
+              _tr do
+                _td 'cc:'
+                _td do
+                  _textarea vars.email_cc.to_s.gsub(/,\s+/,"\n"),
+                    name: 'cc', cols: 60
                 end
-                _tr do
-                  _td 'bcc:'
-                  _td do
-                    _textarea vars.email_bcc.to_s.gsub(/,\s+/,"\n"),
-                      name: 'bcc', cols: 60
-                  end
+              end
+              _tr do
+                _td 'bcc:'
+                _td do
+                  _textarea vars.email_bcc.to_s.gsub(/,\s+/,"\n"),
+                    name: 'bcc', cols: 60
                 end
               end
-              _input type: 'hidden', name: 'action', value: @action
-              _input type: 'submit', value: 'Update'
             end
+            _input type: 'hidden', name: 'action', value: @action
+            _input type: 'submit', value: 'Update'
           end
         end
-    
-      else
-        _h2 'Unsupported action'
-        _table border: 1, cellpadding: 10, cellspacing: 0 do
-          params.sort.each do |key, value|
-            _tr do
-              _td key
-              _td value
-            end
+      end
+  
+    else
+      _h2 'Unsupported action'
+      _table border: 1, cellpadding: 10, cellspacing: 0 do
+        params.sort.each do |key, value|
+          _tr do
+            _td key
+            _td value
           end
         end
       end
+    end
 
-      if ajax
-        _script src: 'jquery-1.7.2.min.js'
-        _script %{
-          function execute_todos() {
-            var todo = $('.todo:first');
-            if (todo.length == 1) {
-              // add a spinner
-              var spinner = $('<img src="spinner.gif"/>');
-              todo.after(spinner);
-
-              // params = cmd plus all of the data-* attributes
-              var params = {cmd: todo.text()};
-              for (var i=0; i<todo[0].attributes.length; i++) {
-                var attr = todo[0].attributes[i];
-                if (attr.name.match("^data-")) {
-                  params[attr.name.substr(5)] = attr.value;
-                }
+    if ajax
+      _script src: 'jquery-1.7.2.min.js'
+      _script %{
+        function execute_todos() {
+          var todo = $('.todo:first');
+          if (todo.length == 1) {
+            // add a spinner
+            var spinner = $('<img src="spinner.gif"/>');
+            todo.after(spinner);
+
+            // params = cmd plus all of the data-* attributes
+            var params = {cmd: todo.text()};
+            for (var i=0; i<todo[0].attributes.length; i++) {
+              var attr = todo[0].attributes[i];
+              if (attr.name.match("^data-")) {
+                params[attr.name.substr(5)] = attr.value;
               }
-
-              // issue request
-              $.post(#{ENV['SCRIPT_NAME'].inspect}, params, function(response) 
{
-                var replacement = $(response.html);
-                spinner.remove();
-                todo.replaceWith(replacement);
-                if (replacement.filter('._stderr,._traceback').length > 0) {
-                  if (!confirm("Error detected.  Continue?")) return;
-                }
-                execute_todos();
-              }, 'json');
-            } else {
-              parent.frames[0].location.reload();
             }
+
+            // issue request
+            $.post(#{ENV['SCRIPT_NAME'].inspect}, params, function(response) {
+              var replacement = $(response.html);
+              spinner.remove();
+              todo.replaceWith(replacement);
+              if (replacement.filter('._stderr,._traceback').length > 0) {
+                if (!confirm("Error detected.  Continue?")) return;
+              }
+              execute_todos();
+            }, 'json');
+          } else {
+            parent.frames[0].location.reload();
           }
-          execute_todos();
         }
-      end
+        execute_todos();
+      }
     end
   end
 end

Reply via email to