diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1463de6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.bundle/
+log/*.log
+pkg/
+test/dummy/db/*.sqlite3
+test/dummy/log/*.log
+test/dummy/tmp/
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..fe6b7ab
--- /dev/null
+++ b/Gemfile
@@ -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'
diff --git a/MIT-LICENSE b/MIT-LICENSE
new file mode 100644
index 0000000..406f17b
--- /dev/null
+++ b/MIT-LICENSE
@@ -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.
diff --git a/README.rdoc b/README.rdoc
new file mode 100644
index 0000000..d51e43f
--- /dev/null
+++ b/README.rdoc
@@ -0,0 +1,3 @@
+= PersonalBook
+
+This project rocks and uses MIT-LICENSE.
\ No newline at end of file
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..861d45f
--- /dev/null
+++ b/Rakefile
@@ -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
diff --git a/app/assets/images/personal_book/.gitkeep b/app/assets/images/personal_book/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/assets/javascripts/personal_book/.gitkeep b/app/assets/javascripts/personal_book/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/assets/javascripts/personal_book/desktop/personal_books.js b/app/assets/javascripts/personal_book/desktop/personal_books.js
new file mode 100644
index 0000000..b744239
--- /dev/null
+++ b/app/assets/javascripts/personal_book/desktop/personal_books.js
@@ -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;
+ }
+ }
+};
+
+
diff --git a/app/assets/stylesheets/personal_book/.gitkeep b/app/assets/stylesheets/personal_book/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/assets/stylesheets/personal_book/desktop/personal_book.css b/app/assets/stylesheets/personal_book/desktop/personal_book.css
new file mode 100644
index 0000000..f0c6ce6
--- /dev/null
+++ b/app/assets/stylesheets/personal_book/desktop/personal_book.css
@@ -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; }
diff --git a/app/assets/stylesheets/personal_book/desktop/personal_book.scss b/app/assets/stylesheets/personal_book/desktop/personal_book.scss
new file mode 100644
index 0000000..ddafade
--- /dev/null
+++ b/app/assets/stylesheets/personal_book/desktop/personal_book.scss
@@ -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;
+ }
+}
\ No newline at end of file
diff --git a/app/controllers/.gitkeep b/app/controllers/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000..307a4ac
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -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
diff --git a/app/controllers/panel/personal_book/back_end/book_author_types_controller.rb b/app/controllers/panel/personal_book/back_end/book_author_types_controller.rb
new file mode 100644
index 0000000..34aa6bb
--- /dev/null
+++ b/app/controllers/panel/personal_book/back_end/book_author_types_controller.rb
@@ -0,0 +1,8 @@
+class Panel::PersonalBook::BackEnd::BookAuthorTypesController < Panel::PersonalBook::BackEnd::WritingBookCategorysController
+
+ def initialize
+ super
+ @app_type = 'book_author_type'
+ end
+
+end
diff --git a/app/controllers/panel/personal_book/back_end/book_paper_types_controller.rb b/app/controllers/panel/personal_book/back_end/book_paper_types_controller.rb
new file mode 100644
index 0000000..4f0ba78
--- /dev/null
+++ b/app/controllers/panel/personal_book/back_end/book_paper_types_controller.rb
@@ -0,0 +1,8 @@
+class Panel::PersonalBook::BackEnd::BookPaperTypesController < Panel::PersonalBook::BackEnd::WritingBookCategorysController
+
+ def initialize
+ super
+ @app_type = 'book_paper_type'
+ end
+
+end
diff --git a/app/controllers/panel/personal_book/back_end/personal_book_intros_controller.rb b/app/controllers/panel/personal_book/back_end/personal_book_intros_controller.rb
new file mode 100644
index 0000000..8e2b5ad
--- /dev/null
+++ b/app/controllers/panel/personal_book/back_end/personal_book_intros_controller.rb
@@ -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
diff --git a/app/controllers/panel/personal_book/back_end/writing_book_categorys_controller.rb b/app/controllers/panel/personal_book/back_end/writing_book_categorys_controller.rb
new file mode 100644
index 0000000..edbe3a8
--- /dev/null
+++ b/app/controllers/panel/personal_book/back_end/writing_book_categorys_controller.rb
@@ -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
diff --git a/app/controllers/panel/personal_book/back_end/writing_books_controller.rb b/app/controllers/panel/personal_book/back_end/writing_books_controller.rb
new file mode 100644
index 0000000..a2b1333
--- /dev/null
+++ b/app/controllers/panel/personal_book/back_end/writing_books_controller.rb
@@ -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
diff --git a/app/controllers/panel/personal_book/desktop/personal_books_controller.rb b/app/controllers/panel/personal_book/desktop/personal_books_controller.rb
new file mode 100644
index 0000000..8036348
--- /dev/null
+++ b/app/controllers/panel/personal_book/desktop/personal_books_controller.rb
@@ -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("
")
+ 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("
")
+ 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
\ No newline at end of file
diff --git a/app/controllers/panel/personal_book/desktop/plugin_intros_controller.rb b/app/controllers/panel/personal_book/desktop/plugin_intros_controller.rb
new file mode 100644
index 0000000..aee4700
--- /dev/null
+++ b/app/controllers/panel/personal_book/desktop/plugin_intros_controller.rb
@@ -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
\ No newline at end of file
diff --git a/app/controllers/panel/personal_book/front_end/writing_books_controller.rb b/app/controllers/panel/personal_book/front_end/writing_books_controller.rb
new file mode 100644
index 0000000..1ce3ef7
--- /dev/null
+++ b/app/controllers/panel/personal_book/front_end/writing_books_controller.rb
@@ -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
diff --git a/app/controllers/panel/personal_book/plugin/writing_books_controller.rb b/app/controllers/panel/personal_book/plugin/writing_books_controller.rb
new file mode 100644
index 0000000..a92fdfd
--- /dev/null
+++ b/app/controllers/panel/personal_book/plugin/writing_books_controller.rb
@@ -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
diff --git a/app/helpers/.gitkeep b/app/helpers/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/helpers/panel/personal_book/desktop/personal_books_helper.rb b/app/helpers/panel/personal_book/desktop/personal_books_helper.rb
new file mode 100644
index 0000000..dcea2c1
--- /dev/null
+++ b/app/helpers/panel/personal_book/desktop/personal_books_helper.rb
@@ -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
diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/models/.gitkeep b/app/models/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/models/book_author_type.rb b/app/models/book_author_type.rb
new file mode 100644
index 0000000..fae9be7
--- /dev/null
+++ b/app/models/book_author_type.rb
@@ -0,0 +1,9 @@
+# encoding: utf-8
+
+class BookAuthorType < WritingBookCategory
+
+ field :title, localize: true
+
+ has_and_belongs_to_many :writing_books
+
+end
\ No newline at end of file
diff --git a/app/models/book_paper_type.rb b/app/models/book_paper_type.rb
new file mode 100644
index 0000000..86d1ec0
--- /dev/null
+++ b/app/models/book_paper_type.rb
@@ -0,0 +1,5 @@
+class BookPaperType < WritingBookCategory
+
+ field :title, localize: true
+
+end
\ No newline at end of file
diff --git a/app/models/personal_book_intro.rb b/app/models/personal_book_intro.rb
new file mode 100644
index 0000000..a817ecf
--- /dev/null
+++ b/app/models/personal_book_intro.rb
@@ -0,0 +1,4 @@
+class PersonalBookIntro < PersonalPluginIntro
+
+
+end
diff --git a/app/models/writing_book.rb b/app/models/writing_book.rb
new file mode 100644
index 0000000..e6359f9
--- /dev/null
+++ b/app/models/writing_book.rb
@@ -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
\ No newline at end of file
diff --git a/app/models/writing_book_category.rb b/app/models/writing_book_category.rb
new file mode 100644
index 0000000..1fdbaaf
--- /dev/null
+++ b/app/models/writing_book_category.rb
@@ -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
\ No newline at end of file
diff --git a/app/models/writing_book_file.rb b/app/models/writing_book_file.rb
new file mode 100644
index 0000000..4efa4ed
--- /dev/null
+++ b/app/models/writing_book_file.rb
@@ -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
diff --git a/app/views/.gitkeep b/app/views/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/app/views/panel/personal_book/back_end/writing_book_categorys/_form.html.erb b/app/views/panel/personal_book/back_end/writing_book_categorys/_form.html.erb
new file mode 100644
index 0000000..b7ea06d
--- /dev/null
+++ b/app/views/panel/personal_book/back_end/writing_book_categorys/_form.html.erb
@@ -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| %>
+
+
<%= t('writing_book_category.key') %> | + <% if @types.is_localized?(:title) %> + <% @site_in_use_locales.each do |locale| %> +<%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %> | + <% end %> + <% else %> +<%= t('writing_book_category.title') %> | + <% end %> +
---|
+ <%= hidden_field_tag 'plugin_file_field_count', @writing_book.writing_book_files.count %> + <%= t(:add) %> +
+ +<%= t("personal_book.year") %> | +<%= t("personal_book.book_title") %> | +<%= t("personal_plugins.author") %> | +
---|
+ <%= t('add')%> + <%= t("personal_book.book_paper_type") %> +
++ <%= t('add')%> + <%= t("personal_book.author_type") %> +
++ + 領域 +
+ +<%= t("personal_book.file")%> | +<%= t("personal_book.file_name")%> | +<%= t("personal_book.description") %> | ++ |
---|---|---|---|
+
+ <%= hidden_field_tag 'plugin_file_field_count', @personal_book.writing_book_files.count %>
+ add
+
+ |
+
<%= t('personal_book.year') %> | +<%= t('personal_book.book_title') %> | +<%= t('personal_book.authors') %> | +
---|---|---|
<%= writing_book.year %> | ++ <%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %> + | +<%= User.find(writing_book.create_user_id).name rescue '' %> | +
<%= t('personal_book.year') %> | +<%= t('personal_book.book_paper_type') %> | +<%= t('personal_book.book_title') %> | +<%= t('personal_book.authors') %> | +
---|---|---|---|
<%= writing_book.year %> | +<%= writing_book.book_paper_type.title %> | ++ <%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %> + | +<%= User.find(writing_book.create_user_id).name rescue '' %> | +
<%= t("personal_book.year")%> | <%= @writing_book.year %> |
---|---|
<%= t("personal_book.language")%> | <%= @writing_book.language %> |
<%= t("personal_book.paper_title")%> | <%= @writing_book.paper_title %> |
<%= t("personal_book.book_title")%> | <%= @writing_book.book_title %> |
<%= t("personal_book.book_paper_type")%> | <%= @writing_book.book_paper_type.title if !@writing_book.book_paper_type.blank? %> |
<%= t("personal_book.author_type")%> | <%= @book_author_types %> |
<%= t("personal_book.extracted_chapters")%> | <%= @writing_book.extracted_chapters %> |
<%= t("personal_book.publisher")%> | <%= @writing_book.publisher %> |
<%= t("personal_book.editor")%> | <%= @writing_book.editor %> |
<%= t("personal_book.publish_date")%> | <%= @writing_book.publish_date %> |
<%= t("personal_book.pages")%> | <%= @writing_book.pages %> |
<%= t("personal_book.isbn")%> | <%= @writing_book.isbn %> |
<%= t("personal_book.publication_date")%> | <%= @writing_book.publication_date %> |
<%= t("personal_book.url")%> | <%= link_to t(:url), @writing_book.url, {:target => '_blank', :title => @writing_book.url} if !@writing_book.url.blank? %> |
<%= t("personal_book.authors")%> | <%= "#{User.from_id(@writing_book.create_user_id).name rescue ''},#{@writing_book.authors rescue ''}"%> |
<%= t("personal_book.files")%> | +
+
+
+
+
+ <% @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 %>
+
+ |
+
+ <% end -%> + | <%= t('personal_book.year') %> | +<%= t('personal_book.book_title') %> | +
---|---|---|
+ <%= check_box_tag 'to_change[]', writing_book.id.to_s, false, :class => "list-check" %> + | + <% end -%> +<%= writing_book.year %> | ++ <%= link_to writing_book.create_link, panel_personal_book_front_end_writing_book_path(writing_book) %> + | +
File | +File Name | ++ |
---|---|---|
+
+ <%= hidden_field_tag 'plugin_file_field_count', @writing_book.writing_book_files.count %>
+ ADD/新增
+
+ |
+
+ | + | + | + | + |
---|