From 5f7dd8514fa8fbcf205d43c745c637fa5197b512 Mon Sep 17 00:00:00 2001 From: Meutel Date: Sun, 5 Jul 2015 10:22:19 +0200 Subject: [PATCH] book cover --- .gitignore | 1 + app/models/book.rb | 4 ++ app/views/books/show.html.erb | 95 +++++++++++++++++++---------------- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index a210281..ce31b1d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ *~ *.*.swp /vendor/ruby +/public/calibre diff --git a/app/models/book.rb b/app/models/book.rb index ccfed92..d6868ea 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -19,4 +19,8 @@ class Book < ActiveRecord::Base has_one :book_serie_link, foreign_key: "book" has_one :serie, through: :book_serie_link + + def has_cover? + has_cover == 1 + end end diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 3eecd0f..be4b63f 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -5,50 +5,59 @@
-

- - <%= "Author".pluralize(@book.authors.count) %> -

- - <% if @book.serie %> -

- - Serie -

-
- <%= link_to @book.serie.name, @book.serie %> - <%= @book.series_index.to_i %> +

+ + <%= "Language".pluralize(@book.languages.count) %> +

+
+ <% @book.languages.each do |language| %> + <%= language.lang_code %> + <% end %> +
+

+ + <%= "Tag".pluralize(@book.tags.count) %> +

+
+ <% @book.tags.each do |tag| %> + <%= tag.name %> + <% end %> +
+

Details

+
    + <% if @book.pubdate %> +
  • Publishing date <%= @book.pubdate.to_formatted_s(:date) %>
  • + <% end %> + <% if @book.publisher %> +
  • Publisher <%= @book.publisher.name %>
  • + <% end %> +
- <% end %> -

- - <%= "Language".pluralize(@book.languages.count) %> -

-
- <% @book.languages.each do |language| %> - <%= language.lang_code %> - <% end %> +<% if @book.has_cover? %> +
+ No cover"/>
-

- - <%= "Tag".pluralize(@book.tags.count) %> -

-
- <% @book.tags.each do |tag| %> - <%= tag.name %> - <% end %> -
-

Details

-
    - <% if @book.pubdate %> -
  • Publishing date <%= @book.pubdate.to_formatted_s(:date) %>
  • - <% end %> - <% if @book.publisher %> -
  • Publisher <%= @book.publisher.name %>
  • - <% end %> -
+<% end %>