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: rewrite feedback form in Vue.js
Date Sun, 01 Apr 2018 17:37:46 GMT
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 d96a532  rewrite feedback form in Vue.js
d96a532 is described below

commit d96a532b424e0d1cd5704f4d5b726c61b8fa8097
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Sun Apr 1 13:37:13 2018 -0400

    rewrite feedback form in Vue.js
---
 www/board/agenda/public/stylesheets/app.css     |  8 ++-
 www/board/agenda/routes.rb                      | 28 +++++------
 www/board/agenda/views/actions/feedback.json.rb |  2 +-
 www/board/agenda/views/app.js.rb                |  1 +
 www/board/agenda/views/feedback.html.rb         | 67 -------------------------
 www/board/agenda/views/router.js.rb             |  3 ++
 6 files changed, 25 insertions(+), 84 deletions(-)

diff --git a/www/board/agenda/public/stylesheets/app.css b/www/board/agenda/public/stylesheets/app.css
index 982b5dc..cba79b6 100644
--- a/www/board/agenda/public/stylesheets/app.css
+++ b/www/board/agenda/public/stylesheets/app.css
@@ -218,7 +218,13 @@ label.checkbox span {
 
 pre {
   background-color: #FFF;
-  border: none
+  border: none;
+}
+
+pre.feedback {
+  background-color: #f5f5f5;
+  border: 1px solid #ccc;
+  margin-left: 2em;
 }
 
 footer .btn {
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index a65d96e..89996af 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -2,21 +2,6 @@
 # Server side Sinatra routes
 #
 
-# temporary
-get %r{/(\d\d\d\d-\d\d-\d\d)/feedback} do |date|
-  _html :feedback
-end
-get %r{/(\d\d\d\d-\d\d-\d\d)/feedback.json} do |date|
-  @agenda = "board_agenda_#{date.gsub('-', '_')}.txt".untaint
-  @dryrun = true
-  _json :'actions/feedback'
-end
-post %r{/(\d\d\d\d-\d\d-\d\d)/feedback.json} do |date|
-  @agenda = "board_agenda_#{date.gsub('-', '_')}.txt".untaint
-  @dryrun = false
-  _json :'actions/feedback'
-end
-
 # redirect root to latest agenda
 get '/' do
   agenda = dir('board_agenda_*.txt').sort.last
@@ -113,6 +98,19 @@ get %r{/(\d\d\d\d-\d\d-\d\d)/digest\.json} do |date|
   )
 end
 
+# feedback
+get %r{/(\d\d\d\d-\d\d-\d\d)/feedback.json} do |date|
+  @agenda = "board_agenda_#{date.gsub('-', '_')}.txt".untaint
+  @dryrun = true
+  _json :'actions/feedback'
+end
+
+post %r{/(\d\d\d\d-\d\d-\d\d)/feedback.json} do |date|
+  @agenda = "board_agenda_#{date.gsub('-', '_')}.txt".untaint
+  @dryrun = false
+  _json :'actions/feedback'
+end
+
 # all agenda pages
 get %r{/(\d\d\d\d-\d\d-\d\d)/(.*)} do |date, path|
   agenda = "board_agenda_#{date.gsub('-','_')}.txt"
diff --git a/www/board/agenda/views/actions/feedback.json.rb b/www/board/agenda/views/actions/feedback.json.rb
index ddb5bbe..a9ac3be 100644
--- a/www/board/agenda/views/actions/feedback.json.rb
+++ b/www/board/agenda/views/actions/feedback.json.rb
@@ -62,7 +62,7 @@ Agenda.parse(@agenda, :full).each do |item|
   }.gsub(/^ {4}/, '').strip
 
   # build cc list
-  cc = []
+  cc = ['secretary@apache.org']
   
   if item['mail_list']
     if item[:attach] =~ /^[A-Z]+/
diff --git a/www/board/agenda/views/app.js.rb b/www/board/agenda/views/app.js.rb
index b7ac8e0..a6967e1 100644
--- a/www/board/agenda/views/app.js.rb
+++ b/www/board/agenda/views/app.js.rb
@@ -30,6 +30,7 @@ require_relative 'pages/missing'
 require_relative 'pages/backchannel'
 require_relative 'pages/roll-call'
 require_relative 'pages/select-actions'
+require_relative 'pages/feedback'
 require_relative 'pages/cache'
 require_relative 'pages/fy23'
 
diff --git a/www/board/agenda/views/feedback.html.rb b/www/board/agenda/views/feedback.html.rb
deleted file mode 100644
index 23a2bc9..0000000
--- a/www/board/agenda/views/feedback.html.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-_html do
-  _head_ do
-    _meta name: "viewport", content: 'width=device-width', initial_scale: 1
-    _style_ %{
-      div:empty {display: none}
-    }
-  end
-
-  _body do
-    _div.alert
-
-    _form_ method: 'post' do
-      _button.btn.btn_primary 'Send email', type: 'submit', disabled: true
-    end
-
-    _p_ 'loading'
-
-    _script %q{
-      var button = document.querySelector('button');
-      var alert = document.querySelector('.alert');
-      var form = document.querySelector('form');
-
-      jQuery.getJSON('feedback.json', function(data) {
-        data.forEach(function(message) {
-          var h1 = document.createElement('h1');
-          h1.setAttribute('id', message.title);
-          h1.textContent = message.title;
-
-          var input = document.createElement('input');
-          input.setAttribute('type', 'checkbox');
-          input.setAttribute('name', 'checked[' +
-            message.title.replace(/\s/g, '_') + ']');
-          input.checked = !message.sent;
-          h1.insertBefore(input, h1.firstChild);
-
-          var pre = document.createElement('pre');
-          pre.textContent = message.mail;
-          form.appendChild(h1);
-          form.appendChild(pre);
-        });
-
-        document.querySelector('p').remove();
-
-        button.disabled = false;
-      });
-
-      button.addEventListener('click', function(event) {
-        event.preventDefault();
-        button.disabled = true;
-        jQuery.ajax('feedback.json', {
-          method: 'POST',
-          data: $(form).serialize(),
-
-          success: function(event) {
-            alert.classList.add('alert-success');
-            alert.textContent = 'emails sent';
-          },
-
-          error: function(event) {
-            alert.classList.add('alert-danger');
-            alert.textContent = event.statusText;
-          }
-        });
-      });
-    }
-  end
-end
diff --git a/www/board/agenda/views/router.js.rb b/www/board/agenda/views/router.js.rb
index 599c428..e3a475d 100644
--- a/www/board/agenda/views/router.js.rb
+++ b/www/board/agenda/views/router.js.rb
@@ -79,6 +79,9 @@ class Router
         end
       end
 
+    elsif path == 'feedback'
+      item = {view: Feedback, title: 'Send Feedback'}
+
     elsif path == 'help'
       item = {view: Help}
 

-- 
To stop receiving notification emails like this one, please contact
rubys@apache.org.

Mime
View raw message