whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Bazley <s...@apache.org>
Subject [whimsy.git] [1/1] Commit b90e943: Split people off into separate listing
Date Tue, 26 Jan 2016 09:49:37 GMT
Commit b90e94369c440c58e2d366961884dc744d63c84b:
    Split people off into separate listing


Branch: refs/heads/master
Author: Sebb <sebb@apache.org>
Committer: Sebb <sebb@apache.org>
Pusher: sebb <sebb@apache.org>

------------------------------------------------------------
www/roster/public_ldap_people.rb                             | +++++++++++++ 
------------------------------------------------------------
51 changes: 51 additions, 0 deletions.
------------------------------------------------------------


diff --git a/www/roster/public_ldap_people.rb b/www/roster/public_ldap_people.rb
new file mode 100644
index 0000000..46984f4
--- /dev/null
+++ b/www/roster/public_ldap_people.rb
@@ -0,0 +1,51 @@
+# Creates JSON output with the following format:
+#
+# {
+#   "people": {
+#     "uid": {
+#       "name": "Public Name",
+#       "noLogin": true // present only if the login is not valid
+#     }
+#     ...
+# }
+#
+
+require 'bundler/setup'
+
+require_relative 'public_json_common'
+
+require 'whimsy/asf'
+
+ldap = ASF.init_ldap
+exit 1 unless ldap
+
+# ASF people
+peo = {}
+
+peeps = ASF::Person.preload(['cn', 'loginShell']) # for performance
+
+# Make output smaller by ommitting commonest case (noLogin: false)
+def makeEntry(hash, e)
+  if e.banned?
+    hash[e.id] = {
+        name: e.public_name,
+        noLogin: true
+    }
+  else
+    hash[e.id] = {
+        name: e.public_name,
+    }
+  end
+end
+
+# Now see if there are any left-over people
+peeps.sort_by {|a| a.name}.each do |e|
+    makeEntry(peo, e)
+end
+
+info = {
+  # There does not seem to be a useful timestamp here
+  people: peo,
+}
+
+public_json_output(info)

Mime
View raw message