Class: App::Views::Citing

Inherits:
Layout
  • Object
show all
Includes:
App::ViewHelpers
Defined in:
app/views/citing.rb

Instance Method Summary collapse

Methods included from App::ViewHelpers

#add_book_button, #admin, #admin?, #app_name, #base_url, #book_permitted, #count_instances, #external_link_glyph, #flag_modal_button, #flags, #get_instances_per_page, #instance_permitted, #instances_by_names, #javascripts, #json_file, #logged_in, #map_height, #metadata, #not_empty, #place_permitted, #places, #rendered_flash, #stylesheets, #user_name

Methods inherited from Layout

#page_title, #selected_item

Instance Method Details

#all_authorsObject


25
26
27
28
# File 'app/views/citing.rb', line 25

def all_authors
  users = Instance.all_users_sorted_by_count.map{ |u| User[u.user_id] }
  authors_string(users)
end

#authors(book) ⇒ Object

A DataMapper list of Users


20
21
22
23
# File 'app/views/citing.rb', line 20

def authors(book) # A DataMapper list of Users
  users = Instance.all_users_sorted_by_count(book).map{ |u| User[u.user_id] }
  authors_string(users)
end

#authors_string(users) ⇒ Object


30
31
32
33
34
35
36
37
38
39
# File 'app/views/citing.rb', line 30

def authors_string(users)
  first_author = users.shift
  author_names = [first_author.fullname_lastname_first]
  if users.length > 0
    users.each do |user|
      author_names << user.fullname
    end
  end
  author_names.to_sentence
end

#cite_booksObject


10
11
12
13
14
15
16
17
18
# File 'app/views/citing.rb', line 10

def cite_books
  @books.map{ |book| {
    authors: authors(book),
    book_title: book.title,
    book_author: book.author,
    book_slug: book.slug
    }
  }
end

#todayObject


6
7
8
# File 'app/views/citing.rb', line 6

def today
  Time.now.strftime("%e %B %Y")
end