Orbit PersonalBook Module

This commit is contained in:
Manson Wang 2014-01-15 18:49:04 +08:00
parent 03df879332
commit 7198ca2111
102 changed files with 3738 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/

17
Gemfile Normal file
View File

@ -0,0 +1,17 @@
source "http://rubygems.org"
# Declare your gem's dependencies in personal_book.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'

20
MIT-LICENSE Normal file
View File

@ -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
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= PersonalBook
This project rocks and uses MIT-LICENSE.

39
Rakefile Normal file
View File

@ -0,0 +1,39 @@
#!/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 = 'PersonalBook'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task :default => :test

View File

View File

@ -0,0 +1,149 @@
orbitDesktop.prototype.initializePersonalBook = function(target,url,cache){ // this init journal papers
this.initializePersonalBook.formCallback = function(data){
if(data.success){
o.notify(data.msg,"success");
o.sub_menu_item($("div[content-type=menu] a").eq(0));
}else{
o.notify(data.msg,"alert");
}
}
this.initializePersonalBook.list = function(){ // to open list part in journal papers page
var journalData;
var bindHandlers = function(){ // to bind handlers for list page
}
bindHandlers();
var bindSecondaryHandlers = function(){
$("#journal_p div#paper_list a.icon-check-empty").click(function(){
if($(this).hasClass("icon-check-empty")){
$(this).switchClass("icon-check-empty","icon-check",0);
} else if($(this) .hasClass("icon-check")) {
$(this).switchClass("icon-check","icon-check-empty",0);
} else if($(this).hasClass("icon-star")){
$(this).removeClass("icon-star").addClass("icon-star-empty");
} else if($(this).hasClass("icon-star-empty")){
$(this).removeClass("icon-star-empty").addClass("icon-star");
}
return false;
})
}
o.enableSharing("div.share_mode");
}
this.initializePersonalBook.bookDelete = function(data,dom){
var parent = dom.parent().parent().parent();
if(data.success){
parent.hide("slide",function(){parent.remove();});
o.notify(data.msg,"success");
}
}
this.initializePersonalBook.cancelbook = function(){
o.highlight_sub_menu_item(0);
}
var uploadFiles = function(){
$('#add_plugin_file a.add').click(function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_writing_journal_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
var x = get_html(old_id,new_id);
var newfield = $(x);
$(this).parents('table').append(newfield);
newfield.find('.action a.delete').click(function(){
newfield.remove();
});
return false;
});
$('.action a.remove_existing_record').click(function(){
$(this).toggleClass("color-red",function(){
if($(this).hasClass('color-red')){
$(this).next('.should_destroy').attr('value', 1);
}else{
$(this).next('.should_destroy').removeAttr('value');
}
})
});
}
var languageSelect = function(){
$(".language_select a").click(function(event) {
$("*[data-language]").hide();
$("*[data-language="+$(this).data("lang")+"]").show();
return false;
});
}
this.initializePersonalBook.editbook = function(){
o.highlight_sub_menu_item(1);
uploadFiles();
languageSelect();
}
this.initializePersonalBook.addbook = function(){ // to open add pages in journal papers page
uploadFiles();
languageSelect();
}
this.initializePersonalBook.brief = function(){
o.enablelanguageSelect();
$("textarea.editor").ckeditor({
height: 300,
width: $(".overview").width() - 20
});
}
this.initializePersonalBook.coAuthorformCallback = function(data){
if(data.success){
o.notify(data.msg,"success");
o.sub_menu_item($("div[content-type=menu] a").eq(3));
}else{
o.notify(data.msg,"alert");
}
}
this.initializePersonalBook.coauthor = function(){ // to open add pages in coauthor page
var bindHandlers = function(){ // to bind handlers for add page
}
bindHandlers();
}
this.initializePersonalBook.coauthorRelationForm = function(data){
if(data.success){
o.notify(data.msg,"success");
$("#co_author_relation_table").html(data.newvalue);
}else{
o.notify(data.msg,"alert");
}
}
this.initializePersonalBook.coauthorRelationEditForm = function(data){
if(data.success){
o.notify(data.msg,"success");
var x = o.layout_data.generate_layout_html(data.newvalue);
$("div[container=true] div.overview").html(x.markup);
}else{
o.notify(data.msg,"alert");
}
}
this.initializePersonalBook.allnone = function(d,o){
switch(o.attr("href")){
case "all":
$("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check");
break;
case "none":
$("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty");
break;
}
}
this.initializePersonalBook.allnone = function(d,o){
switch(o.attr("href")){
case "all":
$("div.overview a.icon-check-empty").removeClass("icon-check-empty").addClass("icon-check");
break;
case "none":
$("div.overview a.icon-check").removeClass("icon-check").addClass("icon-check-empty");
break;
}
}
};

View File

