Skip to content

Instantly share code, notes, and snippets.

@Breefield
Created February 11, 2015 18:55
Show Gist options
  • Save Breefield/b59ca0eb85005b3bdb3a to your computer and use it in GitHub Desktop.
Save Breefield/b59ca0eb85005b3bdb3a to your computer and use it in GitHub Desktop.
Weekly Event Mailer
<h2>This week's parties!</h2>
These parties are all in/close to <%= @user.profile.location %> - because you set your Speakeasy profile's location to there.
<br>You can change your location by <%= link_to "updating your profile", edit_profile_url(:subdomain => 'www') %>.
<br>
<%
# List events at top of email
day = nil
@locations.each do |location|
event = location.event
formatted_day = event.start_time_local.strftime('%A, %B %e')
if formatted_day != day
day = formatted_day
%>
<br><b><%= formatted_day %></b><br>
<% end %>
* <%= "#{event.title}, #{event.location.city}" %><br>
<% end %>
<br>
<%
# List full information
day = nil
@locations.each do |location|
event = location.event
formatted_day = event.start_time_local.strftime('%A, %B %e')
if formatted_day != day
day = formatted_day
%>
<br>
<i>---------------- <%= formatted_day %> ----------------</i>
<br><br>
<% else %>
<br><br><br>
<i>---- Also <%= event.start_time_local.strftime('%A') %> ----</i>
<br><br>
<% end %>
<b><%= event.title %></b>
<br>
<i>Hosted by: <%= event.display_host %></i>
<br><br>
<% if event.description.present? %>
<i><%= event.subtitle %></i>
<%= truncate(event.description, :length => 400, :separator => ' ') %>
<% if event.description.length > 400 %>
<%= link_to 'read more', event.permalink_url %>
<% end %>
<br><br>
<% end %>
<% unless event.location.to_be_announced? %>
<% if full_address?(event, @user) %>
<%= link_to event.location.address, "https://maps.google.com/?q=loc:#{event.location.latitude},#{event.location.longitude}&z=18" %>
<% else %>
<%= event.location.approx_area %> (<%= link_to "knock knock", confirm_event_url(event, 1, :subdomain => 'www') %> for the address)
<% end %>
<% else %>
Location to be announced! RSVP to recieve the address when it's released.
<% end %>
<br>
<%= "#{event.start_time_local.strftime('%l:%M')} #{event.start_time_local.strftime('%p').downcase}-#{event.end_time_local.strftime('%l:%M')} #{event.end_time_local.strftime('%p').downcase}" %>,
<% if event.costs? %>
<%= number_to_currency(event.price) %>
<% else %>
$free
<% end %>
<br>
<%= link_to 'Reserve a spot', confirm_event_url(event, 1, :subdomain => 'www') %>
<br>
<% end %>
<br><br>
You can unsubscribe from these weekly emails by <%= link_to "changing your notification preferences", edit_notifications_url(:subdomain => 'www') %>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment