Class: Protozoa::Views::History

Inherits:
Layout
  • Object
show all
Defined in:
lib/amiba/frontend/views/history.rb

Instance Attribute Summary collapse

Attributes inherited from Layout

#name

Instance Method Summary collapse

Methods inherited from Layout

#edit_url, #escaped_name, #view_url

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



4
5
6
# File 'lib/amiba/frontend/views/history.rb', line 4

def page
  @page
end

#page_numObject (readonly)

Returns the value of attribute page_num.



4
5
6
# File 'lib/amiba/frontend/views/history.rb', line 4

def page_num
  @page_num
end

Instance Method Details



34
35
36
37
38
39
40
41
# File 'lib/amiba/frontend/views/history.rb', line 34

def next_link
  label = "Next »"
  if @versions.size == Gollum::Page.per_page
    %(<a href="/history/#{@page.name}?page=#{@page_num+1}" hotkey="l">#{label}</a>)
  else
    %(<span class="disabled">#{label}</span>)
  end
end


25
26
27
28
29
30
31
32
# File 'lib/amiba/frontend/views/history.rb', line 25

def previous_link
  label = "&laquo; Previous"
  if @page_num == 1
    %(<span class="disabled">#{label}</span>)
  else
    %(<a href="/history/#{@page.name}?page=#{@page_num-1}" hotkey="h">#{label}</a>)
  end
end

#titleObject



6
7
8
# File 'lib/amiba/frontend/views/history.rb', line 6

def title
  @page.title
end

#versionsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/amiba/frontend/views/history.rb', line 10

def versions
  i = @versions.size + 1
  @versions.map do |v|
    i -= 1
    { :id       => v.id,
      :id7      => v.id[0..6],
      :num      => i,
      :selected => @page.version.id == v.id,
      :author   => v.author.name,
      :message  => v.message,
      :date     => v.committed_date.strftime("%B %d, %Y"),
      :gravatar => Digest::MD5.hexdigest(v.author.email) }
  end
end