diff --git a/app/controllers/admin/books_controller.rb b/app/controllers/admin/books_controller.rb
index d922f57..9845722 100644
--- a/app/controllers/admin/books_controller.rb
+++ b/app/controllers/admin/books_controller.rb
@@ -8,7 +8,7 @@ class Admin::BooksController < OrbitMemberController
before_action :set_plugin
def index
- @writing_books = Book.all
+ @writing_books = Book.order_by(:year=>'desc').page(params[:page]).per(10)
respond_to do |format|
format.html # index.html.erb
format.js { }
diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb
index 346b5b6..f8ee1d2 100644
--- a/app/controllers/books_controller.rb
+++ b/app/controllers/books_controller.rb
@@ -1,16 +1,23 @@
class BooksController < ApplicationController
def index
- books = Book.asc(:created_at)
+ books = Book.order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
book_list = books.collect do |book|
{
"book_title" => book.book_title,
- "authors" => book.authors,
+ "author" => book.authors,
+ "year" => book.year,
"link_to_show" => OrbitHelper.url_to_show(book.to_param)
}
end
{
"books" => book_list,
- "extras" => {"widget-title" => "Books"}
+ "extras" => {
+ "widget-title" => t("module_name.book"),
+ "th_year" => t('personal_plugins.year'),
+ "th_title" => t("personal_book.book_title"),
+ "th_author" => t('personal_plugins.author')
+ },
+ "total_pages" => books.total_pages
}
end
diff --git a/app/views/admin/books/_writing_book.html.erb b/app/views/admin/books/_writing_book.html.erb
index 75c4b45..4cde60e 100644
--- a/app/views/admin/books/_writing_book.html.erb
+++ b/app/views/admin/books/_writing_book.html.erb
@@ -1,15 +1,17 @@
-
- <%= writing_book.year %> |
-
- <%= link_to writing_book.create_link, page_for_book(writing_book), target: "blank" %>
-
-
- <%if current_user.is_admin?%>
- - <%= link_to t('edit'), edit_admin_book_path(writing_book) %>
- - <%= link_to t(:delete_), admin_book_path(writing_book), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %>
- <% end -%>
-
-
- |
- <%= writing_book.authors%> |
-
\ No newline at end of file
+<% @writing_books.each do |writing_book| %>
+
+ <%= writing_book.year %> |
+
+ <%= link_to writing_book.create_link, page_for_book(writing_book), target: "blank" %>
+
+
+ <%if current_user.is_admin?%>
+ - <%= link_to t('edit'), edit_admin_book_path(writing_book) %>
+ - <%= link_to t(:delete_), admin_book_path(writing_book), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %>
+ <% end -%>
+
+
+ |
+ <%= writing_book.authors%> |
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/books/index.html.erb b/app/views/admin/books/index.html.erb
index e96a2cc..3ef33ce 100644
--- a/app/views/admin/books/index.html.erb
+++ b/app/views/admin/books/index.html.erb
@@ -7,7 +7,7 @@
- <%= render :partial => 'writing_book', :collection => @writing_books %>
+ <%= render 'writing_book' %>
@@ -16,4 +16,7 @@
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_book_setting_path, :class => 'btn btn-primary pull-right' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_admin_book_path, :class => 'btn btn-primary pull-right' %>
+
\ No newline at end of file
diff --git a/lib/personal_book/engine.rb b/lib/personal_book/engine.rb
index 1aeeac1..916141a 100644
--- a/lib/personal_book/engine.rb
+++ b/lib/personal_book/engine.rb
@@ -13,6 +13,7 @@ module PersonalBook
update_info 'some update_info'
frontend_enabled
icon_class_no_sidebar "icons-user"
+ data_count 1..10
end
end
end