Permalink
Browse files

Added more information to email event notifications, cleaned up email…

… configuration stuff, updated about us page
  • Loading branch information...
percyliang committed Aug 31, 2011
1 parent c76de62 commit 33207d8b4c378c0c934e06ade9cd9b17671d9667
View
@@ -9,6 +9,7 @@ mkdir -p $MLCOMP_BASE_PATH
mkdir -p $MLCOMP_BASE_PATH/programs
mkdir -p $MLCOMP_BASE_PATH/datasets
mkdir -p $MLCOMP_BASE_PATH/runs
+mkdir -p $MLCOMP_BASE_PATH/download
# Create the database.
echo "Do you know your mysql root password? It is necessary to creat the mlcomp_development db, and to grant permissions to it. You should now be prompted for your password."
@@ -62,19 +62,43 @@ def require_login
def action_notification
notify_actions = [
- ["datasets", "create"],
- ["datasets", "update"],
- ["datasets", "destroy"],
- ["programs", "destroy"],
- ["programs", "create"],
- ["programs", "update"],
+ ['datasets', 'create'],
+ ['datasets', 'update'],
+ ['datasets', 'destroy'],
+ ['datasets', 'create_bundle'],
+ ['programs', 'create'],
+ ['programs', 'update'],
+ ['programs', 'destroy'],
+ ['programs', 'create_bundle'],
['runs', 'create'],
+ ['runs', 'destroy'],
+ ['runs', 'create_bundle'],
['users', 'create'],
nil].compact
if notify_actions.member?([params[:controller], params[:action]])
- user = session[:user] ? session[:user].username : "anon"
+ # If logged in, comes from session, if creating new user, comes from params
+ if session[:user]
+ username = session[:user].username || "anon"
+ fullname = session[:user].fullname || "?"
+ elsif params[:user]
+ username = params[:user]['username'] || "anon"
+ fullname = params[:user]['fullname'] || "?"
+ end
+
hostname = `hostname`.chomp
- message = "#{user}@#{hostname}: #{params[:controller]}.#{params[:action]}(#{params[:id] || "nil"})"
+
+ # What thing are we operating on
+ model = nil
+ if params[:controller] == 'datasets' then model = Dataset
+ elsif params[:controller] == 'programs' then model = Program
+ elsif params[:controller] == 'runs' then model = Run
+ end
+ if model
+ x = model.find(params[:id])
+ payload = x ? "#{x.id}:#{x.name}" : params[:id]
+ end
+
+ message = "#{username}@#{hostname} (#{fullname}): #{params[:controller]}.#{params[:action]}(#{payload})"
Notification::notify_event({:message => message})
end
end
@@ -99,18 +99,25 @@ def front_page
def leave_comment
comment = params[:comment]
commenturl = params[:commenturl]
- if session[:user] || comment =~ /notspam/ # If logged in or user said notspam
+ accept = session[:user] || comment =~ /notspam/ # If logged in or user said notspam
+ if accept
username = session[:user] ? session[:user].username : "anon"
fullname = session[:user] ? session[:user].fullname : "anon"
email = session[:user] ? session[:user].email : nil
+ #puts [username, fullname, email].inspect
if SITEPARAMS[:email_configured]
Emailer.deliver_user_comment(username, fullname, email, comment, commenturl)
end
end
render :update do |page|
- page.call "$('comment').clear"
- page[:comment_status].replace_html "Comment sent, Thanks!"
- page.visual_effect :fade, 'comment_status', :duration => 5
+ if accept
+ page.call "$('comment').clear"
+ page[:comment_status].replace_html "Comment sent, Thanks!"
+ page.visual_effect :fade, 'comment_status', :duration => 5
+ else
+ page[:comment_status].replace_html "Comment not sent, please try again."
+ page.visual_effect :fade, 'comment_status', :duration => 5
+ end
end
end
View
@@ -15,24 +15,23 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
class Emailer < ActionMailer::Base
-
# All of the settings here should probably be changed, these are the
# default emailer settings for mlcomp's live server
-
- def user_comment(username, fullname, email, message, url, sent_at = Time.now)
- @subject = "User Comment from #{username} (#{fullname})"
- @recipients = ['mlcomp.support@gmail.com']
- @from = 'MLcomp commenter <noreply@mlcomp.org>'
- @reply_to = email if email
- @sent_on = sent_at
- @body = {:username => username, :fullname => fullname, :message => message, :url => url, :sent => sent_at}
+
+ def user_comment(username, fullname, email, message, url)
+ @subject = "User comment from #{username} (#{fullname})"
+ @recipients = SITEPARAMS[:notify_recipients]
+ @from = 'MLcomp commenter'
+ @reply_to = email
+ @sent_on = Time.now
+ @body = {:username => username, :fullname => fullname, :email => email, :message => message, :url => url}
@headers = {}
end
def general_email(subject, body)
@subject = subject
- @recipients = ['jake@cs.berkeley.edu', 'pliang@cs.berkeley.edu', 'mlcomp.support@gmail.com']
- @from = 'MLcomp server <mlcomp.support@gmail.com>'
+ @recipients = SITEPARAMS[:notify_recipients]
+ @from = 'MLcomp server'
@sent_on = Time.now
@body = {:body => body}
@headers = {}
View
@@ -357,7 +357,7 @@ def finishRun(exitCode)
self.status.status = success ? 'done' : 'failed'
self.status.save
log "Status: #{self.status.status}"
- Notification::notify_event(:message => "Run #{self.id} of #{self.user && self.user.username} finished: #{self.status.status}")
+ Notification::notify_event(:message => "Run #{self.id}:#{self.name} of #{self.user && self.user.username} finished: #{self.status.status}")
end
# return at most maxLines lines of the log file
@@ -1 +1 @@
-page[:dataset_download_box].replace_html (@dataset_bundle_url ? (link_to "[download zip]", @dataset_bundle_url) : "Creating zip failed: #{@dataset_bundle_error}")
+page[:dataset_download_box].replace_html(@dataset_bundle_url ? link_to("[download zip]", @dataset_bundle_url) : "Creating zip failed: #{@dataset_bundle_error}")
@@ -1,3 +1,3 @@
-The user <%= @username + " (#{@fullname})"%> visited URL <%= @url %> and at <%= @sent_at.to_s %> left the following comment:
+User <%= @username + " (#{@fullname}, email #{@email})"%> visited URL <%= @url %> and left the following comment:
<%= @message %>
@@ -24,7 +24,7 @@
pg[:comment_status].appear
}, :with => "Form.serialize('comment_form')",
# Post annoying message
- :confirm => session[:user] ? nil : "Are you a spambot? If not, you must include the string 'notspam' in your comment. For example: \"Hi, mlcomp is great, wonderful job! --notspam\"" %></span><span id="comment_status" style="display:none">empty</span>
+ :confirm => session[:user] ? nil : "Please include the string 'notspam' in your comment or log in to prove you're not a spammer." %></span><span id="comment_status" style="display:none">empty</span>
<% end -%>
<script type="text/javascript" charset="utf-8">
@@ -1,8 +1,8 @@
<div id="creator_list_box">
- <h1>The MLcomp Creators</h1>
+ <h1>MLcomp Team</h1>
<div id="creator_list">
- <div class="left_side">
+ <div class="right_side">
<div class="creator_description">
<img src="/images/jake.png"></img>
<strong><a href="http://www.eecs.berkeley.edu/~jake">Jacob
@@ -13,27 +13,25 @@ <h1>The MLcomp Creators</h1>
</div>
</div>
- <div class="right_side">
+ <div class="left_side">
<img src="/images/percy.jpeg"></img>
<div class="creator_description">
- <strong><a href="http://www.eecs.berkeley.edu/~pliang">Percy Liang</a></strong> is a 5th year Ph.D. student at UC Berkeley,
- advised by Michael Jordan and Dan Klein.
- Percy developed the infrastructure for executing runs, processing
+ <strong><a href="http://cs.stanford.edu/~pliang">Percy Liang</a></strong>
+ is a post-doc at Google and
+ will be an assistant professor at Stanford starting in Fall 2012.
+ He developed the infrastructure for executing runs, processing
programs/datasets, and reporting results.
</div>
</div>
<div style="clear:both"></div>
<div>
- <strong>Special thanks</strong> to <a
- href="http://www.eecs.berkeley.edu/~asimma/">Alex Simma</a>, who
- contributed significantly to both the design and early development of
- MLcomp, as well as to <a
- href="http://radlab.cs.berkeley.edu/node/68">Ariel Kleiner</a>, who
- played a large role in the conceptualization of the site. We would also
- to thank <a href="http://www.eecs.berkeley.edu/~jordan/">Michael
- Jordan</a> for providing MLcomp with computational resources. <br><br>
+ <strong>Special thanks</strong> to
+ Alex Simma, who contributed significantly to both the design and early development of MLcomp,
+ and to Ariel Kleiner, who played a large role in the conceptualization of the site.
+ We would also to thank <a href="http://www.eecs.berkeley.edu/~jordan/">Michael
+ Jordan</a> and Intel for providing computational resources.<br><br>
</div>
<div>
@@ -74,20 +74,20 @@
if SITEPARAMS[:email_configured]
- # This is the code to send emails via gmail
+ # This is the code to send emails
require 'smtp_tls'
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.delivery_method = :smtp
- ActionMailer::Base.smtp_settings = SITEPARAMS[:gmail_config_params]
+ ActionMailer::Base.smtp_settings = SITEPARAMS[:email_config_params]
# A typical configuration of ActionMailer::Base.smtp_settings is:
# {
# :address => "smtp.gmail.com",
# :port => 587,
# :authentication => :plain,
- # :user_name => "mlcomp.support@gmail.com",
+ # :user_name => "<username>@gmail.com",
# :password => ""
# }
@@ -1,14 +1,11 @@
---
-:email_configured: true
-:gmail_config_params:
+:email_configured: true # Set this if you want to enable email.
+:email_config_params: # Information used to send out all emails.
:port: 587
:authentication: :plain
:user_name: USERNAME@gmail.com
:password: PASSWORD
:address: smtp.gmail.com
-:twitter_configured: true
-:twitter_tokens:
- :consumer_secret: 0Dsa...
- :access_secret: jDn3T...
- :consumer_token: G5HO...
- :access_token: 77085...
+:notify_recipients: # When user comments or events happen on the server, these email addresses get notified.
+ - <recipient1-of-events-and-comments>@gmail.com
+ - <recipient2-of-events-and-comments>@gmail.com

0 comments on commit 33207d8

Please sign in to comment.