Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kosuke Tanabe committed Feb 4, 2012
0 parents commit a933c23
Show file tree
Hide file tree
Showing 69 changed files with 7,299 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--colour
17 changes: 17 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
source "http://rubygems.org"

# Declare your gem's dependencies in enju_book_jacket.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# jquery-rails is used by the dummy application
gem "jquery-rails"

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
116 changes: 116 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
PATH
remote: .
specs:
enju_book_jacket (0.0.1)
configatron
rails (~> 3.2)

GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.1)
actionpack (= 3.2.1)
mail (~> 2.4.0)
actionpack (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
activemodel (3.2.1)
activesupport (= 3.2.1)
builder (~> 3.0.0)
activerecord (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
arel (~> 3.0.0)
tzinfo (~> 0.3.29)
activeresource (3.2.1)
activemodel (= 3.2.1)
activesupport (= 3.2.1)
activesupport (3.2.1)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.0)
builder (3.0.0)
configatron (2.9.0)
yamler (>= 0.1.0)
diff-lcs (1.1.3)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.1)
jquery-rails (2.0.0)
railties (>= 3.2.0.beta, < 5.0)
thor (~> 0.14)
json (1.6.5)
mail (2.4.1)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.2.1)
actionmailer (= 3.2.1)
actionpack (= 3.2.1)
activerecord (= 3.2.1)
activeresource (= 3.2.1)
activesupport (= 3.2.1)
bundler (~> 1.0)
railties (= 3.2.1)
railties (3.2.1)
actionpack (= 3.2.1)
activesupport (= 3.2.1)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.8.0)
rspec-core (~> 2.8.0)
rspec-expectations (~> 2.8.0)
rspec-mocks (~> 2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
rspec-rails (2.8.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.8.0)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
yamler (0.1.0)

PLATFORMS
ruby

DEPENDENCIES
enju_book_jacket!
jquery-rails
rspec-rails
sqlite3
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2012 YOURNAME

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= EnjuBookJacket

This project rocks and uses MIT-LICENSE.
37 changes: 37 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'EnjuBookJacket'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'



Bundler::GemHelper.install_tasks

require 'rspec/core'
require 'rspec/core/rake_task'

RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end

task :default => :spec
Empty file.
Empty file.
Empty file.
Empty file added app/controllers/.gitkeep
Empty file.
Empty file added app/helpers/.gitkeep
Empty file.
Empty file added app/mailers/.gitkeep
Empty file.
Empty file added app/models/.gitkeep
Empty file.
Empty file added app/views/.gitkeep
Empty file.
16 changes: 16 additions & 0 deletions app/views/manifestations/_google_book_thumbnail.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div id="gbsthumbnail" class="book_jacket"></div>

<script type="text/javascript">
function addTheCover(booksInfo){
var link = '<%= image_tag("unknown_resource.png", :size => "150x150", :alt => "*") %>';
for (i in booksInfo) {
var book = booksInfo[i];
if (book.thumbnail_url != undefined) {
link = '<img src="' + book.thumbnail_url.replace('zoom=5', 'zoom=1') + '"/>';
}
}
document.getElementById('gbsthumbnail').innerHTML = link;
}
</script>

<script src="http://books.google.com/books?jscmd=viewapi&bibkeys=ISBN:<%= manifestation.isbn %>&callback=addTheCover"></script>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rails.application.routes.draw do
end
25 changes: 25 additions & 0 deletions enju_book_jacket.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$:.push File.expand_path("../lib", __FILE__)

# Maintain your gem's version:
require "enju_book_jacket/version"

# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "enju_book_jacket"
s.version = EnjuBookJacket::VERSION
s.authors = ["Kosuke Tanabe"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/nabeta/enju_book_jacket"
s.summary = "enju_book_jacket plugin"
s.description = "Display book jackets on Next-L Enju"

s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["spec/**/*"]

s.add_dependency "rails", "~> 3.2"
s.add_dependency "configatron"
# s.add_dependency "jquery-rails"

s.add_development_dependency "sqlite3"
s.add_development_dependency "rspec-rails"
end
5 changes: 5 additions & 0 deletions lib/enju_book_jacket.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "enju_book_jacket/engine"
require "enju_book_jacket/book_jacket_helper"

module EnjuBookJacket
end
36 changes: 36 additions & 0 deletions lib/enju_book_jacket/book_jacket_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module EnjuBookJacket
module BookJacketHelper
def screenshot_tag(manifestation, generator = configatron.screenshot.generator)
return nil unless manifestation.try(:access_address)
case generator
when :mozshot
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
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

def book_jacket_tag(manifestation, generator = configatron.book_jacket.source)
return nil unless manifestation
case generator
when :amazon
return nil unless configatron.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://#{configatron.amazon.hostname}/dp/#{book_jacket[:asin]}"
end
when :google
render :partial => 'manifestations/google_book_thumbnail', :locals => {:manifestation => manifestation}
end
end

def amazon_link(asin, hostname = configatron.amazon.hostname)
return nil if asin.blank?
"http://#{hostname}/dp/#{asin}"
end
end
end
6 changes: 6 additions & 0 deletions lib/enju_book_jacket/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'configatron'

module EnjuBookJacket
class Engine < ::Rails::Engine
end
end
3 changes: 3 additions & 0 deletions lib/enju_book_jacket/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module EnjuBookJacket
VERSION = "0.0.1"
end
4 changes: 4 additions & 0 deletions lib/tasks/enju_book_jacket_tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :enju_book_jacket do
# # Task goes here
# end
8 changes: 8 additions & 0 deletions script/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/enju_book_jacket/engine', __FILE__)

require 'rails/all'
require 'rails/engine/commands'
Loading

0 comments on commit a933c23

Please sign in to comment.