You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/03/24 13:53:41 UTC

[whimsy] branch master updated: Edit personal URLs

This is an automated email from the ASF dual-hosted git repository.

sebb 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 24d5197  Edit personal URLs
24d5197 is described below

commit 24d5197ad17a248926d8d5514e8b2e74399109de
Author: Sebb <se...@apache.org>
AuthorDate: Sun Mar 24 13:53:32 2019 +0000

    Edit personal URLs
---
 www/roster/views/actions/urls.json.rb | 38 +++++++++++++++++++++++++++++++++++
 www/roster/views/person/main.js.rb    |  2 +-
 www/roster/views/person/urls.js.rb    | 29 ++++++++++++++++++++++----
 3 files changed, 64 insertions(+), 5 deletions(-)

diff --git a/www/roster/views/actions/urls.json.rb b/www/roster/views/actions/urls.json.rb
new file mode 100644
index 0000000..be980b0
--- /dev/null
+++ b/www/roster/views/actions/urls.json.rb
@@ -0,0 +1,38 @@
+#
+# Update PGP keys attribute for a committer
+#
+
+person = ASF::Person.find(@userid)
+
+# report the previous value in the response
+_previous asf_personalURL: person.attrs['asf-personalURL']
+
+if @urls  # must agree with urls.js.rb
+
+  # report the new values
+  _replacement asf_personalURL: @urls
+
+  @urls.each do |url|
+#    next
+    begin
+      uri = URI.parse(url)
+    rescue
+      _error "Cannot parse URL: #{url}"
+      return
+    end
+    unless uri.scheme =~ /^https?$/ && uri.host.length > 5
+      _error "Invalid http(s) URL: #{url}"
+      return
+    end
+  end
+
+  # update LDAP
+  unless @dryrun
+    _ldap.update do
+      person.modify 'asf-personalURL', @urls
+    end
+  end
+end
+
+# return updated committer info
+_committer Committer.serialize(@userid, env)
diff --git a/www/roster/views/person/main.js.rb b/www/roster/views/person/main.js.rb
index aa16c1d..98b9996 100644
--- a/www/roster/views/person/main.js.rb
+++ b/www/roster/views/person/main.js.rb
@@ -24,7 +24,7 @@ class Person < Vue
 
     # Personal URL
     if @committer.urls
-      _PersonUrls person: self
+      _PersonUrls person: self, edit: @edit
     end
 
     # PMCs
diff --git a/www/roster/views/person/urls.js.rb b/www/roster/views/person/urls.js.rb
index 660e4c6..c794fa8 100644
--- a/www/roster/views/person/urls.js.rb
+++ b/www/roster/views/person/urls.js.rb
@@ -6,13 +6,34 @@ class PersonUrls < Vue
   def render
     committer = @@person.state.committer
 
-    _div.row do
+    _div.row data_edit: 'urls' do
       _div.name 'Personal URL'
 
       _div.value do
-        _ul committer.urls do |url|
-          _li {_a url, href: url}
-        end
+        if @@edit == :urls
+
+          _form method: 'post' do
+            current = 1
+            prefix = 'urls' # must agree with urls.json.rb
+            _input type: 'hidden', name: 'array_prefix', value: prefix
+
+            _div committer.urls do |url|
+              _input name: prefix + current, value: url
+              _br              
+              current += 1
+            end
+            # Spare field to allow new entry to be added
+            _input name: prefix + current, placeholder: '<enter a new URL>'
+            _br             
+
+            _input type: 'submit', value: 'submit'
+          end
+
+        else
+          _ul committer.urls do |url|
+            _li {_a url, href: url}
+          end
+      end
       end
     end
   end