@ -0,0 +1,115 @@
/* Books */
[page-name="books_list"] .list_t_item .inner {
padding-left: 30px; }
[page-name="books_list"] .list_item_action {
font-size: 12px;
float: left;
margin-left: -30px; }
[page-name="books_list"] .list_item_action a {
display: block;
width: 20px;
height: 20px;
line-height: 20px;
margin: 1px 1px 6px 1px; }
[page-name="books_list"] .list_item_action .icon-star-empty {
color: #999;
font-size: 20px; }
[page-name="books_list"] .list_item_action .icon-star {
color: #faa732;
font-size: 20px; }
[page-name="books_list"] .list_item_action .icon-check-empty {
color: #999;
font-size: 20px; }
[page-name="books_list"] .list_item_action .icon-check {
color: #333;
font-size: 20px; }
[page-name="books_list"] .file_view .list_t_des {
overflow: hidden; }
[page-name="books_list"] .file_view .file {
float: left;
width: 120px;
height: 50px;
padding: 6px;
margin: 1px;
position: relative;
-webkit-box-sizing: border-box;
/* webkit */
-khtml-box-sizing: border-box;
/* konqueror */
-moz-box-sizing: border-box;
/* firefox */
-ms-box-sizing: border-box;
/* ie */
box-sizing: border-box;
/* css3 */ }
[page-name="books_list"] .file_view .file:hover {
background-color: #f7f7f7; }
[page-name="books_list"] .file_view .file img {
width: 38px;
height: 38px;
position: absolute;
left: 6px;
top: 6px; }
[page-name="books_list"] .file_view .file .filetitle {
display: block;
width: 100%;
height: 38px;
padding-left: 40px;
overflow: hidden;
-webkit-box-sizing: border-box;
/* webkit */
-khtml-box-sizing: border-box;
/* konqueror */
-moz-box-sizing: border-box;
/* firefox */
-ms-box-sizing: border-box;
/* ie */
box-sizing: border-box;
/* css3 */ }
/* Books Books list */
[page-name="books_books"] .datalist_item .inner {
padding-left: 30px; }
[page-name="books_books"] .list_item_action {
font-size: 12px;
float: left;
margin-left: -30px; }
[page-name="books_books"] .list_item_action i {
color: #999;
font-size: 20px;
display: block;
width: 20px;
height: 20px;
line-height: 20px;
margin: 1px 1px 6px 1px; }
[page-name="books_books"] .list_t_desc {
font-family: Arial, sans-serif;
font-size: 12px;
color: #999; }
/* Books Co-Author */
[page-name="books_coauthor"] .list_t_item {
height: 110px; }
[page-name="books_coauthor"] .list_item_function a {
display: inline-block;
padding: 4px;
font-family: Arial, sans-serif;
font-size: 11px;
-webkit-text-size-adjust: none; }
[page-name="books_coauthor"] .info {
font-family: Arial, sans-serif; }
[page-name="books_coauthor"] .info li {
margin-bottom: 8px;
color: #999; }
[page-name="books_coauthor"] .info .name {
font-size: 18px;
line-height: 24px;
color: #333; }
/* Books Co-Author Relationship*/
[page-name="books_coauthor_relation"] .edit_co_author_relation {
/*margin-left: -10px;*/ }
[page-name="books_coauthor_relation"] .form_space {
margin-bottom: 10px;
font-size: 18px;
font-family: Arial, sans-serif; }

View File

@ -0,0 +1,123 @@
@import "desktop-helper";
/* Books */
[page-name="books_list"] {
.list_t_item .inner { padding-left: 30px; }
.list_item_action {
font-size: 12px;
float: left;
margin-left: -30px;
a {
display: block;
width: 20px;
height: 20px;
line-height: 20px;
margin: 1px 1px 6px 1px;
}
.icon-star-empty { color: #999; font-size: 20px; }
.icon-star { color: #faa732; font-size: 20px; }
.icon-check-empty { color: #999; font-size: 20px; }
.icon-check { color: #333; font-size: 20px; }
}
.file_view {
.list_t_des {
overflow: hidden;
}
.file {
float: left;
width: 120px;
height: 50px;
padding: 6px;
margin: 1px;
position: relative;
@include box-sizing;
&:hover {
background-color: lighten($gray, 10%);
}
img {
width: 38px;
height: 38px;
position: absolute;
left: 6px;
top: 6px;
}
.filetitle {
display: block;
width: 100%;
height: 38px;
padding-left: 40px;
overflow: hidden;
@include box-sizing;
}
}
}
}
/* Books Books list */
[page-name="books_books"] {
.datalist_item .inner {
padding-left: 30px;
}
.list_item_action {
font-size: 12px;
float: left;
margin-left: -30px;
}
.list_item_action i {
color: #999;
font-size: 20px;
display: block;
width: 20px;
height: 20px;
line-height: 20px;
margin: 1px 1px 6px 1px;
}
.list_t_desc {
font-family: Arial, sans-serif;
font-size: 12px;
color: #999;
}
}
/* Books Co-Author */
[page-name="books_coauthor"] {
.list_t_item {
height: 110px;
}
.list_item_function {}
.list_item_function a {
display: inline-block;
padding: 4px;
font-family: Arial, sans-serif;
font-size: 11px;
-webkit-text-size-adjust: none;
}
.info {
font-family: Arial, sans-serif;
}
.info li {
margin-bottom: 8px;
color: #999;
}
.info .name {
font-size: 18px;
line-height: 24px;
color: #333;
}
}
/* Books Co-Author Relationship*/
[page-name="books_coauthor_relation"]{
.edit_co_author_relation {
/*margin-left: -10px;*/
}
.form_space {
margin-bottom: 10px;
font-size: 18px;
font-family: Arial, sans-serif;
}
}

0
app/controllers/.gitkeep Normal file
View File

View File

@ -0,0 +1,23 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale
# Set I18n.locale
def set_locale
# update session if passed
session[:locale] = params[:locale] if params[:locale]
# set locale based on session or default
begin
# check if locale is valid for non site pages
if !VALID_LOCALES.include?(session[:locale])
I18n.locale = I18n.default_locale
else
I18n.locale = session[:locale]
end
rescue
I18n.locale = I18n.default_locale
end
end
end

View File

@ -0,0 +1,8 @@
class Panel::PersonalBook::BackEnd::BookAuthorTypesController < Panel::PersonalBook::BackEnd::WritingBookCategorysController
def initialize
super
@app_type = 'book_author_type'
end
end

View File

@ -0,0 +1,8 @@
class Panel::PersonalBook::BackEnd::BookPaperTypesController < Panel::PersonalBook::BackEnd::WritingBookCategorysController
def initialize
super
@app_type = 'book_paper_type'
end
end

View File

@ -0,0 +1,10 @@
class Panel::PersonalBook::BackEnd::PersonalBookIntrosController < Admin::PersonalPluginIntrosController
def initialize
super
@app_type = 'personal_book_intro'
@app_type_name = 'personal_book'
@reback_name = 'WritingBook'
end
end

View File

@ -0,0 +1,142 @@
class Panel::PersonalBook::BackEnd::WritingBookCategorysController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
open_for_manager :except => [:index]
def index
get_types
@writing_book_categorys = @types.all
@writing_book_category = @types.new(:display => 'List')
# @url = panel_personal_book_back_end_writing_book_categorys_path
@url = eval("panel_personal_book_back_end_#{@app_type}s_path")
respond_to do |format|
format.html # index.html.erb
format.js
end
end
# GET /writing_books/1
# GET /writing_books/1.xml
def show
get_types
@writing_book_category = @types.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.js
end
end
# GET /writing_books/new
# GET /writing_books/new.xml
def new
get_types
@writing_book_category = @types.new(:display => 'List')
@verb = :post
respond_to do |format|
format.html # new.html.erb
format.js
end
end
# GET /writing_books/1/edit
def edit
get_types
@writing_book_category = @types.find(params[:id])
# @url = panel_personal_book_back_end_writing_book_category_path(@writing_book_category)
# @url = eval("panel_personal_book_back_end_#{@app_type}_path(@writing_book_category)")
@url = polymorphic_path([:panel, :personal_book, :back_end, @writing_book_category])
@verb = :put
respond_to do |format|
format.html
format.js
end
end
# POST /writing_books
# POST /writing_books.xml
def create
get_types
@writing_book_category = @types.new(params[:writing_book_category])
respond_to do |format|
if @writing_book_category.save
format.html { redirect_to(panel_personal_book_back_end_writing_book_categorys_url, :notice => t('writing_book_category.create_writing_book_category_success')) }
format.js
else
format.html { render :action => "new" }
format.js { render action: "new" }
end
end
end
# PUT /writing_books/1
# PUT /writing_books/1.xml
def update
get_types
@writing_book_category = @types.find(params[:id])
# debugger
# @url = panel_personal_book_back_end_writing_book_category_path(@writing_book_category)
# @url = eval("panel_personal_book_back_end_#{@app_type}_path(#{@writing_book_category})")
@url = polymorphic_path([:panel, :personal_book, :back_end, @writing_book_category])
respond_to do |format|
if @writing_book_category.update_attributes(params[:writing_book_category])
format.html { redirect_to(panel_personal_book_back_end_writing_book_categorys_url, :notice => t('writing_book_category.update_writing_book_category_success')) }
# format.xml { head :ok }
format.js
else
format.html { render :action => "edit" }
format.js { render :action => "edit" }
end
end
end
# DELETE /writing_books/1
# DELETE /writing_books/1.xml
def destroy
get_types
@writing_book_category = @types.find(params[:id])
@writing_book_category.disable = @writing_book_category.disable ? false : true
if @writing_book_category.save!
respond_to do |format|
format.html { redirect_to(panel_personal_book_back_end_writing_book_categorys_url) }
# format.xml { head :ok }
format.js
end
else
flash[:error] = t("writing_book_category.update_failed")
format.html { render :action => "index" }
end
end
protected
def get_types
@types = @app_type.classify.constantize
end
end

View File

@ -0,0 +1,322 @@
class Panel::PersonalBook::BackEnd::WritingBooksController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :authenticate_user!
before_filter :only => [ :new,:edit,:update] do |controller|
controller.get_categorys('WritingBookCategory')
end
def index
get_plugins
# @tags = get_tags
# @categories = get_categories_for_index
# @statuses = get_statuses
# category_ids = @categories.collect{|t| t.id}
@paper_type_ids = BookPaperType.all.collect{|t| t.id.to_s} + [nil]
@writing_books = get_sorted_and_filtered("writing_book", :book_paper_type_id.in => @paper_type_ids)
respond_to do |format|
format.html # index.html.erb
format.js { }
format.xml { render :xml => @writing_books }
end
end
def writing_book_setting
get_plugins
@author_types = BookAuthorType.all
@paper_types = BookPaperType.all
@tags = get_tags
@set_author_type = BookAuthorType.new(:display => 'List')
@author_type_url = panel_personal_book_back_end_writing_books_path
@set_paper_type = BookPaperType.new(:display => 'List')
@paper_type_url = panel_personal_book_back_end_writing_books_path
end
def author_type_quick_add
@set_author_type = BookAuthorType.new(:display => 'List')
@author_type_url = panel_personal_book_back_end_writing_books_path
@set_author_type.id = params[:id]
respond_to do |format|
format.js
end
end
def author_type_quick_edit
@set_author_type = BookAuthorType.find(params[:writing_book_id])
@author_type_url = panel_personal_book_back_end_writing_book_path(@set_author_type)
respond_to do |format|
format.js
end
end
def paper_type_quick_add
@set_paper_type = BookPaperType.new(:display => 'List')
@paper_type_url = panel_personal_book_back_end_writing_books_path
@set_paper_type.id = params[:id]
respond_to do |format|
format.js
end
end
def paper_type_quick_edit
@set_paper_type = BookPaperType.find(params[:writing_book_id])
@paper_type_url = panel_personal_book_back_end_writing_book_path(@set_paper_type)
respond_to do |format|
format.js
end
end
# GET /writing_books/1
# GET /writing_books/1.xml
def show
@writing_book = WritingBook.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @writing_book }
end
end
# GET /writing_books/new
# GET /writing_books/new.xml
def new
get_plugins
@writing_book = WritingBook.new
# @writing_book_files = WritingBookFile.all
# @level_types = BookLevelType.all
@author_types = BookAuthorType.all
@paper_types = BookPaperType.all
@tags = get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @writing_book }
end
end
# GET /writing_books/1/edit
def edit
get_plugins
@writing_book = WritingBook.find(params[:id])
# @level_types = BookLevelType.all
@author_types = BookAuthorType.all
@paper_types = BookPaperType.all
@tags = get_tags
end
# POST /writing_books
# POST /writing_books.xml
def create
if params[:book_author_type]
@book_author_type = BookAuthorType.new(params[:book_author_type])
respond_to do |format|
if @book_author_type.save
format.js { render 'create_writing_book_setting' }
end
end
elsif params[:book_paper_type]
@book_paper_type = BookPaperType.new(params[:book_paper_type])
respond_to do |format|
if @book_paper_type.save
format.js { render 'create_writing_book_setting' }
end
end
else
# @level_types = BookLevelType.all
@author_types = BookAuthorType.all
@paper_types = BookPaperType.all
@tags = get_tags
@writing_book = WritingBook.new(params[:writing_book])
if params[:writing_book][:user_id]
@writing_book.create_user_id = params[:writing_book][:user_id]
@writing_book.update_user_id = params[:writing_book][:user_id]
else
@writing_book.create_user_id = current_user.id
@writing_book.update_user_id = current_user.id
end
respond_to do |format|
if @writing_book.save
if params[:writing_book][:user_id]
format.html { redirect_to(admin_users_new_interface_url(:id=>params[:writing_book][:user_id],:show_plugin_profile=>"WritingBook")) }
else
format.html { redirect_to(panel_personal_book_back_end_writing_books_url) }
end
format.xml { render :xml => @writing_book, :status => :created, :location => @writing_book }
else
format.html { render :action => "new" }
format.xml { render :xml => @writing_book.errors, :status => :unprocessable_entity }
end
end
end
end
# PUT /writing_books/1
# PUT /writing_books/1.xml
def update
if params[:book_author_type]
@book_author_type = BookAuthorType.find(params[:id])
respond_to do |format|
if @book_author_type.update_attributes(params[:book_author_type])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_writing_book_setting' }
end
end
elsif params[:book_paper_type]
@book_paper_type = BookPaperType.find(params[:id])
respond_to do |format|
if @book_paper_type.update_attributes(params[:book_paper_type])
# format.html { redirect_to(panel_announcement_back_end_bulletins_url) }
format.js { render 'update_writing_book_setting' }
end
end
else
@writing_book = WritingBook.find(params[:id])
@writing_book.update_user_id = current_user.id
params[:writing_book][:tag_ids] ||=[]
respond_to do |format|
if @writing_book.update_attributes(params[:writing_book])
format.html { redirect_to(panel_personal_book_back_end_writing_books_url) }
# format.js { render 'toggle_enable' }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @writing_book.errors, :status => :unprocessable_entity }
end
end
end
end
# DELETE /writing_books/1
# DELETE /writing_books/1.xml
def destroy
@writing_book = WritingBook.find(params[:id])
@writing_book.destroy
respond_to do |format|
format.html { redirect_to(panel_personal_book_back_end_writing_books_url) }
# format.xml { head :ok }
format.js
end
end
def delete
if params[:ids]
writing_books = WritingBook.any_in(:_id => params[:ids]).destroy_all
end
redirect_to panel_personal_book_back_end_writing_books_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
def data_share
if params[:ids]
@writing_books = WritingBook.any_in(:_id => params[:ids])
@writing_books.each do |writing_book|
writing_book.is_hidden = params[:disable]
writing_book.save
end
end
respond_to do |format|
format.html { redirect_to(admin_users_new_interface_url(:id=>params[:user_id],:show_plugin_profile=>"WritingBook")) }
format.json { render json: {"success"=>true}.to_json}
end
end
protected
# def get_index_categories(id = nil)
# @bulletin_categorys = []
# if(is_manager? || is_admin?)
# @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
# elsif is_sub_manager?
# @bulletin_categorys = BulletinCategory.all
# end
# @bulletin_categorys
# end
# def get_categorys(id = nil)
# @writing_book_categorys = []
# if(is_manager? || is_admin?)
# @writing_book_categorys = (id ? WritingBookCategory.admin_manager_all.find(id).to_a : WritingBookCategory.admin_manager_all))
# elsif is_sub_manager?
# @writing_book_categorys = WritingBookCategory.all.authed_for_user(current_user,'edit')
# end
# if @writing_book_categorys.empty? && params[:action] != "index"
# flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
# redirect_to :action => :index
# end
# end
def get_plugins
@plugins = OrbitApp::Plugin::Registration.all
end
end

View File

@ -0,0 +1,73 @@
class Panel::PersonalBook::Desktop::PersonalBooksController < ApplicationController
def index
@writing_books = WritingBook.where(create_user_id: current_user.id)
@view_by = params[:view]
page = params[:page]
page ||= 1
@per_column = 5
case @view_by
when "abstract"
@per_column = 1
when "file"
@per_column = 2
end
if @view_by.nil?
@view_by = " "
@writing_books = @writing_books.asc(:paper_title)
else
@writing_books = @writing_books.asc(@view_by).asc(:paper_title)
end
@writing_books = @writing_books.page(page).per(50)
respond_to do |format|
format.html { render :layout => false}
end
end
def new
@personal_book = WritingBook.new
@author_types = BookAuthorType.all
render :layout => false
end
def create
params[:writing_book][:create_user_id] = current_user.id
@personal_book = WritingBook.new(params[:writing_book])
if @personal_book.save
render json: {success: true, msg: t('create_success')}.to_json
else
error_msg = @personal_book.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def edit
@personal_book = WritingBook.find(params[:id])
@author_types = BookAuthorType.all
render :layout => false
end
def update
params[:writing_book][:create_user_id] = current_user.id
@personal_book = WritingBook.find(params[:id])
if @personal_book.update_attributes(params[:writing_book])
render json: {success: true, msg: t('create_success')}.to_json
else
error_msg = @personal_book.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def destroy
@personal_book = WritingBook.find(params[:id])
@personal_book.destroy
render :json => {success: true, msg: t('delete_success')}
end
def books_window
render :layout => false
end
end

View File

@ -0,0 +1,32 @@
class Panel::PersonalBook::Desktop::PluginIntrosController < ApplicationController
def index
@intro = PersonalBookIntro.where(:user_id => current_user.id.to_s).first
if @intro.blank?
@intro = PersonalBookIntro.new
render "new", :layout => false
else
render "edit", :layout => false
end
end
def create
@intro = PersonalBookIntro.new(params[:personal_book_intro])
@intro.user_id = current_user.id
if @intro.save
render :json => {"success" => true}.to_json
else
render :json => {"success" => false}.to_json
end
end
def update
@intro = PersonalBookIntro.find(params[:id])
if @intro.update_attributes(params[:personal_book_intro])
render :json => {"success" => true}.to_json
else
render :json => {"success" => false}.to_json
end
end
end

View File

@ -0,0 +1,24 @@
class Panel::PersonalBook::FrontEnd::WritingBooksController < OrbitWidgetController
def initialize
super
@app_title = 'personal_book'
end
def index
@writing_books = WritingBook.where(:is_hidden => false).desc(:year,:publish_date).page(params[:page]).per(10)
end
# GET /writing_books/1
# GET /writing_books/1.xml
def show
@writing_book = WritingBook.find(params[:id])
@book_author_types = ( !@writing_book.book_author_types.blank? ? @writing_book.book_author_types.collect{|x| x.title}.join(', ') : nil)
end
end

View File

@ -0,0 +1,179 @@
class Panel::PersonalBook::Plugin::WritingBooksController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :authenticate_user!
# before_filter :for_app_manager,:except => [:index,:show]
before_filter :only => [ :new,:edit,:update] do |controller|
controller.get_categorys('WritingBookCategory')
end
def index
get_categorys("BookPaperType",params[:book_paper_type_id])
@filter = params[:filter]
new_filter = params[:new_filter]
if @filter && params[:clear]
@filter.delete(params[:type])
elsif @filter && new_filter
if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
@filter[new_filter[:type]].delete(new_filter[:id].to_s)
elsif @filter.has_key?(new_filter[:type])
@filter[new_filter[:type]] << new_filter[:id].to_s
else
@filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
end
elsif new_filter
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
end
@paper_types = BookPaperType.all
@paper_type_ids = @paper_types.collect{|t| t.id.to_s} + [nil]
# @writing_books = WritingBook.search(params[:category_id])
#@writing_books = (params[:sort] || @filter) ? get_sorted_and_filtered_writing_books : WritingBook.all.page(params[:page]).per(10)
@writing_books = (params[:sort] || @filter) ? get_sorted_and_filtered("writing_book",:create_user_id => current_user.id) : get_viewable("writing_book", :create_user_id => current_user.id)
@tags = get_tags
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @writing_books }
format.js
end
end
# GET /writing_books/1
# GET /writing_books/1.xml
def show
@writing_book = WritingBook.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @writing_book }
end
end
# GET /writing_books/new
# GET /writing_books/new.xml
def new
@writing_book = WritingBook.new
# @writing_book_files = WritingBookFile.all
# @level_types = BookLevelType.all
@author_types = BookAuthorType.all
@paper_types = BookPaperType.all
@tags = get_tags
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @writing_book }
end
end
# GET /writing_books/1/edit
def edit
@writing_book = WritingBook.find(params[:id])
# @level_types = BookLevelType.all
@author_types = BookAuthorType.all
@paper_types = BookPaperType.all
@tags = get_tags
end
# POST /writing_books
# POST /writing_books.xml
def create
# @level_types = BookLevelType.all
@author_types = BookAuthorType.all
@paper_types = BookPaperType.all
@tags = get_tags
@writing_book = WritingBook.new(params[:writing_book])
@writing_book.create_user_id = current_user.id
@writing_book.update_user_id = current_user.id
respond_to do |format|
if @writing_book.save
format.html { redirect_to(panel_personal_book_plugin_writing_books_url) }
format.xml { render :xml => @writing_book, :status => :created, :location => @writing_book }
else
format.html { render :action => "new" }
format.xml { render :xml => @writing_book.errors, :status => :unprocessable_entity }
end
end
end
# PUT /writing_books/1
# PUT /writing_books/1.xml
def update
@writing_book = WritingBook.find(params[:id])
@writing_book.update_user_id = current_user.id
params[:writing_book][:tag_ids] ||=[]
respond_to do |format|
if @writing_book.update_attributes(params[:writing_book])
format.html { redirect_to(panel_personal_book_plugin_writing_books_url) }
# format.js { render 'toggle_enable' }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @writing_book.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /writing_books/1
# DELETE /writing_books/1.xml
def destroy
@writing_book = WritingBook.find(params[:id])
@writing_book.destroy
respond_to do |format|
format.html { redirect_to(panel_personal_book_plugin_writing_books_url) }
# format.xml { head :ok }
format.js
end
end
def delete
if params[:ids]
writing_books = WritingBook.any_in(:_id => params[:ids]).destroy_all
end
redirect_to panel_personal_book_plugin_writing_books_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
protected
# def get_index_categories(id = nil)
# @bulletin_categorys = []
# if(is_manager? || is_admin?)
# @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all)
# elsif is_sub_manager?
# @bulletin_categorys = BulletinCategory.all
# end
# @bulletin_categorys
# end
# def get_categorys(id = nil)
# @writing_book_categorys = []
# if(is_manager? || is_admin?)
# @writing_book_categorys = (id ? WritingBookCategory.admin_manager_all.find(id).to_a : WritingBookCategory.admin_manager_all))
# elsif is_sub_manager?
# @writing_book_categorys = WritingBookCategory.all.authed_for_user(current_user,'edit')
# end
# if @writing_book_categorys.empty? && params[:action] != "index"
# flash[:alert] = t("announcement.error.no_avilb_cate_for_posting")
# redirect_to :action => :index
# end
# end
end

0
app/helpers/.gitkeep Normal file
View File

View File

@ -0,0 +1,103 @@
module Panel::PersonalBook::Desktop::PersonalBooksHelper
def publication_record publication, view
content_tag :li,
"item" => "true",
"data-id" => publication.id.to_s,
:class => "list_t_item #{view.blank? ? '' : "#{view}_view" } #{publication.is_hidden? ? "private" : "public" }" do
content_tag :div,
:class => "inner" do
marker(publication.id) + \
content(publication, view) + \
edit_or_delete(publication)
end
end
end
def marker id
content_tag :div,
:class => "list_item_action" do
content_tag(:a, "",:href=>"",
:class => "icon-check-empty",
"toggle-onclick"=>"icon-check-empty icon-check",
"data-id" => id.to_s,
"ajax-remote"=>"false") + \
content_tag(:a, "",:href=>"",
:class => "icon-star-empty",
"toggle-onclick"=>"icon-star-empty icon-star",
"data-id" => id.to_s,
"ajax-remote"=>"false")
end
end
def content publication, view
case view
when "book_title"
des = content_tag(:div, publication.book_title,
:class => "list_t_des")
when "keywords"
des = content_tag(:div, publication.keywords,
:class => "list_t_des")
when "publisher"
des = content_tag(:div, publication.publisher,
:class => "list_t_des")
when "file"
des = content_tag(:div, link_publication_file(publication),
:class => "list_t_des")
else
end
content_tag(:div, publication.paper_title,
:class => "list_t_title") + des
end
def edit_or_delete publication
content_tag :div,
:class => "list_item_function" do
content_tag(:a, t("edit"),
:class => "journal_paper_edit admbg2 admtxt",
:href => edit_panel_personal_book_desktop_personal_book_path(publication),
"callback-method" => "editbook",
"ajax-remote" => "get") + \
content_tag(:a, t(:delete_),
"ajax-remote" => "delete",
"confirm-message" => t("sure?"),
"callback-method" => "bookDelete",
:class => "journal_paper_delete admbg2 admtxt",
:href => panel_personal_book_desktop_personal_book_path(publication))
end
end
def link_publication_file publication
publication.writing_book_files.map{|file|
link_to(image_tag(check_file_type(file.file.url)) + \
content_tag(:span, (file.title_translations[I18n.locale.to_s] rescue nil), :class => "filetitle"),
file.file.url,
:class => "file",
"target" => "_blank",
"title" => (file.title_translations[I18n.locale.to_s] rescue nil))
}.inject(:+)
end
def check_file_type file
if not file.nil?
file_type = MIME::Types.type_for(file).first.to_s.split("/")[1]
file_type = "/assets/ft-icons/#{file_type}/#{file_type}-48_32.png"
else
file_type = ""
end
end
def generate_authors_name ids
author_name = ids.map{|m|
if m == "0"
#{:id => 0, :text => current_user.name, :email => current_user.email }
{:id => 0, :text => current_user.name }
else
#{:id => m, :text => ConferenceCoAuthor.find(m).co_author, :email => ConferenceCoAuthor.find(m).email}
{:id => m, :text => ConferenceCoAuthor.find(m).co_author}
end
}
author_name.to_json
end
end

0
app/mailers/.gitkeep Normal file
View File

0
app/models/.gitkeep Normal file
View File

View File

@ -0,0 +1,9 @@
# encoding: utf-8
class BookAuthorType < WritingBookCategory
field :title, localize: true
has_and_belongs_to_many :writing_books
end

View File

@ -0,0 +1,5 @@
class BookPaperType < WritingBookCategory
field :title, localize: true
end

View File

@ -0,0 +1,4 @@
class PersonalBookIntro < PersonalPluginIntro
end

116
app/models/writing_book.rb Normal file
View File

@ -0,0 +1,116 @@
# encoding: utf-8
class WritingBook
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
include OrbitModel::LanguageRestrict
include OrbitModel::Status
include OrbitTag::Taggable
LANGUAGE_TYPES = [ "English", "Chinese" ]
field :paper_title, localize: true
field :book_title, localize: true
field :authors, localize: true
field :extracted_chapters, localize: true
field :publisher, localize: true
field :editor, localize: true
# has_and_belongs_to_many :tags, :class_name => "PersonalBookTag"
has_and_belongs_to_many :book_author_types
belongs_to :book_paper_type
field :year
field :language
field :publish_date , :type => Date
field :pages
field :isbn
field :keywords
field :publication_date, :type => Date
field :url
field :note
field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId
paginates_per 10
has_many :writing_book_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :writing_book_files, :allow_destroy => true
# before_save :clean_checkboxs
validates :paper_title, :at_least_one => true
before_validation :add_http
after_save :save_writing_book_files
validates :url, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i, :unless => Proc.new{self.url.blank?}
def self.search( category_id = nil )
if category_id.to_s.size > 0
find(:all, :conditions => {writing_book_category_id: category_id}).desc( :is_top, :title )
else
find(:all).desc( :is_top, :title)
end
end
def self.widget_datas
where( :is_hidden => false ).desc(:is_top, :created_at)
end
def save_writing_book_files
self.writing_book_files.each do |t|
if t.should_destroy
t.destroy
end
end
end
def create_link
title = []
title << self.authors if self.authors.present?
# title << self.paper_title if self.paper_title.present?
title << self.book_title if self.book_title.present?
title << self.publisher if self.publisher.present?
title << self.isbn if self.isbn.present?
if !self.publish_date.nil?
pd = self.publish_date.strftime("%Y-%m-%d").split('-')
title << pd[0]+"/"+pd[1]
end
# title << "(#{self.journal_level_types.collect{|x| x.title}.join(', ')})"
title.join(', ')
end
protected
def add_http
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end
def clean_checkboxs
self.tag_ids.delete('')
self.book_author_type_ids.delete('')
end
end

View File

@ -0,0 +1,30 @@
# encoding: utf-8
class WritingBookCategory
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable
# include Mongoid::MultiParameterAttributes
AfterObjectAuthUrl = '/panel/personal_book/back_end/writing_book_categorys'
APP_NAME = 'writing_book'
# ObjectAuthTitlesOptions = %W{edit}
ObjectAuthTitlesOptions = %W{submit_new fact_check}
field :key
has_many :writing_books
def pp_object
title
end
def self.from_id(id)
WritingBookCategory.find(id) rescue nil
end
def self.is_localized?(field_name)
self.fields[field_name.to_s].localized?
end
end

View File

@ -0,0 +1,14 @@
class WritingBookFile
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, AssetUploader
field :description, localize: true
field :should_destroy, :type => Boolean
field :title, localize: true
belongs_to :writing_book
end

0
app/views/.gitkeep Normal file
View File

View File

@ -0,0 +1,44 @@
<% # encoding: utf-8 %>
<%= form_for(:writing_book_category, :remote => true, :url => @url, :method => @verb, :html => { :id => 'form_writing_book_category' } ) do |f| %>
<h2><%= (@writing_book_category.new_record? ? 'Add' : 'Edit') %></h2>
<div id="widget-title">
<%= f.label :key %>
<%= f.text_field :key %>
</div>
<div id="widget-title">
<% if @types.is_localized?(:title) %>
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (@writing_book_category.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
<% else %>
<div id="widget-title">
<%= f.label :title %>
<%= f.text_field :title %>
</div>
<% end %>
</div>
<div id="widget-title">
<%#= f.label :display %>
<%#= f.radio_button :display, "List" List%>
<%#= f.radio_button :display, "Picture" Picture%>
<%# <br />顯示方式是設定在前台頁面時,資訊所呈現的樣式 %>
</div>
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
</div>
<% end %>

View File

@ -0,0 +1,28 @@
<% # encoding: utf-8 %>
<div id="qe-basic" class="qe-edit-div">
<div id="widget-title">
<%= f.label :key %>
<%= f.text_field :key %>
</div>
<div id="widget-title">
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (news_bulletin_category.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div id="widget-title">
<%= f.label :display %>
<%= f.radio_button :display, "List" %>List
<%= f.radio_button :display, "Picture" %>Picture
<br />顯示方式是設定在前台頁面時,資訊所呈現的樣式
</div>
</div>

View File

@ -0,0 +1,22 @@
<tr id="<%= dom_id writing_book_category %>" class="with_action">
<td>
<%= writing_book_category.key %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if is_admin?%>
<li><%= link_to t('writing_book_category.edit'),
polymorphic_path([:panel, :personal_book, :back_end, writing_book_category], {:action => :edit}), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(writing_book_category), polymorphic_path([:panel, :personal_book, :back_end, writing_book_category]), :confirm => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle" %></li>
<% end %>
</ul>
</div>
</td>
<% if @types.is_localized?(:title) %>
<% @site_in_use_locales.each do |locale| %>
<td><%= writing_book_category.title_translations[locale] rescue nil %></td>
<% end %>
<% else %>
<td><%= writing_book_category.title %></td>
<% end %>
</tr>

View File

@ -0,0 +1,2 @@
$('<%= j render :partial => 'writing_book_category', :collection => [@writing_book_category] %>').appendTo('#writing_book_categorys').hide().fadeIn();
$("#form_writing_book_category")[0].reset();

View File

@ -0,0 +1 @@
$("#<%= dom_id @writing_book_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@writing_book_category) %> ");

View File

@ -0,0 +1,7 @@
<h1><%= t('personal_book.editing_personal_book_class') %></h1>
<%= form_for @writing_book_category, :url => panel_personal_book_back_end_writing_book_category_path(@writing_book_category) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>

View File

@ -0,0 +1 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -0,0 +1,29 @@
<%= flash_messages %>
<%= @types %>
<table id="writing_book_categorys" class="table main-list">
<thead>
<tr>
<th class="span1-2"><%= t('writing_book_category.key') %></th>
<% if @types.is_localized?(:title) %>
<% @site_in_use_locales.each do |locale| %>
<th class="span1-2"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
<% end %>
<% else %>
<th class="span1-2"><%= t('writing_book_category.title') %></th>
<% end %>
</tr>
</thead>
<tbody>
<%= render :partial => 'writing_book_category', :collection => @writing_book_categorys %>
</tbody>
</table>
<div id="form"><%= render :partial => "form" if is_manager? %></div>

View File

@ -0,0 +1,19 @@
<% content_for :secondary do %>
<%= render :partial => '/panel/personal_book/back_end/personal_book_secondary' %>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<h1><%= t('writing_book_category.new_personal_book_class') %></h1>
<%= form_for @writing_book_category, :url => panel_personal_book_back_end_writing_book_categorys_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>

View File

@ -0,0 +1 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -0,0 +1,4 @@
$("#<%= dom_id @writing_book_category %>").replaceWith("<%= j render :partial => 'writing_book_category', :collection => [@writing_book_category] %>");
<% @writing_book_category = @types.new(:display => 'List') # reset for new form %>
$("#form_writing_book_category").replaceWith("<%= j render "form" %>")
$("#form_writing_book_category")[0].reset();

View File

@ -0,0 +1,34 @@
<% # encoding: utf-8 %>
<%= form_for(@set_author_type, :remote => true, :url => @author_type_url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabe2"><%= (@set_author_type.new_record? ? 'Add 作者型態' : 'Edit 作者型態') %></h3>
</div>
<div class="modal-body">
<div class="control-group">
<label for="http" class="control-label">Key</label>
<div class="controls">
<%= f.text_field :key %>
</div>
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "link-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'control-label', :value => (@set_author_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= hidden_field_tag 'writing_book_category[author_type]', @set_author_type.id %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,9 @@
<div class="table-label">
<div id="sort_headers" class="table-label">
<%= render 'sort_headers' %>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "sort_header" %>
<% end %>

View File

@ -0,0 +1,340 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<%= f.error_messages %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<% if show_form_status_field(@writing_book) %>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
<% end %>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if !params[:user_id].blank? %>
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= User.from_id(params[:user_id]).name rescue ''%>
</div>
</div>
<% end %>
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.author_type") %></label>
<div class="controls">
<% @author_types.each do |author_type| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'writing_book[book_author_type_ids][]', author_type.id, @writing_book.book_author_type_ids.include?(author_type.id)%>
<%= author_type.title %>
<%= hidden_field_tag 'writing_book[book_author_type_ids][]', '' %>
<% end %>
<% end %>
</div>
</div>
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.book_paper_type") %></label>
<div class="controls">
<%= f.select :book_paper_type_id, @paper_types.collect {|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- year -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.year") %></label>
<div class="controls">
<%= select_year((@writing_book.year ? @writing_book.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'writing_book[year]',:class => 'span1'} ) %>
</div>
</div>
<!-- publish_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.publish_date") %></label>
<div class="controls">
<%= f.date_select :publish_date, {:use_month_numbers => true, :start_year => Time.now.year, :end_year => 1930, :order => [:year, :month, :day] }, {:class => 'span1'} %>
</div>
</div>
<!-- publication_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.publication_date") %></label>
<div class="controls">
<%= f.date_select :publication_date, {:use_month_numbers => true, :start_year => Time.now.year, :end_year => 1890, :order => [:year, :month, :day] }, {:class => 'span1'} %>
</div>
</div>
<!-- url -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.url") %></label>
<div class="controls">
<%= f.text_field :url , :class => "span6" %>
</div>
</div>
<!-- keywords -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords %>
</div>
</div>
<!-- pages -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.pages") %></label>
<div class="controls">
<%= f.text_field :pages %>
</div>
</div>
<!-- isbn -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.isbn") %></label>
<div class="controls">
<%= f.text_field :isbn %>
</div>
</div>
<!-- language -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.language") %></label>
<div class="controls">
<%= f.radio_button :language, "Chinese" %> <%= t("personal_book.Chinese") %>
<%= f.radio_button :language, "English" %> <%= t("personal_book.English") %>
</div>
</div>
<!-- note -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_book.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
<% if show_form_status_field(@writing_book) %>
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @writing_book.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<% end %>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<% @tags.each do |tag| %>
<label class="checkbox inline btn <%= 'active' if @writing_book.tag_ids.include?(tag.id) %>">
<%= check_box_tag 'writing_book[tag_ids][]', tag.id, @writing_book.tag_ids.include?(tag.id) %> <%= tag.name %>
<%= hidden_field_tag 'writing_book[tag_ids][]', '' %>
</label>
<% end %>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- paper_title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_book.paper_title") %></label>
<div class="controls">
<%= f.fields_for :paper_title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.paper_title"), value: (@writing_book.paper_title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- book_title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_book.book_title") %></label>
<div class="controls">
<%= f.fields_for :book_title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.book_title"), value: (@writing_book.book_title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- extracted_chapters-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_book.extracted_chapters") %></label>
<div class="controls">
<%= f.fields_for :extracted_chapters_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.extracted_chapters"), value: (@writing_book.extracted_chapters_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- publisher-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_book.publisher") %></label>
<div class="controls">
<%= f.fields_for :publisher_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.publisher"), value: (@writing_book.publisher_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- editor-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_book.editor") %></label>
<div class="controls">
<%= f.fields_for :editor_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.editor"), value: (@writing_book.editor_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- authors-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_book.authors") %></label>
<div class="controls">
<%= f.fields_for :authors_translations do |f| %>
<%= f.text_area locale, rows: 2, class: "input-block-level", value: (@writing_book.authors_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @writing_book && !@writing_book.writing_book_files.blank? %>
<div class="exist">
<% @writing_book.writing_book_files.each_with_index do |writing_book_file, i| %>
<%= f.fields_for :writing_book_files, writing_book_file do |f| %>
<%= render :partial => 'form_file', :object => writing_book_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'plugin_file_field_count', @writing_book.writing_book_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(document).ready(function() {
$('.main-forms .add-on').tooltip();
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_writing_book_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :writing_book_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>
<% end %>

View File

@ -0,0 +1,45 @@
<% if form_file.new_record? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,11 @@
<% # encoding: utf-8 %>
<tr id="<%= dom_id list_author_type %>">
<td><%= list_author_type.title %></td>
<td class="span2">
<a href="<%= panel_personal_book_back_end_writing_book_author_type_quick_edit_path(list_author_type) %>#myModal2" data-toggle="modal" data-remote="true" class="action"><%= t('edit')%></a>
<%= link_to 'Delete',
polymorphic_path([:panel, :personal_book, :back_end, list_author_type]), :confirm => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1,11 @@
<% # encoding: utf-8 %>
<tr id="<%= dom_id list_paper_type %>">
<td><%= list_paper_type.title %></td>
<td class="span2">
<a href="<%= panel_personal_book_back_end_writing_book_paper_type_quick_edit_path(list_paper_type) %>#myModal1" data-toggle="modal" data-remote="true" class="action"><%= t('edit')%></a>
<%= link_to 'Delete',
polymorphic_path([:panel, :personal_book, :back_end, list_paper_type]), :confirm => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1,34 @@
<% # encoding: utf-8 %>
<%= form_for(@set_paper_type, :remote => true, :url => @paper_type_url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabe1"><%= (@set_paper_type.new_record? ? 'Add 類別' : 'Edit 類別') %></h3>
</div>
<div class="modal-body">
<div class="control-group">
<label for="http" class="control-label">Key</label>
<div class="controls">
<%= f.text_field :key %>
</div>
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "link-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'control-label', :value => (@set_paper_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
<div class="modal-footer">
<%= hidden_field_tag 'writing_book_category[paper_type]', @set_paper_type.id %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,16 @@
<tr id="<%= dom_id writing_book %>" class="with_action">
<td class="span1"><%= writing_book.year %></td>
<td class="span1">
<%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<%if at_least_module_manager || writing_book.writing_book_category.cur_user_is_sub_manager_of(:edit)%>
<li><%= link_to t('edit'), edit_panel_personal_book_back_end_writing_book_path(writing_book) %></li>
<li><%= link_to t(:delete_), panel_personal_book_back_end_writing_book_path(writing_book), :confirm => t('sure?'), :method => :delete, :remote => true %></li>
<% end -%>
</ul>
</div>
</td>
<td class="span1"><%= User.from_id(writing_book.create_user_id).name rescue ''%></td>
</tr>

View File

@ -0,0 +1 @@
$("#myModal2").html("<%= j render "author_type_qe" %>");

View File

@ -0,0 +1 @@
$("#myModal2").html("<%= j render "author_type_qe" %>");

View File

@ -0,0 +1,10 @@
<% if !@book_paper_type.blank? %>
$("#myModal1").modal('hide');
$('<%= j render :partial => 'list_paper_type', :collection => [@book_paper_type] %>').appendTo('#paper_types').hide().fadeIn();
<% end %>
<% if !@book_author_type.blank? %>
$("#myModal2").modal('hide');
$('<%= j render :partial => 'list_author_type', :collection => [@book_author_type] %>').appendTo('#author_types').hide().fadeIn();
<% end %>

View File

@ -0,0 +1 @@
$("#<%= dom_id @writing_book %>").remove();

View File

@ -0,0 +1,16 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(@site), :icon => 'icons-users', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<div class="subnav">
<%= render :partial => 'admin/plugins/plugin_list' %>
</div>
<%= form_for @writing_book, url: panel_personal_book_back_end_writing_book_path(@writing_book), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,35 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(@site), :icon => 'icons-users', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<div class="subnav">
<%= render :partial => 'admin/plugins/plugin_list' %>
<%= render 'filter' %>
</div>
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t("personal_book.year") %></th>
<th class="span7"><%= t("personal_book.book_title") %></th>
<th class="span1"><%= t("personal_plugins.author") %></th>
</tr>
</thead>
<tbody id="tbody_writing_books" class="sort-holder">
<%= render :partial => 'writing_book', :collection => @writing_books %>
</tbody>
</table>
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), panel_personal_book_back_end_writing_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_panel_personal_book_back_end_writing_book_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
<%= paginate @writing_books, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
</div>
</div>

View File

@ -0,0 +1,3 @@
$("#sort_headers").html("<%= j render 'sort_headers' %>");
$("#tbody_writing_books").html("<%= j render :partial => 'writing_book', :collection => @writing_books %>");
$("#writing_book_pagination").html("<%= j paginate @writing_books, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>");

View File

@ -0,0 +1,16 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(@site), :icon => 'icons-users', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<div class="subnav">
<%= render :partial => 'admin/plugins/plugin_list' %>
</div>
<%= form_for @writing_book, url: panel_personal_book_back_end_writing_books_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1 @@
$("#myModal1").html("<%= j render "paper_type_qe" %>");

View File

@ -0,0 +1 @@
$("#myModal1").html("<%= j render "paper_type_qe" %>");

View File

@ -0,0 +1,3 @@
$("#enable_<%= @bulletin.id %>").toggle();
$("#disable_<%= @bulletin.id %>").toggle();
$("#bulletin_<%= @bulletin.id %>").toggleClass('disable');

View File

@ -0,0 +1,10 @@
<% if !@book_paper_type.blank? %>
$("#myModal1").modal('hide');
$("#<%= dom_id @book_paper_type %>").replaceWith("<%= j render :partial => 'list_paper_type', :collection => [@book_paper_type] %>");
<% end %>
<% if !@book_author_type.blank? %>
$("#myModal2").modal('hide');
$("#<%= dom_id @book_author_type %>").replaceWith("<%= j render :partial => 'list_author_type', :collection => [@book_author_type] %>");
<% end %>

View File

@ -0,0 +1,153 @@
<% # encoding: utf-8 %>
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(@site), :icon => 'icons-users', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<div class="subnav">
<%= render :partial => 'admin/plugins/plugin_list' %>
</div>
<div id="isotope">
<div class="item element">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= panel_personal_book_back_end_writing_book_paper_type_quick_add_path('add') %>#myModal1" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_book.book_paper_type") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="paper_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_paper_type', :collection => @paper_types %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="item element">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= panel_personal_book_back_end_writing_book_author_type_quick_add_path('add') %>#myModal2" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_book.author_type") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="author_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_author_type', :collection => @author_types %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="item element">
<div class="detail w-a h-a">
<p class="totle">
<button class="btn btn-small btn-primary pull-right" type="button" data-toggle="modal" data-target="#myModal4"><i class="icon-plus"></i> 新增</button>
<span>領域</span>
</p>
<ul class="nav nav-tabs">
<li class="active"><a href="#">中文</a></li>
<li><a href="#">English</a></li>
</ul>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table class="table table-striped">
<tbody>
<tr>
<td>Corresponding Author</td>
<td>編輯 刪除</td>
</tr>
<tr>
<td>First Author, Co- Authors</td>
<td>編輯 刪除</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<!-- <a class="btn btn-primary pull-right" href><i class="icon-plus icon-white"></i> 匯出</a>&nbsp;
<a class="btn btn-primary pull-right" href><i class="icon-plus icon-white"></i> 匯入</a>&nbsp; -->
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_panel_personal_book_back_end_writing_book_path, :class => 'btn btn-primary pull-right' %>
</div>
<div id="author_type_qe">
<div style="display:none;" class="modal" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<%= render :partial => "author_type_qe" %>
</div>
</div>
<div id="paper_type_qe">
<div style="display:none;" class="modal" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<%= render :partial => "paper_type_qe" %>
</div>
</div>
<div style="display:none;" class="modal" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">領域</h3>
</div>
<ul class="nav nav-tabs">
<li class="active"><a href="#">中文</a></li>
<li><a href="#">English</a></li>
</ul>
<div class="modal-body">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputvalue">名稱</label>
<div class="controls">
<input type="text" id="inputvalue" placeholder="Value">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "item" %>
<% end %>

View File

@ -0,0 +1,162 @@
<div class="toolbar hh1">
<div class="fn_g hp">
<%= f.submit t("save"), name: "commit", class: "fn_btn ini_input hp hh1 thmc2 thmtxt" %>
<% if not @personal_book.new_record? %>
<%= submit_tag t("cancel"), :type => "button", "callback-method"=>"cancelbook", "ajax-remote" => "get", :href => panel_personal_book_desktop_personal_books_path, class: "fn_btn ini_input hp hh1 admbg2 admtxt" %>
<% end %>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1 ">Language</div>
<div class="admbg sdm_o language_select">
<ul>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li><a class="hp hh1 admtxt" href="" data-lang="<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1"><span class="icon-question-sign"></span></div>
</div>
</div>
<div class="overview" content-layout="simple" base-width="420">
<ul class="s_form" isotope="true">
<li class="s_grid_row" >
<% @site_in_use_locales.each_with_index do |locale, i| %>
<% style = locale != I18n.locale.to_s ? 'style=display:none;' : "" %>
<% data = "data-language=" + locale %>
<div class="form_fix" <%= style %> <%= data %>>
<%= f.fields_for :paper_title_translations do |f| %>
<%= f.text_area locale,
class: "s_grid_12 s_grid s_grid_h_3",
size: "20x4",
placeholder: t("personal_book.paper_title")+ "("+I18nVariable.from_locale(locale)+")",
value: (@personal_book.paper_title_translations[locale.to_s] rescue nil) %>
<% end %>
<%= f.fields_for :book_title_translations do |f| %>
<%= f.text_field locale,
size: "20",
placeholder: t("personal_book.book_title") + "("+I18nVariable.from_locale(locale)+")",
class: "s_grid_12 s_grid",
value: (@personal_book.book_title_translations[locale.to_s] rescue nil) %>
<% end %>
<%= f.fields_for :extracted_chapters_translations do |f| %>
<%= f.text_field locale,
size: "20",
placeholder: t("personal_book.extracted_chapters")+ "("+I18nVariable.from_locale(locale)+")",
class: "s_grid_12 s_grid",
value: (@personal_book.extracted_chapters_translations[locale.to_s] rescue nil) %>
<% end %>
<%= f.fields_for :publishers_translations do |f| %>
<%= f.text_field locale,
size: "20",
placeholder: t("personal_book.publishers")+ "("+I18nVariable.from_locale(locale)+")",
class: "s_grid_12 s_grid",
value: (@personal_book.publishers_translations[locale.to_s] rescue nil) %>
<% end %>
</div>
<% end %>
</li>
<li class="s_grid_row">
<%= label_tag("", t("personal_book.book_paper_type"), class: "s_grid_4 s_grid") %>
<%= f.select :book_paper_type_id, BookPaperType.all.collect {|t| [ t.title, t.id ]}, {:class => "s_grid s_grid_8"} %>
</li>
<li class="s_grid_row">
<%= label_tag("", t("personal_book.author_type"), class: "s_grid_4 s_grid") %>
<div class="s_select_g s_grid s_grid_8 s_grid_h_1">
<ul>
<% @author_types.each_with_index do |author_type, i| %>
<li>
<%= check_box_tag "writing_book[book_author_type_ids][]",
author_type.id,
@personal_book.book_author_type_ids.include?(author_type.id),
id: "field-#{i}"
%><%= label_tag("field-#{i}", author_type.title) %>
</li>
<% end %>
</ul>
</div>
</li>
<!-- <li class="s_grid_row">
<%#= f.text_area :author_tokens,
class: "s_grid_12 s_grid",
size: "20x2",
placeholder: t("personal_journal.authors"),
"autocomplete" => "/panel/personal_journal/desktop/journal_pages/new.json",
"autocomplete-format" => "--:[text,email]",
"data-pre" => generate_authors_name(@personal_book.journal_co_author_ids) %>
</li> -->
<li class="s_grid_row">
<%= label_tag("", t("personal_book.publication_date"), class: "s_grid_4 s_grid") %>
<%= f.date_select :publish_date, {:use_month_numbers => true, :start_year => Time.now.year, :end_year => 1930, :order => [:year] }, {:class => 's_grid_4 s_grid'} %>
<%= f.date_select :publish_date, {:use_month_numbers => true, :order => [:month, :day] }, {:class => 's_grid_2 s_grid'} %>
</li>
<li class="s_grid_row">
<%= label_tag("", t("personal_book.url"), class: "s_grid_4 s_grid") %><%= f.text_field :url, size: "20", class: "s_grid_8 s_grid"%>
</li>
<li class="s_grid_row">
<%= f.text_area :keywords, size: "20x3", placeholder: t("personal_book.keywords"), class: "s_grid_12 s_grid_h_2 s_grid"%>
</li>
<li class="s_grid_row">
<%= label_tag("", t("personal_book.pages"), class: "s_grid_4 s_grid") %><%= f.text_field :pages, size: "20", class: "s_grid_8 s_grid"%>
</li>
<li class="s_grid_row">
<%= f.label :language, t("personal_book.language"), :class => "s_grid s_grid_4" %>
<%= f.select :language, WritingBook::LANGUAGE_TYPES,{} ,{:class => "s_grid s_grid_8"} %>
</li>
<li class="s_grid_row">
<%= label_tag("", t("personal_book.isbn"), class: "s_grid_4 s_grid") %><%= f.text_field :isbn, size: "20", class: "s_grid_8 s_grid"%>
</li>
<li class="s_grid_row">
<%= f.text_area :note, size: "20x3", placeholder: t("personal_book.note"), class: "s_grid_12 s_grid s_grid_h_5 s_grid_h_full"%>
</li>
<li class="s_grid_row">
<table class="s_table">
<thead>
<tr>
<th class="s_grid_2"><%= t("personal_book.file")%></th>
<th class="s_grid_4"><%= t("personal_book.file_name")%></th>
<th class="s_grid_4"><%= t("personal_book.description") %></th>
<th class="s_grid_2"></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<div id='add_plugin_file' class="info_input plugin_files_block s_action">
<%= hidden_field_tag 'plugin_file_field_count', @personal_book.writing_book_files.count %>
<a class="add setting_btn thmc1 thmtxt w1 hh1 hp" href="#"><i class="icon-plus icon-white"></i> add</a>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% @personal_book.writing_book_files.each_with_index do |writing_book_file, i| %>
<%= f.fields_for :writing_book_files, writing_book_file do |f| %>
<%= render :partial => 'form_file', :object => writing_book_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>
</li>
</ul>
</div>
<script>
var get_html = function(old_id,new_id){
return ("<%= escape_javascript(add_attribute 'form_file', f, :writing_book_files) %>").replace(old_id, new_id);
}
</script>

View File

@ -0,0 +1,50 @@
<tr id="<%= "plugin_file_#{form_file.id}" if !form_file.new_record? %>" class="list_item">
<td>
<div>
<% if form_file.new_record? %>
<%= f.file_field :file, class: "s_grid_2", onchange:"var temp = o.filepathSplitter(this.value);temp=temp[temp.length - 1];this.parentNode.getElementsByTagName('label')[0].innerHTML = temp;var inputs = this.parentNode.parentNode.parentNode.getElementsByClassName('title_field');inputs[0].value = temp;inputs[1].value = temp;" %>
<label></label>
<% else %>
<%= link_to(image_tag(check_file_type(form_file.file.url)),
form_file.file.url,
:class => "file",
"target" => "_blank",
"title" => form_file.title) %>
<% end %>
</div>
</td>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<% style = locale != I18n.locale.to_s ? 'style=display:none;' : "" %>
<% data = "data-language=" + locale %>
<td <%= style %> <%= data %>>
<%= f.fields_for :file_title_translations do |f| %>
<%= f.text_field locale,
class: 's_grid_4 title_field',
placeholder: I18nVariable.from_locale(locale),
value: (form_file.file_title_translations[locale] rescue nil) %>
<% end %>
</td>
<td <%= style %> <%= data %>>
<%= f.fields_for :file_description_translations do |f| %>
<%= f.text_field locale,
class: 's_grid_4',
placeholder: I18nVariable.from_locale(locale),
value: (form_file.file_description_translations[locale] rescue nil) %>
<% end %>
</td>
<% end %>
<td>
<span class="action">
<% if form_file.new_record? %>
<a class="delete"><i class="icon-remove" style="cursor:pointer;"></i></a>
<% else %>
<%= f.hidden_field :id %>
<a class="remove_existing_record" style="cursor:pointer;"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
<%= form_file.file.file ? ( link_to '', form_file.file.url, {:class => 'icon-eye-open', :target => '_blank', :title => t(:view)} ) : '' %>
</span>
</td>
</tr>

View File

@ -0,0 +1,36 @@
<%= stylesheet_link_tag "/assets/personal_book/desktop/personal_book" %>
<%= javascript_include_tag "personal_book/desktop/personal_books" %>
<div id="books">
<div id="content">
<div id="header" class="hh2">
<div class="dtitle w2 hh2 hp">
<span class="thmtxth">Books</span>
</div>
<div id="search_app" class="hfn w2 hh1 hp thmc3">
<input type="text" class="ini_input form" value="Search" id="searchbox" />
<input type="submit" class="ini_input submit thmc1" value="Submit"/>
</div>
</div>
<div id="holder">
<div id="panel_l" class="ph">
<div class="s_menu sm_v" content-type="menu">
<ul id='setting_left_nav'>
<li><a href="<%= panel_personal_book_desktop_personal_books_path %>" callback-method="list" class="hh1 w2 hp active thmc1 thmtxt" load="true" onclick='return false;'>List</a></li>
<li><a href="<%= new_panel_personal_book_desktop_personal_book_path %>" callback-method="addbook" class="admtxt hh1 w2 hp" onclick='return false;'>Add/Edit</a></li>
<li><a href="<%= panel_personal_book_desktop_plugin_intros_path %>" class="admtxt hh1 w2 hp" callback-method="brief" onclick='return false;'>Brief Info</a></li>
<!-- <li><a href="" class="admtxt hh1 w2 hp" onclick='return false;'>Books</a></li>
<li><a href="" class="admtxt hh1 w2 hp" onclick='return false;'>Co-Authors</a></li>
<li><a href="" class="admtxt hh1 w2 hp" onclick='return false;'>Tags &amp; Keywords</a></li>
<li><a href="" class="admtxt hh1 w2 hp" onclick='return false;'>Analysis</a></li>
<li><a href="" class="admtxt hh1 w2 hp" onclick='return false;'>Import</a></li>
<li><a href="" class="admtxt hh1 w2 hp" onclick='return false;'>Export</a></li> -->
</ul>
</div>
</div>
<div id="panel_r" container="true" class="ph pw admbg hp">
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
<%= form_for @personal_book, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"}, url: panel_personal_book_desktop_personal_book_path(@personal_book) do |f| %>
<%= render partial: 'form', locals: {:f => f} %>
<%end%>

View File

@ -0,0 +1,70 @@
<div class="toolbar hh1">
<div class="hh1 hp sdm">
<div class="sdm_t hh1"><span class="icon-check"></span></div>
<div class="admbg sdm_o">
<ul id="journal_selection_options">
<li><a class="hp hh1 admtxt" href="all" ajax-remote="false" callback-method="allnone">All</a></li>
<li><a class="hp hh1 admtxt" href="none" ajax-remote="false" callback-method="allnone">None</a></li>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1">More</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh1 admtxt" href="">Delete</a></li>
<li><a class="hp hh1 admtxt" href="">Tag</a></li>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1">Tag</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh1 admtxt" href="">All</a></li>
<li><a class="hp hh1 admtxt" href="">Starred</a></li>
<li><a class="hp hh1 admtxt" href="">MIT</a></li>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1">Status</div>
<div class="admbg sdm_o">
<ul>
<li><a class="hp hh1 admtxt" href="">All</a></li>
<li><a class="hp hh1 admtxt" href="">Published</a></li>
<li><a class="hp hh1 admtxt" href="">Pending</a></li>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1">View</div>
<div class="admbg sdm_o">
<ul id="journal_view_selection">
<li><%= link_to "Title", panel_personal_book_desktop_personal_books_path + "?view=book_title", :class => "hp hh1 admtxt", "ajax-remote" => "get" %></li>
<li><%= link_to "File", panel_personal_book_desktop_personal_books_path + "?view=file", :class => "hp hh1 admtxt", "ajax-remote" => "get" %></li>
<li><%= link_to "Keywords", panel_personal_book_desktop_personal_books_path + "?view=keywords", :class => "hp hh1 admtxt", "ajax-remote" => "get" %></li>
<li><%= link_to "Publisher", panel_personal_book_desktop_personal_books_path + "?view=publisher", :class => "hp hh1 admtxt", "ajax-remote" => "get" %></li>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1">Share</div>
<div class="admbg sdm_o share_mode" data-link="<%= data_share_panel_personal_book_back_end_writing_books_path %>" data-var="disable" >
<ul>
<li><a class="hp hh1 admtxt" href="" item-class="private" data-mode="true" >Private</a></li>
<li><a class="hp hh1 admtxt" href="" item-class="public" data-mode="false" >Public</a></li>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1"><span class="icon-question-sign"></span></div>
</div>
</div>
<div class="overview" page-name="books_list" content-layout="simple" base-width="300" per-column="<%= @per_column.to_s %>" pagination-var="view=<%= @view_by %>&page" >
<ul isotope="true">
<% @writing_books.each do |w| %>
<%= publication_record w, @view_by%>
<% end %>
</ul>
</div>

View File

@ -0,0 +1,3 @@
<%= form_for @personal_book, html: { multipart: true, "form-type"=>"ajax_form", "callback-method"=>"formCallback"}, url: panel_personal_book_desktop_personal_books_path do |f| %>
<%= render partial: 'form', locals: {:f => f} %>
<%end%>

View File

@ -0,0 +1,54 @@
<div class="toolbar hh1">
<div class="fn_g hp">
<%= f.submit t("save"), name: "commit", class: "fn_btn ini_input hp hh1 thmc2 thmtxt" %>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1 ">Language</div>
<div class="admbg sdm_o language_select">
<ul>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li><a class="hp hh1 admtxt" href="" data-lang="<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
</div>
</div>
<div class="hh1 hp sdm">
<div class="sdm_t hh1"><span class="icon-question-sign"></span></div>
</div>
</div>
<div class="overview" content-layout="simple">
<ul class="s_form">
<li class="s_grid_row">
<%= label_tag("", "Frontend Page", :class => 's_grid s_grid_4') %>
<div class="s_select_g s_grid s_grid_8 s_grid_h_2">
<ul>
<li>
<%= f.check_box :brief_intro,
id: "field-0" %>
<label for="field-0"> Brief Intro </label>
</li>
<li>
<%= f.check_box :complete_list,
id: "field-1" %>
<label for="field-1"> Complete List </label>
</li>
</ul>
</div>
</li>
<% @site_in_use_locales.each_with_index do |locale, i| %>
<% style = locale != I18n.locale.to_s ? 'style=display:none;' : "" %>
<% data = "data-language=" + locale %>
<li class="s_grid_row" <%= style %> <%= data %>>
<%= label_tag("", I18nVariable.from_locale(locale), :class => 's_grid s_grid_4') %>
</li>
<li class="s_grid_row" <%= style %> <%= data %>>
<%= f.fields_for :text_translations do |f| %>
<%= f.text_area locale, :class=>"editor", rows: 5, :value => (@intro.text_translations[locale] rescue nil) %>
<% end %>
</li>
<% end %>
</ul>
</div>

View File

@ -0,0 +1,3 @@
<%= form_for @intro, html: { multipart: true, "form-type"=>"ajax_form","notification"=>"Brief Intro Updated"}, url: panel_personal_book_desktop_plugin_intro_path(@intro) do |f| %>
<%= render partial: 'form', locals: {:f => f} %>
<%end%>

View File

@ -0,0 +1,3 @@
<%= form_for @intro, html: { multipart: true, "form-type"=>"ajax_form", "notification"=>"Brief Intro Saved"}, url: panel_personal_book_desktop_plugin_intros_path do |f| %>
<%= render partial: 'form', locals: {f: f} %>
<% end %>

View File

@ -0,0 +1,50 @@
<%
if @member
@writing_books = WritingBook.where(is_hidden: false, :create_user_id => @member.id).desc(:year,:publish_date)
@writing_book_intro = !PersonalBookIntro.where(:user_id => @member.id).blank? ? PersonalBookIntro.where(:user_id => @member.id).first : PersonalBookIntro.new
%>
<% if @writing_book_intro.brief_intro and !@writing_book_intro.blank? %>
<div class="info">
<%= @writing_book_intro.text.html_safe rescue '' %>
</div>
<% end %>
<% if ( !@writing_book_intro.blank? and @writing_book_intro.complete_list ) or @writing_book_intro.blank? %>
<% if !@writing_books.blank? %>
<table class="table">
<thead>
<tr>
<th class="grid1"><%= t('personal_book.year') %></th>
<th class="grid8"><%= t('personal_book.book_title') %></th>
<th class="grid3"><%= t('personal_book.authors') %></th>
</tr>
</thead>
<tbody>
<% @writing_books.each do |writing_book| %>
<tr>
<td><%= writing_book.year %></td>
<td>
<%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %>
</td>
<td><%= User.find(writing_book.create_user_id).name rescue '' %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>
<% end %>

View File

@ -0,0 +1,38 @@
<% # encoding: utf-8 %>
<%= flash_messages %>
<h1><%= t('module_name.personal_book') %></h1>
<table class="table">
<thead>
<tr>
<th class="grid1"><%= t('personal_book.year') %></th>
<th class="grid1"><%= t('personal_book.book_paper_type') %></th>
<th class="grid8"><%= t('personal_book.book_title') %></th>
<th class="grid3"><%= t('personal_book.authors') %></th>
</tr>
</thead>
<tbody>
<% @writing_books.each do |writing_book| %>
<tr>
<td><%= writing_book.year %></td>
<td><%= writing_book.book_paper_type.title %></td>
<td>
<%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %>
</td>
<td><%= User.find(writing_book.create_user_id).name rescue '' %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @writing_books, :params => {:inner => false}%>

View File

@ -0,0 +1,79 @@
<% # encoding: utf-8 %>
<table>
<caption> <%= t("module_name.personal_book") %> </caption>
<tbody>
<% if !@writing_book.year.blank? %>
<tr><th><%= t("personal_book.year")%></th><td><%= @writing_book.year %></td></tr>
<% end %>
<% if !@writing_book.language.blank? %>
<tr><th><%= t("personal_book.language")%></th><td><%= @writing_book.language %></td></tr>
<% end %>
<% if !@writing_book.paper_title.blank? %>
<tr><th><%= t("personal_book.paper_title")%></th><td><%= @writing_book.paper_title %></td></tr>
<% end %>
<% if !@writing_book.book_title.blank? %>
<tr><th><%= t("personal_book.book_title")%></th><td><%= @writing_book.book_title %></td></tr>
<% end %>
<% if !@writing_book.book_paper_type.blank? %>
<tr><th><%= t("personal_book.book_paper_type")%></th><td><%= @writing_book.book_paper_type.title if !@writing_book.book_paper_type.blank? %></td></tr>
<% end %>
<% if !@book_author_types.blank? %>
<tr><th><%= t("personal_book.author_type")%></th><td><%= @book_author_types %></td></tr>
<% end %>
<% if !@writing_book.extracted_chapters.blank? %>
<tr><th><%= t("personal_book.extracted_chapters")%></th><td><%= @writing_book.extracted_chapters %></td></tr>
<% end %>
<% if !@writing_book.publisher.blank? %>
<tr><th><%= t("personal_book.publisher")%></th><td><%= @writing_book.publisher %></td></tr>
<% end %>
<% if !@writing_book.editor.blank? %>
<tr><th><%= t("personal_book.editor")%></th><td><%= @writing_book.editor %></td></tr>
<% end %>
<% if !@writing_book.publish_date.blank? %>
<tr><th><%= t("personal_book.publish_date")%></th><td><%= @writing_book.publish_date %></td></tr>
<% end %>
<% if !@writing_book.pages.blank? %>
<tr><th><%= t("personal_book.pages")%></th><td><%= @writing_book.pages %></td></tr>
<% end %>
<% if !@writing_book.isbn.blank? %>
<tr><th><%= t("personal_book.isbn")%></th><td><%= @writing_book.isbn %></td></tr>
<% end %>
<% if !@writing_book.publication_date.blank? %>
<tr><th><%= t("personal_book.publication_date")%></th><td><%= @writing_book.publication_date %></td></tr>
<% end %>
<% if !@writing_book.url.blank? %>
<tr><th><%= t("personal_book.url")%></th><td><%= link_to t(:url), @writing_book.url, {:target => '_blank', :title => @writing_book.url} if !@writing_book.url.blank? %></td></tr>
<% end %>
<tr><th><%= t("personal_book.authors")%></th><td><%= "#{User.from_id(@writing_book.create_user_id).name rescue ''},#{@writing_book.authors rescue ''}"%></td></tr>
<% if @writing_book.writing_book_files.size > 0 %>
<tr><th><%= t("personal_book.files")%></th>
<td>
<div>
<div class="showFile">
<i class="icons-paperclip"></i>
<% @writing_book.writing_book_files.each do | wjfile | %>
<%= link_to wjfile.title, wjfile.file.url, {:target => '_blank', :title => wjfile.title} if wjfile.file.file %>
<% end %>
</div>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@ -0,0 +1,96 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/list-check" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/list-check" %>
<% end %>
<%
@filter = params[:filter]
new_filter = params[:new_filter]
if @filter && params[:clear]
@filter.delete(params[:type])
elsif @filter && new_filter
if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
@filter[new_filter[:type]].delete(new_filter[:id].to_s)
elsif @filter.has_key?(new_filter[:type])
@filter[new_filter[:type]] << new_filter[:id].to_s
else
@filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
end
elsif new_filter
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
end
if @user && is_admin?
@writing_books = WritingBook.where(:create_user_id => @user.id).desc(:year).page(params[:page]).per(10)
else
@writing_books = WritingBook.where(is_hidden: false, :create_user_id => @user.id).desc(:year).page(params[:page]).per(10)
end
%>
<% if is_admin? %>
<div class="list-active">
<div class="btn-group">
<%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => data_share_panel_personal_book_back_end_writing_books_path(:user_id => params[:id], :disable => 'true') ) %>
<%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => data_share_panel_personal_book_back_end_writing_books_path(:user_id => params[:id], :disable => 'false') ) %>
</div>
</div>
<% end -%>
<table class="table table-condensed table-striped">
<thead>
<tr>
<% if is_admin? %>
<th><input type="checkbox" class="list-check" /></th>
<% end -%>
<th class="span1"><%= t('personal_book.year') %></th>
<th><%= t('personal_book.book_title') %></th>
</tr>
</thead>
<tbody>
<% @writing_books.each do |writing_book| %>
<tr class="<%= writing_book.is_hidden ? "checkHide" : "" %>">
<% if is_admin? %>
<td>
<%= check_box_tag 'to_change[]', writing_book.id.to_s, false, :class => "list-check" %>
</td>
<% end -%>
<td><%= writing_book.year %></td>
<td>
<%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% if is_admin? %>
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus') + t('personal_plugins.edit_brief_intro'), panel_personal_book_back_end_personal_book_intros_path(:user_id => @user.id), :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus') + t('announcement.add_new'), new_panel_personal_book_back_end_writing_book_path(:user_id => @user.id), :class => 'btn btn-primary' %>
</div>
<div class="pagination pagination-centered">
<%= paginate @writing_books, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
</div>
</div>
<% end %>
<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><%= t(:sure?) %></h3>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<button class="delete-item btn btn-danger"><%= t(:submit) %></button>
</div>
</div>

View File

@ -0,0 +1,11 @@
<div id="filter" class="subnav">
<div class="filters">
<div id="sort_headers" class="table-label">
<%= render 'sort_headers' %>
</div>
</div>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "sort_header" %>
<% end %>

View File

@ -0,0 +1,246 @@
<% # encoding: utf-8 %>
<%= f.error_messages %>
<!--Widget start-->
<div id="sub-wiget">
<div id="widget-tags" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="Setting">
<a class="action"><i class="icon-cog icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag"></i><%= f.label :author_type ,t("personal_book.author_type")%></h3>
<div class="widget-content clear form-horizontal">
<% @author_types.each do |author_type| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'writing_book[book_author_type_ids][]', author_type.id, @writing_book.book_author_type_ids.include?(author_type.id)%>
<%= author_type.title %>
<%= hidden_field_tag 'writing_book[book_author_type_ids][]', '' %>
<% end %>
<% end %>
</div>
</div>
<div id="widget-tags" class="widget-box widget-size-300">
<div class="widget-action clear tip" title="Setting">
<a class="action"><i class="icon-cog icon-white"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag"></i>Tags</h3>
<div class="widget-content clear form-horizontal">
<% @tags.each do |tag| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'writing_book[tag_ids][]', tag.id, @writing_book.tag_ids.include?(tag.id)%>
<%= tag.name %>
<%= hidden_field_tag 'writing_book[tag_ids][]', '' %>
<% end %>
<% end %>
</div>
</div>
</div>
<!--Wiget End-->
<!--Post Start-->
<div id="post-body">
<div id="post-body-content" class="clear">
<div class="title">
<%= f.label :year ,t("personal_book.year")%>
<%= select_year((@writing_book.year ? @writing_book.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'writing_book[year]'} ) %>
</div>
<div class="title">
<%= f.label :book_paper_type ,t("personal_book.book_paper_type")%>
<%= f.select :book_paper_type_id, @paper_types.collect {|t| [ t.title, t.id ]} %>
</div>
<ul class="nav nav-tabs">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="title">
<%= f.label :publish_date ,t("personal_book.publish_date")%>
<%= f.date_select :publish_date, {:use_month_numbers => true, :start_year => Time.now.year, :end_year => 1930, :order => [:year, :month, :day] }, {:class => 'span1'} %>
</div>
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= f.label :paper_title ,t("personal_book.paper_title")%>
<%= f.fields_for :paper_title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@writing_book.paper_title_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="title">
<%= f.label :book_title ,t("personal_book.book_title")%>
<%= f.fields_for :book_title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@writing_book.book_title_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="title">
<%= f.label :extracted_chapters ,t("personal_book.extracted_chapters")%>
<%= f.fields_for :extracted_chapters_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@writing_book.extracted_chapters_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="title">
<%= f.label :publisher ,t("personal_book.publisher")%>
<%= f.fields_for :publisher_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@writing_book.publisher_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="title">
<%= f.label :editor ,t("personal_book.editor")%>
<%= f.fields_for :editor_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@writing_book.editor_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="title">
<%= f.label :authors,t("web_resource.authors") %>
<%= f.fields_for :authors_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :size => "60x3", :value => (@writing_book.authors_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<% end %>
</div>
<div class="title">
<%= f.label :publication_date ,t("personal_book.publication_date")%>
<%= f.date_select :publication_date, {:use_month_numbers => true, :start_year => Time.now.year, :end_year => 1890, :order => [:year, :month, :day] }, {:class => 'span1'} %>
</div>
<div class="title">
<%= f.label :url, t("personal_book.url") %>
<%= f.text_field :url %>
</div>
<div class="title">
<%= f.label :keywords, t("personal_book.keywords") %>
<%= f.text_field :keywords %>
</div>
<div class="title">
<%= f.label :pages, t("personal_book.pages") %>
<%= f.text_field :pages %>
</div>
<div class="title">
<%= f.label :isbn, t("personal_book.isbn") %>
<%= f.text_field :isbn %>
</div>
<div id="title">
<%= f.label :language, t("personal_book.language") %>
<%= f.radio_button :language, "Chinese" %> <%= t("personal_book.Chinese") %>
<%= f.radio_button :language, "English" %> <%= t("personal_book.English") %>
</div>
<div class="title">
<%= f.label :note, t("personal_book.note") %>
<%= f.text_area :note, :size => "60x3" %>
</div>
</div>
<div>
<div id='plugin_files' class="plugin_files_block">
<table class="table table-condensed">
<thead>
<tr>
<th>File</th>
<th>File Name</th>
<th class="span1"></th>
</tr>
</thead>
<tfoot>
<tr>
<td style="text-align:center" colspan="3">
<div id='add_plugin_file' class="info_input plugin_files_block">
<%= hidden_field_tag 'plugin_file_field_count', @writing_book.writing_book_files.count %>
<a class="add"><span class="btn btn-primary btn-small"><i class="icon-plus icon-white"></i> ADD/新增</span></a>
</div>
</td>
</tr>
</tfoot>
<tbody>
<% @writing_book.writing_book_files.each_with_index do |writing_book_file, i| %>
<%= f.fields_for :writing_book_files, writing_book_file do |f| %>
<%= render :partial => 'form_file', :object => writing_book_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
<!--Post End-->
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "archive_plugin_form" %>
<script>
$('#add_plugin_file a.add').live('click', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_add_plugin_files", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parents('table').append(("<%= escape_javascript(add_attribute 'form_file', f, :writing_book_files) %>").replace(old_id, new_id));
});
$('.add_plugin_files_block a.delete').live('click', function(){
$(this).parents('.list_item').remove();
});
$('.action a.remove_existing_record').live('click', function(){
$(this).next('.should_destroy').attr('value', 1);
$("tr#add_plugin_file_" + $(this).prev().attr('value')).hide();
});
</script>
<% end %>

View File

@ -0,0 +1,50 @@
<% # encoding: utf-8 %>
<tr id="<%= "plugin_file_#{form_file.id}" if !form_file.new_record? %>" class='list_item'>
<td>
<div class="control-group">
<div class="controls">
<%= f.file_field :file %>
<%= form_file.file.file ? ( link_to t(:view), form_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %>
</div>
</div>
</td>
<td>
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<%#= f.fields_for :i18n_variable, (form_file.new_record? ? form_file.build_i18n_variable : form_file.i18n_variable ) do |f| %>
<%= f.fields_for :file_title_translations do |f| %>
<div class="control-group">
<label for="link-<%= locale %>" class="control-label"><%= I18nVariable.from_locale(locale) %></label>
<div class="controls">
<%= f.text_field locale, :class=>'post-file_title', :value => (form_file.file_title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
</td>
<td>
<span class="action">
<% if form_file.new_record? %>
<a class="delete"><i class="icon-remove"></i></a>
<% else %>
<%= f.hidden_field :id %>
<a class="remove_existing_record"><i class="icon-remove"></i></a>
<%= f.hidden_field :should_destroy, :value => nil, :class => 'should_destroy' %>
<% end %>
</span>
</td>
</tr>

View File

@ -0,0 +1,20 @@
<tr id="<%= dom_id writing_book %>" class="with_action">
<td>
<% if (writing_book.create_user_id == current_user.id) || is_manager? %>
<%= check_box_tag 'to_delete[]', writing_book.id, false, :class => "checkbox_in_list" %>
<% end -%>
</td>
<td><%= writing_book.year %></td>
<td>
<%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<%if at_least_module_manager || writing_book.writing_book_category.cur_user_is_sub_manager_of(:edit)%>
<li><%= link_to t('edit'), edit_panel_personal_book_plugin_writing_book_path(writing_book) %></li>
<li><%= link_to t(:delete_), panel_personal_book_plugin_writing_book_path(writing_book), :confirm => t('sure?'), :method => :delete, :remote => true %></li>
<% end -%>
</ul>
</div>
</td>
</tr>

View File

@ -0,0 +1 @@
$("#<%= dom_id @writing_book %>").remove();

View File

@ -0,0 +1,5 @@
<h1><%= t('personal_book.editing_personal_book') %></h1>
<%= form_for @writing_book, :url => panel_personal_book_plugin_writing_book_path(@writing_book), :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -0,0 +1,22 @@
<%= render 'filter' %>
<table class="table main-list">
<thead>
<tr>
<th class="span1"></th>
<th class="span1"></th>
<th class="span2"></th>
<th class="span3"></th>
<th class="span2"></th>
</tr>
</thead>
<tbody id="tbody_writing_books" class="sort-holder">
<%= render :partial => 'writing_book', :collection => @writing_books %>
</tbody>
</table>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_panel_personal_book_plugin_writing_book_path, :class => 'btn btn-primary pull-right' %>
<div id="writing_book_pagination" class="paginationFixed">
<%= paginate @writing_books, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
</div>
</div>

View File

@ -0,0 +1,3 @@
$("#sort_headers").html("<%= j render 'sort_headers' %>");
$("#tbody_writing_books").html("<%= j render :partial => 'writing_book', :collection => @writing_books %>");
$("#writing_book_pagination").html("<%= j paginate @writing_books, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>");

View File

@ -0,0 +1,10 @@
<%= flash_messages %>
<div id="poststuff">
<h1><%= t('writing_book.new_personal_book') %></h1>
<%= form_for @writing_book, :url => panel_personal_book_plugin_writing_books_path, :html => {:class => 'clear'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
<%#= link_back %>

View File

@ -0,0 +1,3 @@
$("#enable_<%= @bulletin.id %>").toggle();
$("#disable_<%= @bulletin.id %>").toggle();
$("#bulletin_<%= @bulletin.id %>").toggleClass('disable');

53
config/locales/en.yml Normal file
View File

@ -0,0 +1,53 @@
en:
module_name:
personal_book: Book
personal_book:
paper_title : "Paper Title"
book_title : "Book Title"
extracted_chapters : "Extracted Chapters"
publisher : "Publishers"
authors : "Authors"
tags : "Tags"
year : "Year"
language : "Language"
isbn : "ISSN(ISBN)"
vol_no : "Vol.No"
issue_no : "Issue.No"
form_to_start : "From"
form_to_end : "To"
total_pages : "Total Pages"
keywords : "Keywords"
abstract : "Abstract"
publication_date : "Date of Publication"
url : "Reference URL"
note : "Note"
level_type : "Level Type"
author_type : "Author Type"
from : "From"
to : "To"
file : "File"
file_name : "File name"
description : "File Description"
pages : "Pages"
book_paper_type : "Book Paper Type"
frontend:
writing_books: "Book Frontend"
create_success : "Successfully Create"
update_success : "Successfully Update"
delete_success : "Successfully Delete"
add: "Add"
back: "Back"
delete: "Delete"
edit: "Edit"
nothing: "Nothing"
show: "Show"
sure?: "Are you sure?"
update: "Update"
yes_: "Yes"
no_: "No"
cancel : "Cancel"
save: "save"
hintText: "Type in a search term"
noResultsText: "No results"
searchingText: "Searching…"

55
config/locales/zh_tw.yml Normal file
View File

@ -0,0 +1,55 @@
zh_tw:
module_name:
personal_book: 專書
personal_book:
paper_title : "論文名稱"
book_title : "書名"
extracted_chapters : "部份章節"
publisher : "出版社"
authors : "作者"
tags : "領域"
year : "年度"
language : "語言"
isbn : "ISSN(ISBN)"
vol_no : "卷數"
issue_no : "期數"
form_to_start : "起"
form_to_end : "訖"
total_pages : "總頁數"
keywords : "關鍵字"
abstract : "摘要"
publication_date : "發表日期"
url : "參考連結"
note : "記事"
level_type : "期刊類別"
author_type : "作者類別"
from : "起"
to : "訖"
file : "檔案"
file_name : "檔案名稱"
description : "描述"
pages : "頁次"
book_paper_type : "專書類別"
publish_date : "出版日期"
editor : "主編"
frontend:
writing_books: "專書前台"
create_success : "新增完成!!"
update_success : "更新完成!!"
delete_success : "刪除成功!!"
add: "新增"
back: "返回"
delete: "刪除"
edit: "編輯"
nothing: "無"
show: "顯示"
sure?: "您肯定嗎?"
update: "更新"
yes_: "是"
no_: "否"
cancel : "取消"
save: "儲存"
hintText: "請輸入搜尋關鍵字"
noResultsText: "沒有相關的比對結果"
searchingText: "搜尋中…"

51
config/routes.rb Normal file
View File

@ -0,0 +1,51 @@
Rails.application.routes.draw do
namespace :panel do
namespace :personal_book do
namespace :desktop do
match 'books_window' => "personal_books#books_window"
resources :personal_books
resources :plugin_intros
end
namespace :back_end do
match 'writing_book_setting' => "writing_books#writing_book_setting" ,:as => :writing_book_setting
# match 'writing_book_intro' => "writing_books#writing_book_intro" ,:as => :writing_book_intro
resources :writing_books do
collection do
get 'delete'
get 'data_share'
end
match "author_type_quick_add" => "writing_books#author_type_quick_add" ,:as => :author_type_quick_add
match "author_type_quick_edit" => "writing_books#author_type_quick_edit" ,:as => :author_type_quick_edit
match "paper_type_quick_add" => "writing_books#paper_type_quick_add" ,:as => :paper_type_quick_add
match "paper_type_quick_edit" => "writing_books#paper_type_quick_edit" ,:as => :paper_type_quick_edit
end
resources :personal_book_intros
resources :book_paper_types
resources :book_author_types
resources :tags
end
namespace :front_end do
resources :writing_books
end
namespace :plugin do
resources :writing_books
end
namespace :widget do
match "writing_books" => "writing_books#index"
match "home_list" => "writing_books#home_list"
match "reload_writing_books" => "writing_books#reload_writing_books"
end
end
end
match "/appfront/*path" => redirect("/panel/*path")
end

4
lib/personal_book.rb Normal file
View File

@ -0,0 +1,4 @@
require "personal_book/engine"
module PersonalBook
end

View File

@ -0,0 +1,25 @@
module PersonalBook
class Engine < Rails::Engine
initializer "personal_book" do
OrbitApp.registration "PersonalBook",:type=> 'ModuleApp' do
module_label 'module_name.personal_book'
base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '25', :app_name=>"WritingBook", :intro_app_name=>"PersonalBookIntro",:path=>"panel/personal_book/plugin/profile",:front_path=>"panel/personal_book/front_end/profile",:admin_path=>"/panel/personal_book/back_end/writing_books",:i18n=>'module_name.personal_book'
version "0.1"
organization "Rulingcom"
author "RD dep"
intro "I am intro"
update_info 'some update_info'
front_end do
app_page 'writing_books' do
frontend_i18n "personal_book.frontend.writing_books"
end
end
end
end
end
end

View File

@ -0,0 +1,3 @@
module PersonalBook
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :personal_book do
# # Task goes here
# end

23
personal_book.gemspec Normal file
View File

@ -0,0 +1,23 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "personal_book/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "personal_book"
s.version = PersonalBook::VERSION
s.authors = ["RulingDigital"]
s.email = ["service@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = ""
s.description = "Orbit PersonalBook module"
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
# s.add_dependency "rails", "~> 3.1.4"
# s.add_dependency "jquery-rails"
s.add_development_dependency "sqlite3"
end

Some files were not shown because too many files have changed in this diff Show More