Skip to content

Commit

Permalink
Merge pull request #46 from aaronpk/microformats2
Browse files Browse the repository at this point in the history
Microformats2
  • Loading branch information
jc00ke committed Sep 15, 2013
2 parents da94c80 + 369cb0c commit 8bc90ef
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def tag_link(type, tag, link_class=nil)
when :venue then venues_path(:tag => tag.name)
end

link_classes = [link_class]
link_classes = [link_class, "p-category"]
link_classes << "external #{tag.machine_tag[:namespace]} #{tag.machine_tag[:predicate]}" if tag.machine_tag[:url]

link_to escape_once(tag.name), (tag.machine_tag[:url] || internal_url), :class => link_classes.compact.join(' ')
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/time_range_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def to_s

# Combine the pieces
results = []
results << %Q|<abbr class="dtstart" title="#{@start_time.strftime('%Y-%m-%dT%H:%M:%S')}">| if @format == :hcal
results << %Q|<time class="dtstart dt-start" title="#{@start_time.strftime('%Y-%m-%dT%H:%M:%S')}" datetime="#{@start_time.strftime('%Y-%m-%dT%H:%M:%S')}">| if @format == :hcal
results << format_details_by_list(start_details, start_format_list)
results << %Q|</abbr>| if @format == :hcal
results << %Q|</time>| if @format == :hcal
if end_format_list
results << conjunction
results << %Q|<abbr class="dtend" title="#{@end_time.strftime('%Y-%m-%dT%H:%M:%S')}">| if @format == :hcal
results << %Q|<time class="dtend dt-end" title="#{@end_time.strftime('%Y-%m-%dT%H:%M:%S')}" datetime="#{@end_time.strftime('%Y-%m-%dT%H:%M:%S')}">| if @format == :hcal
results << format_details_by_list(end_details, end_format_list)
results << %Q|</abbr>| if @format == :hcal
results << %Q|</time>| if @format == :hcal
end
results.join('').html_safe
end
Expand Down
28 changes: 14 additions & 14 deletions app/views/events/_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ html_classes = "single_event"
html_classes << " contentbar" if has_contentbar
%>
<div class="<%= html_classes %>">
<div class="vevent" itemscope itemtype="http://schema.org/Event">
<h1 class="summary" itemprop="name"><%= event.title %></h1>
<div class="vevent h-event" itemscope itemtype="http://schema.org/Event">
<h1 class="summary p-name" itemprop="name"><%= event.title %></h1>
<meta itemprop="startDate" content="<%= event.start_time.to_time.iso8601 %>">
<% if event.end_time %>
<meta itemprop="endDate" content="<%= event.end_time.to_time.iso8601 %>">
<% end %>
<div class='date'><%= normalize_time(event) -%></div>
<% unless event.venue.blank? %>
<div class="clearfix location vcard<%= " closed" if event.venue.closed? %>" itemprop="location" itemscope itemtype="http://schema.org/Place">
<div class="clearfix location p-location h-card vcard<%= " closed" if event.venue.closed? %>" itemprop="location" itemscope itemtype="http://schema.org/Place">
<%= google_map event %>
<a class="url" href='<%= event.venue.new_record? ? "#" : venue_url(event.venue) %>'>
<span class='fn org' itemprop="name"><%= event.venue.title -%></span>
<a class="url u-url" href='<%= event.venue.new_record? ? "#" : venue_url(event.venue) %>'>
<span class='fn org p-name' itemprop="name"><%= event.venue.title -%></span>
</a>
<% if event.venue.closed? %><p class='closed_callout'>This venue is no longer open for business.</p><% end %>
<div class="adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<div class="adr p-adr h-adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<% if !event.venue.street_address.blank? -%>
<div class="street-address" itemprop="streetAddress"><%= event.venue.street_address -%></div>
<div class="p-street-address" itemprop="streetAddress"><%= event.venue.street_address -%></div>
<% end %>
<% if !event.venue.locality.blank? -%>
<span class="locality" itemprop="addressLocality"><%= event.venue.locality -%></span><%= "," if event.venue.region.present? or event.venue.postal_code.present? or event.venue.country.present? %>
<span class="p-locality" itemprop="addressLocality"><%= event.venue.locality -%></span><%= "," if event.venue.region.present? or event.venue.postal_code.present? or event.venue.country.present? %>
<% end -%>
<% if !event.venue.region.blank? -%>
<span class="region" itemprop="addressRegion"><%= event.venue.region -%></span><%= "," if event.venue.country.present? and not event.venue.postal_code.present? %>
<span class="p-region" itemprop="addressRegion"><%= event.venue.region -%></span><%= "," if event.venue.country.present? and not event.venue.postal_code.present? %>
<% end -%>
<% if !event.venue.postal_code.blank? -%>
<span class="postal-code" itemprop="postalCode"><%= event.venue.postal_code -%></span><%= "," if event.venue.country.present? %>
<span class="p-postal-code" itemprop="postalCode"><%= event.venue.postal_code -%></span><%= "," if event.venue.country.present? %>
<% end -%>
<% if !event.venue.country.blank? -%>
<span class='country-name'><%= event.venue.country -%></span>
<span class='p-country-name'><%= event.venue.country -%></span>
<% end -%>
<% if event.venue && event.venue.has_full_address? -%>
(<a href='<%=google_maps_url(event.venue.full_address) -%>'>map</a>)
Expand All @@ -55,7 +55,7 @@ html_classes << " contentbar" if has_contentbar
<% end -%>
<% unless event.venue_details.blank? -%>
<p>
<p class="p-description">
<%= format_description(event.venue_details) %>
</p>
<% end -%>
Expand All @@ -67,14 +67,14 @@ html_classes << " contentbar" if has_contentbar
<% unless event.url.blank? -%>
<h3>Website</h3>
<div class="website">
<%= link_to "#{truncate(event.url, :length => 128)}", h(event.url), :class => "url", :rel => "nofollow",
<%= link_to "#{truncate(event.url, :length => 128)}", h(event.url), :class => "url u-url", :rel => "nofollow",
:itemprop => "url" %>
</div>
<% end -%>
<% unless event.description.blank? -%>
<h3>Description</h3>
<div class="description" itemprop="description">
<div class="description e-description" itemprop="description">
<%= format_description(event.description) %>
</div>
<% end -%>
Expand Down
10 changes: 5 additions & 5 deletions app/views/events/_list_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ opts ||= {}
opts[:dates] = opts.has_key?(:dates) ? opts[:dates] : true
show_year ||= false
%>
<div class='vevent'>
<div class='vevent h-event'>
<% date_class = (opts[:dates]==false || !new_day) ? ' hidden' : '' -%>
<div class='list_date<%=date_class%>'>
<div class='day_of_week'><%= today_tomorrow_or_weekday(event) %></div>
Expand All @@ -14,20 +14,20 @@ show_year ||= false
<% end %>
</div>
<div class='list_content'>
<a class='summary' href='<%= url_for event_url(event) %>'><%= event.title %></a>
<a class='summary p-name u-url' href='<%= url_for event_url(event) %>'><%= event.title %></a>
<div>
<%= normalize_time(event, :context => event.start_time.to_date) -%>
<% if event.venue && !event.venue.title.blank? %>
<br/><a class='location' href='<%= url_for venue_url(event.venue) %>'><%= event.venue.title -%></a>
<br/><a class='location p-location h-card' href='<%= url_for venue_url(event.venue) %>'><%= event.venue.title -%></a>
<% end -%>
</div>
<% if !event.description.blank? %>
<div class='description'>
<div class='description e-description'>
<%= format_description(event.description) -%>
</div>
<% end -%>
<% if !event.url.blank? -%>
<%= link_to "Website", h(event.url), :class => "url", :rel => "nofollow" -%>
<%= link_to "Website", h(event.url), :class => "url u-url", :rel => "nofollow" -%>
<% end -%>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions app/views/events/_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rowspans = calculate_rowspans(events)
<tbody>
<% unless events.size==0 %>
<% events.each_with_index do |event, index| %>
<tr class='vevent'>
<tr class='vevent h-event'>
<% if rowspans[index] > 0 %>
<td class='date' rowspan="<%=rowspans[index]%>">
<div class='day_of_week <%= today_tomorrow_or_weekday(event).downcase -%>'>
Expand All @@ -42,18 +42,18 @@ rowspans = calculate_rowspans(events)
</td>
<% end %>
<td class='event_summary'>
<a class='summary' href='<%= url_for event_url(event) %>' name='<%= "event-#{event.id}" %>' id='<%= "event-#{event.id}" %>'><%= event.title %></a><br />
<a class='summary p-name u-url' href='<%= url_for event_url(event) %>' name='<%= "event-#{event.id}" %>' id='<%= "event-#{event.id}" %>'><%= event.title %></a><br />
<%= normalize_time(event, :context => event.start_time.to_date) -%>
<% if event.venue && !event.venue.title.blank? %>
<a class='location' href='<%= url_for venue_url(event.venue) %>'><%= event.venue.title -%></a>
<a class='location p-location h-card' href='<%= url_for venue_url(event.venue) %>'><%= event.venue.title -%></a>
<% end -%>
<% if !event.description.blank? %>
<div class='description'>
<div class='description e-description'>
<%= format_description(event.description) -%>
</div>
<% end -%>
<% if !event.url.blank? -%>
<%= link_to "Website", event.url, :class => "url", :rel => "nofollow" -%>
<%= link_to "Website", event.url, :class => "url u-url", :rel => "nofollow" -%>
<% end -%>
</td>
</tr>
Expand Down
16 changes: 8 additions & 8 deletions spec/helpers/time_range_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
tests = [
# comment, end_time, results_without_context, results_with_context
[ "start time only", nil,
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 at 9am</abbr>",
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">9am</abbr>"],
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 at 9am</time>",
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">9am</time>"],
[ "same day & am-pm", DateTime.new(2008, 4, 1, 11, 00),
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 from 9</abbr>&ndash;<abbr class=\"dtend\" title=\"2008-04-01T11:00:00\">11am</abbr>",
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">9</abbr>&ndash;<abbr class=\"dtend\" title=\"2008-04-01T11:00:00\">11am</abbr>" ],
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 from 9</time>&ndash;<time class=\"dtend dt-end\" title=\"2008-04-01T11:00:00\" datetime=\"2008-04-01T11:00:00\">11am</time>",
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">9</time>&ndash;<time class=\"dtend dt-end\" title=\"2008-04-01T11:00:00\" datetime=\"2008-04-01T11:00:00\">11am</time>" ],
[ "same day, different am-pm", DateTime.new(2008, 4, 1, 13, 30),
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 from 9am</abbr>&ndash;<abbr class=\"dtend\" title=\"2008-04-01T13:30:00\">1:30pm</abbr>",
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">9am</abbr>&ndash;<abbr class=\"dtend\" title=\"2008-04-01T13:30:00\">1:30pm</abbr>" ],
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 from 9am</time>&ndash;<time class=\"dtend dt-end\" title=\"2008-04-01T13:30:00\" datetime=\"2008-04-01T13:30:00\">1:30pm</time>",
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">9am</time>&ndash;<time class=\"dtend dt-end\" title=\"2008-04-01T13:30:00\" datetime=\"2008-04-01T13:30:00\">1:30pm</time>" ],
[ "different days", DateTime.new(2009, 4, 1, 13, 30),
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 at 9am</abbr> through <abbr class=\"dtend\" title=\"2009-04-01T13:30:00\">Wednesday, April 1, 2009 at 1:30pm</abbr>",
"<abbr class=\"dtstart\" title=\"2008-04-01T09:00:00\">9am</abbr> through <abbr class=\"dtend\" title=\"2009-04-01T13:30:00\">Wednesday, April 1, 2009 at 1:30pm</abbr>" ]
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">Tuesday, April 1, 2008 at 9am</time> through <time class=\"dtend dt-end\" title=\"2009-04-01T13:30:00\" datetime=\"2009-04-01T13:30:00\">Wednesday, April 1, 2009 at 1:30pm</time>",
"<time class=\"dtstart dt-start\" title=\"2008-04-01T09:00:00\" datetime=\"2008-04-01T09:00:00\">9am</time> through <time class=\"dtend dt-end\" title=\"2009-04-01T13:30:00\" datetime=\"2009-04-01T13:30:00\">Wednesday, April 1, 2009 at 1:30pm</time>" ]
]

[nil, Date.new(2008, 4, 1)].each do |context_date|
Expand Down

0 comments on commit 8bc90ef

Please sign in to comment.