whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curc...@apache.org
Subject [whimsy] branch master updated: Add bootstrap and whimsy styles
Date Sat, 03 Jun 2017 22:56:12 GMT
This is an automated email from the ASF dual-hosted git repository.

curcuru pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  fbc0f3f   Add bootstrap and whimsy styles
fbc0f3f is described below

commit fbc0f3f60d6543b7cbbabd3621f882cff3d809e0
Author: Shane Curcuru <asf@shanecurcuru.org>
AuthorDate: Sat Jun 3 18:56:07 2017 -0400

    Add bootstrap and whimsy styles
    
    NOTE: no code logic was changed - merely styling and reorganizing the
    output.
    I’d like to refactor some of the code that gathers all the data, and
    the giant if…elsif….elsif… at the bottom, if for no other reason than
    to make the code easier to read.
---
 www/officers/acreq.cgi | 437 ++++++++++++++++++++++++++-----------------------
 1 file changed, 235 insertions(+), 202 deletions(-)

diff --git a/www/officers/acreq.cgi b/www/officers/acreq.cgi
index e858554..6e29113 100755
--- a/www/officers/acreq.cgi
+++ b/www/officers/acreq.cgi
@@ -1,22 +1,11 @@
 #!/usr/bin/env ruby
-#
-#   Build a properly formatted and validated new-account-reqs.txt entry based
-#   on web input.  Does both full client validation and Server-side
-#   validation.
-#
-#   Should validation succeed, the entry will be appended to the
-#   new-account-reqs.txt and committed.  An email will be sent to root
-#   (copying the relevant pmc private list) of the request.
-#
-#   The response contains
-#   the messages produced by the commit (if any) in the response, and
-#   a copy of the email that was sent.
-#
-
+PAGETITLE = "Apache Account Submission Helper Form" # Wvisible:infra accounts
 $LOAD_PATH.unshift File.realpath(File.expand_path('../../../lib', __FILE__))
-
+require 'wunderbar'
+require 'wunderbar/bootstrap'
 require 'wunderbar/jquery'
 require 'whimsy/asf/rack'
+require 'whimsy/asf'
 require 'mail'
 require 'date'
 require 'open3'
@@ -92,19 +81,10 @@ pending.each {|email| iclas.delete email}
 # HTML output
 _html do
   _head do
