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: obtain session and pass to client
Date Tue, 04 Oct 2016 16:45:30 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  45b785d   obtain session and pass to client
45b785d is described below

commit 45b785dab7786332415c5609126fe778061f6b87
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Tue Oct 4 12:44:51 2016 -0400

    obtain session and pass to client
    
    also: detab
---
 www/board/agenda/daemon/session.rb | 34 +++++++++++++++++-----------------
 www/board/agenda/main.rb           |  1 +
 www/board/agenda/routes.rb         |  1 +
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/www/board/agenda/daemon/session.rb b/www/board/agenda/daemon/session.rb
index 8ad005a..29d70b0 100644
--- a/www/board/agenda/daemon/session.rb
+++ b/www/board/agenda/daemon/session.rb
@@ -18,7 +18,7 @@ require 'concurrent'
 #
 
 class Session
-  WORKDIR = File.expand_path('sessions', __dir__)
+  WORKDIR = File.expand_path('sessions', AGENDA_WORK)
   DAY = 24*60*60 # seconds
 
   @@sessions = Concurrent::Map.new
@@ -64,27 +64,27 @@ class Session
     @@semaphore.synchronize do
       # default files to all files in the workdir and @@sessions hash
       files ||= Dir["#{WORKDIR}/*"].map {|file| file.dup.untaint} +
-	@@sessions.keys.map {|secret| File.join(WORKDIR, secret)}
+        @@sessions.keys.map {|secret| File.join(WORKDIR, secret)}
 
       files.uniq.each do |file|
-	secret = File.basename(file)
-	session = @@sessions[secret]
+        secret = File.basename(file)
+        session = @@sessions[secret]
 
-	File.delete file if session and session[:mtime] < Time.now - 2 * DAY
+        File.delete file if session and session[:mtime] < Time.now - 2 * DAY
 
-	if File.exist? file
-	  # update class variables if the file changed
-	  mtime = File.mtime(file)
-	  next if session and session[:mtime] == mtime
+        if File.exist? file
+          # update class variables if the file changed
+          mtime = File.mtime(file)
+          next if session and session[:mtime] == mtime
 
-	  session = {id: File.read(file), secret: secret, mtime: mtime}
-	  @@sessions[secret] == session
-	  @@users[session[:id]] << session
-	else
-	  # remove session if the file no longer exists
-	  @@users[session[:id]].delete(session) if session
-	  @@sessions.delete(secret)
-	end
+          session = {id: File.read(file), secret: secret, mtime: mtime}
+          @@sessions[secret] == session
+          @@users[session[:id]] << session
+        else
+          # remove session if the file no longer exists
+          @@users[session[:id]].delete(session) if session
+          @@sessions.delete(secret)
+        end
       end
     end
   end
diff --git a/www/board/agenda/main.rb b/www/board/agenda/main.rb
index c61e5c6..eec8498 100755
--- a/www/board/agenda/main.rb
+++ b/www/board/agenda/main.rb
@@ -40,6 +40,7 @@ require_relative './models/agenda'
 require_relative './models/minutes'
 require_relative './models/comments'
 require_relative './helpers/string'
+require_relative './daemon/session'
 
 # if AGENDA_WORK doesn't exist yet, make it
 if not Dir.exist? AGENDA_WORK
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 287f5af..5ab1e82 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -92,6 +92,7 @@ get %r{/(\d\d\d\d-\d\d-\d\d)/(.*)} do |date, path|
     firstname: username.split(' ').first.downcase,
     initials: initials,
     online: IPC.present,
+    session: Session.user(userid),
     role: role,
     directors: Hash[ASF::Service['board'].members.map {|person| 
       initials = person.public_name.gsub(/[^A-Z]/, '').downcase

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

Mime
View raw message