enju_manifestation_viewer 0.1.0.pre5 → 0.1.0.pre6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/manifestations/_google_book_thumbnail.html.erb +5 -0
- data/app/views/manifestations/_google_book_thumbnail_header.html.erb +43 -0
- data/lib/enju_manifestation_viewer/book_jacket_helper.rb +94 -0
- data/lib/enju_manifestation_viewer/version.rb +1 -1
- data/lib/enju_manifestation_viewer.rb +2 -0
- data/lib/generators/enju_manifestation_viewer/setup/USAGE +8 -0
- data/lib/generators/enju_manifestation_viewer/setup/setup_generator.rb +8 -0
- data/spec/dummy/app/models/setting.rb +4 -0
- data/spec/dummy/config/application.rb +2 -0
- data/spec/dummy/config/application.yml +38 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/helpers/book_jacket_helper_spec.rb +28 -0
- data/spec/spec_helper.rb +8 -0
- metadata +43 -6
- data/spec/dummy/log/test.log +0 -564
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4150e203781e05840b564eb46ef7f6f565bb08af
|
4
|
+
data.tar.gz: b8be289f020bf8280f06594d04564768447e5df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38680e9f107a17b6722d0dca062b5c7a2c020e6be7c45a563432349cf58b5e320b22956552b6edc011bec7655ab9e964d8eae518278eaaf1e5656b758634238b
|
7
|
+
data.tar.gz: b6b11f3f14c8083e3ca9bdaf30eb3c502a6ef77c678362b127459df78f020fd22bd45a40867ae0568e5b32b266fe85e3c05b378f624920a5dd2d49e602706f6c
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
function addTheCover(booksInfo){
|
3
|
+
jQuery(function(){
|
4
|
+
var link = '';
|
5
|
+
for (i in booksInfo.items) {
|
6
|
+
var book = booksInfo.items[i]
|
7
|
+
var image = book.volumeInfo.imageLinks;
|
8
|
+
if (image && image.thumbnail != undefined) {
|
9
|
+
var thumbnail = image.thumbnail.replace('zoom=5', 'zoom=1');
|
10
|
+
if ( document.location.protocol == 'https:' ) {
|
11
|
+
var parser = document.createElement('a');
|
12
|
+
parser.href = thumbnail;
|
13
|
+
parser.protocol = 'https:';
|
14
|
+
parser.hostname = 'encrypted.google.com';
|
15
|
+
thumbnail = parser.href;
|
16
|
+
}
|
17
|
+
if (thumbnail) {
|
18
|
+
var link = '<img src="' + thumbnail + '" alt="' + book.volumeInfo.title + '" />';
|
19
|
+
if (book.accessInfo && book.accessInfo.viewability != "NO_PAGES") {
|
20
|
+
var preview = book.volumeInfo.previewLink;
|
21
|
+
link += '<br /><a href="' + preview + '" target="_blank"><img border=0 src="//www.google.com/googlebooks/images/gbs_preview_button1.gif" title="Google Preview" alt="Google Preview" /></a>';
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
if (link === '') {
|
27
|
+
<% if Setting.book_jacket.unknown_resource.blank? %>
|
28
|
+
var link = '<%= image_tag("unknown_resource.png", :size => "150x150", :alt => "*") %>';
|
29
|
+
<% else %>
|
30
|
+
var link = '<%= Setting.book_jacket.unknown_resource %>';
|
31
|
+
<% end %>
|
32
|
+
}
|
33
|
+
|
34
|
+
var thumb_element = document.getElementById('gbsthumbnail');
|
35
|
+
if (thumb_element) {
|
36
|
+
thumb_element.innerHTML = link;
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
</script>
|
41
|
+
<% if @manifestation.try(:isbn?) %>
|
42
|
+
<script src="https://www.googleapis.com/books/v1/volumes?q=isbn:<%= @manifestation.isbn %>&callback=addTheCover"></script>
|
43
|
+
<% end %>
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module EnjuManifestationViewer
|
2
|
+
module BookJacketHelper
|
3
|
+
def book_jacket(manifestation)
|
4
|
+
if manifestation.picture_files.exists?
|
5
|
+
link = ''
|
6
|
+
manifestation.picture_files.each_with_index do |picture_file, i|
|
7
|
+
if i == 0
|
8
|
+
link += link_to(show_image(picture_file, :size => :thumb), picture_file_path(picture_file, :format => :download), :rel => "manifestation_#{manifestation.id}")
|
9
|
+
else
|
10
|
+
link += content_tag :span, :style => "display: none" do
|
11
|
+
link_to(show_image(picture_file, :size => :thumb), picture_file_path(picture_file, :format => :download), :rel => "manifestation_#{manifestation.id}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
return link.html_safe
|
16
|
+
else
|
17
|
+
link = book_jacket_tag(manifestation)
|
18
|
+
unless link
|
19
|
+
link = screenshot_tag(manifestation)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
unless link
|
24
|
+
link = link_to image_tag('unknown_resource.png', :width => '100', :height => '100', :alt => '*', :itemprop => 'image'), manifestation
|
25
|
+
end
|
26
|
+
link
|
27
|
+
end
|
28
|
+
|
29
|
+
def screenshot_tag(manifestation, generator = Setting.screenshot.generator)
|
30
|
+
return nil unless manifestation.try(:access_address)
|
31
|
+
case generator
|
32
|
+
when :mozshot
|
33
|
+
link_to image_tag("http://mozshot.nemui.org/shot?#{manifestation.access_address}", :width => 128, :height => 128, :alt => manifestation.original_title, :border => 0, :itemprop => 'image'), manifestation.access_address
|
34
|
+
when :simpleapi
|
35
|
+
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
|
36
|
+
when :heartrails
|
37
|
+
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
|
38
|
+
when :thumbalizr
|
39
|
+
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
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def book_jacket_tag(manifestation, generator = Setting.book_jacket.source)
|
44
|
+
return nil unless manifestation
|
45
|
+
case generator
|
46
|
+
when :amazon
|
47
|
+
return nil unless Setting.amazon.hostname
|
48
|
+
book_jacket = manifestation.amazon_book_jacket
|
49
|
+
if book_jacket
|
50
|
+
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://#{Setting.amazon.hostname}/dp/#{book_jacket[:asin]}"
|
51
|
+
end
|
52
|
+
when :google
|
53
|
+
render :partial => 'manifestations/google_book_thumbnail', :locals => {:manifestation => manifestation}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def amazon_link(asin, hostname = Setting.amazon.hostname)
|
58
|
+
return nil if asin.blank?
|
59
|
+
"http://#{hostname}/dp/#{asin}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def book_jacket_source_link
|
63
|
+
case Setting.book_jacket.source
|
64
|
+
when :google
|
65
|
+
link_to "Google Books", "http://books.google.com/"
|
66
|
+
when :amazon
|
67
|
+
link_to "Amazon Web Services", "http://aws.amazon.com/"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def book_jacket_header(source)
|
72
|
+
string = ''
|
73
|
+
case source
|
74
|
+
when :google
|
75
|
+
string << javascript_tag(nil, :src => "https://www.google.com/jsapi")
|
76
|
+
string << render('manifestations/google_book_thumbnail_header')
|
77
|
+
end
|
78
|
+
string.html_safe
|
79
|
+
end
|
80
|
+
|
81
|
+
def screenshot_generator_link
|
82
|
+
case Setting.screenshot.generator
|
83
|
+
when :mozshot
|
84
|
+
link_to "MozShot", "http://mozshot.nemui.org/"
|
85
|
+
when :simpleapi
|
86
|
+
link_to "SimpleAPI", "http://img.simpleapi.net/"
|
87
|
+
when :heartrails
|
88
|
+
link_to "HeartRails Capture", "http://capture.heartrails.com/"
|
89
|
+
when :thumbalizr
|
90
|
+
link_to "thumbalizr", "http://www.thumbalizr.com/"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require "enju_manifestation_viewer/engine"
|
2
2
|
require "enju_manifestation_viewer/manifestation_viewer_helper"
|
3
|
+
require "enju_manifestation_viewer/book_jacket_helper"
|
3
4
|
require "addressable/uri"
|
4
5
|
|
5
6
|
module EnjuManifestationViewer
|
@@ -51,3 +52,4 @@ end
|
|
51
52
|
|
52
53
|
ActiveRecord::Base.send :include, EnjuManifestationViewer
|
53
54
|
ActionView::Base.send :include, EnjuManifestationViewer::ManifestationViewerHelper
|
55
|
+
ActionView::Base.send :include, EnjuManifestationViewer::BookJacketHelper
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class EnjuManifestationViewer::SetupGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def setup
|
5
|
+
rake("enju_purchase_request_engine:install:migrations")
|
6
|
+
inject_into_class 'app/models/manifestation.rb', Manifestation,
|
7
|
+
" enju_manifestation_viewer\n"
|
8
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
enju:
|
3
|
+
web_hostname: localhost
|
4
|
+
web_port_number: 3000
|
5
|
+
|
6
|
+
family_name_first: true
|
7
|
+
max_number_of_results: 500
|
8
|
+
write_search_log_to_file: true
|
9
|
+
csv_charset_conversion: true
|
10
|
+
|
11
|
+
# Choose a locale from 'ca', 'de', 'fr', 'jp', 'uk', 'us'
|
12
|
+
#AMAZON_AWS_HOSTNAME = 'ecs.amazonaws.com'
|
13
|
+
amazon:
|
14
|
+
aws_hostname: ecs.amazonaws.jp
|
15
|
+
hostname: www.amazon.co.jp
|
16
|
+
access_key: REPLACE_WITH_YOUR_AMAZON_ACCESS_KEY
|
17
|
+
secret_access_key: REPLACE_WITH_YOUR_AMAZON_SECRET_ACCESS_KEY
|
18
|
+
|
19
|
+
# :google, :amazon
|
20
|
+
book_jacket:
|
21
|
+
source: :google
|
22
|
+
unknown_resource:
|
23
|
+
|
24
|
+
# :mozshot, :simpleapi, :heartrails, :thumbalizr
|
25
|
+
screenshot:
|
26
|
+
generator: :mozshot
|
27
|
+
|
28
|
+
uploaded_file:
|
29
|
+
storage: :local
|
30
|
+
|
31
|
+
development:
|
32
|
+
<<: *defaults
|
33
|
+
|
34
|
+
test:
|
35
|
+
<<: *defaults
|
36
|
+
|
37
|
+
production:
|
38
|
+
<<: *defaults
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# Specs in this file have access to a helper object that includes
|
5
|
+
# the PatronsHelper. For example:
|
6
|
+
#
|
7
|
+
# describe PatronsHelper do
|
8
|
+
# describe "string concat" do
|
9
|
+
# it "concats two strings with spaces" do
|
10
|
+
# helper.concat_strings("this","that").should == "this that"
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
# end
|
14
|
+
describe EnjuManifestationViewer::BookJacketHelper do
|
15
|
+
fixtures :manifestations
|
16
|
+
|
17
|
+
it "should get screenshot", :vcr => true do
|
18
|
+
helper.screenshot_tag(manifestations(:manifestation_00003)).should eq "<a href=\"http://www.slis.keio.ac.jp/\"><img alt=\"これからの生命科学研究者のためのバイオ特許入門講座\" border=\"0\" height=\"128\" itemprop=\"image\" src=\"http://mozshot.nemui.org/shot?http://www.slis.keio.ac.jp/\" width=\"128\" /></a>"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should get book jacket" do
|
22
|
+
helper.book_jacket_tag(manifestations(:manifestation_00001)).should =~ /<div id=\"gbsthumbnail\" class=\"book_jacket\"><\/div>/
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should generate a link to Amazon" do
|
26
|
+
helper.amazon_link(manifestations(:manifestation_00001).isbn).should =~ /http:\/\/www.amazon.co.jp\/dp\/4798002062/
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,7 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
3
3
|
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
4
|
require 'rspec/rails'
|
5
5
|
require 'rspec/autorun'
|
6
|
+
require 'vcr'
|
6
7
|
|
7
8
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
8
9
|
# in spec/support/ and its subdirectories.
|
@@ -30,3 +31,10 @@ RSpec.configure do |config|
|
|
30
31
|
# rspec-rails.
|
31
32
|
config.infer_base_class_for_anonymous_controllers = false
|
32
33
|
end
|
34
|
+
|
35
|
+
VCR.configure do |c|
|
36
|
+
c.cassette_library_dir = 'spec/cassette_library'
|
37
|
+
c.hook_into :fakeweb
|
38
|
+
c.configure_rspec_metadata!
|
39
|
+
c.allow_http_connections_when_no_cassette = true
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_manifestation_viewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kosuke Tanabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.0.
|
33
|
+
version: 0.1.0.pre30
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.0.
|
40
|
+
version: 0.1.0.pre30
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fakeweb
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
83
111
|
description: embed external contents on Next-L Enju
|
84
112
|
email:
|
85
113
|
- tanabe@mwr.mediacom.keio.ac.jp
|
@@ -89,14 +117,19 @@ extra_rdoc_files: []
|
|
89
117
|
files:
|
90
118
|
- app/views/manifestations/_flickr.html.erb
|
91
119
|
- app/views/manifestations/_google_book_search.html.erb
|
120
|
+
- app/views/manifestations/_google_book_thumbnail.html.erb
|
121
|
+
- app/views/manifestations/_google_book_thumbnail_header.html.erb
|
92
122
|
- app/views/manifestations/_nicovideo.html.erb
|
93
123
|
- app/views/manifestations/_scribd.html.erb
|
94
124
|
- app/views/manifestations/_youtube.html.erb
|
95
125
|
- config/routes.rb
|
126
|
+
- lib/enju_manifestation_viewer/book_jacket_helper.rb
|
96
127
|
- lib/enju_manifestation_viewer/engine.rb
|
97
128
|
- lib/enju_manifestation_viewer/manifestation_viewer_helper.rb
|
98
129
|
- lib/enju_manifestation_viewer/version.rb
|
99
130
|
- lib/enju_manifestation_viewer.rb
|
131
|
+
- lib/generators/enju_manifestation_viewer/setup/setup_generator.rb
|
132
|
+
- lib/generators/enju_manifestation_viewer/setup/USAGE
|
100
133
|
- lib/generators/enju_manifestation_viewer/views_generator.rb
|
101
134
|
- lib/tasks/enju_manifestation_viewer_tasks.rake
|
102
135
|
- MIT-LICENSE
|
@@ -107,8 +140,10 @@ files:
|
|
107
140
|
- spec/dummy/app/controllers/application_controller.rb
|
108
141
|
- spec/dummy/app/helpers/application_helper.rb
|
109
142
|
- spec/dummy/app/models/manifestation.rb
|
143
|
+
- spec/dummy/app/models/setting.rb
|
110
144
|
- spec/dummy/app/views/layouts/application.html.erb
|
111
145
|
- spec/dummy/config/application.rb
|
146
|
+
- spec/dummy/config/application.yml
|
112
147
|
- spec/dummy/config/boot.rb
|
113
148
|
- spec/dummy/config/database.yml
|
114
149
|
- spec/dummy/config/environment.rb
|
@@ -130,7 +165,6 @@ files:
|
|
130
165
|
- spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb
|
131
166
|
- spec/dummy/db/schema.rb
|
132
167
|
- spec/dummy/db/test.sqlite3
|
133
|
-
- spec/dummy/log/test.log
|
134
168
|
- spec/dummy/public/404.html
|
135
169
|
- spec/dummy/public/422.html
|
136
170
|
- spec/dummy/public/500.html
|
@@ -139,6 +173,7 @@ files:
|
|
139
173
|
- spec/dummy/README.rdoc
|
140
174
|
- spec/dummy/script/rails
|
141
175
|
- spec/fixtures/manifestations.yml
|
176
|
+
- spec/helpers/book_jacket_helper_spec.rb
|
142
177
|
- spec/helpers/manifestation_viewer_helper_spec.rb
|
143
178
|
- spec/spec_helper.rb
|
144
179
|
homepage: https://github.com/next-l/enju_manifestation_viewer
|
@@ -170,8 +205,10 @@ test_files:
|
|
170
205
|
- spec/dummy/app/controllers/application_controller.rb
|
171
206
|
- spec/dummy/app/helpers/application_helper.rb
|
172
207
|
- spec/dummy/app/models/manifestation.rb
|
208
|
+
- spec/dummy/app/models/setting.rb
|
173
209
|
- spec/dummy/app/views/layouts/application.html.erb
|
174
210
|
- spec/dummy/config/application.rb
|
211
|
+
- spec/dummy/config/application.yml
|
175
212
|
- spec/dummy/config/boot.rb
|
176
213
|
- spec/dummy/config/database.yml
|
177
214
|
- spec/dummy/config/environment.rb
|
@@ -193,7 +230,6 @@ test_files:
|
|
193
230
|
- spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb
|
194
231
|
- spec/dummy/db/schema.rb
|
195
232
|
- spec/dummy/db/test.sqlite3
|
196
|
-
- spec/dummy/log/test.log
|
197
233
|
- spec/dummy/public/404.html
|
198
234
|
- spec/dummy/public/422.html
|
199
235
|
- spec/dummy/public/500.html
|
@@ -202,5 +238,6 @@ test_files:
|
|
202
238
|
- spec/dummy/README.rdoc
|
203
239
|
- spec/dummy/script/rails
|
204
240
|
- spec/fixtures/manifestations.yml
|
241
|
+
- spec/helpers/book_jacket_helper_spec.rb
|
205
242
|
- spec/helpers/manifestation_viewer_helper_spec.rb
|
206
243
|
- spec/spec_helper.rb
|