whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject [whimsy.git] [9/50] Commit c4c8e18: add svninfo support; remove dead code
Date Fri, 04 Dec 2015 19:19:44 GMT
Commit c4c8e18a05ef5c5960ff1826bd17b47b367137cb:
    add svninfo support; remove dead code
    git-svn-id: https://svn.apache.org/repos/infra/infrastructure/trunk/projects/whimsy@819415
90ea9780-b833-de11-8433-001ec94261de


Branch: refs/heads/master
Author: Sam Ruby <rubys@apache.org>
Committer: Sam Ruby <rubys@apache.org>
Pusher: rubys <rubys@apache.org>

------------------------------------------------------------
www/secretary/workbench/file.cgi                             | ++++++++ ----
www/secretary/workbench/worklist.cgi                         |  --
www/secretary/workbench/worklist.js                          | + --------
------------------------------------------------------------
115 changes: 59 additions, 56 deletions.
------------------------------------------------------------


diff --git a/www/secretary/workbench/file.cgi b/www/secretary/workbench/file.cgi
index 96132a9..5a8c076 100755
--- a/www/secretary/workbench/file.cgi
+++ b/www/secretary/workbench/file.cgi
@@ -201,6 +201,38 @@ def check
   end
 end
 
+def svn_info(source)
+  source.untaint if Dir.chdir(RECEIVED) {Dir['*']}.include? source
+  source = File.join(RECEIVED, source)
+  source += svn_at(source)
+  info = {
+    'from' =>  `svn propget email:name #{source}`.chomp,
+    'email' => `svn propget email:addr #{source}`.chomp
+  }
+
+  if info['from'].empty? and info['email'].empty?
+    log=`svn log #{source}`
+    from=log.scan(/\nFrom: (.*)/).flatten.first
+
+    if from and from !~ /"eFax"/
+      email = from.gsub(/.*<(.*)>$/, '\1')
+      info['email'] = email if email.include?('@')
+    
+      from.gsub! /\s<.*>$/, ''
+      from.gsub! /^"(.*)"$/, '\1'
+      info['from'] = from unless from.include?('@')
+    end
+  end
+
+  info.each do |name, value| 
+    value.gsub!(/\\x[0-9a-fA-F][0-9a-fA-F]/) {|c| [c[2..3].to_i(16)].pack('C')}
+    value.force_encoding('utf-8')
+    value.force_encoding('iso-8859-1') unless value.valid_encoding?
+  end
+
+  info
+end
+
 def email(target, message)
   pending = YAML.load(open(PENDING_YML))
 
@@ -335,31 +367,31 @@ _json do
     "svn update #{DOCUMENTS}",
   ]
 
-  _html do
-    if @cmd == 'icla.txt issues'
-      _! check
-    elsif @cmd =~ /email (.*)/
-      _! email $1, @message
-    elsif @cmd =~ /svn commit/ and committable.include? @file
-      message, file = @message, @file
-      _! html_fragment {
-        _.system [
-          'svn', 'commit', '-m', message, '--no-auth-cache',
-          (['--username', $USER, '--password', $PASSWORD] if $PASSWORD),
-          file
-        ]
-      }
-    else
-      cmd = @cmd.untaint
-      _! html_fragment { 
-        if safe.include? cmd
-          _.system cmd.untaint
-        else
-          _pre._stdin cmd
-          _pre._stderr 'Unauthorized command'
-        end
-      }
-    end
+  if @cmd == 'svninfo'
+    _! svn_info(@source)
+  elsif @cmd == 'icla.txt issues'
+    _html check
+  elsif @cmd =~ /email (.*)/
+    _html! email $1, @message
+  elsif @cmd =~ /svn commit/ and committable.include? @file
+    message, file = @message, @file
+    _html html_fragment {
+      _.system [
+        'svn', 'commit', '-m', message, '--no-auth-cache',
+        (['--username', $USER, '--password', $PASSWORD] if $PASSWORD),
+        file
+      ]
+    }
+  else
+    cmd = @cmd
+    _html html_fragment { 
+      if safe.include? cmd
+        _.system cmd.untaint
+      else
+        _pre._stdin cmd
+        _pre._stderr 'Unauthorized command'
+      end
+    }
   end
 end
 
diff --git a/www/secretary/workbench/worklist.cgi b/www/secretary/workbench/worklist.cgi
index c3cd5c7..5b87d71 100755
--- a/www/secretary/workbench/worklist.cgi
+++ b/www/secretary/workbench/worklist.cgi
@@ -372,8 +372,6 @@ _html do
 
           _div_.buttons!.buttons do
             _input type: 'submit', value: 'File'
-            # _input type: 'submit', id: 'archive', value: 'Archive',
-            # onclick: 'return namesFromArchive()'
             _input type: 'submit', name: 'action', value: 'Cancel'
           end
 
diff --git a/www/secretary/workbench/worklist.js b/www/secretary/workbench/worklist.js
index 8be0a17..84b389a 100644
--- a/www/secretary/workbench/worklist.js
+++ b/www/secretary/workbench/worklist.js
@@ -66,33 +66,6 @@ function generateFileName(selection) {
   return value.replace(/-+/g, '-').toLowerCase();
 }
 
-// replace realname input field with a selection list
-function namesFromArchive() {
-  $.getJSON('unscanned.cgi', {}, function(unscanned) {
-    var select = $('<select name="realname" id="realname"/>')[0];
-    for (var i=0; i<unscanned.length; i++) {
-      select.options[i] = new Option(unscanned[i][1], i);
-    }
-    $('#realname').before(select).remove();
-
-    $("#archive").attr("disabled","disabled");
-
-    // process selection
-    $('#realname').focus().change(function() {
-      var icla = unscanned[$("#realname option:selected").val()];
-      $("#realname").before('<input type="text" ' +
-        'id="realname" name="realname"/>').remove();
-      $("#realname").val(icla[1]);
-      $("#pubname").val(icla[2]);
-      $("#email").val(icla[3]);
-      $("#replaces").val(icla[0] + ':' + icla[3]);
-      $("#filename").val('').focus();
-      $("#archive").removeAttr("disabled");
-    });
-  });
-  return false;
-}
-
 $(document).ready(function() {
   // member autofill
   $('#mavailid').change(function() {
@@ -134,7 +107,7 @@ $(document).ready(function() {
       $("#icla-form input").addClass("loading");
       $("#ccla-form input").addClass("loading");
       $("#grant-form input").addClass("loading");
-      $.getJSON('svninfo.cgi', {source: link}, function(info) {
+      $.post('file.cgi', {cmd: 'svninfo', source: link}, function(info) {
         if (!$('#realname').val()) $('#realname').val(info.from);
         if (!$('#nname').val())    $('#nname').val(info.from);
         if (!$('#contact').val())  $('#contact').val(info.from);
@@ -153,7 +126,7 @@ $(document).ready(function() {
         $("#icla-form input").removeClass("loading");
         $("#ccla-form input").removeClass("loading");
         $("#grant-form input").removeClass("loading");
-      });
+      }, 'json');
     }
   });
 

Mime
View raw message