whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: rough in memapp form (UI only so far)
Date Sat, 01 Apr 2017 14:14:16 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys 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  63601e2   rough in memapp form (UI only so far)
63601e2 is described below

commit 63601e27b83e199ec4f34bc75c3f0887c5457e03
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Sat Apr 1 10:13:49 2017 -0400

    rough in memapp form (UI only so far)
---
 www/secmail/server.rb                |   4 ++
 www/secmail/views/forms/memapp.js.rb | 116 ++++++++++++++++++++++++++++++++++-
 www/secmail/views/memapp.json.rb     |  13 ++++
 3 files changed, 132 insertions(+), 1 deletion(-)

diff --git a/www/secmail/server.rb b/www/secmail/server.rb
index b97fa6f..e376407 100644
--- a/www/secmail/server.rb
+++ b/www/secmail/server.rb
@@ -167,6 +167,10 @@ get %r{^/(\d{6})/(\w+)/(.*?)$} do |month, hash, name|
   [200, {'Content-Type' => part.content_type}, part.body.to_s]
 end
 
+get '/memapp.json' do
+  _json :memapp
+end
+
 # event stream for server sent events (a.k.a EventSource)
 get '/events', provides: 'text/event-stream' do
   events = Events.new
diff --git a/www/secmail/views/forms/memapp.js.rb b/www/secmail/views/forms/memapp.js.rb
index 83d5145..a00e84c 100644
--- a/www/secmail/views/forms/memapp.js.rb
+++ b/www/secmail/views/forms/memapp.js.rb
@@ -1,5 +1,119 @@
 class MemApp < React
+  def initialize
+    @received = []
+    @disabled = true
+  end
+
   def render
-    _p 'Membership Application'
+    _h4 'Membership Application'
+
+    _form method: 'post', action: '../../tasklist/memapp', target: 'content' do
+      _input type: 'hidden', name: 'message'
+      _input type: 'hidden', name: 'signature', value: @@signature
+
+      _table.form do
+        _tr do
+          _td do
+            _label 'Public Name', for: 'pubname'
+          end
+
+          _td do
+            _select id: 'availid', name: 'availid', onChange: self.setid do
+              _option value: '', selected: true
+              @received.each do |line|
+                next unless line.apply == 'no'
+                _option line.name, value: line.id
+              end
+            end
+          end
+        end
+
+        _tr do
+          _td do
+            _label 'Full Name', for: 'fullname'
+          end
+          _td do
+            _input type: :text, name: 'fullname', id: 'fullname', value: @name
+          end
+        end
+
+        _tr do
+          _td do
+            _label 'Address', for: 'addr'
+          end
+          _td do
+            _textarea rows: 5, name: 'addr', id: 'addr'
+          end
+        end
+
+        _tr do
+          _td do
+            _label 'Country', for: 'country'
+          end
+          _td do
+            _input type: :text, name: 'country', id: 'country'
+          end
+        end
+
+        _tr do
+          _td do
+            _label 'Telephone', for: 'tele'
+          end
+          _td do
+            _input type: :text, name: 'tele', id: 'tele'
+          end
+        end
+
+        _tr do
+          _td do
+            _label 'Fax', for: 'fax'
+          end
+          _td do
+            _input type: :text, name: 'fax', id: 'fax'
+          end
+        end
+
+        _tr do
+          _td do
+            _label 'E-Mail', for: 'email'
+          end
+          _td do
+            _input type: :email, name: 'email', id: 'email', value: @email
+          end
+        end
+
+        _tr do
+          _td do
+            _label 'File Name', for: 'filename'
+          end
+          _td do
+            _input type: :text, name: 'filename', id: 'filename',
+              value: @filename
+          end
+        end
+      end
+
+      _input.btn.btn_primary value: 'File', type: 'submit', disabled: @disabled
+    end
+  end
+
+  # on initial display, default email and fetch memapp-received.txt
+  def componentDidMount()
+    @email = @@headers.from
+
+    jQuery.getJSON('../../memapp.json') do |result|
+      @received = result.received
+    end
+  end
+
+  def setid(event)
+    id = event.target.value
+    @received.each do |line|
+      if line.id == id
+        @name = line.name
+        @filename = asciize(line.name).downcase().gsub(/\W+/, '-')
+        @disabled = false
+      end
+    end
   end
 end
diff --git a/www/secmail/views/memapp.json.rb b/www/secmail/views/memapp.json.rb
new file mode 100644
index 0000000..e2cb198
--- /dev/null
+++ b/www/secmail/views/memapp.json.rb
@@ -0,0 +1,13 @@
+# parse and return the contents of the latest memapp-received file
+
+# find latest memapp-received.txt file in the foundation/Meetings directory
+meetings = ASF::SVN['private/foundation/Meetings']
+received = Dir["#{meetings}/2*/memapp-received.txt"].sort.last.untaint
+
+# extract contents
+pattern = /^\w+\s+(\w+)\s+(\w+)\s+(\w+)\s+(\w+)\s+(.*)\n/
+table = File.read(received).scan(pattern)
+
+# map contents to a hash
+fields = %w(apply mail karma id name)
+{received: table.map {|results| fields.zip(results).to_h}}

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

Mime
View raw message