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] [32/50] Commit 7770a08: rough in more server props
Date Fri, 22 Jan 2016 02:40:56 GMT
Commit 7770a08ec9336c9ca8b50c891c4f1734ee5b1703:
    rough in more server props


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

------------------------------------------------------------
routes.rb                                                    | +++++++ 
views/agenda.js.rb                                           | ++ --
views/main.js.rb                                             | +++++ -
------------------------------------------------------------
17 changes: 14 additions, 3 deletions.
------------------------------------------------------------


diff --git a/routes.rb b/routes.rb
index 8ea4fca..cb97789 100755
--- a/routes.rb
+++ b/routes.rb
@@ -17,11 +17,18 @@
 
   @base = env['PATH_INFO'].chomp(path).untaint
 
+  require 'etc'
+  userid = env['REMOTE_USER'] || Etc.getlogin
+
   @server = {
+    userid: env['REMOTE_USER'] || Etc.getlogin,
     agendas: dir('board_agenda_*.txt').sort,
     drafts: dir('board_minutes_*.txt').sort
   }
 
+  @server[:username] = Etc.getpwnam(@server[:userid])[4].split(',').first
+  @server[:initials] = @server[:username].gsub(/[^A-Z]/, '').downcase
+
   @page = {
     date: date,
     path: path,
diff --git a/views/agenda.js.rb b/views/agenda.js.rb
index c6b4bd6..72a4667 100644
--- a/views/agenda.js.rb
+++ b/views/agenda.js.rb
@@ -85,7 +85,7 @@ def self.file
   def self.prev
     result = {title: 'Help', href: 'help'}
 
-    @@agendas.each do |agenda|
+    Server.agendas.each do |agenda|
       date = agenda[/(\d+_\d+_\d+)/, 1].gsub('_', '-')
 
       if date < @@date and (result.title == 'Help' or date > result.title)
@@ -99,7 +99,7 @@ def self.prev
   def self.next
     result = {title: 'Help', href: 'help'}
 
-    @@agendas.each do |agenda|
+    Server.agendas.each do |agenda|
       date = agenda[/(\d+_\d+_\d+)/, 1].gsub('_', '-')
 
       if date > @@date and (result.title == 'Help' or date < result.title)
diff --git a/views/main.js.rb b/views/main.js.rb
index 804ec02..c23d1d2 100644
--- a/views/main.js.rb
+++ b/views/main.js.rb
@@ -49,9 +49,13 @@ def render
   def componentWillMount()
     Agenda.load(@@page.parsed)
     Agenda.date = @@page.date
-    Agenda._agendas = @@server.agendas
     self.route(@@page.path, @@page.query)
 
+    # copy server info for later use
+    for prop in @@server
+      Server[prop] = @@server[prop]
+    end
+
     # free memory
     @@page.parsed = nil
   end

Mime
View raw message