Page MenuHomeGRNET

No OneTemporary

File Metadata

Created
Sat, Mar 21, 3:41 PM
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 03a5d23..7bc03bb 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,59 +1,57 @@
module ApplicationHelper
TIME_PERIODS = {
1.second => 'second',
1.minute => 'minute',
1.hour => 'hour',
1.day => 'day',
1.week => 'week',
1.month => 'month',
1.year => 'year',
}
def can_edit?(object)
return true if admin?
return true unless object.respond_to?(:editable?)
object.editable?
end
def seconds_to_human(seconds)
acc = {}
remaining = seconds
TIME_PERIODS.to_a.reverse_each do |p, human|
period_count, remaining = remaining.divmod(p)
acc[human] = period_count if not period_count.zero?
end
acc.map { |singular, count|
human = count < 2 ? singular : "#{singular}s"
"#{count} #{human}"
}.join(', ')
end
def link_to_edit(*args, &block)
link_to(abbr_glyph(:pencil, 'Edit'), *args, &block)
end
def link_to_destroy(*args, &block)
link_to(abbr_glyph(:remove, 'Remove'), *args, &block)
end
def link_to_enable(*args, &block)
link_to(abbr_glyph(:'eye-close', 'Enable'), *args, &block)
end
def link_to_disable(*args, &block)
link_to(abbr_glyph(:'eye-open', 'Disable'), *args, &block)
end
def glyph(icon)
content_tag(:span, '', class: "glyphicon glyphicon-#{icon}")
end
- private
-
def abbr_glyph(icon, title)
content_tag(:abbr, glyph(icon), title: title)
end
end
diff --git a/app/views/domains/index.html.erb b/app/views/domains/index.html.erb
index 7c7d6dc..ca04204 100644
--- a/app/views/domains/index.html.erb
+++ b/app/views/domains/index.html.erb
@@ -1,31 +1,31 @@
<table class="table table-striped">
<thead>
</thead>
<tbody>
<% @domains.group_by(&:group).each do |group, domains| %>
<tr>
<th colspan="2"><%= link_to group.name, group_path(group) %></th>
<th colspan="2">Controls</th>
</tr>
<% domains.each do |domain| %>
<tr>
<td><%= link_to domain.name, domain %></td>
<td>
<% if domain.reverse? %>
- <abbr title="Reverse"><span class="glyphicon glyphicon-chevron-left"></span></abbr>
+ <%= abbr_glyph('chevron-left', 'Reverse') %>
<% else %>
- <abbr title="Forward"><span class="glyphicon glyphicon-chevron-right"></span></abbr>
+ <%= abbr_glyph('chevron-right', 'Forward') %>
<% end %>
</td>
<td><%= link_to_edit edit_domain_path(domain) %></td>
<td><%= link_to_destroy domain, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<p>
<%= link_to 'New Domain &raquo;'.html_safe, new_domain_path, class: 'btn btn-lg btn-primary' %>
</p>

Event Timeline