book cover

This commit is contained in:
Meutel 2015-07-05 10:22:19 +02:00
parent e5263033dd
commit 5f7dd8514f
3 changed files with 57 additions and 43 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@
*~ *~
*.*.swp *.*.swp
/vendor/ruby /vendor/ruby
/public/calibre

View File

@ -19,4 +19,8 @@ class Book < ActiveRecord::Base
has_one :book_serie_link, foreign_key: "book" has_one :book_serie_link, foreign_key: "book"
has_one :serie, through: :book_serie_link has_one :serie, through: :book_serie_link
def has_cover?
has_cover == 1
end
end end

View File

@ -5,6 +5,9 @@
</h1> </h1>
</div> </div>
<div class="row"> <div class="row">
<% if @book.has_cover? %>
<div class="col-xs-12 col-md-6">
<% end %>
<h2> <h2>
<span class="glyphicon glyphicon-user"></span> <span class="glyphicon glyphicon-user"></span>
<%= "Author".pluralize(@book.authors.count) %> <%= "Author".pluralize(@book.authors.count) %>
@ -51,4 +54,10 @@
<li><strong>Publisher</strong> <%= @book.publisher.name %></li> <li><strong>Publisher</strong> <%= @book.publisher.name %></li>
<% end %> <% end %>
</ul> </ul>
</div>
<% if @book.has_cover? %>
<div class="col-xs-12 col-md-6">
<img alt="No cover" class="img-responsive img-rounded" src="<%= "/calibre/#{url_encode(@book.path)}/cover.jpg" %>"/>
</div>
<% end %>
</div> </div>