You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/09/26 22:08:38 UTC

[whimsy] branch master updated: code to post a new agenda

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

rubys 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 df1411b  code to post a new agenda
df1411b is described below

commit df1411bfa84d86bb0d7db456e536abe8b3e3430e
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Sep 26 18:08:26 2017 -0400

    code to post a new agenda
---
 lib/whimsy/asf/committee.rb        | 33 ++++++++++++++++++++++-----------
 lib/whimsy/asf/svn.rb              |  7 +++++++
 www/board/agenda/data/agenda.erb   |  1 +
 www/board/agenda/routes.rb         | 26 +++++++++++++++++++++++++-
 www/board/agenda/views/new.html.rb | 23 +++++++++++++++++++++++
 5 files changed, 78 insertions(+), 12 deletions(-)

diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb
index f575b28..16d785d 100644
--- a/lib/whimsy/asf/committee.rb
+++ b/lib/whimsy/asf/committee.rb
@@ -89,20 +89,31 @@ module ASF
     # load committee info from <tt>committee-info.txt</tt>.  Will not reparse
     # if the file has already been parsed and the underlying file has not
     # changed.
-    def self.load_committee_info
-      board = ASF::SVN['private/committers/board']
-      file = "#{board}/committee-info.txt"
-      return unless File.exist? file
+    def self.load_committee_info(contents = nil, info = nil)
+      if contents
+        if info
+          @committee_mtime = @@svn_change =
+            Time.parse(info[/Last Changed Date: (.*) \(/, 1]).gmtime
+        else
+          @committee_mtime = @@svn_change = Time.now
+        end
 
-      if @committee_info and File.mtime(file) == @committee_mtime
-        return @committee_info 
-      end
+        parse_committee_info contents
+      else
+        board = ASF::SVN['private/committers/board']
+        file = "#{board}/committee-info.txt"
+        return unless File.exist? file
 
-      @committee_mtime = File.mtime(file)
-      @@svn_change = Time.parse(
-        `svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime
+        if @committee_info and File.mtime(file) <= @committee_mtime
+          return @committee_info 
+        end
+
+        @committee_mtime = File.mtime(file)
+        @@svn_change = Time.parse(
+          `svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime
 
-      parse_committee_info File.read(file)
+        parse_committee_info File.read(file)
+      end
     end
 
     # update next month section.  Remove entries that have reported or
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 4ad58f8..c74370d 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -103,6 +103,9 @@ module ASF
     # retrieve info, [err] for a path in svn
     def self.getInfo(path, user=nil, password=nil)
       return nil, 'path must not be nil' unless path
+
+      path = (@base + path).to_s
+
       # build svn info command
       cmd = ['svn', 'info', path, '--non-interactive']
     
@@ -122,6 +125,8 @@ module ASF
 
     # retrieve revision, [err] for a path in svn
     def self.getRevision(path, user=nil, password=nil)
+      path = (@base + path).to_s
+
       out, err = getInfo(path, user, password)
       if out
         # extract revision number
@@ -133,6 +138,8 @@ module ASF
 
     # retrieve revision, content for a file in svn
     def self.get(path, user=nil, password=nil)
+      path = (@base + path).to_s
+
       # build svn info command
       cmd = ['svn', 'info', path, '--non-interactive']
 
diff --git a/www/board/agenda/data/agenda.erb b/www/board/agenda/data/agenda.erb
index fbbe84b..8499a66 100644
--- a/www/board/agenda/data/agenda.erb
+++ b/www/board/agenda/data/agenda.erb
@@ -47,6 +47,7 @@
         Ross Gardler
         Craig L Russell
         Ulrich Stärk
+        Kevin A. McGrail
 
     Executive Officers (expected to be) Absent:
 
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 25785a5..c689950 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -320,6 +320,12 @@ get '/new' do
   localtime = ASF::Board::TIMEZONE.utc_to_local(@meeting)
   @time = localtime.strftime('%l:%M%P')
 
+  # retrieve latest committee info
+  url = 'private/committers/board/committee-info.txt'
+  info = ASF::SVN.getInfo(url, env.user, env.password)
+  revision, contents = ASF::SVN.get(url, env.user, env.password)
+  ASF::Committee.load_committee_info(contents)
+
   # Get directors, list of pmcs due to report, and shepherds
   @directors = ASF::Board.directors
   @pmcs = ASF::Board.reporting(@meeting)
@@ -346,5 +352,23 @@ get '/new' do
     select {|date| draft[date.strftime('%B %d, %Y')] != 'approved'}
 
   template = File.read('data/agenda.erb')
-  _text Erubis::Eruby.new(template).result(binding)
+  @agenda = Erubis::Eruby.new(template).result(binding)
+
+  _html :new
+end
+
+# post a new agenda
+post %r{/(\d\d\d\d-\d\d-\d\d)/} do |date|
+  board = 'https://svn.apache.org/repos/private/foundation/board'
+  agenda = "board_agenda_#{date.gsub('-', '_')}.txt"
+  auth = "--user #{env.user} --password #{env.password}"
+
+  Dir.mktmpdir do |dir|
+    `svn checkout --depth empty #{dir} #{auth}`
+    File.write "#{dir}/#{agenda}", params[:agenda]
+    `svn add #{dir}/#{agenda}`
+    `svn commit #{dir}/#{agenda} -message "Post #{date} agenda" #{auth}`
+  end
+
+  redirect to('/')
 end
diff --git a/www/board/agenda/views/new.html.rb b/www/board/agenda/views/new.html.rb
new file mode 100644
index 0000000..adb7092
--- /dev/null
+++ b/www/board/agenda/views/new.html.rb
@@ -0,0 +1,23 @@
+#
+# Post a new agenda
+#
+
+_html do
+  _base href: @base
+  _title 'ASF Board Agenda'
+  _link rel: 'stylesheet', href: "../stylesheets/app.css?#{@cssmtime}"
+  _meta name: 'viewport', content: 'width=device-width, initial-scale=1.0'
+
+  _div.container do
+    _form method: 'post',  action: @meeting.strftime("%Y-%m-%d/") do
+
+      _div.text_center style: 'margin: 1em' do
+        _button.btn.btn_primary 'Post'
+      end
+
+      _textarea.form_control @agenda, name: 'agenda',
+        rows: [@agenda.split("\n").length, 20].max,
+        style: 'overflow: hidden'
+    end
+  end
+end

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