Module: EnjuManifestationViewer::BookJacketHelper

Defined in:
app/helpers/enju_manifestation_viewer/book_jacket_helper.rb

Instance Method Summary collapse

Instance Method Details



60
61
62
63
64
# File 'app/helpers/enju_manifestation_viewer/book_jacket_helper.rb', line 60

def amazon_link(asin, hostname = LibraryGroup.site_config.settings[:amazon_hostname])
  return nil if asin.blank?

  "http://#{hostname}/dp/#{asin}"
end

#book_jacket(manifestation) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/helpers/enju_manifestation_viewer/book_jacket_helper.rb', line 3

def book_jacket(manifestation)
  if manifestation.picture_files.exists?
    link = ''
    manifestation.picture_files.each_with_index do |picture_file, i|
      link += if i == 0
                link_to(show_image(picture_file, size: :thumb), picture_file_path(picture_file, format: :download), rel: "manifestation_#{manifestation.id}")
              else
                 :span, style: "display: none" do
                  link_to(show_image(picture_file, size: :thumb), picture_file_path(picture_file, format: :download), rel: "manifestation_#{manifestation.id}")
                end
              end
    end
    return link.html_safe
  else
    link = book_jacket_tag(manifestation)
    link ||= screenshot_tag(manifestation)
  end

  link ||= link_to image_tag('unknown_resource.png', width: '100', height: '100', alt: '*', itemprop: 'image'), manifestation
  link
end

#book_jacket_header(source = LibraryGroup.site_config.book_jacket_source) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'app/helpers/enju_manifestation_viewer/book_jacket_helper.rb', line 75

def book_jacket_header(source = LibraryGroup.site_config.book_jacket_source)
  string = ''
  case source
  when "google"
    string << javascript_tag(nil, src: "https://www.google.com/jsapi")
    string << render('manifestations/google_book_thumbnail_header')
  when "openbd"
    string << render('manifestations/openbd_thumbnail_header')
  end
  string.html_safe
end


66
67
68
69
70
71
72
73
# File 'app/helpers/enju_manifestation_viewer/book_jacket_helper.rb', line 66

def book_jacket_source_link(source = LibraryGroup.site_config.book_jacket_source)
  case source
  when "google"
    link_to "Google Books", "http://books.google.com/"
  when "amazon"
    link_to "Amazon Web Services", "http://aws.amazon.com/"
  end
end

#book_jacket_tag(manifestation, generator = LibraryGroup.site_config.book_jacket_source) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/enju_manifestation_viewer/book_jacket_helper.rb', line 40

def book_jacket_tag(manifestation, generator = LibraryGroup.site_config.book_jacket_source)
  return nil unless manifestation

  case generator
  when "amazon"
    return nil unless LibraryGroup.site_config.settings[:amazon_hostname]

    book_jacket = manifestation.amazon_book_jacket
    if book_jacket
      link_to image_tag(book_jacket[:url], width: book_jacket[:width], height: book_jacket[:height], alt: manifestation.original_title, class: 'book_jacket', itemprop: 'image'), "http://#{LibraryGroup.site_config.settings[:amazon_hostname]}/dp/#{book_jacket[:asin]}"
    end
  when "google"
    render partial: 'manifestations/google_book_thumbnail', locals: {manifestation: manifestation}
  when "hanmotocom"
    render partial: 'manifestations/hanmotocom_thumbnail', locals: {manifestation: manifestation}
  when "openbd"
    render partial: 'manifestations/openbd_thumbnail', locals: {manifestation: manifestation}
  end
end


87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/helpers/enju_manifestation_viewer/book_jacket_helper.rb', line 87

def screenshot_generator_link(generator = LibraryGroup.site_config.screenshot_generator)
  case generator
  when "mozshot"
    link_to "MozShot", "http://mozshot.nemui.org/"
  when "simpleapi"
    link_to "SimpleAPI", "http://img.simpleapi.net/"
  when "heartrails"
    link_to "HeartRails Capture", "http://capture.heartrails.com/"
  when "thumbalizr"
    link_to "thumbalizr", "http://www.thumbalizr.com/"
  end
end

#screenshot_tag(manifestation, generator = LibraryGroup.site_config.screenshot_generator) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/enju_manifestation_viewer/book_jacket_helper.rb', line 25

def screenshot_tag(manifestation, generator = LibraryGroup.site_config.screenshot_generator)
  return nil unless manifestation.try(:access_address)

  case generator
  when "mozshot"
    link_to image_tag("https://blinky.nemui.org/shot?#{manifestation.access_address}", width: 128, height: 128, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
  when "simpleapi"
    link_to image_tag("http://img.simpleapi.net/small/#{manifestation.access_address}", width: 128, height: 128, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
  when "heartrails"
    link_to image_tag("http://capture.heartrails.com/medium?#{manifestation.access_address}", width: 120, height: 90, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
  when "thumbalizr"
    link_to image_tag("http://api.thumbalizr.com/?url=#{manifestation.access_address}&width=128", width: 128, height: 144, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
  end
end