-    _title 'Submit ASF Account Request'
+    _title PAGETITLE
 
     _style :system
     _style %{
-      label {width: 6em; float: left}
-      legend {background: #141; color: #DFD; padding: 0.4em}
-      fieldset {background: #EFE; width: 28em}
-      fieldset div {clear: both; padding: 0.4em 0 0 1.5em}
-      input,textarea {width: 3in}
-      select {width: 3.06in}
-      input[type=checkbox] {margin-left: 6em; width: 1em}
-      input[type=submit] {margin-top: 0.5em; margin-left: 3em; width: 8em}
-      .error {margin: 1em; padding: 1em; background: red; color: white}
       pre.email {background-color: #BDF; padding: 1em 3em; border-radius: 1em}
     }
 
@@ -159,190 +139,243 @@ _html do
     }
   end
 
-  _body do
-    _form method: 'post' do
-      _fieldset do
-        _legend 'ASF New Account Request'
-
-        _div do
-          _label 'User ID', for: "user"
-          _input name: "user", id: "user", autofocus: true,
-            type: "text", required: true,
-            pattern: '^[a-z][-a-z0-9_]+$' # useridvalidationpattern dup
-        end
-
-        _div do
-          _label 'Name', for: "name"
-          _select name: "name", id: "name", required: true do
-            _option value: ''
-            iclas.invert.to_a.sort.each do |name, email|
-              _option name, value: name, data_email: email
+  _body? do
+    _whimsy_body(
+      title: PAGETITLE,
+      subtitle: 'How To Make Account Requests',
+      related: {
+        'https://whimsy.apache.org/roster' => 'Whimsy Roster Tool',
+        'https://reference.apache.org/infra' => 'Infra Reference Documentation',
+        'https://reference.apache.org/pmc/acreq' => 'Infra How To Create New Account Docs'
+      },
+      helpblock: -> {
+        _p %{
+          This page builds a properly formatted and validated new-account-reqs.txt entry
based
+          on your input below.  Does both full client validation and Server-sidevalidation.
+        }
+        _p %{
+          Should validation succeed, the entry will be appended to the
+          new-account-reqs.txt and committed.  An email will be sent to root
+          (copying the relevant pmc private list) of the request.
+        }
+        _p %{
+          The response contains
+          the messages produced by the commit (if any) in the response, and
+          a copy of the email that was sent.
+        }
+      }
+    ) do
+      
+      _div.row do
+        _div.col_md_8 do
+          # Display the data input form for an account request
+          _whimsy_panel('Request A New Apache Account', style: 'panel-success') do
+            _form.form_horizontal method: 'post' do
+              _div.form_group do
+                _label.control_label.col_sm_2 'User ID', for: "user"
+                _div.col_sm_10 do
+                  _input.form_control name: "user", id: "user", autofocus: true,
+                    type: "text", required: true,
+                    pattern: '^[a-z][-a-z0-9_]+$' # useridvalidationpattern dup
+                end
+              end
+
+              _div.form_group do
+                _label.control_label.col_sm_2 'Name', for: "name"
+                _div.col_sm_10 do
+                  _select.form_control name: "name", id: "name", required: true do
+                    _option value: ''
+                    iclas.invert.to_a.sort.each do |name, email|
+                      _option name, value: name, data_email: email
+                    end
+                  end
+                end
+              end
+
+              _div.form_group do
+                _label.control_label.col_sm_2 'Email', for: "email"
+                _div.col_sm_10 do
+                  _select.form_control name: "email", id: "email", required: true do
+                    _option value: ''
+                    iclas.to_a.sort_by {|email, name| email.downcase}.
+                      each do |email, name|
+                      _option email.downcase, value: email, data_name:name
+                    end
+                  end
+                end
+              end
+
+              _div.form_group do
+                _label.control_label.col_sm_2 'PMC', for: "pmc"
+                _div.col_sm_10 do
+                  _select.form_control name: "pmc", id: "pmc" do
+                    _option value: ''
+                    pmcs.each do |pmc| 
+                      _option pmc, value: pmc
+                    end
+                  end
+                end
+              end
+
+              _div.form_group do
+                _label.control_label.col_sm_2 'Podling', for: "podling"
+                _div.col_sm_10 do
+                  _select.form_control name: "podling", id: "podling" do
+                    _option value: ''
+                    podlings.each do |podling| 
+                      _option podling, value: podling
+                    end
+                  end
+                end
+              end
+
+              _div.form_group do
+                _label.control_label.col_sm_2 'Vote Link', for: "votelink"
+                _div.col_sm_10 do
+                  _input.form_control name: "votelink", id: "votelink", type: "text",
+                    pattern: '.*://.*|.*@.*', placeholder: 'https://lists.apache.org/list.html?dev@project.apache.org'
+                end
+              end
+
+              _div.form_group do
+                _label.control_label.col_sm_2 'Comments', for: "comments"
+                _div.col_sm_10 do
+                  _textarea.form_control name: "comments", id: "comments" 
+                end
+              end
+              
+              _div.form_group do
+                _div.col_sm_offset_2.col_sm_10 do
+                  _input.btn.btn_default type: "submit", value: "Submit"
+                end
+              end
             end
-          end
-        end
 
-        _div do
-          _label 'Email', for: "email"
-          _select name: "email", id: "email", required: true do
-            _option value: ''
-            iclas.to_a.sort_by {|email, name| email.downcase}.
-              each do |email, name|
-              _option email.downcase, value: email, data_name:name
-            end
+            # If making a request, validate, checkin, and display results
+            if _.post?
+              _div.well.well_lg do
+                # server side validation
+                if pending.include? @email
+                  _div.bg_danger "Account request already pending for #{@email}"
+                elsif taken.include? @user
+                  _div.bg_danger "UserID #{@user} is not available"
+                elsif @user !~ /^[a-z][a-z0-9_]+$/ # useridvalidationpattern dup (disallow
'-' in names because of INFRA-7390)
+                  _div.bg_danger "Invalid userID #{@user}"
+                elsif @user.length > 16
+                  # http://forums.freebsd.org/showthread.php?t=14636
+                  _div.bg_danger "UserID #{@user} is too long (max 16)"
+                elsif @pmc !~ /^[0-9a-z-]+$/
+                  _div.bg_danger "Unsafe PMC #{@pmc}"
+                elsif @podling and @podling !~ /^[0-9a-z-]*$/
+                  _div.bg_danger "Unsafe podling name #{@podling}"
+                elsif not iclas.include? @email
+                  _div.bg_danger "No ICLA on record for #{@email}"
+                elsif not iclas[@email] == @name
+                  _div.bg_danger "Name #{@name} does not match name on ICLA"
+                elsif not pmcs.include? @pmc
+                  _div.bg_danger "Unrecognized PMC name #{@pmc}"
+                else
+
+                  tobe = nil
+
+                  # build the line to be added
+                  line = "#{@user};#{@name};#{@email};#{@pmc};" +
+                    "#{@pmc};#{Date.today.strftime('%m-%d-%Y')};yes;yes;no;"
+
+                  # determine the requesting party and cc_list
+                  @pmc =~ /([\w.-]+)/
+                  requestor = $1
+                  requestor.untaint
+                  pmc_list = ASF::Committee.find(@pmc).mail_list
+                  cc_list = ["private@#{pmc_list}.apache.org".untaint]
+                  if requestor == 'incubator' and not @podling.empty?
+                    if File.read("#{APMAIL_BIN}/.archives").include? "incubator-#{@podling}-private"
+                      cc_list << "#{@podling}-private@#{pmc_list}.apache.org".untaint
+                    else
+                      cc_list << "private@#{@podling}.#{pmc_list}.apache.org".untaint
+                    end
+                    requestor = "#{@podling}@incubator".untaint
+                  end
+                  cc_list << "<#{@email}>".untaint # TODO: add @name RFC822-escaped
+
+                  # build the mail to be sent
+                  ASF::Mail.configure
+                  mail = Mail.new do
+                    from  "#{user.public_name} <#{user.id}@apache.org>"
+                    return_path "root@apache.org"
+                    to      "root@apache.org"
+                    cc      cc_list
+                  end
+
+                  mail.subject "[FORM] Account Request - #{requestor}: #{@name}"
+
+                  mail.body = <<-EOF.gsub(/^ {10}/, '').gsub(/(Vote reference:)?\n\s+\n/,
"\n\n")
+                    Prospective userid: #{@user}
+                    Full name: #{@name}
+                    Forwarding email address: #{@email}
+
+                    Vote reference:
+                      #{@votelink.to_s.gsub('mail-search.apache.org/pmc/', 'mail-search.apache.org/members/')}
+
+                    #{@comments}
+
+                    -- 
+                    Submitted by https://#{ENV['HTTP_HOST']}#{ENV['REQUEST_URI'].split('?').first}
+                    From #{`/usr/bin/host #{ENV['REMOTE_ADDR'].dup.untaint}`.chomp}
+                    Using #{ENV['HTTP_USER_AGENT']}
+                  EOF
+
+                  Dir.mktmpdir do |tmpdir|
+                    tmpdir.untaint
+
+                    # Checkout the ACREQ directory
+                    `#{SVN} co #{ACREQ} #{tmpdir}`
+
+                    # Update the new-account-reqs file...
+                    File.open("#{tmpdir}/new-account-reqs.txt", 'a') do |file|
+                      file.puts(line)
+                    end
+
+                    # and commit the change ...
+                    _h2 'Commit messages'
+                    rc = _.system ['/usr/bin/svn',
+                      ['--username', env.user, '--password', env.password],
+                      'commit', "#{tmpdir}/new-account-reqs.txt",
+                      '-m', "#{requestor} account request by #{user.id}"]
+
+                    if rc == 0
+                      mail.deliver!
+                    else
+                      tobe = 'that would have been '
+                    end
+                  end
+
+                  # report on status
+                  _h2 "New entry #{tobe}added:"
+                  _pre line
+                  _h2 "Mail #{tobe}sent:"
+                  _pre.email mail.to_s
+                end
+              end
+            end # of if _.post?
           end
         end
-
-        _div do
-          _label 'PMC', for: "pmc"
-          _select name: "pmc", id: "pmc" do
-            _option value: ''
-            pmcs.each do |pmc| 
-              _option pmc, value: pmc
+        # Add separate column for ICLA options
+        _div.col_md_4 do
+          unless _.post?
+            _div.well.well_lg do
+              if @iclas == 'all'
+                _span 'Now showing all ICLAs ever received.  Click here to'
+                _a 'show only ICLAs received recently', href: '?'
+                _span '.'
+              else
+                _span 'Now showing only ICLAs received recently.  Click here to'
+                _a 'choose from the full list of ICLA submitters', href: '?iclas=all'
+                _span '.'
+              end
             end
           end
         end
-
-        _div do
-          _label 'Podling', for: "podling"
-          _select name: "podling", id: "podling" do
-            _option value: ''
-            podlings.each do |podling| 
-              _option podling, value: podling
-            end
-          end
-        end
-
-        _div do
-          _label 'Vote Link', for: "votelink"
-          _input name: "votelink", id: "votelink", type: "text",
-            pattern: '.*://.*|.*@.*'
-        end
-
-        _div do
-          _label 'Comments', for: "comments"
-          _textarea name: "comments", id: "comments" 
-        end
-
-        _input type: "submit", value: "Submit"
-      end
-    end
-
-    if _.post?
-      # server side validation
-      if pending.include? @email
-        _div.error "Account request already pending for #{@email}"
-      elsif taken.include? @user
-        _div.error "UserID #{@user} is not available"
-      elsif @user !~ /^[a-z][a-z0-9_]+$/ # useridvalidationpattern dup (disallow '-' in names
because of INFRA-7390)
-        _div.error "Invalid userID #{@user}"
-      elsif @user.length > 16
-        # http://forums.freebsd.org/showthread.php?t=14636
-        _div.error "UserID #{@user} is too long (max 16)"
-      elsif @pmc !~ /^[0-9a-z-]+$/
-        _div.error "Unsafe PMC #{@pmc}"
-      elsif @podling and @podling !~ /^[0-9a-z-]*$/
-        _div.error "Unsafe podling name #{@podling}"
-      elsif not iclas.include? @email
-        _div.error "No ICLA on record for #{@email}"
-      elsif not iclas[@email] == @name
-        _div.error "Name #{@name} does not match name on ICLA"
-      elsif not pmcs.include? @pmc
-        _div.error "Unrecognized PMC name #{@pmc}"
-      else
-
-        tobe = nil
-
-        # build the line to be added
-        line = "#{@user};#{@name};#{@email};#{@pmc};" +
-          "#{@pmc};#{Date.today.strftime('%m-%d-%Y')};yes;yes;no;"
-
-        # determine the requesting party and cc_list
-        @pmc =~ /([\w.-]+)/
-        requestor = $1
-        requestor.untaint
-        pmc_list = ASF::Committee.find(@pmc).mail_list
-        cc_list = ["private@#{pmc_list}.apache.org".untaint]
-        if requestor == 'incubator' and not @podling.empty?
-          if File.read("#{APMAIL_BIN}/.archives").include? "incubator-#{@podling}-private"
-            cc_list << "#{@podling}-private@#{pmc_list}.apache.org".untaint
-          else
-            cc_list << "private@#{@podling}.#{pmc_list}.apache.org".untaint
-          end
-          requestor = "#{@podling}@incubator".untaint
-        end
-        cc_list << "<#{@email}>".untaint # TODO: add @name RFC822-escaped
-
-        # build the mail to be sent
-        ASF::Mail.configure
-        mail = Mail.new do
-          from  "#{user.public_name} <#{user.id}@apache.org>"
-          return_path "root@apache.org"
-          to      "root@apache.org"
-          cc      cc_list
-        end
-
-        mail.subject "[FORM] Account Request - #{requestor}: #{@name}"
-
-        mail.body = <<-EOF.gsub(/^ {10}/, '').gsub(/(Vote reference:)?\n\s+\n/, "\n\n")
-          Prospective userid: #{@user}
-          Full name: #{@name}
-          Forwarding email address: #{@email}
-
-          Vote reference:
-            #{@votelink.to_s.gsub('mail-search.apache.org/pmc/', 'mail-search.apache.org/members/')}
-
-          #{@comments}
-
-          -- 
-          Submitted by https://#{ENV['HTTP_HOST']}#{ENV['REQUEST_URI'].split('?').first}
-          From #{`/usr/bin/host #{ENV['REMOTE_ADDR'].dup.untaint}`.chomp}
-          Using #{ENV['HTTP_USER_AGENT']}
-        EOF
-
-        Dir.mktmpdir do |tmpdir|
-          tmpdir.untaint
-
-          # Checkout the ACREQ directory
-          `#{SVN} co #{ACREQ} #{tmpdir}`
-
-          # Update the new-account-reqs file...
-          File.open("#{tmpdir}/new-account-reqs.txt", 'a') do |file|
-            file.puts(line)
-          end
-
-          # and commit the change ...
-          _h2 'Commit messages'
-          rc = _.system ['/usr/bin/svn',
-            ['--username', env.user, '--password', env.password],
-            'commit', "#{tmpdir}/new-account-reqs.txt",
-            '-m', "#{requestor} account request by #{user.id}"]
-
-          if rc == 0
-            mail.deliver!
-          else
-            tobe = 'that would have been '
-          end
-        end
-
-        # report on status
-        _h2 "New entry #{tobe}added:"
-        _pre line
-        _h2 "Mail #{tobe}sent:"
-        _pre.email mail.to_s
-      end
-    end
-
-    unless _.post?
-      _p do
-        if @iclas == 'all'
-          _span 'This page shows all ICLAs ever received.  Click here to'
-          _a 'show only ICLAs received recently', href: '?'
-          _span '.'
-        else
-          _span 'This page shows only ICLAs received recently.  Click here to'
-          _a 'choose from the full list of ICLA submitters', href: '?iclas=all'
-          _span '.'
-        end
       end
     end
   end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <commits@whimsical.apache.org>'].

Mime
View raw message