Compare commits
58 Commits
revert-91f
...
master
Author | SHA1 | Date |
---|---|---|
chiu | 393873135f | |
chiu | 7d0194e620 | |
chiu | 0d6ab9100c | |
chiu | d53e9a48c7 | |
chiu | 25449e9803 | |
chiu | 45d49bc290 | |
wmcheng | 0e2ba7ab1b | |
chiu | 52413762a3 | |
chiu | 46bf1679b2 | |
chiu | cf3b7ebc2b | |
chiu | 6a058ebbab | |
chiu | cd9c36c283 | |
chiu | 100bce4208 | |
chiu | 05d57635ca | |
chiu | 6864592244 | |
chiu | 1a373605ef | |
chiu | fda398e8a8 | |
chiu | fe636d4aa2 | |
chiu | 7c58b3fee6 | |
chiu | 8a8fe31ec3 | |
chiu | ea1be9befa | |
chiu | 7f4b994670 | |
chiu | e523087b96 | |
chiu | 868d87886b | |
chiu | 4bc6962248 | |
chiu | 7c338ff4bc | |
chiu | 20d35e7162 | |
chiu | 4d4a2dc766 | |
chiu | 823feb3f6b | |
Allen Cheng | 44449e9188 | |
Allen Cheng | 3d6f57086b | |
chiu | ad892f6e0f | |
chiu | 0a95f1e957 | |
chiu | 6a2ef23e7b | |
chiu | f76e785d9f | |
chiu | e6bcd9af37 | |
chiu | 4a9213d5ad | |
chiu | d004d722ca | |
chiu | cbd05be1ea | |
chiu | ce9f375221 | |
chiu | 6d3b6f5fcb | |
chiu | f9f6108f30 | |
chiu | 40f9361ea4 | |
chiu | 9cc10eaa64 | |
chiu | 44ed0018a8 | |
chiu | 3204aa0b7d | |
chiu | 01c1e7a076 | |
chiu | aa0febbd30 | |
chiu | c6058905fa | |
chiu | 7f5e34934f | |
chiu | 534100fd7c | |
chiu | 2c1e8bdde2 | |
chiu | b16553aa19 | |
chiu | 732a5d6a40 | |
chiu | 44b89ad43c | |
chiu | d03e62138f | |
chiu | fcbd1d786c | |
chiu | 7d94f13928 |
|
@ -8,6 +8,44 @@ class Admin::BooksController < OrbitMemberController
|
||||||
|
|
||||||
before_action :need_access_right
|
before_action :need_access_right
|
||||||
before_action :allow_admin_only, :only => [:index, :setting]
|
before_action :allow_admin_only, :only => [:index, :setting]
|
||||||
|
def merge_process
|
||||||
|
params['book_id'].each do |book_id|
|
||||||
|
book_ids = book_id.split('/')
|
||||||
|
books = Book.find(book_ids)
|
||||||
|
member_ids = books.collect(&:member_profile_id).uniq
|
||||||
|
books.each_with_index do |book,index1|
|
||||||
|
if index1== 0
|
||||||
|
book.member_profile_id = member_ids
|
||||||
|
book.save!
|
||||||
|
else
|
||||||
|
book.delete
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
redirect_to :action=> 'index'
|
||||||
|
end
|
||||||
|
def merge
|
||||||
|
@books=Book.order_by(:year=>'desc').map{|value| value}.group_by{|v| [v[:book_title],v[:isbn]]}
|
||||||
|
@books.each do |key,value|
|
||||||
|
if value.length<=1
|
||||||
|
@books.delete key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if params['mode']!='simple'
|
||||||
|
@books.each do |key,value|
|
||||||
|
@books[key] = value.group_by{|v| [get_publisher(v),get_author_type(v),get_paper_type(v),get_publication_date(v)]}
|
||||||
|
@books[key].each do |key1,value1|
|
||||||
|
if value1.length<=1
|
||||||
|
@books[key].delete key1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if @books[key].length==0
|
||||||
|
@books.delete key
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@writing_books = Book.order_by(:year=>'desc').page(params[:page]).per(10)
|
@writing_books = Book.order_by(:year=>'desc').page(params[:page]).per(10)
|
||||||
|
@ -49,14 +87,15 @@ class Admin::BooksController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@member = @book.member_profile
|
@member = get_member(@book)
|
||||||
if params[:desktop]
|
if params[:desktop]
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = @book.member_profile
|
@member = get_member(@book)
|
||||||
|
book_params['member_profile_id'] = params[:author_members]
|
||||||
@book.update_attributes(book_params)
|
@book.update_attributes(book_params)
|
||||||
@book.save
|
@book.save
|
||||||
if params[:desktop] == "true"
|
if params[:desktop] == "true"
|
||||||
|
@ -68,7 +107,7 @@ class Admin::BooksController < OrbitMemberController
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@book = Book.new
|
@book = Book.new
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = Array(MemberProfile.find_by(:uid=>params['uid'])) rescue nil
|
||||||
if params[:desktop]
|
if params[:desktop]
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
@ -90,9 +129,9 @@ class Admin::BooksController < OrbitMemberController
|
||||||
|
|
||||||
elsif !params[:author_members].blank?
|
elsif !params[:author_members].blank?
|
||||||
|
|
||||||
params[:author_members].each do |author_member|
|
#params[:author_members].each do |author_member|
|
||||||
|
|
||||||
book_params['member_profile_id'] = author_member
|
book_params['member_profile_id'] = params[:author_members]
|
||||||
@book = Book.new(book_params)
|
@book = Book.new(book_params)
|
||||||
@book.save
|
@book.save
|
||||||
|
|
||||||
|
@ -100,7 +139,7 @@ class Admin::BooksController < OrbitMemberController
|
||||||
render json: {"data" => get_paper_list}.to_json
|
render json: {"data" => get_paper_list}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
#end
|
||||||
|
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
|
|
||||||
|
|
|
@ -1,132 +1,199 @@
|
||||||
class PersonalBooksController < ApplicationController
|
class PersonalBooksController < ApplicationController
|
||||||
|
include Admin::PersonalBooksHelper
|
||||||
def index
|
def index
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
books = Book.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
page_data_count = OrbitHelper.page_data_count
|
||||||
page = Page.where(:page_id => params[:page_id]).first rescue nil
|
books = Book.where(is_hidden: false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count)
|
||||||
|
page = Page.where(page_id: params[:page_id]).first rescue nil
|
||||||
|
|
||||||
if page.custom_string_field == "table"
|
if page.custom_string_field == 'table'
|
||||||
fields_to_show = page.custom_array_field rescue []
|
fields_to_show = page.custom_array_field rescue []
|
||||||
fields_to_show = [
|
if fields_to_show.blank?
|
||||||
"authors",
|
fields_to_show = %w[
|
||||||
"book_title",
|
authors
|
||||||
"extracted_chapters",
|
book_title
|
||||||
"publisher",
|
extracted_chapters
|
||||||
"isbn",
|
publisher
|
||||||
"publish_date"
|
isbn
|
||||||
] if fields_to_show.blank?
|
publish_date
|
||||||
|
]
|
||||||
|
end
|
||||||
else
|
else
|
||||||
fields_to_show = [
|
fields_to_show = %w[
|
||||||
"year",
|
year
|
||||||
"book_title"
|
book_title
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
if !params[:selectbox].nil?
|
||||||
|
books_temp = Book.where(is_hidden: false).sort_by { |tp| [-tp[:year].to_i, -tp[:publication_date].to_i] }
|
||||||
|
case params[:selectbox]
|
||||||
|
when 'book_title', 'extracted_chapters', 'default'
|
||||||
|
search_temp = if params[:selectbox] == 'default'
|
||||||
|
'book_title'
|
||||||
|
else
|
||||||
|
params[:selectbox]
|
||||||
|
end
|
||||||
|
if page.custom_string_field == 'table'
|
||||||
|
books_show = books_temp.select { |value| search_all_words(value.send(search_temp), params[:keywords]) }
|
||||||
|
else
|
||||||
|
books_show = books_temp.select { |value| search_all_words(value.create_link, params[:keywords]) }
|
||||||
|
end
|
||||||
|
when 'publish_date', 'publication_date'
|
||||||
|
books_show = books_temp.select { |value| search_all_words((value.send(params[:selectbox]).strftime('%Y/%m/%d') rescue ''), params[:keywords]) }
|
||||||
|
when 'author_type'
|
||||||
|
books_show = books_temp.select { |value| search_all_words(value.book_author_types.collect(&:title).join(', '), params[:keywords]) }
|
||||||
|
when 'book_paper_type'
|
||||||
|
books_show = books_temp.select { |value| search_all_words((value.book_type.title rescue ''), params[:keywords]) }
|
||||||
|
when 'language'
|
||||||
|
books_show = books_temp.select { |value| search_all_words((!value.language.nil? ? t(value.language.to_s) : ''), params[:keywords]) }
|
||||||
|
when 'authors'
|
||||||
|
books_show = books_temp.select { |value| search_all_words(get_authors_text(value), params[:keywords]) }
|
||||||
|
when 'note'
|
||||||
|
books_show = books_temp.select { |value| search_all_words(Nokogiri::HTML(value.note).text, params[:keywords]) }
|
||||||
|
else
|
||||||
|
books_show = books_temp.select { |value| search_all_words(value.send(params[:selectbox]).to_s, params[:keywords]) }
|
||||||
|
end
|
||||||
|
page_to_show = params[:page_no].nil? ? 1 : params[:page_no].to_i
|
||||||
|
books = books_show[(page_to_show - 1) * page_data_count...page_to_show * page_data_count]
|
||||||
|
books_total_pages = (books_show.length / page_data_count.to_f).ceil
|
||||||
|
else
|
||||||
|
books_total_pages = books.total_pages
|
||||||
|
end
|
||||||
book_list = []
|
book_list = []
|
||||||
books.each do |book|
|
books.each do |book|
|
||||||
t = []
|
t = []
|
||||||
fields_to_show.each do |fs|
|
fields_to_show.each do |fs|
|
||||||
case fs
|
case fs
|
||||||
when "book_title", "extracted_chapters"
|
when 'book_title', 'extracted_chapters'
|
||||||
if page.custom_string_field == "table"
|
t << if page.custom_string_field == 'table'
|
||||||
t << {"value" => "<a href='#{OrbitHelper.url_to_show(book.to_param)}'>#{book.send(fs)}</a>"}
|
{ 'value' => "<a href='#{OrbitHelper.url_to_show(book.to_param)}'>#{book.send(fs)}</a>" }
|
||||||
else
|
else
|
||||||
t << {"value" => "<a href='#{OrbitHelper.url_to_show(book.to_param)}'>#{book.create_link}</a>"}
|
{ 'value' => "<a href='#{OrbitHelper.url_to_show(book.to_param)}'>#{book.create_link}</a>" }
|
||||||
end
|
end
|
||||||
when "publish_date", "publication_date"
|
when 'publish_date', 'publication_date'
|
||||||
pd = ""
|
t << { 'value' => (!book.send(fs).nil? ? book.send(fs).strftime('%Y/%m') : '' rescue '') }
|
||||||
if !book.publication_date.nil?
|
when 'author_type'
|
||||||
pd = book.publication_date.strftime("%Y-%m-%d").split('-')
|
t << { 'value' => (book.book_author_types.collect(&:title).join(', ') rescue '') }
|
||||||
pd = pd[0]+"/"+pd[1]
|
when 'language'
|
||||||
end
|
t << { 'value' => (!book.language.nil? ? t(book.language.to_s) : '') }
|
||||||
t << {"value" => pd}
|
when 'book_paper_type'
|
||||||
when "author_type"
|
t << { 'value' => (book.book_type.title rescue '') }
|
||||||
t << {"value" => (book.book_author_types.collect{|bat| bat.title}.join(", ") rescue "")}
|
when 'url'
|
||||||
when "language"
|
t << { 'value' => book.url.to_s.blank? ? "" : "<a href='#{book.url}'>#{book.url}</a>"}
|
||||||
t << {"value" => (I18n.t("personal_book.#{book.language}") if !book.language.nil? rescue "")}
|
when 'authors'
|
||||||
|
t << { 'value' => get_authors_show(book) }
|
||||||
else
|
else
|
||||||
t << {"value" => book.send(fs)}
|
t << { 'value' => (book.send(fs) rescue '') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
book_list << {"books" => t}
|
book_list << { 'books' => t }
|
||||||
end
|
end
|
||||||
|
choice_show = []
|
||||||
headers = []
|
headers = []
|
||||||
fields_to_show.each do |fs|
|
fields_to_show.each do |fs|
|
||||||
col = 2
|
col = 2
|
||||||
col = 3 if fs == "paper_title"
|
col = 3 if fs == 'paper_title'
|
||||||
headers << {
|
headers << {
|
||||||
"head-title" => t("personal_book.#{fs}"),
|
'head-title' => t("personal_book.#{fs}"),
|
||||||
"col" => col
|
'col' => col
|
||||||
}
|
}
|
||||||
|
choice_show << t("personal_book.#{fs}")
|
||||||
end
|
end
|
||||||
|
choice_value = fields_to_show
|
||||||
|
choice_value.unshift('default')
|
||||||
|
choice_select = choice_value.map { |iter| iter == params[:selectbox] ? 'selected' : '' }
|
||||||
|
choice_select = choice_select.map { |value| { 'choice_select' => value } }
|
||||||
|
choice_value = choice_value.map { |value| { 'choice_value' => value } }
|
||||||
|
choice_default = t('personal_book.select_class')
|
||||||
|
choice_show.unshift(choice_default)
|
||||||
|
choice_show = choice_show.map { |value| { 'choice_show' => value } }
|
||||||
|
choice = choice_value.zip(choice_show, choice_select)
|
||||||
|
choice = choice.map { |value| value.inject :merge }
|
||||||
|
select_text = t('personal_book.search_class')
|
||||||
|
search_text = t('personal_book.word_to_search')
|
||||||
{
|
{
|
||||||
"book_list" => book_list,
|
'book_list' => book_list,
|
||||||
"extras" => {"widget-title" => t("module_name.book")},
|
'extras' => { 'widget-title' => t('module_name.book'),
|
||||||
"headers" => headers,
|
'url' => '/' + params[:locale] + params[:url],
|
||||||
"total_pages" => books.total_pages
|
'select_text' => select_text,
|
||||||
|
'search_text' => search_text,
|
||||||
|
'search_value' => params[:keywords] },
|
||||||
|
'headers' => headers,
|
||||||
|
'total_pages' => books_total_pages,
|
||||||
|
'choice' => choice
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
plugin = Book.where(:is_hidden=>false).find_by(uid: params[:uid])
|
plugin = Book.where(is_hidden: false).find_by(uid: params[:uid])
|
||||||
fields_to_show = [
|
fields_to_show = %w[
|
||||||
"year",
|
year
|
||||||
"book_title",
|
book_title
|
||||||
"authors",
|
authors
|
||||||
"book_paper_type",
|
book_paper_type
|
||||||
"extracted_chapters",
|
extracted_chapters
|
||||||
"publisher",
|
publisher
|
||||||
"publish_date",
|
publish_date
|
||||||
"pages",
|
pages
|
||||||
"editor",
|
editor
|
||||||
"author_type",
|
author_type
|
||||||
"number_of_authors",
|
number_of_authors
|
||||||
"isbn",
|
isbn
|
||||||
"url",
|
url
|
||||||
"publication_date",
|
file
|
||||||
"language"
|
publication_date
|
||||||
|
language
|
||||||
|
note
|
||||||
]
|
]
|
||||||
|
|
||||||
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
{ 'plugin_datas' => plugin.get_plugin_data(fields_to_show) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_fields_for_index
|
def get_fields_for_index
|
||||||
@page = Page.find(params[:page_id]) rescue nil
|
@page = Page.find(params[:page_id]) rescue nil
|
||||||
@fields_to_show = [
|
@fields_to_show = %w[
|
||||||
"year",
|
year
|
||||||
"book_title",
|
book_title
|
||||||
"authors",
|
authors
|
||||||
"book_paper_type",
|
book_paper_type
|
||||||
"extracted_chapters",
|
extracted_chapters
|
||||||
"publisher",
|
publisher
|
||||||
"publish_date",
|
publish_date
|
||||||
"pages",
|
pages
|
||||||
"editor",
|
editor
|
||||||
"author_type",
|
author_type
|
||||||
"number_of_authors",
|
number_of_authors
|
||||||
"isbn",
|
isbn
|
||||||
"url",
|
url
|
||||||
"file",
|
publication_date
|
||||||
"publication_date",
|
language
|
||||||
"language"
|
note
|
||||||
]
|
]
|
||||||
@fields_to_show = @fields_to_show.map{|fs| [t("personal_book.#{fs}"), fs]}
|
@fields_to_show = @fields_to_show.map { |fs| [t("personal_book.#{fs}"), fs] }
|
||||||
@default_fields_to_show = [
|
@default_fields_to_show = %w[
|
||||||
"authors",
|
authors
|
||||||
"book_title",
|
book_title
|
||||||
"extracted_chapters",
|
extracted_chapters
|
||||||
"publisher",
|
publisher
|
||||||
"isbn",
|
isbn
|
||||||
"publish_date"
|
publish_date
|
||||||
]
|
]
|
||||||
render :layout => false
|
render layout: false
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_index_fields
|
def save_index_fields
|
||||||
page = Page.find(params[:page_id]) rescue nil
|
page = Page.find(params[:page_id]) rescue nil
|
||||||
page.custom_array_field = params[:keys]
|
page.custom_array_field = params[:keys]
|
||||||
page.save
|
page.save
|
||||||
render :json => {"success" => true}.to_json
|
render json: { 'success' => true }.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def search_all_words(target, word)
|
||||||
|
target = target.upcase
|
||||||
|
words = word.upcase.split(' ')
|
||||||
|
words.select { |value| target.include? value } == words
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,5 +1,28 @@
|
||||||
module Admin::PersonalBooksHelper
|
module Admin::PersonalBooksHelper
|
||||||
|
def get_authors_text(book)
|
||||||
|
(book.authors.to_s.blank? ? get_member(book).collect(&:name).join('/') : Nokogiri::HTML(book.authors.to_s).text rescue '')
|
||||||
|
end
|
||||||
|
def get_authors_show(book)
|
||||||
|
(book.authors.to_s.blank? ? get_member_show(book) : book.authors.to_s) rescue ''
|
||||||
|
end
|
||||||
|
def get_member(book)
|
||||||
|
Array(MemberProfile.find(Array(book).collect(&:member_profile_id)))
|
||||||
|
end
|
||||||
|
def get_member_show(book)
|
||||||
|
get_member(book).collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('/')
|
||||||
|
end
|
||||||
|
def get_publisher(book)
|
||||||
|
book.publisher
|
||||||
|
end
|
||||||
|
def get_author_type(book)
|
||||||
|
book.book_author_types.collect(&:title).join(', ') rescue ''
|
||||||
|
end
|
||||||
|
def get_paper_type(book)
|
||||||
|
!book.book_type.blank? ? book.book_type.title : nil
|
||||||
|
end
|
||||||
|
def get_publication_date(book)
|
||||||
|
book.publication_date.strftime('%Y/%m/%d') rescue ''
|
||||||
|
end
|
||||||
def get_paper_list
|
def get_paper_list
|
||||||
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
user = current_user.nil? ? OrbitHelper.current_user : current_user
|
||||||
user_profile = user.member_profile
|
user_profile = user.member_profile
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Book
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::Attributes::Dynamic
|
include Mongoid::Attributes::Dynamic
|
||||||
|
include Admin::PersonalBooksHelper
|
||||||
include OrbitModel::Status
|
include OrbitModel::Status
|
||||||
include MemberHelper
|
include MemberHelper
|
||||||
include Slug
|
include Slug
|
||||||
|
@ -40,7 +40,9 @@ class Book
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc", :publication_date => "desc") }
|
scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(:year => "desc", :publish_date => "desc", :publication_date => "desc") }
|
||||||
|
def book_paper_type
|
||||||
|
self.book_type.title rescue ""
|
||||||
|
end
|
||||||
def create_link
|
def create_link
|
||||||
title = []
|
title = []
|
||||||
# title << self.member_profile.name if self.member_profile.present?
|
# title << self.member_profile.name if self.member_profile.present?
|
||||||
|
@ -118,7 +120,7 @@ class Book
|
||||||
when "author_type"
|
when "author_type"
|
||||||
pd_data << {"data_title" => (p.book_author_types.collect{|bat| bat.title}.join(", ") rescue "")}
|
pd_data << {"data_title" => (p.book_author_types.collect{|bat| bat.title}.join(", ") rescue "")}
|
||||||
when "language"
|
when "language"
|
||||||
pd_data << {"data_title" => (I18n.t("personal_book.#{p.language}") if !p.language.nil? rescue "")}
|
pd_data << {"data_title" => (I18n.t("#{p.language}") if !p.language.nil? rescue "")}
|
||||||
else
|
else
|
||||||
pd_data << { "data_title" => p.send(t) }
|
pd_data << { "data_title" => p.send(t) }
|
||||||
end
|
end
|
||||||
|
@ -152,9 +154,9 @@ class Book
|
||||||
def get_plugin_field_data(field)
|
def get_plugin_field_data(field)
|
||||||
case field
|
case field
|
||||||
when "book_paper_type"
|
when "book_paper_type"
|
||||||
value = self.book_type.title rescue ""
|
value = (self.book_type.title rescue "")
|
||||||
when "author_type"
|
when "author_type"
|
||||||
value = self.book_author_types.collect{|type| type.title}.join(',') rescue ""
|
value = (self.book_author_types.collect{|type| type.title}.join(',') rescue "")
|
||||||
when "author_name"
|
when "author_name"
|
||||||
value = []
|
value = []
|
||||||
([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale|
|
([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale|
|
||||||
|
@ -164,20 +166,23 @@ class Book
|
||||||
end
|
end
|
||||||
value = value.join(" / ")
|
value = value.join(" / ")
|
||||||
when "language"
|
when "language"
|
||||||
value = I18n.t(self.language) if !self.language.nil? rescue ""
|
value = I18n.t("#{self.language}") if !self.language.nil? rescue ""
|
||||||
# value = I18n.t("personal_book.#{self.language}") if !self.language.nil? rescue ""
|
|
||||||
when "publish_date", "publication_date"
|
when "publish_date", "publication_date"
|
||||||
value = self.send(field).to_date.strftime("%Y-%m-%d") rescue nil
|
value = self.send(field).to_date.strftime("%Y-%m-%d") rescue nil
|
||||||
when "file"
|
when "file"
|
||||||
files = []
|
files = []
|
||||||
self.book_files.each do |book_file|
|
self.book_files.each do |book_file|
|
||||||
url = book_file.member_book_file.url
|
url = book_file.member_book_file.url
|
||||||
title = (book_file.title.blank? ? File.basename(book_file.member_book_file.path) : book_file.title)
|
title = ((book_file.title.blank? ? File.basename(book_file.member_book_file.path) : book_file.title) rescue "")
|
||||||
files << "<li><a href='#{url}'' target='_blank'>#{title}</li>"
|
files << (url.nil? ? "" : "<li><a href='#{url}'' target='_blank'>#{title}</li>")
|
||||||
end
|
end
|
||||||
value = files.join("")
|
value = files.join("")
|
||||||
|
when "url"
|
||||||
|
value = self.url.to_s.blank? ? "" : "<a href='#{self.url}'>#{self.url}</a>"
|
||||||
|
when "authors"
|
||||||
|
value = get_authors_show(self)
|
||||||
else
|
else
|
||||||
value = self.send(field) rescue ""
|
value = (self.send(field) rescue "")
|
||||||
end
|
end
|
||||||
|
|
||||||
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
<label class="control-label muted"><%= t("personal_book.authors") %></label>
|
<label class="control-label muted"><%= t("personal_book.authors") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.fields_for :authors_translations do |f| %>
|
<%= f.fields_for :authors_translations do |f| %>
|
||||||
<%= f.text_area locale, class: "input-block-level", placeholder: t("personal_book.authors"), value: (@book.authors_translations[locale] rescue nil) %>
|
<%= f.text_area locale, class: "ckeditor input-block-level", placeholder: t("personal_book.authors"), value: (@book.authors_translations[locale] rescue nil) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -141,26 +141,17 @@
|
||||||
<!-- Basic Module -->
|
<!-- Basic Module -->
|
||||||
<div class="tab-pane fade in active" id="basic">
|
<div class="tab-pane fade in active" id="basic">
|
||||||
|
|
||||||
<% if !@member.nil? %>
|
|
||||||
|
|
||||||
<div class="control-group big-group">
|
<div class="control-group big-group">
|
||||||
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= @member.name rescue ''%>
|
<% if !@member.nil? %>
|
||||||
<%= f.hidden_field :member_profile_id, :value => @member.id %>
|
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:@member} %>
|
||||||
|
<% else %>
|
||||||
|
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:[]} %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% else %>
|
|
||||||
|
|
||||||
<div class="control-group big-group">
|
|
||||||
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
|
|
||||||
<div class="controls">
|
|
||||||
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:[]} %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<!-- year -->
|
<!-- year -->
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -263,7 +254,7 @@
|
||||||
<div class="control-group big-group">
|
<div class="control-group big-group">
|
||||||
<label class="control-label muted"><%= t("personal_book.note") %></label>
|
<label class="control-label muted"><%= t("personal_book.note") %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
|
<%= f.text_area :note, rows: 2, class: "ckeditor input-block-level" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<tr id="<%= dom_id writing_book %>" class="with_action">
|
<tr id="<%= dom_id writing_book %>" class="with_action">
|
||||||
<td class="span1"><%= writing_book.year %></td>
|
<td class="span1"><%= writing_book.year %></td>
|
||||||
<td class="span1">
|
<td class="span1">
|
||||||
<%= link_to writing_book.create_link, OrbitHelper.url_to_plugin_show(writing_book.to_param,'personal_book'), target: "blank" %>
|
<%= link_to Nokogiri::HTML(writing_book.create_link).text, OrbitHelper.url_to_plugin_show(writing_book.to_param,'personal_book'), target: "blank" %>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
<ul class="nav nav-pills hide">
|
<ul class="nav nav-pills hide">
|
||||||
<% if current_user.is_admin? %>
|
<% if current_user.is_admin? %>
|
||||||
|
@ -12,6 +12,6 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td><%= writing_book.member_profile.name rescue "" %></td>
|
<td><%= get_member_show(writing_book).html_safe %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
<script src="https://kit.fontawesome.com/1fa49cfdc9.js" crossorigin="anonymous"></script>
|
||||||
|
<script>
|
||||||
|
function MergeUrl(){
|
||||||
|
location.href = '<%= merge_admin_books_path %>'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<table class="table main-list">
|
<table class="table main-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -14,8 +20,12 @@
|
||||||
<div class="bottomnav clearfix">
|
<div class="bottomnav clearfix">
|
||||||
<div class="action pull-right">
|
<div class="action pull-right">
|
||||||
<div class="dropup upload-button">
|
<div class="dropup upload-button">
|
||||||
|
<button class="btn btn-primary" type="button" onclick="MergeUrl()">
|
||||||
|
<i class="far fa-object-group"></i>
|
||||||
|
<span class="group"></span><%= t('personal_book.merge') %>
|
||||||
|
</button>
|
||||||
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
|
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||||
<i class="icon-upload-alt icon-white"></i>上傳
|
<i class="icon-upload-alt icon-white"></i><%= t('personal_book.upload') %>
|
||||||
<span class="caret"></span>
|
<span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="dropdown-menu upload-box">
|
<div class="dropdown-menu upload-box">
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
<%= csrf_meta_tags %>
|
||||||
|
<% content_for :page_specific_css do %>
|
||||||
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||||
|
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||||
|
<%= stylesheet_link_tag "lib/main-list" %>
|
||||||
|
<%= stylesheet_link_tag "lib/main-form-col2" %>
|
||||||
|
<style>
|
||||||
|
table.table.main-list.tablet.footable-loaded td{
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<% end %>
|
||||||
|
<script>
|
||||||
|
function change_mode(){
|
||||||
|
var value = $("form[name='mode_form']").find("input[type='checkbox']")[0].checked
|
||||||
|
if (value){
|
||||||
|
$("input[name='mode']").val("strict")
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("input[name='mode']").val("simple")
|
||||||
|
}
|
||||||
|
document.mode_form.submit()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<nobr>
|
||||||
|
<form method="get" action='?' name='mode_form'>
|
||||||
|
<%= t('strict_compare_mode') +':' %>
|
||||||
|
<input type='hidden' name='mode' value=''>
|
||||||
|
<% if params['mode']!='simple' %>
|
||||||
|
<input type="checkbox" onchange='change_mode()' checked><span style="margin-right: 2em;"><%= t('yes_') %></span>
|
||||||
|
<% else %>
|
||||||
|
<input type="checkbox" onchange='change_mode()'><span style="margin-right: 2em;"><%= t('no_') %></span>
|
||||||
|
<% end %>
|
||||||
|
<button type="button" onclick="merge_form.submit()"><%= t('personal_conference.merge') %></button>
|
||||||
|
</form>
|
||||||
|
</nobr>
|
||||||
|
<form method="post" action='/admin/books/merge_process?' name='merge_form'>
|
||||||
|
<%= token_tag(nil) %>
|
||||||
|
<table class="table main-list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= t('personal_book.book_title') %></th>
|
||||||
|
<th><%= t('personal_book.isbn') %></th>
|
||||||
|
<% if params['mode']!='simple' %>
|
||||||
|
<th><%= t('personal_book.publisher') %></th>
|
||||||
|
<th><%= t('personal_book.author_type') %></th>
|
||||||
|
<th><%= t('personal_book.book_paper_type') %></th>
|
||||||
|
<th><%= t('personal_book.publication_date') %></th>
|
||||||
|
<% end %>
|
||||||
|
<th><%= t("personal_book.merge") %></th>
|
||||||
|
<th><%= t("personal_book.author") %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @books.each do |key,books| %>
|
||||||
|
<tr>
|
||||||
|
<% if params['mode']=='simple'
|
||||||
|
len = books.length
|
||||||
|
else
|
||||||
|
len = books.values.reduce(0){|sum,num| sum+num.length}
|
||||||
|
end
|
||||||
|
%>
|
||||||
|
<td rowspan="<%= len %>">
|
||||||
|
<%= key[0].values.map{|v| v=="" ? t('personal_book.no_input') : v}.join('/') %>
|
||||||
|
</td>
|
||||||
|
<td rowspan="<%= len %>">
|
||||||
|
<%= key[1] %>
|
||||||
|
</td>
|
||||||
|
<% if params['mode']=='simple' %>
|
||||||
|
<td rowspan="<%= len %>">
|
||||||
|
<input type="checkbox" class="checkbox" name="books_id[]" value="<%= books.collect(&:id).join('/') %>">
|
||||||
|
</td>
|
||||||
|
<% books.each_with_index do |book,i| %>
|
||||||
|
<td>
|
||||||
|
<a href="<%= edit_admin_book_path(book) %>" target="_blank">
|
||||||
|
<%= get_member(book).collect(&:name).join(' / ') rescue t('personal_book.no_input') %>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<% if len!=(i+1) %>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<% i=0 %>
|
||||||
|
<% books.each do |k,v| %>
|
||||||
|
<% len1 = v.length %>
|
||||||
|
<% k.each do |keychild| %>
|
||||||
|
<td rowspan="<%= len1 %>">
|
||||||
|
<%= keychild.to_s.blank? ? t('personal_book.no_input') : keychild %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
<td rowspan="<%= len1 %>">
|
||||||
|
<input type="checkbox" class="checkbox" name="book_id[]" value="<%= v.collect(&:id).join('/') %>">
|
||||||
|
</td>
|
||||||
|
<% v.each_with_index do |book_child,index1| %>
|
||||||
|
<td>
|
||||||
|
<a href="<%= edit_admin_book_path(book_child) %>" target="_blank">
|
||||||
|
<%= get_member(book_child).collect(&:name).join(' / ') rescue t('personal_book.no_input') %>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<% if len1!=index1 %>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% if len1!=(i+1) %>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<% end %>
|
||||||
|
<% i =i+1 %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
|
@ -4,6 +4,12 @@ en:
|
||||||
book_paper: "Book / Book Chapter"
|
book_paper: "Book / Book Chapter"
|
||||||
personal_book: "Book / Book Chapter"
|
personal_book: "Book / Book Chapter"
|
||||||
personal_book:
|
personal_book:
|
||||||
|
merge: Merge
|
||||||
|
upload: Upload
|
||||||
|
no_input: No Input
|
||||||
|
select_class: "——select class——"
|
||||||
|
search_class: "search class:"
|
||||||
|
word_to_search: "word to search:"
|
||||||
paper_title : "Paper Title"
|
paper_title : "Paper Title"
|
||||||
book_title : "Book Title"
|
book_title : "Book Title"
|
||||||
extracted_chapters : "Extracted Chapters"
|
extracted_chapters : "Extracted Chapters"
|
||||||
|
@ -40,7 +46,7 @@ en:
|
||||||
graph_by : "Graph By"
|
graph_by : "Graph By"
|
||||||
frontend:
|
frontend:
|
||||||
writing_books: "Book Front-end"
|
writing_books: "Book Front-end"
|
||||||
|
strict_compare_mode: Strict Compare mode
|
||||||
create_success : "Successfully Create"
|
create_success : "Successfully Create"
|
||||||
update_success : "Successfully Update"
|
update_success : "Successfully Update"
|
||||||
delete_success : "Successfully Delete"
|
delete_success : "Successfully Delete"
|
||||||
|
|
|
@ -4,6 +4,12 @@ zh_tw:
|
||||||
book_paper: "專書 / 專書章節"
|
book_paper: "專書 / 專書章節"
|
||||||
personal_book : "專書 / 專書章節"
|
personal_book : "專書 / 專書章節"
|
||||||
personal_book:
|
personal_book:
|
||||||
|
merge: "合併"
|
||||||
|
upload: "上傳"
|
||||||
|
no_input: "未輸入"
|
||||||
|
select_class: "——選取分類——"
|
||||||
|
search_class: "搜尋類別:"
|
||||||
|
word_to_search: "關鍵字搜尋:"
|
||||||
paper_title : "論文名稱"
|
paper_title : "論文名稱"
|
||||||
book_title : "書名"
|
book_title : "書名"
|
||||||
extracted_chapters : "部份章節"
|
extracted_chapters : "部份章節"
|
||||||
|
@ -40,7 +46,7 @@ zh_tw:
|
||||||
graph_by : "Graph By"
|
graph_by : "Graph By"
|
||||||
frontend:
|
frontend:
|
||||||
writing_books: "專書前台"
|
writing_books: "專書前台"
|
||||||
|
strict_compare_mode: "嚴格比較模式"
|
||||||
create_success : "新增完成!!"
|
create_success : "新增完成!!"
|
||||||
update_success : "更新完成!!"
|
update_success : "更新完成!!"
|
||||||
delete_success : "刪除成功!!"
|
delete_success : "刪除成功!!"
|
||||||
|
|
|
@ -8,6 +8,8 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
resources :books do
|
resources :books do
|
||||||
collection do
|
collection do
|
||||||
|
post 'merge_process' => 'books#merge_process'
|
||||||
|
get 'merge' => 'books#merge'
|
||||||
get 'toggle_hide' => 'books#toggle_hide'
|
get 'toggle_hide' => 'books#toggle_hide'
|
||||||
get 'analysis'
|
get 'analysis'
|
||||||
get 'analysis_report'
|
get 'analysis_report'
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<table class="table table-hover table-striped journal-papers-index">
|
||||||
|
<caption><h1>{{widget-title}}</h1></caption>
|
||||||
|
<thead>
|
||||||
|
<tr data-level="0" data-list="headers">
|
||||||
|
<th class="col-md-{{col}}">{{head-title}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody data-level="0" data-list="book_list">
|
||||||
|
<tr data-level="1" data-list="books">
|
||||||
|
<td>{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{pagination_goes_here}}
|
|
@ -0,0 +1,37 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
$( ".selectbox" ).ready(function() {
|
||||||
|
var option_len = $(".search-widget option").length
|
||||||
|
for (var i=0;i<option_len;i++){
|
||||||
|
if($(".search-widget option").eq(i).data('selected')=="selected"){
|
||||||
|
$(".search-widget option").eq(i).attr('selected','selected')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<h3>{{widget-title}}</h3>
|
||||||
|
<div class="search-widget">
|
||||||
|
<form action="{{url}}" method="get">
|
||||||
|
{{select_text}}
|
||||||
|
<select class="selectbox" name="selectbox" data-level="0" data-list="choice">
|
||||||
|
<option value={{choice_value}} data-selected='{{choice_select}}' >
|
||||||
|
{{choice_show}}</option>
|
||||||
|
</select>
|
||||||
|
{{search_text}}
|
||||||
|
<input name="keywords" placeholder="Keywords" type="text" value="{{search_value}}">
|
||||||
|
<button>Go</button>
|
||||||
|
<a id="filter" style="" href="{{url}}">Clear</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<table class="table table-hover table-striped journal-papers-index">
|
||||||
|
<thead>
|
||||||
|
<tr data-level="0" data-list="headers">
|
||||||
|
<th class="col-md-{{col}}">{{head-title}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody data-level="0" data-list="book_list">
|
||||||
|
<tr data-level="1" data-list="books">
|
||||||
|
<td>{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{pagination_goes_here}}
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"frontend": [
|
||||||
|
{
|
||||||
|
"filename" : "index",
|
||||||
|
"name" : {
|
||||||
|
"zh_tw" : "1. 列表",
|
||||||
|
"en" : "1. List"
|
||||||
|
},
|
||||||
|
"thumbnail" : "thumb.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "index_search1",
|
||||||
|
"name" : {
|
||||||
|
"zh_tw" : "2. 列表(含搜尋)",
|
||||||
|
"en" : "2. List which includes search"
|
||||||
|
},
|
||||||
|
"thumbnail" : "thumb.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<table class="table table-striped plugin-show-table">
|
||||||
|
<tbody data-list="plugin_datas" data-level="0">
|
||||||
|
<tr>
|
||||||
|
<th class="{{title_class}}">{{title}}</th>
|
||||||
|
<td class="{{value_class}}">{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
|
@ -2,7 +2,20 @@ $:.push File.expand_path("../lib", __FILE__)
|
||||||
|
|
||||||
# Maintain your gem's version:
|
# Maintain your gem's version:
|
||||||
require "personal_book/version"
|
require "personal_book/version"
|
||||||
|
app_path = File.expand_path(__dir__)
|
||||||
|
template_path = ENV['PWD'] + '/app/templates'
|
||||||
|
all_template = Dir.glob(template_path+'/*/')
|
||||||
|
puts 'copying module'
|
||||||
|
all_template.each do |folder|
|
||||||
|
if folder.split('/')[-1] != 'mobile'
|
||||||
|
begin
|
||||||
|
system ('cp -r '+ app_path + '/modules/ ' + folder)
|
||||||
|
rescue
|
||||||
|
puts 'error copy'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
system ('rm -r '+app_path + '/modules/')
|
||||||
# Describe your gem and declare its dependencies:
|
# Describe your gem and declare its dependencies:
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "personal_book"
|
s.name = "personal_book"
|
||||||
|
|
Loading…
Reference in New Issue