From 0d5fb4f05c84eef55fc821e7e64ee2c32260e67f Mon Sep 17 00:00:00 2001 From: rulingcom Date: Fri, 26 May 2023 22:17:05 +0800 Subject: [PATCH] first commit --- .gitignore | 8 + Gemfile | 14 + MIT-LICENSE | 20 + README.rdoc | 3 + Rakefile | 34 ++ .../images/personal_asia_database/.keep | 0 .../personal_asia_database/application.js | 13 + .../personal_asia_database/application.css | 15 + .../admin/asia_databases_controller.rb | 82 ++++ app/controllers/asia_databases_controller.rb | 406 ++++++++++++++++++ app/helpers/admin/asia_databases_helper.rb | 5 + app/models/asia_academy.rb | 8 + app/models/asia_department.rb | 8 + app/models/asia_exhibition.rb | 20 + app/models/asia_export_store.rb | 31 ++ app/models/asia_paper.rb | 12 + app/models/asia_patent.rb | 21 + app/models/asia_project.rb | 21 + app/models/asia_teacher.rb | 152 +++++++ app/models/asia_tec_transfer.rb | 20 + .../asia_databases/asia_exhibitions.html.erb | 25 ++ .../admin/asia_databases/asia_papers.html.erb | 25 ++ .../asia_databases/asia_patents.html.erb | 25 ++ .../asia_databases/asia_projects.html.erb | 25 ++ .../asia_databases/asia_teachers.html.erb | 33 ++ .../asia_tec_transfers.html.erb | 25 ++ app/views/admin/asia_databases/index.html.erb | 20 + app/views/admin/asia_databases/show.html.erb | 21 + .../asia_databases/_export_excel.xlsx.axlsx | 42 ++ .../get_fields_for_index.html.erb | 48 +++ app/views/asia_databases/index.html.erb | 1 + app/views/asia_databases/show.html.erb | 1 + asia_academies.json | 1 + asia_database.gemspec | 19 + asia_depart_teachers.json | 1 + asia_teachers.json | 1 + bin/rails | 12 + combined_departs.rb | 7 + config/locales/en.yml | 73 ++++ config/locales/zh_tw.yml | 71 +++ config/routes.rb | 51 +++ lib/asia_database.rb | 4 + lib/asia_database/engine.rb | 22 + lib/asia_database/version.rb | 3 + lib/tasks/asia_database_tasks.rake | 245 +++++++++++ modules/asia_database/index.html.erb | 23 + modules/asia_database/index_search0.html.erb | 54 +++ modules/asia_database/index_search1.html.erb | 126 ++++++ modules/asia_database/info.json | 12 + modules/asia_database/show.html.erb | 8 + modules/asia_database/thumbs/thumb.png | Bin 0 -> 4075 bytes test/dummy/README.rdoc | 28 ++ test/dummy/Rakefile | 6 + test/dummy/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 13 + .../app/assets/stylesheets/application.css | 15 + .../app/controllers/application_controller.rb | 5 + test/dummy/app/controllers/concerns/.keep | 0 test/dummy/app/helpers/application_helper.rb | 2 + test/dummy/app/mailers/.keep | 0 test/dummy/app/models/.keep | 0 test/dummy/app/models/concerns/.keep | 0 .../app/views/layouts/application.html.erb | 14 + test/dummy/bin/bundle | 3 + test/dummy/bin/rails | 4 + test/dummy/bin/rake | 4 + test/dummy/config.ru | 4 + test/dummy/config/application.rb | 23 + test/dummy/config/boot.rb | 5 + test/dummy/config/database.yml | 25 ++ test/dummy/config/environment.rb | 5 + test/dummy/config/environments/development.rb | 37 ++ test/dummy/config/environments/production.rb | 78 ++++ test/dummy/config/environments/test.rb | 39 ++ test/dummy/config/initializers/assets.rb | 8 + .../initializers/backtrace_silencers.rb | 7 + .../config/initializers/cookies_serializer.rb | 3 + .../initializers/filter_parameter_logging.rb | 4 + test/dummy/config/initializers/inflections.rb | 16 + test/dummy/config/initializers/mime_types.rb | 4 + .../config/initializers/session_store.rb | 3 + .../config/initializers/wrap_parameters.rb | 14 + test/dummy/config/locales/en.yml | 23 + test/dummy/config/routes.rb | 4 + test/dummy/config/secrets.yml | 22 + test/dummy/lib/assets/.keep | 0 test/dummy/log/.keep | 0 test/dummy/public/404.html | 67 +++ test/dummy/public/422.html | 67 +++ test/dummy/public/500.html | 66 +++ test/dummy/public/favicon.ico | 0 test/integration/navigation_test.rb | 10 + test/personal_asia_database_test.rb | 7 + test/test_helper.rb | 19 + 94 files changed, 2571 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 MIT-LICENSE create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 app/assets/images/personal_asia_database/.keep create mode 100644 app/assets/javascripts/personal_asia_database/application.js create mode 100644 app/assets/stylesheets/personal_asia_database/application.css create mode 100644 app/controllers/admin/asia_databases_controller.rb create mode 100644 app/controllers/asia_databases_controller.rb create mode 100644 app/helpers/admin/asia_databases_helper.rb create mode 100644 app/models/asia_academy.rb create mode 100644 app/models/asia_department.rb create mode 100644 app/models/asia_exhibition.rb create mode 100644 app/models/asia_export_store.rb create mode 100644 app/models/asia_paper.rb create mode 100644 app/models/asia_patent.rb create mode 100644 app/models/asia_project.rb create mode 100644 app/models/asia_teacher.rb create mode 100644 app/models/asia_tec_transfer.rb create mode 100644 app/views/admin/asia_databases/asia_exhibitions.html.erb create mode 100644 app/views/admin/asia_databases/asia_papers.html.erb create mode 100644 app/views/admin/asia_databases/asia_patents.html.erb create mode 100644 app/views/admin/asia_databases/asia_projects.html.erb create mode 100644 app/views/admin/asia_databases/asia_teachers.html.erb create mode 100644 app/views/admin/asia_databases/asia_tec_transfers.html.erb create mode 100644 app/views/admin/asia_databases/index.html.erb create mode 100644 app/views/admin/asia_databases/show.html.erb create mode 100644 app/views/asia_databases/_export_excel.xlsx.axlsx create mode 100644 app/views/asia_databases/get_fields_for_index.html.erb create mode 100644 app/views/asia_databases/index.html.erb create mode 100644 app/views/asia_databases/show.html.erb create mode 100644 asia_academies.json create mode 100644 asia_database.gemspec create mode 100644 asia_depart_teachers.json create mode 100644 asia_teachers.json create mode 100644 bin/rails create mode 100644 combined_departs.rb create mode 100644 config/locales/en.yml create mode 100644 config/locales/zh_tw.yml create mode 100644 config/routes.rb create mode 100644 lib/asia_database.rb create mode 100644 lib/asia_database/engine.rb create mode 100644 lib/asia_database/version.rb create mode 100644 lib/tasks/asia_database_tasks.rake create mode 100644 modules/asia_database/index.html.erb create mode 100644 modules/asia_database/index_search0.html.erb create mode 100644 modules/asia_database/index_search1.html.erb create mode 100644 modules/asia_database/info.json create mode 100644 modules/asia_database/show.html.erb create mode 100644 modules/asia_database/thumbs/thumb.png create mode 100644 test/dummy/README.rdoc create mode 100644 test/dummy/Rakefile create mode 100644 test/dummy/app/assets/images/.keep create mode 100644 test/dummy/app/assets/javascripts/application.js create mode 100644 test/dummy/app/assets/stylesheets/application.css create mode 100644 test/dummy/app/controllers/application_controller.rb create mode 100644 test/dummy/app/controllers/concerns/.keep create mode 100644 test/dummy/app/helpers/application_helper.rb create mode 100644 test/dummy/app/mailers/.keep create mode 100644 test/dummy/app/models/.keep create mode 100644 test/dummy/app/models/concerns/.keep create mode 100644 test/dummy/app/views/layouts/application.html.erb create mode 100644 test/dummy/bin/bundle create mode 100644 test/dummy/bin/rails create mode 100644 test/dummy/bin/rake create mode 100644 test/dummy/config.ru create mode 100644 test/dummy/config/application.rb create mode 100644 test/dummy/config/boot.rb create mode 100644 test/dummy/config/database.yml create mode 100644 test/dummy/config/environment.rb create mode 100644 test/dummy/config/environments/development.rb create mode 100644 test/dummy/config/environments/production.rb create mode 100644 test/dummy/config/environments/test.rb create mode 100644 test/dummy/config/initializers/assets.rb create mode 100644 test/dummy/config/initializers/backtrace_silencers.rb create mode 100644 test/dummy/config/initializers/cookies_serializer.rb create mode 100644 test/dummy/config/initializers/filter_parameter_logging.rb create mode 100644 test/dummy/config/initializers/inflections.rb create mode 100644 test/dummy/config/initializers/mime_types.rb create mode 100644 test/dummy/config/initializers/session_store.rb create mode 100644 test/dummy/config/initializers/wrap_parameters.rb create mode 100644 test/dummy/config/locales/en.yml create mode 100644 test/dummy/config/routes.rb create mode 100644 test/dummy/config/secrets.yml create mode 100644 test/dummy/lib/assets/.keep create mode 100644 test/dummy/log/.keep create mode 100644 test/dummy/public/404.html create mode 100644 test/dummy/public/422.html create mode 100644 test/dummy/public/500.html create mode 100644 test/dummy/public/favicon.ico create mode 100644 test/integration/navigation_test.rb create mode 100644 test/personal_asia_database_test.rb create mode 100644 test/test_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de5d954 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/db/*.sqlite3-journal +test/dummy/log/*.log +test/dummy/tmp/ +test/dummy/.sass-cache diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..d97db1e --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +source "https://rubygems.org" + +# Declare your gem's dependencies in personal_course.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# 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 'debugger' diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..f017636 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2022 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..fa7bf5b --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += PersonalAsiaDatabase + +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..c2da108 --- /dev/null +++ b/Rakefile @@ -0,0 +1,34 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'PersonalAsiaDatabase' + 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_asia_database/.keep b/app/assets/images/personal_asia_database/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/personal_asia_database/application.js b/app/assets/javascripts/personal_asia_database/application.js new file mode 100644 index 0000000..a1873dd --- /dev/null +++ b/app/assets/javascripts/personal_asia_database/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/app/assets/stylesheets/personal_asia_database/application.css b/app/assets/stylesheets/personal_asia_database/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/app/assets/stylesheets/personal_asia_database/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/app/controllers/admin/asia_databases_controller.rb b/app/controllers/admin/asia_databases_controller.rb new file mode 100644 index 0000000..607c3e9 --- /dev/null +++ b/app/controllers/admin/asia_databases_controller.rb @@ -0,0 +1,82 @@ +class Admin::AsiaDatabasesController < OrbitAdminController + def index + @asia_academies = AsiaAcademy.all.page(params[:page]).per(10) + end + def render_404 + render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html' + end + def show + begin + uid = params[:id].split('-').last + @asia_academy = AsiaAcademy.find_by(:uid=>uid) + @asia_departs = @asia_academy.asia_departments.page(params[:page]).per(10) + rescue + render_404 + end + end + def asia_teachers + begin + uid = params[:id].split('-').last + @asia_depart = AsiaDepartment.find_by(:uid=>uid) + @asia_academy = @asia_depart.asia_academy + @asia_teachers = @asia_depart.asia_teachers.page(params[:page]).per(10) + rescue + render_404 + end + end + def asia_projects + begin + uid = params[:id].split('-').last + @asia_teacher = AsiaTeacher.find_by(:uid=>uid) + @asia_depart = @asia_teacher.asia_department + @asia_academy = @asia_teacher.asia_academy + @asia_projects = @asia_teacher.asia_projects.page(params[:page]).per(10) + rescue + render_404 + end + end + def asia_papers + begin + uid = params[:id].split('-').last + @asia_teacher = AsiaTeacher.find_by(:uid=>uid) + @asia_depart = @asia_teacher.asia_department + @asia_academy = @asia_teacher.asia_academy + @asia_papers = @asia_teacher.asia_papers.page(params[:page]).per(10) + rescue + render_404 + end + end + def asia_patents + begin + uid = params[:id].split('-').last + @asia_teacher = AsiaTeacher.find_by(:uid=>uid) + @asia_depart = @asia_teacher.asia_department + @asia_academy = @asia_teacher.asia_academy + @asia_patents = @asia_teacher.asia_patents.page(params[:page]).per(10) + rescue + render_404 + end + end + def asia_tec_transfers + begin + uid = params[:id].split('-').last + @asia_teacher = AsiaTeacher.find_by(:uid=>uid) + @asia_depart = @asia_teacher.asia_department + @asia_academy = @asia_teacher.asia_academy + @asia_tec_transfers = @asia_teacher.asia_tec_transfers.page(params[:page]).per(10) + rescue + render_404 + end + end + def asia_exhibitions + begin + uid = params[:id].split('-').last + @asia_teacher = AsiaTeacher.find_by(:uid=>uid) + @asia_depart = @asia_teacher.asia_department + @asia_academy = @asia_teacher.asia_academy + @asia_exhibitions = @asia_teacher.asia_exhibitions.page(params[:page]).per(10) + rescue + render_404 + end + end +end \ No newline at end of file diff --git a/app/controllers/asia_databases_controller.rb b/app/controllers/asia_databases_controller.rb new file mode 100644 index 0000000..9efbdf4 --- /dev/null +++ b/app/controllers/asia_databases_controller.rb @@ -0,0 +1,406 @@ +class AsiaDatabasesController < ApplicationController + include Admin::AsiaTeachersHelper + ExtraFields = { + 'discipline_expertise'=> ['discipline_expertise'], + 'project'=> ['project_name', 'start_date', 'sponsor'], + 'paper'=> ['paper_name', 'issue_year', 'journal_name'], + 'patent'=> ['patent_name', 'certification_date', 'patent_country'], + 'tec_transfer'=> ['tech_transfer_name', 'start_date', 'receiving_unit'], + 'exhibition'=> ['exhibition_name', 'exhibition_date', 'host'] + } + def render_404 + render :file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => :not_found, :content_type => 'text/html' + end + def get_data(params, for_frontend=false) + # choice unit + choice_unit = [] + selected_unit = params[:unit] + selected_academy = nil + if selected_unit == 'all' + choice_unit << {"choice_value"=> 'all', "choice_show"=> 'All', 'choice_select'=> 'selected'} + AsiaAcademy.all.each do |academy| + choice_unit << {"choice_value"=> academy.uid, "choice_show"=> academy.academy_name, 'choice_select'=>''} + end + else + choice_unit << {"choice_value"=> 'all', "choice_show"=> 'All', 'choice_select'=> ''} + AsiaAcademy.all.each do |academy| + uid = academy.uid + if uid == selected_unit + selected_academy = academy + choice_select = 'selected' + else + choice_select = '' + end + choice_unit << {"choice_value"=> uid, "choice_show"=> academy.academy_name, 'choice_select'=> choice_select} + end + end + # choice field + choice_field = [{'choice_show'=> t('asia_database.extend_translate.select_field'), 'choice_value' => 'default', 'choice_select' => ''}] + fields_to_select = ["discipline_expertise", "project", "paper", "patent", "tec_transfer", "exhibition"] + fields_to_select.each do |fs| + choice_field << {'choice_show'=> t("asia_database.extend_translate.#{fs}"), 'choice_value' => fs, 'choice_select' => ''} + end + selected_field_int = 0 + selected_field = fields_to_select[0] + choice_field.each_with_index do |h, i| + field_name = h['choice_value'] + if field_name == params[:field] + h['choice_select'] = 'selected' + if field_name == 'default' + selected_field_int = 0 + else + selected_field = field_name + selected_field_int = i - 1 + end + break + end + end + fields_to_show = ['academy', 'department', 'teacher'] + if selected_field_int == 0 + fields_to_show += ExtraFields[selected_field] + table_headers = fields_to_show.map do |fs| + { + 'head-title' => t("asia_database.#{fs}"), + 'col' => (fs == 'teacher' ? 3 : 2) + } + end + else + table_headers = fields_to_show.map do |fs| + { + 'head-title' => t("asia_database.#{fs}"), + 'col' => (fs == 'teacher' ? 3 : 2) + } + end + fields_to_show = fields_to_show.map{|fs| "asia_teacher.#{fs}"} + extra_fields = ExtraFields[selected_field] + fields_to_show += extra_fields + table_headers += extra_fields.map do |fs| + { + 'head-title' => t("asia_database.asia_#{selected_field}.#{fs}"), + 'col' => 2 + } + end + end + search_field = nil + if selected_field_int == 0 #Discipline Expertise + if selected_academy + asia_data = selected_academy.asia_teachers + else + asia_data = AsiaTeacher.all + end + search_field = 'discipline_expertise' + elsif selected_field_int == 1 #Project + if selected_academy + asia_data = AsiaProject.where(:asia_teacher_id.in=>selected_academy.asia_teacher_ids) + else + asia_data = AsiaProject.all + end + search_field = 'project_name' + elsif selected_field_int == 2 #Paper + if selected_academy + asia_data = AsiaPaper.where(:asia_teacher_id.in=>selected_academy.asia_teacher_ids) + else + asia_data = AsiaPaper.all + end + search_field = 'paper_name' + elsif selected_field_int == 3 #Patent + if selected_academy + asia_data = AsiaPatent.where(:asia_teacher_id.in=>selected_academy.asia_teacher_ids) + else + asia_data = AsiaPatent.all + end + search_field = 'patent_name' + elsif selected_field_int == 4 #Technology Transfer + if selected_academy + asia_data = AsiaTecTransfer.where(:asia_teacher_id.in=>selected_academy.asia_teacher_ids) + else + asia_data = AsiaTecTransfer.all + end + search_field = 'tech_transfer_name' + elsif selected_field_int == 5 #Exhibition + if selected_academy + asia_data = AsiaExhibition.where(:asia_teacher_id.in=>selected_academy.asia_teacher_ids) + else + asia_data = AsiaExhibition.all + end + search_field = 'exhibition_name' + end + asia_data = asia_data.sort_order + if params[:keywords].present? + asia_data = filter_keywords(asia_data,search_field,params[:keywords]) + end + if for_frontend + asia_data = asia_data.page(params[:page_no]).per(OrbitHelper.page_data_count) + end + if for_frontend + asia_data_list = asia_data.collect do |asia_record| + {'jps' => fields_to_show.map{|field| {"value"=> get_display_field(asia_record,field)}}} + end + else + all_count = asia_data.count + store_record_id = @store_record.id + asia_data_list = asia_data.collect.with_index do |asia_record, i| + AsiaExportStore.where(:id=>store_record_id).update_all(:finish_percent=> ((i + 1) * 100.0 / all_count).round(1)) + fields_to_show.map{|field| get_raw_field(asia_record, field)} + end + end + return asia_data_list, asia_data, table_headers, choice_unit, choice_field + end + def index + params = OrbitHelper.params + # page = OrbitHelper.page rescue Page.where(page_id: params[:page_id]).first + asia_data_list, asia_data, table_headers, choice_unit, choice_field = get_data(params, true) + download_excel_text = t('asia_database.extend_translate.download_excel') + select_field_text = t('asia_database.extend_translate.search_field') + select_text = t('asia_database.extend_translate.search_class') + search_text = t('asia_database.extend_translate.word_to_search') + @_request = OrbitHelper.request + csrf_value = form_authenticity_token + extras = {} #{"th-academy" => I18n.t("asia_database.academy"), "th-department" => I18n.t("asia_database.department"), "th-teacher" => I18n.t("asia_database.teacher"), "th-discipline_expertise" => I18n.t("asia_database.discipline_expertise"), "th-asia_project.project_name" => I18n.t("asia_database.asia_project.project_name"), "th-asia_project.start_date" => I18n.t("asia_database.asia_project.start_date"), "th-asia_project.sponsor" => I18n.t("asia_database.asia_project.sponsor"), "th-asia_paper.paper_name" => I18n.t("asia_database.asia_paper.paper_name"), "th-asia_paper.issue_year" => I18n.t("asia_database.asia_paper.issue_year"), "th-asia_paper.journal_name" => I18n.t("asia_database.asia_paper.journal_name"), "th-asia_patent.patent_name" => I18n.t("asia_database.asia_patent.patent_name"), "th-asia_patent.certification_date" => I18n.t("asia_database.asia_patent.certification_date"), "th-asia_patent.patent_country" => I18n.t("asia_database.asia_patent.patent_country"), "th-asia_tec_transfer.tech_transfer_name" => I18n.t("asia_database.asia_tec_transfer.tech_transfer_name"), "th-asia_tec_transfer.start_date" => I18n.t("asia_database.asia_tec_transfer.start_date"), "th-asia_tec_transfer.receiving_unit" => I18n.t("asia_database.asia_tec_transfer.receiving_unit"), "th-asia_exhibition.exhibition_name" => I18n.t("asia_database.asia_exhibition.exhibition_name"), "th-asia_exhibition.exhibition_date" => I18n.t("asia_database.asia_exhibition.exhibition_date"), "th-asia_exhibition.host" => I18n.t("asia_database.asia_exhibition.host")} + tmp_id = Time.now.to_i.to_s + '-' + csrf_value.gsub(/[\n\/]/, '') + extras = extras.merge({ 'url' => '/' + I18n.locale.to_s + params[:url], + 'download_url' => "/xhr/asia_database/download_excel?tmp_id=#{tmp_id}", + 'export_url' => '/xhr/asia_database/export_excel', + 'check_url' => "/xhr/asia_database/get_store_status?tmp_id=#{tmp_id}", + 'download_excel_text' => download_excel_text, + 'select_field_text' => select_field_text, + 'select_text' => select_text, + 'search_text' => search_text, + 'search_value' => params[:keywords].to_s.gsub(/\"/,''), + 'search_trans' => t('asia_database.extend_translate.search'), + 'unit_trans' => t('asia_database.extend_translate.unit'), + 'csrf_value' => csrf_value, + 'tmp_id' => tmp_id + }) + extras["widget-title"] = I18n.t("module_name.asia_database") + { + "asia_databases" => asia_data_list, + "headers" => table_headers, + "extras" => extras, + "total_pages" => asia_data.total_pages, + 'choice_unit' => choice_unit, + 'choice_field' => choice_field + } + end + def export_excel + tmp_id = params['tmp_id'] + if tmp_id.blank? + render(:nothing => true) and return + end + AsiaExportStore.where(:tmp_id.ne=>tmp_id, :updated_at.lte=> Time.now.to_i - 3600 * 24).destroy + filter_str = params.except('action', 'controller', 'tmp_id').to_query + @store_record = AsiaExportStore.any_of([{:tmp_id=>tmp_id}, {:filter_str=>filter_str}]).first + if @store_record.nil? + @store_record = AsiaExportStore.new(:tmp_id=>tmp_id) + else + if @store_record.filter_str == filter_str + render :json => {success: true} and return + end + @store_record.reinit + end + @store_record.filter_str = filter_str + @store_record.save + Thread.new do + begin + @asia_data_list, asia_data, @table_headers, choice_unit, choice_field = get_data(params) + store_record_id = @store_record.id + AsiaExportStore.where(:id=>store_record_id).update_all(:status=>1) + @excel_title = I18n.t("module_name.asia_database") + excel_contents = render_to_string( handlers: [:axlsx], formats: [:xlsx] ,partial: 'export_excel.xlsx',locals: {:@asia_data_list=> @asia_data_list, :@table_headers=> @table_headers, :@excel_title=> @excel_title} ) + File.open(@store_record.file_path, 'w') do |f| + f.write excel_contents + end + AsiaExportStore.where(:id=>store_record_id).update_all(:status=>2) + rescue => e + puts [e.to_s, e.backtrace] + end + end + render :json => {success: true} + end + def download_excel + tmp_id = params['tmp_id'] + @store_record = AsiaExportStore.where(:tmp_id=>tmp_id).first + if @store_record.nil? || @store_record.status != 2 + render_404 + else + send_file(@store_record.file_path,:filename=>'export_excel.xlsx') + end + end + def get_store_status + tmp_id = params['tmp_id'] + @store_record = AsiaExportStore.where(:tmp_id=>tmp_id).first + if @store_record.nil? + render :json => {:finish_percent=> 0, :status=> 0} + else + render :json => {:finish_percent=> @store_record.finish_percent, :status=> @store_record.status} + end + end + def show + params = OrbitHelper.params + plugin = AsiaTeacher.where(:is_hidden=>false).find_by(uid: params[:uid].to_s) + fields_to_show = ["academy", "department", "teacher", "discipline_expertise", "asia_project.project_name", "asia_project.start_date", "asia_project.sponsor", "asia_paper.paper_name", "asia_paper.issue_year", "asia_paper.journal_name", "asia_patent.patent_name", "asia_patent.certification_date", "asia_patent.patent_country", "asia_tec_transfer.tech_transfer_name", "asia_tec_transfer.start_date", "asia_tec_transfer.receiving_unit", "asia_exhibition.exhibition_name", "asia_exhibition.exhibition_date", "asia_exhibition.host"] + {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} + end + def get_raw_field(asia_teacher, field) + text_only = false + value = asia_teacher.send(field) rescue "" + if field.include?(".") + value = asia_teacher + field.split(".").each{|f| value = value.send(f) rescue nil} + end + if value.class == Array + value = value.join("\n") + end + return value + end + def get_display_field(asia_teacher,field) + text_only = false + value = asia_teacher.send(field) rescue "" + if field.include?(".") + value = asia_teacher + field.split(".").each do |f| + if f == 'teacher' + tmp_value = value.teacher + value = "#{tmp_value}" + else + value = value.send(f) rescue nil + end + end + elsif field == 'teacher' + value = "#{value}" + end + if value.class == Array + tmp = '' + value = tmp + end + # file_fields = [] + # link_fields = [] + # member_fields = [] + # if file_fields.include?(field) + # files = asia_teacher.send(field.pluralize) + # value = files.map do |file| + # url = file.file.url + # title = (file.title.blank? ? File.basename(file.file.path) : file.title) + # "
  • #{title}
  • " + # end + # value = value.join("") + # elsif link_fields.include?(field) + # links = asia_teacher.send(field.pluralize) + # value = links.map do |link| + # url = link.url + # title = (link.title.blank? ? url : link.title) + # "
  • #{title}
  • " + # end + # value = value.join("") + # elsif member_fields.include?(field) + # members = asia_teacher.send(field.pluralize) + # value = members.map{|m| + # path = OrbitHelper.url_to_plugin_show(m.to_param, 'member') rescue '#' + # ((text_only rescue false) ? m.name : "#{m.name}") + # } + # join_text = (text_only rescue false) ? "," : "
    " + # value = value.join(join_text) + # elsif field == "authors" + # value = get_authors_show(asia_teacher) + # end + # strftime_hash = {} + # if strftime_hash.keys.include?(field) + # value = value.strftime(strftime_hash[field]) rescue value + # end + # if field == "teacher" + # link = OrbitHelper.url_to_plugin_show(asia_teacher.to_param,'asia_database') + # tmp_title = value + # url_to_plugin_show_blank = OrbitHelper.instance_variable_get(:@url_to_plugin_show_blank) + # value = url_to_plugin_show_blank ? tmp_title : "#{tmp_title}" + # end + return value + end + def get_fields_for_index + @page = Page.find(params[:page_id]) rescue nil + @fields_to_show = ["sid", "academy", "department", "teacher", "url", "discipline_expertise", "asia_project.project_name", "asia_project.start_date", "asia_project.sponsor", "asia_paper.paper_name", "asia_paper.issue_year", "asia_paper.journal_name", "asia_patent.patent_name", "asia_patent.certification_date", "asia_patent.patent_country", "asia_tec_transfer.tech_transfer_name", "asia_tec_transfer.start_date", "asia_tec_transfer.receiving_unit", "asia_exhibition.exhibition_name", "asia_exhibition.exhibition_date", "asia_exhibition.host"] + @fields_to_show = @fields_to_show.map { |fs| [t("asia_database.#{fs}"), fs] } + if @page.present? && @page.custom_string_field == 'table' + @default_fields_to_show = ["academy", "department", "teacher", "discipline_expertise", "asia_project.project_name", "asia_project.start_date", "asia_project.sponsor", "asia_paper.paper_name", "asia_paper.issue_year", "asia_paper.journal_name", "asia_patent.patent_name", "asia_patent.certification_date", "asia_patent.patent_country", "asia_tec_transfer.tech_transfer_name", "asia_tec_transfer.start_date", "asia_tec_transfer.receiving_unit", "asia_exhibition.exhibition_name", "asia_exhibition.exhibition_date", "asia_exhibition.host"] + else + @default_fields_to_show = ["year", "teacher"] + end + render layout: false + end + + def save_index_fields + page = Page.find(params[:page_id]) rescue nil + page.custom_array_field = params[:keys] + page.save + render json: { 'success' => true }.to_json + end + def filter_keywords(asia_data,select_field,keywords) + member_fields = [] + file_fields = [] + link_fields = [] + if select_field == "default" + asia_data = asia_data.where(:slug_title=>/#{gsub_invalid_character(keywords)}/) + elsif select_field == "member_profile" + ms = MemberProfile.all.select{|m| m.name.include?(keywords)} + asia_data = asia_data.where(:member_profile_id.in=>ms.map{|m| m.id}) + elsif member_fields.include?(select_field) + ms = MemberProfile.all.select{|m| m.name.include?(keywords)} + m_ids = ms.map{|m| m.id.to_s } + tmp_asia_data = asia_data.select{|p| (p.send("#{select_field.singularize}_ids") & m_ids).count != 0} + asia_data = asia_data.where(:id.in=>tmp_asia_data.map{|p| p.id}) + elsif select_field.split(".").count > 1 + relate_name = select_field.split(".").first + field_name = select_field.split(".").last.gsub(/^\$+/, '') + relate = relate_name.camelize.constantize + relate_ids = relate.where(field_name=>/#{gsub_invalid_character(keywords)}/).pluck(:id) + asia_data = asia_data.where("#{relate_name.singularize}_id"=>{'$in'=>relate_ids}) + elsif (asia_data.klass.fields[select_field].options[:type] == Date rescue false) + keywords = keywords.split(/[\/\-]/) + if keywords.count > 1 + Date.parse(keywords.join("/")) + else + start_date = Date.parse(keywords[0] + "/1/1") + end_date = Date.parse(keywords[0] + "/12/31") + asia_data = asia_data.where(select_field=>{'$gte'=>start_date,'$lte'=>end_date}) + end + elsif (asia_data.klass.fields[select_field].options[:type] == DateTime rescue false) + keywords = keywords.split(/[\/\-]/) + if keywords.count > 1 + DateTime.parse(keywords.join("/")) + elsif keywords[0].include?(":") + tmp_asia_data = asia_data.select{|p| (p.send(select_field).strftime('%Y/%m/%d %H:%M').include?(keywords[0]) rescue false)} + asia_data = asia_data.where(:id.in=>tmp_asia_data.map{|p| p.id}) + else + start_date = DateTime.parse(keywords[0] + "/1/1 00:00") + end_date = DateTime.parse(keywords[0] + "/12/31 23:59") + asia_data = asia_data.where(select_field=>{'$gte'=>start_date,'$lte'=>end_date}) + end + elsif (asia_data.klass.fields[select_field].options[:type] == Integer rescue false) + tmp_asia_data = asia_data.select{|p| p.send(select_field).to_s.include?(keywords)} + asia_data = asia_data.where(:id.in=>tmp_asia_data.map{|p| p.id}) + elsif file_fields.include?(select_field) + file_field = select_field.camelize.constantize + ids1 = file_field.where(:file=>/#{gsub_invalid_character(keywords)}/).pluck(:id) + ids2 = file_field.where(:title=>/#{gsub_invalid_character(keywords)}/).pluck(:id) + ids = ids1 + ids2 + tmp_asia_data = asia_data.select{|p| (p.send("#{select_field}_ids") & ids).count != 0} + asia_data = asia_data.where(:id.in=>tmp_asia_data.map{|p| p.id}) + elsif link_fields.include?(select_field) + link_field = select_field.camelize.constantize + ids1 = link_field.where(:title=>/#{gsub_invalid_character(keywords)}/).pluck(:id) + ids2 = link_field.where(:url=>/#{gsub_invalid_character(keywords)}/).pluck(:id) + ids = ids1 + ids2 + tmp_asia_data = asia_data.select{|p| (p.send("#{select_field}_ids") & ids).count != 0} + asia_data = asia_data.where(:id.in=>tmp_asia_data.map{|p| p.id}) + else + asia_data = asia_data.where(select_field=>/#{gsub_invalid_character(keywords)}/) + end + return asia_data + end + def gsub_invalid_character(text) + ::Regexp.escape(text.to_s) + end +end \ No newline at end of file diff --git a/app/helpers/admin/asia_databases_helper.rb b/app/helpers/admin/asia_databases_helper.rb new file mode 100644 index 0000000..a1e7f48 --- /dev/null +++ b/app/helpers/admin/asia_databases_helper.rb @@ -0,0 +1,5 @@ +module Admin::AsiaDatabasesHelper + def thead_t(label) + "#{I18n.t(label)}".html_safe + end +end \ No newline at end of file diff --git a/app/models/asia_academy.rb b/app/models/asia_academy.rb new file mode 100644 index 0000000..5702083 --- /dev/null +++ b/app/models/asia_academy.rb @@ -0,0 +1,8 @@ +class AsiaAcademy + include Mongoid::Document + include Mongoid::Timestamps + include Slug + field :academy_name, :type => String, :default => "", :localize => true, :as => :slug_title + has_many :asia_departments + has_many :asia_teachers +end \ No newline at end of file diff --git a/app/models/asia_department.rb b/app/models/asia_department.rb new file mode 100644 index 0000000..dbcfeb8 --- /dev/null +++ b/app/models/asia_department.rb @@ -0,0 +1,8 @@ +class AsiaDepartment + include Mongoid::Document + include Mongoid::Timestamps + include Slug + field :department_name, :type => String, :default => "", :localize => true, :as => :slug_title + belongs_to :asia_academy + has_many :asia_teachers +end \ No newline at end of file diff --git a/app/models/asia_exhibition.rb b/app/models/asia_exhibition.rb new file mode 100644 index 0000000..4653ffa --- /dev/null +++ b/app/models/asia_exhibition.rb @@ -0,0 +1,20 @@ +class AsiaExhibition + include Mongoid::Document + include Mongoid::Timestamps + include Slug + field :exhibition_name, :type => String, :default => "", :localize => true, :as => :slug_title + field :exhibition_start_date, :type => Date + field :exhibition_end_date, :type => Date + field :host, :type => String, :default => "", :localize => true + field :rss2_id + belongs_to :asia_teacher, index: true + scope :sort_order, ->{order({exhibition_start_date: -1})} + index({exhibition_start_date: -1}, { unique: false, background: true }) + def exhibition_date + if self.exhibition_start_date.nil? && self.exhibition_end_date.nil? + "" + else + "#{self.exhibition_start_date} ~ #{self.exhibition_end_date}" + end + end +end \ No newline at end of file diff --git a/app/models/asia_export_store.rb b/app/models/asia_export_store.rb new file mode 100644 index 0000000..fadc7c1 --- /dev/null +++ b/app/models/asia_export_store.rb @@ -0,0 +1,31 @@ +class AsiaExportStore + require "fileutils" + include Mongoid::Document + include Mongoid::Timestamps + + field :tmp_id, :type => String # for syncing + field :filter_str, :type => String + field :status, :type => Integer, :default => 0 # 0 => preparing, 1 => generating, 2 => finish + field :finish_percent, :type => Float, :default => 0 + StoreDir = "tmp/asia_db_export" + index({filter_str: 1}, { unique: false, background: true }) + index({tmp_id: -1}, { unique: false, background: true }) + before_create do + FileUtils.mkdir_p(StoreDir) + FileUtils.rm(self.file_path, :force => true) + end + before_destroy do + FileUtils.rm(self.file_path, :force => true) + end + + def file_path + "#{StoreDir}/#{tmp_id}.xlsx" + end + def reinit + FileUtils.mkdir_p(StoreDir) + FileUtils.rm(self.file_path, :force => true) + self.status = 0 + self.finish_percent = 0.0 + self.save + end +end \ No newline at end of file diff --git a/app/models/asia_paper.rb b/app/models/asia_paper.rb new file mode 100644 index 0000000..9af21a5 --- /dev/null +++ b/app/models/asia_paper.rb @@ -0,0 +1,12 @@ +class AsiaPaper + include Mongoid::Document + include Mongoid::Timestamps + include Slug + field :paper_name, :type => String, :default => "", :localize => true, :as => :slug_title + field :issue_year, :type => String + field :journal_name, :type => String, :default => "", :localize => true + field :rss2_id + belongs_to :asia_teacher, index: true + scope :sort_order, ->{order({issue_year: -1})} + index({issue_year: -1}, { unique: false, background: true }) +end \ No newline at end of file diff --git a/app/models/asia_patent.rb b/app/models/asia_patent.rb new file mode 100644 index 0000000..f8610fd --- /dev/null +++ b/app/models/asia_patent.rb @@ -0,0 +1,21 @@ +class AsiaPatent + include Mongoid::Document + include Mongoid::Timestamps + include Slug + field :patent_name, :type => String, :default => "", :localize => true, :as => :slug_title + field :patent_no, :type => String, :default => "" + field :certification_date, :type => Date + field :end_date, :type => Date + field :patent_country, :type => String, :default => "", :localize => true + field :rss2_id + belongs_to :asia_teacher, index: true + scope :sort_order, ->{order({certification_date: -1})} + index({certification_date: -1}, { unique: false, background: true }) + def term_of_patent + if self.certification_date.nil? && self.end_date.nil? + "" + else + "#{self.certification_date} ~ #{self.end_date}" + end + end +end \ No newline at end of file diff --git a/app/models/asia_project.rb b/app/models/asia_project.rb new file mode 100644 index 0000000..94f33e5 --- /dev/null +++ b/app/models/asia_project.rb @@ -0,0 +1,21 @@ +class AsiaProject + include Mongoid::Document + include Mongoid::Timestamps + include Slug + field :project_name, :type => String, :default => "", :localize => true, :as => :slug_title + field :start_date, :type => Date + field :end_date, :type => Date + field :sponsor, :type => String, :default => "", :localize => true + field :sort_position, type: Integer, default: 0 + field :rss2_id + belongs_to :asia_teacher, index: true + scope :sort_order, ->{order({start_date: -1})} + index({start_date: -1}, { unique: false, background: true }) + def date + if self.start_date.nil? && self.end_date.nil? + "" + else + "#{self.start_date} ~ #{self.end_date}" + end + end +end \ No newline at end of file diff --git a/app/models/asia_teacher.rb b/app/models/asia_teacher.rb new file mode 100644 index 0000000..74145eb --- /dev/null +++ b/app/models/asia_teacher.rb @@ -0,0 +1,152 @@ +class AsiaTeacher + include Mongoid::Document + include Mongoid::Timestamps + include Slug + + field :email_id # for syncing + field :ukey, :type => String + field :academy, :type => String, :default => "", :localize => true + field :department, :type => String, :default => "", :localize => true + field :teacher, :type => String, :default => "", :localize => true, :as => :slug_title + field :discipline_expertise, :type => Array, :default => [], :localize => true + field :authors, :type => String, :default => "", :localize => true + + belongs_to :asia_academy, index: true + belongs_to :asia_department, index: true + has_many :asia_projects + has_many :asia_papers + has_many :asia_patents + has_many :asia_tec_transfers + has_many :asia_exhibitions + scope :sort_order, ->{order({ukey: 1})} + index({ukey: 1}, { unique: false, background: true }) + before_save do + if self.asia_academy_id_changed? + self.academy_translations = self.asia_academy.academy_name_translations rescue "" + end + if self.asia_department_id_changed? + self.department_translations = self.asia_department.department_name_translations rescue "" + end + AsiaExportStore.destroy_all + end + def url + "https://webap.asia.edu.tw/TchEportfolio/#{self.email_id}" + end + def parse_time(time_str) + DateTime.parse("0000-01-01 " + time_str) + end + + def get_plugin_data(fields_to_show) + plugin_datas = [] + fields_to_show.each do |field| + plugin_data = self.get_plugin_field_data(field) rescue nil + next if plugin_data.blank? or plugin_data['value'].blank? + plugin_datas << plugin_data + end + plugin_datas + end + + def get_plugin_field_data(field) + asia_teacher = self + value = asia_teacher.send(field) rescue "" + if field.include?(".") + value = asia_teacher + field.split(".").each{|f| value = value.send(f) rescue nil } + end + file_fields = [] + link_fields = [] + member_fields = [] + if file_fields.include?(field) + files = asia_teacher.send(field.pluralize) + value = files.map do |file| + url = file.file.url + title = (file.title.blank? ? File.basename(file.file.path) : file.title) + "
  • #{title}
  • " + end + value = value.join("") + elsif link_fields.include?(field) + links = asia_teacher.send(field.pluralize) + value = links.map do |link| + url = link.url + title = (link.title.blank? ? url : link.title) + "
  • #{title}
  • " + end + value = value.join("") + elsif member_fields.include?(field) + members = asia_teacher.send(field.pluralize) + value = members.map{|m| + path = OrbitHelper.url_to_plugin_show(m.to_param, 'member') rescue '#' + ((text_only rescue false) ? m.name : "#{m.name}") + } + join_text = (text_only rescue false) ? "," : "
    " + value = value.join(join_text) + elsif field == "member_profile" || field == "authors" + value = get_authors_show(asia_teacher) + end + strftime_hash = {} + if strftime_hash.keys.include?(field) + value = value.strftime(strftime_hash[field]) rescue value + end + value + + value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "#{value}" : value + + { + "key"=>field, + "title_class"=>"asia_teacher-#{field.gsub('_','-')}-field", + "value_class"=>"asia_teacher-#{field.gsub('_','-')}-value", + "title"=>I18n.t('asia_database.'+field), + "value"=>value + } + end + + def display_field(field,text_only=false,title_is_paper_format=false) + asia_teacher = self + value = asia_teacher.send(field) rescue "" + if field.include?(".") + value = asia_teacher + field.split(".").each{|f| value = value.send(f) rescue nil } + end + file_fields = [] + link_fields = [] + member_fields = [] + if file_fields.include?(field) + files = asia_teacher.send(field.pluralize) + value = files.map do |file| + url = file.file.url + title = (file.title.blank? ? File.basename(file.file.path) : file.title) + "
  • #{title}
  • " + end + value = value.join("") + elsif link_fields.include?(field) + links = asia_teacher.send(field.pluralize) + value = links.map do |link| + url = link.url + title = (link.title.blank? ? url : link.title) + "
  • #{title}
  • " + end + value = value.join("") + elsif member_fields.include?(field) + members = asia_teacher.send(field.pluralize) + value = members.map{|m| + path = OrbitHelper.url_to_plugin_show(m.to_param, 'member') rescue '#' + ((text_only rescue false) ? m.name : "#{m.name}") + } + join_text = (text_only rescue false) ? "," : "
    " + value = value.join(join_text) + elsif field == "member_profile" || field == "authors" + value = get_authors_show(asia_teacher) + end + strftime_hash = {} + if strftime_hash.keys.include?(field) + value = value.strftime(strftime_hash[field]) rescue value + end + if field == "teacher" + link = OrbitHelper.url_to_plugin_show(asia_teacher.to_param,'asia_database') + tmp_title = value + url_to_plugin_show_blank = OrbitHelper.instance_variable_get(:@url_to_plugin_show_blank) + value = url_to_plugin_show_blank ? tmp_title : "#{tmp_title}" + end + value + end +end \ No newline at end of file diff --git a/app/models/asia_tec_transfer.rb b/app/models/asia_tec_transfer.rb new file mode 100644 index 0000000..42631b7 --- /dev/null +++ b/app/models/asia_tec_transfer.rb @@ -0,0 +1,20 @@ +class AsiaTecTransfer + include Mongoid::Document + include Mongoid::Timestamps + include Slug + field :tech_transfer_name, :type => String, :default => "", :localize => true, :as => :slug_title + field :start_date, :type => Date + field :end_date, :type => Date + field :receiving_unit, :type => String, :default => "", :localize => true + field :rss2_id + belongs_to :asia_teacher, index: true + scope :sort_order, ->{order({start_date: -1})} + index({start_date: -1}, { unique: false, background: true }) + def period + if self.start_date.nil? && self.end_date.nil? + "" + else + "#{self.start_date} ~ #{self.end_date}" + end + end +end \ No newline at end of file diff --git a/app/views/admin/asia_databases/asia_exhibitions.html.erb b/app/views/admin/asia_databases/asia_exhibitions.html.erb new file mode 100644 index 0000000..f100b48 --- /dev/null +++ b/app/views/admin/asia_databases/asia_exhibitions.html.erb @@ -0,0 +1,25 @@ + + + + + <%= thead_t('asia_database.asia_exhibition.exhibition_name') %> + <%= thead_t('asia_database.asia_exhibition.exhibition_date') %> + <%= thead_t('asia_database.asia_exhibition.host') %> + + + + <% @asia_exhibitions.each do |exhibition| %> + + + + + + <% end %> + +

    <%= @asia_academy.academy_name %><%= " - #{@asia_depart.department_name}" if @asia_depart.department_name.present? %> - <%=@asia_teacher.teacher %>

    <%= exhibition.exhibition_name %><%= exhibition.exhibition_date %><%= exhibition.host %>
    + +
    + +
    \ No newline at end of file diff --git a/app/views/admin/asia_databases/asia_papers.html.erb b/app/views/admin/asia_databases/asia_papers.html.erb new file mode 100644 index 0000000..9bbbf7f --- /dev/null +++ b/app/views/admin/asia_databases/asia_papers.html.erb @@ -0,0 +1,25 @@ + + + + + <%= thead_t('asia_database.asia_paper.paper_name') %> + <%= thead_t('asia_database.asia_paper.issue_year') %> + <%= thead_t('asia_database.asia_paper.journal_name') %> + + + + <% @asia_papers.each do |paper| %> + + + + + + <% end %> + +

    <%= @asia_academy.academy_name %><%= " - #{@asia_depart.department_name}" if @asia_depart.department_name.present? %> - <%=@asia_teacher.teacher %>

    <%= paper.paper_name %><%= paper.issue_year %><%= paper.journal_name %>
    + +
    + +
    \ No newline at end of file diff --git a/app/views/admin/asia_databases/asia_patents.html.erb b/app/views/admin/asia_databases/asia_patents.html.erb new file mode 100644 index 0000000..7668551 --- /dev/null +++ b/app/views/admin/asia_databases/asia_patents.html.erb @@ -0,0 +1,25 @@ + + + + + <%= thead_t('asia_database.asia_patent.patent_name') %> + <%= thead_t('asia_database.asia_patent.term_of_patent') %> + <%= thead_t('asia_database.asia_patent.patent_country') %> + + + + <% @asia_patents.each do |patent| %> + + + + + + <% end %> + +

    <%= @asia_academy.academy_name %><%= " - #{@asia_depart.department_name}" if @asia_depart.department_name.present? %> - <%=@asia_teacher.teacher %>

    <%= patent.patent_name %><%= patent.term_of_patent %><%= patent.patent_country %>
    + +
    + +
    \ No newline at end of file diff --git a/app/views/admin/asia_databases/asia_projects.html.erb b/app/views/admin/asia_databases/asia_projects.html.erb new file mode 100644 index 0000000..8eb72de --- /dev/null +++ b/app/views/admin/asia_databases/asia_projects.html.erb @@ -0,0 +1,25 @@ + + + + + <%= thead_t('asia_database.asia_project.project_name') %> + <%= thead_t('asia_database.asia_project.date') %> + <%= thead_t('asia_database.asia_project.sponsor') %> + + + + <% @asia_projects.each do |project| %> + + + + + + <% end %> + +

    <%= @asia_academy.academy_name %><%= " - #{@asia_depart.department_name}" if @asia_depart.department_name.present? %> - <%=@asia_teacher.teacher %>

    <%= project.project_name %><%= project.date %><%= project.sponsor %>
    + +
    + +
    \ No newline at end of file diff --git a/app/views/admin/asia_databases/asia_teachers.html.erb b/app/views/admin/asia_databases/asia_teachers.html.erb new file mode 100644 index 0000000..c203568 --- /dev/null +++ b/app/views/admin/asia_databases/asia_teachers.html.erb @@ -0,0 +1,33 @@ + + + + + <%= thead_t('asia_database.teacher') %> + <%= thead_t('asia_database.extend_translate.discipline_expertise') %> + <%= thead_t('asia_database.extend_translate.project') %> + <%= thead_t('asia_database.extend_translate.paper') %> + <%= thead_t('asia_database.extend_translate.patent') %> + <%= thead_t('asia_database.extend_translate.tec_transfer') %> + <%= thead_t('asia_database.extend_translate.exhibition') %> + + + + <% @asia_teachers.each do |teacher| %> + + + + + + + + + + <% end %> + +

    <%= @asia_academy.academy_name %><%= " - #{@asia_depart.department_name}" if @asia_depart.department_name.present? %>

    <%= teacher.teacher %>

    <%= teacher.discipline_expertise %><%= teacher.asia_projects.count %><%= teacher.asia_papers.count %><%= teacher.asia_patents.count %><%= teacher.asia_tec_transfers.count %><%= teacher.asia_exhibitions.count %>
    + +
    + +
    \ No newline at end of file diff --git a/app/views/admin/asia_databases/asia_tec_transfers.html.erb b/app/views/admin/asia_databases/asia_tec_transfers.html.erb new file mode 100644 index 0000000..c1abce6 --- /dev/null +++ b/app/views/admin/asia_databases/asia_tec_transfers.html.erb @@ -0,0 +1,25 @@ + + + + + <%= thead_t('asia_database.asia_tec_transfer.tech_transfer_name') %> + <%= thead_t('asia_database.asia_tec_transfer.period') %> + <%= thead_t('asia_database.asia_tec_transfer.receiving_unit') %> + + + + <% @asia_tec_transfers.each do |tec_transfer| %> + + + + + + <% end %> + +

    <%= @asia_academy.academy_name %><%= " - #{@asia_depart.department_name}" if @asia_depart.department_name.present? %> - <%=@asia_teacher.teacher %>

    <%= tec_transfer.tech_transfer_name %><%= tec_transfer.period %><%= tec_transfer.receiving_unit %>
    + +
    + +
    \ No newline at end of file diff --git a/app/views/admin/asia_databases/index.html.erb b/app/views/admin/asia_databases/index.html.erb new file mode 100644 index 0000000..c97d70e --- /dev/null +++ b/app/views/admin/asia_databases/index.html.erb @@ -0,0 +1,20 @@ + + + + <%= thead_t('asia_database.academy') %> + + + + <% @asia_academies.each do |academy| %> + + + + <% end %> + +

    <%= academy.academy_name %>

    + +
    + +
    \ No newline at end of file diff --git a/app/views/admin/asia_databases/show.html.erb b/app/views/admin/asia_databases/show.html.erb new file mode 100644 index 0000000..648a4be --- /dev/null +++ b/app/views/admin/asia_databases/show.html.erb @@ -0,0 +1,21 @@ + + + + + <%= thead_t('asia_database.department') %> + + + + <% @asia_departs.each do |depart| %> + + + + <% end %> + +

    <%= @asia_academy.academy_name %>

    <%= "#{@asia_academy.academy_name}#{depart.department_name.present? ? (' - ' + depart.department_name) : ''}" %>

    + +
    + +
    \ No newline at end of file diff --git a/app/views/asia_databases/_export_excel.xlsx.axlsx b/app/views/asia_databases/_export_excel.xlsx.axlsx new file mode 100644 index 0000000..196b724 --- /dev/null +++ b/app/views/asia_databases/_export_excel.xlsx.axlsx @@ -0,0 +1,42 @@ +# encoding: utf-8 + +wb = xlsx_package.workbook + +wb.add_worksheet(name: @excel_title) do |sheet| + + row = [] + + @table_headers.each do |h| + row << h['head-title'] + end + highlight_style = wb.styles.add_style( + :bg_color => 'ffeb3b', + :b => true, + :border => { :style => :thick, :color => "000000", :edges => [:top, :left, :bottom, :right] }, + :alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true} + ) + sheet.add_row row, :style => (0...row.count).collect{ highlight_style } + + + date_time_style = wb.styles.add_style({:format_code => 'yyyy/mm/dd hh:mm', :alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}}) + wrap_text_style = wb.styles.add_style({:alignment => {:horizontal => :center, :vertical => :center, :wrap_text => true}}) + # types = [:time] + # styles = [date_time_style] + types = [] + styles = [] + @asia_data_list.each_with_index do |data, i| + row2 = [] + data.each do |v| + row2 << v + end + if i == 0 + (0...(row2.count)).each do |i| + types << :string + styles << wrap_text_style + end + end + sheet.add_row row2 , :types => types, :style => styles + end + +end + diff --git a/app/views/asia_databases/get_fields_for_index.html.erb b/app/views/asia_databases/get_fields_for_index.html.erb new file mode 100644 index 0000000..7ae4bad --- /dev/null +++ b/app/views/asia_databases/get_fields_for_index.html.erb @@ -0,0 +1,48 @@ +<% if !@page.nil? %> +
    +
    +
      + <% if @page.custom_array_field.blank? %> + <% @default_fields_to_show.each do |fs| %> +
    • <%= t("asia_database.#{fs}") %>
    • + <% end %> + <% else %> + <% @page.custom_array_field.each do |fs| %> +
    • <%= t("asia_database.#{fs}") %>
    • + <% end %> + <% end %> +
    +
    + +
    + +
    + +
    + <%= select_tag "fields_to_show_for_pp", options_for_select(@fields_to_show), prompt: "---Select something---" %> +
    +
    + Add Field + + +
    +
    + +<% else %> +

    Page not found.

    +<% end %> \ No newline at end of file diff --git a/app/views/asia_databases/index.html.erb b/app/views/asia_databases/index.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/asia_databases/index.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/asia_databases/show.html.erb b/app/views/asia_databases/show.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/asia_databases/show.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/asia_academies.json b/asia_academies.json new file mode 100644 index 0000000..89c6a03 --- /dev/null +++ b/asia_academies.json @@ -0,0 +1 @@ +{"醫學暨健康學院":[["健康產業管理學系","ha.asia.edu.tw"],["食品營養與保健生技學系","als.asia.edu.tw"],["醫學檢驗暨生物技術學系","mlsb.asia.edu.tw"],["心理學系","psy.asia.edu.tw"],["視光學系","opt.asia.edu.tw"],["聽力暨語言治療學系","audslp.asia.edu.tw"],["職能治療學系","ot.asia.edu.tw"],["物理治療學系","pt.asia.edu.tw"],["學士後獸醫學系","dvm.asia.edu.tw"]],"資訊電機學院":[["生物資訊與醫學工程學系","bime.asia.edu.tw"],["資訊工程學系","csie.asia.edu.tw"],["行動商務與多媒體應用學系","mcma.asia.edu.tw"],["資訊傳播學系","infocom.asia.edu.tw"],["人工智慧博士學位學程","aip.asia.edu.tw"]],"管理學院":[["經營管理學系","dba.asia.edu.tw"],["休閒與遊憩管理學系","leisure.asia.edu.tw"],["會計與資訊學系","ai.asia.edu.tw"],["財務金融學系","fn.asia.edu.tw"],["財經法律學系","fel.asia.edu.tw"],["管理學院雙聯學制","dual.asia.edu.tw"]],"人文社會學院":[["外國語文學系","flts.asia.edu.tw"],["社會工作學系","sw.asia.edu.tw"],["幼兒教育學系","ece.asia.edu.tw"]],"創意設計學院":[["數位媒體設計系","dmd.asia.edu.tw"],["視覺傳達設計系","vcd.asia.edu.tw"],["創意商品設計系","cpd.asia.edu.tw"],["時尚設計系","dfd.asia.edu.tw"],["室內設計系","id.asia.edu.tw"],["創意設計暨發明中心","cdic.asia.edu.tw"]],"護理學院":[["護理學系","nur.asia.edu.tw"],["學士後護理學系","pbn.asia.edu.tw"]],"國際學院":[["國際學術交流中心","ciae.asia.edu.tw"],["華語文中心","jclc.asia.edu.tw"],["兩岸教育交流中心","ccae.asia.edu.tw"]],"人工智慧學院":[["人工智慧研究中心","aicenter.asia.edu.tw"]],"通識教育中心":[["","ged.asia.edu.tw"]],"體育室":[["","pe.asia.edu.tw"]]} \ No newline at end of file diff --git a/asia_database.gemspec b/asia_database.gemspec new file mode 100644 index 0000000..42e7a78 --- /dev/null +++ b/asia_database.gemspec @@ -0,0 +1,19 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "asia_database/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "asia_database" + s.version = AsiaDatabase::VERSION + s.authors = ["Bohung"] + s.email = ["bohung@rulingcom.com"] + s.homepage = "https://orbitek.co" + s.summary = "Asia Database Summary." + s.description = "Asia Database Description." + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] +end \ No newline at end of file diff --git a/asia_depart_teachers.json b/asia_depart_teachers.json new file mode 100644 index 0000000..564c38b --- /dev/null +++ b/asia_depart_teachers.json @@ -0,0 +1 @@ +{"醫學暨健康學院":{"健康產業管理學系":["clyaung","atsai","yanghc","tnwu","ptkung","plday","jjwang","okonkwolin","elong","chengchia","chihching","iju65","hwchien","jdlin","mingyu","heliao","yyyeh","mislu","lingjan"],"食品營養與保健生技學系":["leemm","yincheng","hlchen908","honda224","hyweuan","sytsai","jyyeh","cp.lin","mmong","fushin","dengjs","jackhan","yachenyang","cychao","pjhuang","cclee168","henrytsai","cshuang","irenewu","wangzh","sunnylee"],"醫學檢驗暨生物技術學系":["yuanli","cychang","kikichenwolf","shhuang","tsaicf","ysho","yyao","angelashih","chuan","ck","yichih","ytzekiong92","yflin","chaoyang","rmhu","d9138001","yihlin","cyhuang","yclin","sschen1965","110100007","jjwu1019"],"心理學系":["evanlo","jennyko","huams","blake","someday","shujen","yhchang","hclin","psythc","curler","ctlee0503","tingying","changht","wupeiyu","PsyYPY","hmlu","hwu","elong","ycliao","ki222975","Klin90","llchein","Ta8001017","rmliao","fenfang"],"視光學系":["zn731","ahkai0420","samuelchiang","rschen","d9138001","art0802","stanelywu","rueilin","leesun","lindon","fugong","yuanli"],"聽力暨語言治療學系":["audslp","shchen","lucas","violet","cwhsien","nataliewang","vincenttien0623","sandychang0217","peggyliu","TinaZeng","sashalin","laylayjean","hintat"],"職能治療學系":["ot","otrlin","jennyleenet","jessiechen","patrice_yu","tywu820","ball0818","long0529","cvsliu0325","cindywang323"],"物理治療學系":[],"學士後獸醫學系":["chdvmm","chiita","andyp1998","jielonghe","dvmlai","cch99","dvm","yjh0425","ellis7374365"]},"資訊電機學院":{"生物資訊與醫學工程學系":["president","rmhu","cwlou","wenpinhu","cnwang","wlchan","wenyusu","ylsong","baskaran","sethho","ctchen"],"資訊工程學系":["president","g_sheu","arbee","mshwang","zshae1","benwnag1104","robertchh","wenhsu","cdma2000","yaonanlien","shih","cshsiao","bbgupta","chencn","rikki","chchuang","tlkung","ren","htchu","jdwang","tommyho","changkm","rsyu","chwu","cwhsien","rhyeh","hjko","weifu","wzyang","kky","dodinhthuan","wtchang","cyulin","wechen","kthuang14"],"行動商務與多媒體應用學系":["liao","sstseng","tchen","jishieh","CSChan","jliu","wjshih","cmchang","yytsai","lienfa","vincentpan","chchen"],"資訊傳播學系":["nung","ling","sunny","megcychen","edgarlin","twspeedy","tyk","siya24","whtsai","dayus","hjko"],"人工智慧博士學位學程":["yaonanlien"]},"管理學院":{"經營管理學系":["pt","pjwang","hcchang6912","yuchieh","108100040","yinlee","bebe2021","dvmlai"],"休閒與遊憩管理學系":["lsgau","twtang","felo","yywleisure","tcstcs","kent","nelsonchen","claire69","yuchen","mjlee","leisure","peter72","a0955331491","pjmonawu"],"會計與資訊學系":["ai","melodyp","joanchen","danielcc","meihuang","ling-yi","yapinghu","aleclin","hueichun","wzyang","laitc"],"財務金融學系":["yukl","chinyda","swtzang","gicha","yllin","yuarn","changjp","liao_meihua","andrewchien","ktwang","tony_w","finance"],"財經法律學系":["tangshumei","julan_hsieh","lin520314","940101194","minghsi_sung","wetzel","chuangyt","insong","mithclu","mlshih","tzh"],"管理學院雙聯學制":["lincwr","suntu","joyce","tangshumei","yukl","yywleisure","melodyp","shing7067","mlshih","khwang1516","shsheu","tsengminglang","wong","beatrice","940101194","peter72","yllin"]},"人文社會學院":{"外國語文學系":["csc71","ychen52","earljackson","vivwu123","klchuang","shuping","violet","ch.fang","wangliji","jeaniemao","curtis3883","mm","linpk","cswang","mccay","cannyh"],"社會工作學系":["mllee","shuchuan9","meichi","auteacher2012","maria","tzjuni","nany","yuling","chb-hsiao","chenyj","108100077","ccf511215","azo2319","zhichi"],"幼兒教育學系":["shen","yafeng999","tzuhuaho","yulinglo","linhuichun78","Jjm2","shenlu","ece","yawencheng","clairechang"]},"創意設計學院":{"數位媒體設計系":["chenjh","aleppo","teng","ervine","zeros","changkm","wzyang","ctlee","hmwang"],"視覺傳達設計系":["linpansong","chenjh","design99","hsiehsm","930100839","tingyi","houhsiaopei","suehuang","chrishuang","mengchihlin","vcd"],"創意商品設計系":["hhlin","teng","chenchs","cwlung","ophir","yu4038","chrisko","spacecat","yuting80145","zionw","waterwu50","an9868","au913","tyou5072","swc1017612","yayu_huang","moshikevin","dustin0424","WuWade","111200054","tomis750","shih","chi"],"時尚設計系":["chinghui","sisykitten","kijcandy","aleppo","chi","ophir","a-jen","lorenzo"],"室內設計系":["aleppo","zone","scshih","lin888","Liusy","chiawa","jhchan722","enzo","107200114","id","ckweng","lcf808","chencn"],"創意設計暨發明中心":["hhlin","sarahyu716","may111129"]},"護理學院":{"護理學系":["huashan","celine","jdlin","109100010","yuanli","joy831","yyao","fushin","dengjs","tzekiong","hwchien","plshao","sthuang","pyc620","lichun","csha615","huijunghung","lainey","chuan70","chiahui","syhuang02","lin1969","lucy6734","wlg1483ms48","yyfan","dilysbee93","slliu","107100005","manting","migikojin","nur","109300100","110100023","yschou","lshirong","shuwei","yawen172","10267ling","111100032","111100009","chiweilin","sgi0412"],"學士後護理學系":["huashan","mytseng","celine","yuanli","yyao","fushin","dengjs","tzekiong","jadeching","shuchen","huichili","feimei","yrtsai","110100117","BonnieChou","yang106071","111100033","chienhui","m099016"]},"國際學院":{"國際學術交流中心":["ciae","fenfang","niki860711","andylee"],"華語文中心":["ychen52","joyang35","flo","shiaoyuhchou","mwang9673","tecsid"],"兩岸教育交流中心":["danielcc"]},"人工智慧學院":{"人工智慧研究中心":[]},"通識教育中心":{"":["jang6812","shih","sun1023","ping","emily","emily_po","jillwu","flo","poicare999","a88022240","chsu","ymliou","fshuang","lcmpaul","dakuntea","chao137","111200003","ri6961car","caludius","e799792004","yusumm","alexponysys","111200080","111200081"]},"體育室":{"":["ytlin","peter72","david","vivian","iju65","chin1020","mjlee","yuting"]}} \ No newline at end of file diff --git a/asia_teachers.json b/asia_teachers.json new file mode 100644 index 0000000..ee8588f --- /dev/null +++ b/asia_teachers.json @@ -0,0 +1 @@ +{"orbitadm1.asia.edu.tw":[],"ai.asia.edu.tw":["ai","melodyp","joanchen","danielcc","meihuang","ling-yi","yapinghu","aleclin","hueichun","wzyang","laitc"],"als.asia.edu.tw":["leemm","yincheng","hlchen908","honda224","hyweuan","sytsai","jyyeh","cp.lin","mmong","fushin","dengjs","jackhan","yachenyang","cychao","pjhuang","cclee168","henrytsai","cshuang","irenewu","wangzh","sunnylee"],"audslp.asia.edu.tw":["audslp","shchen","lucas","violet","cwhsien","nataliewang","vincenttien0623","sandychang0217","peggyliu","TinaZeng","sashalin","laylayjean","hintat"],"bime.asia.edu.tw":["president","rmhu","cwlou","wenpinhu","cnwang","wlchan","wenyusu","ylsong","baskaran","sethho","ctchen"],"cai.asia.edu.tw":["changyc"],"cas.asia.edu.tw":["rayfang"],"ccd.asia.edu.tw":["chenchs"],"ccs.asia.edu.tw":["ccs","tombs35","ting","president","g_sheu","arbee","mshwang","zshae1","robertchh","cdma2000","yaonanlien","shih","cshsiao","chencn","rikki","chchuang","tlkung","ren","htchu","jdwang","tommyho","changkm","rsyu","chwu","cwhsien","rschen","rhyeh","hjko","weifu","wzyang","kky","dodinhthuan","wtchang","liao","sstseng","tchen","jishieh","CSChan","jliu","wjshih","cmchang","yytsai","lienfa","vincentpan","chchen","nung","ling","sunny","lucas","megcychen","shenjh","ck1226","edgarlin","twspeedy","tyk","siya24","whtsai"],"chs.asia.edu.tw":["shchen","blake","jjwang","yuanli","ahkai0420","otrlin","chdvmm","leemm","jjwu1019","sschen1965"],"ci.asia.edu.tw":["auic","tina840716","yungyi","aurellia","niki860711","cathyyying"],"cm.asia.edu.tw":["cmanagement","shing7067"],"cn.asia.edu.tw":["cn","huashan"],"cpd.asia.edu.tw":["hhlin","teng","chenchs","cwlung","ophir","yu4038","chrisko","spacecat","yuting80145","zionw","waterwu50","an9868","au913","tyou5072","swc1017612","yayu_huang","moshikevin","dustin0424","WuWade","111200054","tomis750","shih","chi"],"csie.asia.edu.tw":["president","g_sheu","arbee","mshwang","zshae1","benwnag1104","robertchh","wenhsu","cdma2000","yaonanlien","shih","cshsiao","bbgupta","chencn","rikki","chchuang","tlkung","ren","htchu","jdwang","tommyho","changkm","rsyu","chwu","cwhsien","rhyeh","hjko","weifu","wzyang","kky","dodinhthuan","wtchang","cyulin","wechen","kthuang14"],"sw.asia.edu.tw":["mllee","shuchuan9","meichi","auteacher2012","maria","tzjuni","nany","yuling","chb-hsiao","chenyj","108100077","ccf511215","azo2319","zhichi"],"pbn.asia.edu.tw":["huashan","mytseng","celine","yuanli","yyao","fushin","dengjs","tzekiong","jadeching","shuchen","huichili","feimei","yrtsai","110100117","BonnieChou","yang106071","111100033","chienhui","m099016"],"dba.asia.edu.tw":["pt","pjwang","hcchang6912","yuchieh","108100040","yinlee","bebe2021","dvmlai"],"dfd.asia.edu.tw":["chinghui","sisykitten","kijcandy","aleppo","chi","ophir","a-jen","lorenzo"],"dmd.asia.edu.tw":["chenjh","aleppo","teng","ervine","zeros","changkm","wzyang","ctlee","hmwang"],"dvm.asia.edu.tw":["chdvmm","chiita","andyp1998","jielonghe","dvmlai","cch99","dvm","yjh0425","ellis7374365"],"ece.asia.edu.tw":["shen","yafeng999","tzuhuaho","yulinglo","linhuichun78","Jjm2","shenlu","ece","yawencheng","clairechang"],"fel.asia.edu.tw":["tangshumei","julan_hsieh","lin520314","940101194","minghsi_sung","wetzel","chuangyt","insong","mithclu","mlshih","tzh"],"flts.asia.edu.tw":["csc71","ychen52","earljackson","vivwu123","klchuang","shuping","violet","ch.fang","wangliji","jeaniemao","curtis3883","mm","linpk","cswang","mccay","cannyh"],"fn.asia.edu.tw":["yukl","chinyda","swtzang","gicha","yllin","yuarn","changjp","liao_meihua","andrewchien","ktwang","tony_w","finance"],"ha.asia.edu.tw":["clyaung","atsai","yanghc","tnwu","ptkung","plday","jjwang","okonkwolin","elong","chengchia","chihching","iju65","hwchien","jdlin","mingyu","heliao","yyyeh","mislu","lingjan"],"id.asia.edu.tw":["aleppo","zone","scshih","lin888","Liusy","chiawa","jhchan722","enzo","107200114","id","ckweng","lcf808","chencn"],"infocom.asia.edu.tw":["nung","ling","sunny","megcychen","edgarlin","twspeedy","tyk","siya24","whtsai","dayus","hjko"],"leisure.asia.edu.tw":["lsgau","twtang","felo","yywleisure","tcstcs","kent","nelsonchen","claire69","yuchen","mjlee","leisure","peter72","a0955331491","pjmonawu"],"mcma.asia.edu.tw":["liao","sstseng","tchen","jishieh","CSChan","jliu","wjshih","cmchang","yytsai","lienfa","vincentpan","chchen"],"mlsb.asia.edu.tw":["yuanli","cychang","kikichenwolf","shhuang","tsaicf","ysho","yyao","angelashih","chuan","ck","yichih","ytzekiong92","yflin","chaoyang","rmhu","d9138001","yihlin","cyhuang","yclin","sschen1965","110100007","jjwu1019"],"nur.asia.edu.tw":["huashan","celine","jdlin","109100010","yuanli","joy831","yyao","fushin","dengjs","tzekiong","hwchien","plshao","sthuang","pyc620","lichun","csha615","huijunghung","lainey","chuan70","chiahui","syhuang02","lin1969","lucy6734","wlg1483ms48","yyfan","dilysbee93","slliu","107100005","manting","migikojin","nur","109300100","110100023","yschou","lshirong","shuwei","yawen172","10267ling","111100032","111100009","chiweilin","sgi0412"],"opt.asia.edu.tw":["zn731","ahkai0420","samuelchiang","rschen","d9138001","art0802","stanelywu","rueilin","leesun","lindon","fugong","yuanli"],"ot.asia.edu.tw":["ot","otrlin","jennyleenet","jessiechen","patrice_yu","tywu820","ball0818","long0529","cvsliu0325","cindywang323"],"psy.asia.edu.tw":["evanlo","jennyko","huams","blake","someday","shujen","yhchang","hclin","psythc","curler","ctlee0503","tingying","changht","wupeiyu","PsyYPY","hmlu","hwu","elong","ycliao","ki222975","Klin90","llchein","Ta8001017","rmliao","fenfang"],"vcd.asia.edu.tw":["linpansong","chenjh","design99","hsiehsm","930100839","tingyi","houhsiaopei","suehuang","chrishuang","mengchihlin","vcd"],"120.108.101.127":["eros","vincentpan","amos_chiu","k06132001","jefflu","ccw0811","hopooho","liyu-asia","james","ching","akai","michael","stuart","jerryck","zz_denis","wizoza35346","leafwble","hitomi168","wechen"],"sample.orbitadm3.asia.edu.tw":[],"sec.asia.edu.tw":["eros","shih","flo","chiu","wlchan","hychang74","megan","rabbit","sylviaf","a7901302000","chainrone","lin888","godwkdgh","ling21"],"rd.asia.edu.tw":["black0510","chency","shih","yuchen","acec","csie06","hsinyi","liaojoe","jianyong","alice"],"ac.asia.edu.tw":["academic","sttsai","johnsoniris10","tony_w","kiki","winnieli"],"general.asia.edu.tw":["chang-yh","tpy","akh","111300093","sunny","linda_yang","yumin","polly","ben","ken595","a00350","joanchang1004"],"rc.asia.edu.tw":["yincheng","wenpinhu","lcyang","ariel","karen","yanci5422","jielonghe","cychao","wangzh","rd.asia","irenewu","curler"],"iic.asia.edu.tw":["yllin","tingying","tsaiww","hsiawei","chingpin","Ren0924","Tammy","jianian","cnwang"],"persond.asia.edu.tw":["hjko","molly","chiayu_lin","zxc40736","ling47"],"acc.asia.edu.tw":["carolchen","jessicahus","rubyzhan","tinawen","tanya","ginatseng","anita","apeicoco"],"sd.asia.edu.tw":["schang","rebeccawu","108300198","lin1991831","poijkltw","e-6119","abar5346","dt1478","a113283","kuoyu","swli54088","lucky9sch","tsao0614","teche0216","highway","kuma52","psythc","be_frutiful","bemi","sun76856","107300290","emily_po","vicki","roger6103","yfliao","linrong","st878110","chiaoyu03","hclin","lin0829","florahsu","dolcech","ichaelm88","shaofenk","cecileshuan","shahu","chunwei","ww66jj","domo430","chuang.wanting","tree790726","peiju","angel9152328","yifong","comma","may","tiffany","109300060","yuling","yu-rong","daisy1231","peijen","ra110300153","eddy3103520","wenwen","104300113","jerryhu0616","fisheryu","zongxun","victor771005","t111300094","vvn0328","lotso0097","verna"],"library.asia.edu.tw":[],"dual.asia.edu.tw":["lincwr","suntu","joyce","tangshumei","yukl","yywleisure","melodyp","shing7067","mlshih","khwang1516","shsheu","tsengminglang","wong","beatrice","940101194","peter72","yllin"],"home.orbitadm3.asia.edu.tw":["tnwu","tchen","teng","jennyko","sstseng","cmhs","ccs","cmanagement","arts-sciences","ccd","cn","mis"],"asiamodern.asia.edu.tw":["alexiskam8516","yummy00158","joyce1005","caca7932","khduh"],"aip.asia.edu.tw":["yaonanlien"],"env.asia.edu.tw":["sunny","paultsai","cp.lin","ching1978","n25031","insun1","akh","yuchen"],"ird.asia.edu.tw":["tnwu","sttsai","ytshiao","yhchou","waterrice","pxlin","karl1203","kilio92","high1069coco","water","chen12","puli","samlin010","yulinglo","tzyinchen"],"trfdc.asia.edu.tw":[],"cdic.asia.edu.tw":["hhlin","sarahyu716","may111129"],"ged.asia.edu.tw":["jang6812","shih","sun1023","ping","emily","emily_po","jillwu","flo","poicare999","a88022240","chsu","ymliou","fshuang","lcmpaul","dakuntea","chao137","111200003","ri6961car","caludius","e799792004","yusumm","alexponysys","111200080","111200081"],"pe.asia.edu.tw":["ytlin","peter72","david","vivian","iju65","chin1020","mjlee","yuting"],"ciae.asia.edu.tw":["ciae","fenfang","niki860711","andylee"],"ccae.asia.edu.tw":["danielcc"],"cltr.asia.edu.tw":["ychen52","mavise.lin","nathan.miller","paul802","thomaslagrua","gilly"],"jclc.asia.edu.tw":["ychen52","joyang35","flo","shiaoyuhchou","mwang9673","tecsid"],"chm.asia.edu.tw":["ychen52","jen23","msirene604"],"idtec.asia.edu.tw":["shiaoyuh"],"idp.asia.edu.tw":["zone","jhchan722"],"5i.asia.edu.tw":["sttsai","karl1203","kilio92","anny50235","yisyun","tzyinchen","ting","rita10014","sarahlin","changyc","rebeccawu","wadeuuu884","k06132001","puli","water"],"chtsai.asia.edu.tw":[],"pims.asia.edu.tw":[],"foodsafety.asia.edu.tw":["honda224"],"i2school.asia.edu.tw":["teng","draven1220","chen12","sydniechen0"],"acs.asia.edu.tw":["tnwu","karl1203","yisyun"],"gcs.asia.edu.tw":["zongxun","ra110300153"],"artseason.asia.edu.tw":["rebeccawu"],"geec.asia.edu.tw":[],"pao.asia.edu.tw":["sunny","maa89462"],"eo.asia.edu.tw":[],"caa.asia.edu.tw":["sun1023","rebeccawu"],"fintech.asia.edu.tw":["apc888888","lincwr","yukl","tommyho","ren","yytsai","andrewchien","jefflu","mshwang"],"iat.asia.edu.tw":["leeshinda","otrlin","pjwang","sandychang0217"],"3dprinting.asia.edu.tw":["tchen"],"dmte.asia.edu.tw":["poijkltw","e-6119","abar5346","dt1478","a113283","kuoyu","swli54088","lucky9sch","tsao0614","teche0216","highway"],"ds.asia.edu.tw":["may","tsao0614","highway","tiffany","jerryhu0616"],"healthyau.asia.edu.tw":["hclin","florahsu","dolcech","ichaelm88","cecileshuan","shahu","chunwei","peiju","angel9152328","yifong","comma","chuang.wanting","domo430","ww66jj","tree790726","lin0829","peijen","dt1478","victor771005","lotso0097","verna"],"character.asia.edu.tw":[],"silgs.asia.edu.tw":["rhyeh","cathyhsu","inpin","ctrl87824"],"cdgs.asia.edu.tw":["yuling","yu-rong","daisy1231","abar5346","career","104300113"],"daisr.asia.edu.tw":["jennyko","schang","lincwr","yulinglo","samlin010","karl1203","tzyinchen"],"thefv.asia.edu.tw":[],"qae.asia.edu.tw":["irene","lin888","chainrone"],"info.asia.edu.tw":[],"emi.asia.edu.tw":[],"emi-amc.asia.edu.tw":[],"iaptc.asia.edu.tw":[],"sustainabilityau.asia.edu.tw":["karl1203","tzyinchen","yulinglo","ausd","jiahua"],"as-center.asia.edu.tw":["sashalin"],"ipr.asia.edu.tw":["sun76856"],"aupe.asia.edu.tw":["eros","tombs35"],"autheuir.asia.edu.tw":[],"alumni.asia.edu.tw":["daisy1231"],"quantum.asia.edu.tw":[],"bigdata.asia.edu.tw":["wechen","cyulin","cnwang","jianian","jdwang","robertchh","ctchen"],"www.asia.edu.tw":["tnwu","tchen","teng","jennyko","sstseng","cmhs","ccs","cmanagement","arts-sciences","ccd","cn","chenchs","mis","liyu-asia"],"enweb.asia.edu.tw":["tnwu","tchen","teng","jennyko","sstseng","cmhs","ccs","cmanagement","arts-sciences","ccd","cn","chenchs","mis","liyu-asia"]} \ No newline at end of file diff --git a/bin/rails b/bin/rails new file mode 100644 index 0000000..38c2a68 --- /dev/null +++ b/bin/rails @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/personal_course/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require 'rails/all' +require 'rails/engine/commands' diff --git a/combined_departs.rb b/combined_departs.rb new file mode 100644 index 0000000..0bc64f7 --- /dev/null +++ b/combined_departs.rb @@ -0,0 +1,7 @@ +asia_teachers = JSON.parse(File.read('asia_teachers.json')) +asia_academies = JSON.parse(File.read('asia_academies.json')) + +asia_depart_teachers = asia_academies.map do |academy, departs_info| + [academy, departs_info.map{|depart_name, url| [depart_name, asia_teachers[url].to_a] }.to_h ] +end.to_h +File.open('asia_depart_teachers.json', 'w+'){|f| f.write(asia_depart_teachers.to_json)} \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..d083101 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,73 @@ +en: + restful_actions: + asia_teachers: "Teacher" + asia_projects: "Project" + asia_papers: "Paper" + asia_patents: "Patent" + asia_tec_transfers: "Technology Transfer" + asia_exhibitions: "Exhibition" + module_name: + asia_database: Asia Talent Database + asia_database: + extend_translate: + download_excel: Download Excel + start_time: Start time + end_time: End time + start_date: Start date + end_date: End date + start_date_time: Start date & time + end_date_time: End date & time + start_year: Start year + end_year: End year + start_year_month: Start year/month + end_year_month: End year/month + total_number: Total number + select_class: "——select class——" + select_field: "——select field——" + search: "Search" + search_field: "Search Field:" + search_class: "Search Class:" + word_to_search: "Search Contents:" + discipline_expertise: "Discipline Expertise" + project: "Project" + paper: "Paper" + patent: "Patent" + tec_transfer: "Technology Transfer" + exhibition: "Exhibition" + unit: "Unit:" + graph_by: "Graph By" + sid: Staff ID + academy: Academy + department: Department + teacher: Teacher + url: URL + discipline_expertise: Discipline Expertise + asia_academy: + academy_name: "Academy Name" + asia_department: + department_name: "Department Name" + asia_project: + project_name: Project name + date: Date + start_date: Start Date + sponsor: Sponsor + asia_paper: + paper_name: Paper Name + issue_year: Issue Year + journal_name: Journal Name + asia_patent: + patent_name: Patent Name + term_of_patent: Term of Patent + certification_date: Certification Date + patent_country: Patent Country + asia_tec_transfer: + tech_transfer_name: Technology Transfer Name + period: Period + start_date: Start Date + receiving_unit: Receiving Unit + asia_exhibition: + exhibition_name: Exhibition Name + exhibition_date: Exhibition Date + host: Host + member_profile: Author + \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml new file mode 100644 index 0000000..c21ef4c --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,71 @@ +zh_tw: + restful_actions: + asia_teachers: "老師" + asia_projects: "計畫" + asia_papers: "論文(期刊+研討會)" + asia_patents: "專利" + asia_tec_transfers: "技轉" + asia_exhibitions: "展演" + module_name: + asia_database: 亞大人才資料庫 + asia_database: + extend_translate: + download_excel: "下載Excel" + start_time: 開始時間 + end_time: 結束時間 + start_date: 開始日期 + end_date: 結束日期 + start_date_time: 開始日期時間 + end_date_time: 結束日期時間 + start_year: 開始年分 + end_year: 結束年分 + start_year_month: 開始年月 + end_year_month: 結束年月 + total_number: 總數量 + select_class: "——選取分類——" + select_field: "——選取欄位——" + search: "搜尋" + search_field: "搜尋欄位:" + search_class: "搜尋類別:" + word_to_search: "關鍵字搜尋:" + discipline_expertise: "專長" + project: "計畫" + paper: "論文(期刊+研討會)" + patent: "專利" + tec_transfer: "技轉" + exhibition: "展演" + unit: "單位:" + graph_by: "Graph By" + sid: "員工編號" + academy: "學院" + department: "系所" + teacher: "老師" + url: URL + discipline_expertise: "專長" + asia_academy: + academy_name: "學院名稱" + asia_department: + department_name: "系所名稱" + asia_project: + project_name: "計畫名稱" + date: "時間" + start_date: "開始時間" + sponsor: "補助單位" + asia_paper: + paper_name: "論文名稱" + issue_year: "發表年份" + journal_name: "期刊名稱" + asia_patent: + patent_name: "專利名稱" + term_of_patent: "專利有效期" + certification_date: "獲證時間" + patent_country: "專利國家" + asia_tec_transfer: + tech_transfer_name: "技轉名稱" + period: "期間" + start_date: "開始時間" + receiving_unit: "技轉對象" + asia_exhibition: + exhibition_name: "展演名稱" + exhibition_date: "展演時間" + host: "展演單位" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..9198427 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,51 @@ +Rails.application.routes.draw do + Thread.new do + AsiaTeacher.create_indexes + AsiaProject.create_indexes + AsiaPaper.create_indexes + AsiaPatent.create_indexes + AsiaTecTransfer.create_indexes + AsiaExhibition.create_indexes + AsiaExportStore.create_indexes + end + locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales + scope "(:locale)", locale: Regexp.new(locales.join("|")) do + namespace :admin do + get 'asia_teacher_setting' => "asia_teachers#setting" + resources :asia_teachers do + collection do + get 'toggle_hide' => 'asia_teachers#toggle_hide' + get 'analysis' + get 'analysis_report' + get "download_excel" + end + end + + resources :members do + collection do + scope '(:name-:uid)' do + resources :asia_teachers do + collection do + get 'frontend_setting' => 'asia_teachers#frontend_setting' + post 'update_frontend_setting' => 'asia_teachers#update_frontend_setting' + end + end + end + end + end + resources :asia_databases do + member do + get 'asia_teachers' + get 'asia_projects' + get 'asia_papers' + get 'asia_patents' + get 'asia_tec_transfers' + get 'asia_exhibitions' + end + end + end + post "/xhr/asia_database/export_excel" => "asia_databases#export_excel" + get "/xhr/asia_database/download_excel" => "asia_databases#download_excel" + post '/xhr/asia_database/get_store_status' => 'asia_databases#get_store_status' + end +end \ No newline at end of file diff --git a/lib/asia_database.rb b/lib/asia_database.rb new file mode 100644 index 0000000..0c3a004 --- /dev/null +++ b/lib/asia_database.rb @@ -0,0 +1,4 @@ +require "asia_database/engine" + +module AsiaDatabase +end diff --git a/lib/asia_database/engine.rb b/lib/asia_database/engine.rb new file mode 100644 index 0000000..8f975a3 --- /dev/null +++ b/lib/asia_database/engine.rb @@ -0,0 +1,22 @@ +module AsiaDatabase + class Engine < ::Rails::Engine + initializer "asia_database" do + OrbitApp.registration "AsiaDatabase",:type=> 'ModuleApp' do + module_label 'module_name.asia_database' + base_url File.expand_path File.dirname(__FILE__) + version "0.0.1" + desktop_enabled true + organization "Rulingcom" + author "RD dep" + frontend_enabled + data_count 1..10 + side_bar do + head_label_i18n 'module_name.asia_database', icon_class: "fas fa-school-flag" + available_for "users" + active_for_controllers (['admin/asia_databases', 'admin/asia_teachers']) + head_link_path "admin_asia_databases_path" + end + end + end + end +end \ No newline at end of file diff --git a/lib/asia_database/version.rb b/lib/asia_database/version.rb new file mode 100644 index 0000000..aac5300 --- /dev/null +++ b/lib/asia_database/version.rb @@ -0,0 +1,3 @@ +module AsiaDatabase + VERSION = "0.0.1" +end diff --git a/lib/tasks/asia_database_tasks.rake b/lib/tasks/asia_database_tasks.rake new file mode 100644 index 0000000..938a7c1 --- /dev/null +++ b/lib/tasks/asia_database_tasks.rake @@ -0,0 +1,245 @@ +require 'net/http' +require "base64" +module AsiaDatabasePlugin + InUseLocales = Site.first.in_use_locales rescue [:en,:zh_tw] + class SafeHash < Hash + attr_accessor :duplicate_check_off + def []=(key, value) + if !duplicate_check_off && has_key?(key) + super(key,Array(self[key])+[value]) + else + super + end + end + end + IV = [0x12, 0x34, 0x56, 0x84, 0x9b, 0xab, 0xcd, 0xef].pack('C*') + KEY = "Tch#^837".bytes.pack('C*') + def self.localize_data(data, locales=InUseLocales) + return locales.map{|locale| [locale, data.dup] }.to_h + end + # 研究計畫 Research Grants + def self.sync_projects(query_result, asia_teacher) + email_id = asia_teacher.email_id + return if email_id.blank? + puts "Projects(Research Grants) for user: #{email_id}" + projects = query_result["research"].to_a + if !query_result['emp'].blank? + AsiaProject.where(asia_teacher: asia_teacher,:rss2_id.ne=>nil).where(:rss2_id.nin=>projects.map{|v| v["ukey"]}).destroy + end + return if projects.count == 0 + projects.each do |project| + pj = AsiaProject.where(:rss2_id=> project["ukey"]).first + pj = AsiaProject.new if pj.nil? + pj.rss2_id = project["ukey"] + pj.project_name_translations = localize_data(project["name"]) #計畫名稱 + # pj.sponsor = + if project["period"].present? + period = project["period"].split('~').map{|date| DateTime.parse(date) rescue nil} + pj.start_date = period[0] + pj.end_date = period[1] + else + pj.start_date = nil + pj.end_date = nil + end + pj.asia_teacher = asia_teacher + puts "Project(Research Grants) #{pj.id} saved" if pj.save + end + end + def self.sync_papers(query_result, asia_teacher) # journal and conference papers + email_id = asia_teacher.email_id + return if email_id.blank? + puts "Paper for user: #{email_id}" + journal_papers = query_result["journal"].to_a + conference_papers = query_result["conference"].to_a + papers = journal_papers + conference_papers + if !query_result['emp'].blank? + AsiaPaper.where(asia_teacher: asia_teacher,:rss2_id.ne=>nil).where(:rss2_id.nin=>papers.map{|v| v["ukey"]}).destroy + end + return if papers.count == 0 + journal_papers.each do |journal_paper| + jp = AsiaPaper.where(:rss2_id=> journal_paper["ukey"]).first + jp = AsiaPaper.new if jp.nil? + jp.rss2_id = journal_paper["ukey"] + jp.paper_name_translations = localize_data(journal_paper["Thesis_name"]) + jp.journal_name_translations = localize_data(journal_paper["Journal_name"]) + jp.issue_year = journal_paper["Thesis_year"] + jp.asia_teacher = asia_teacher + puts "Journal Paper #{jp.id} saved" if jp.save + end + conference_papers.each do |conference_paper| + wc = AsiaPaper.where(:rss2_id=> conference_paper["ukey"]).first + wc = AsiaPaper.new if wc.nil? + wc.rss2_id = conference_paper["ukey"] + titles = conference_paper["name"].split("-") + wc.paper_name_translations = localize_data(titles[0]) + wc.journal_name_translations = localize_data(titles[1..-1].join("-")) + wc.issue_year = conference_paper["Thesis_year"] + wc.asia_teacher = asia_teacher + puts "conference paper #{wc.id} saved" if wc.save + end + end + def self.sync_patents(query_result, asia_teacher) # patents + email_id = asia_teacher.email_id + return if email_id.blank? + puts "Patent for user: #{email_id}" + patents = query_result["patent"].to_a + if !query_result['emp'].blank? + AsiaPatent.where(asia_teacher: asia_teacher,:rss2_id.ne=>nil).where(:rss2_id.nin=>patents.map{|v| v["ukey"]}).destroy + end + return if patents.count == 0 + patents.each do |patent| + pt = AsiaPatent.where(:rss2_id=> patent["ukey"]).first + pt = AsiaPatent.new if pt.nil? + pt.rss2_id = patent["ukey"] + pt.patent_name_translations = localize_data(patent["Patent_name"]) + pt.patent_country, pt.patent_no = patent["Patent_id"].split(":") #專利國家:專利編號, ex: 中華民國設計專利:D170464 + if patent["sDate"].present? + period = patent["sDate"].split('~').map{|date| DateTime.parse(date) rescue nil} + pt.certification_date = period[0] + pt.end_date = period[1] + else + pt.certification_date = nil + pt.end_date = nil + end + pt.asia_teacher = asia_teacher + puts "Patent #{pt.id} saved" if pt.save + end + end + #技術轉移 Technology transfer + def self.sync_tec_transfers(query_result, asia_teacher) + email_id = asia_teacher.email_id + return if email_id.blank? + puts "Technology transfer for user: #{email_id}" + tec_transfers = query_result["tec_transfer"].to_a + if !query_result['emp'].blank? + AsiaTecTransfer.where(asia_teacher: asia_teacher,:rss2_id.ne=>nil).where(:rss2_id.nin=>tec_transfers.map{|v| v["ukey"]}).destroy + end + return if tec_transfers.count == 0 + tec_transfers.each do |tec_transfer| + tt = AsiaTecTransfer.where(:rss2_id=> tec_transfer["ukey"]).first + tt = AsiaTecTransfer.new if tt.nil? + tt.rss2_id = tec_transfer["ukey"] + tt.tech_transfer_name_translations = localize_data(tec_transfer["Trans_Data_NAME"]) #技轉名稱 + tt.receiving_unit_translations = localize_data(tec_transfer["Trans_Unit"]) #技轉對象 + if tec_transfer["period"].present? #技轉期間 + period = tec_transfer["period"].split('~').map{|date| Date.parse(date) rescue nil} + tt.start_date = period[0] + tt.end_date = period[1] + else + tt.start_date = nil + tt.end_date = nil + end + tt.asia_teacher = asia_teacher + puts "Technology transfer #{tt.id} saved" if tt.save + end + end + def self.sync_exhibitions(query_result, asia_teacher) # exhibitions + email_id = asia_teacher.email_id + return if email_id.blank? + puts "Exhibition(show) for user: #{email_id}" + exhibitions = query_result["show"].to_a + if !query_result['emp'].blank? + AsiaExhibition.where(asia_teacher: asia_teacher,:rss2_id.ne=>nil).where(:rss2_id.nin=>exhibitions.map{|v| v["ukey"]}).destroy + end + return if exhibitions.count == 0 + exhibitions.each do |exhibition| + et = AsiaExhibition.where(:rss2_id=> exhibition["ukey"]).first + et = AsiaExhibition.new if et.nil? + et.rss2_id = exhibition["ukey"] + et.exhibition_name_translations = localize_data(exhibition["show_name"]) + et.host_translations = localize_data(exhibition["show_author_local"]) + if exhibition["period"].present? #展演期間 + period = exhibition["period"].split('~').map{|date| DateTime.parse(date) rescue nil} + et.exhibition_start_date = period[0] + et.exhibition_end_date = period[1] + else + et.exhibition_start_date = nil + et.exhibition_end_date = nil + end + et.asia_teacher = asia_teacher + puts "Exhibition(show) #{et.id} saved" if et.save + end + end +end +namespace :asia_database do + desc "Sync asia database" + task :sync,[:user_names, :only_sync_data] => [:environment] do |task,args| + if args.user_names.present? + asia_teachers = AsiaTeacher.where(:email_id.in=>args.user_names).to_a + else + if args.only_sync_data.blank? || (args.only_sync_data != 'true' && args.only_sync_data != true) + asia_depart_teachers = JSON.parse(File.read(File.expand_path("../../../asia_depart_teachers.json", __FILE__))) + asia_depart_teachers.each do |academy_name, departs_info| + academy = AsiaAcademy.where("academy_name.zh_tw"=>academy_name).first + if academy.nil? + academy = AsiaAcademy.create({:academy_name_translations=>AsiaDatabasePlugin.localize_data(academy_name)}) + end + departs_info.each do |depart_name, user_names| + depart = AsiaDepartment.where("department_name.zh_tw"=>depart_name, "asia_academy"=>academy).first + if depart.nil? + depart = AsiaDepartment.create({:department_name_translations=>AsiaDatabasePlugin.localize_data(depart_name), :asia_academy=>academy}) + end + user_names.each do |email_id| + teacher_data = get_sync_data(email_id) + emp = teacher_data["emp"] + next if emp.blank? + emp = emp[0] + asia_teacher = AsiaTeacher.where(:email_id=>email_id).first + if asia_teacher.nil? + asia_teacher = AsiaTeacher.new(:email_id=>email_id, :asia_academy=>academy, :asia_department=>depart) + else + asia_teacher.asia_academy = academy + asia_teacher.asia_department = depart + end + asia_teacher.ukey = emp["ukey"] + asia_teacher.teacher_translations = {"zh_tw"=>emp["emp_nm"], "en"=>emp["emp_enm"]} + asia_teacher.save + end + end + end + end + asia_teachers = AsiaTeacher.all.to_a + end + asia_teachers.each do |asia_teacher| + query_result = get_sync_data(asia_teacher.email_id) + discipline_expertise_translations = AsiaDatabasePlugin.localize_data([], ['zh_tw', 'en']) + query_result['RshSkill'].to_a.each do |h| + tmp = h["RSkill"].to_s.strip + tmp2 = h["eRSkill"].to_s.strip + discipline_expertise_translations['zh_tw'] << [tmp, tmp2].select{|s| s.present?}.join('/') + discipline_expertise_translations['en'] << (tmp2.present? ? tmp2 : tmp) + end + asia_teacher.discipline_expertise_translations = discipline_expertise_translations + asia_teacher.save + AsiaDatabasePlugin.sync_projects(query_result, asia_teacher) + AsiaDatabasePlugin.sync_papers(query_result, asia_teacher) + AsiaDatabasePlugin.sync_patents(query_result, asia_teacher) + AsiaDatabasePlugin.sync_tec_transfers(query_result, asia_teacher) + AsiaDatabasePlugin.sync_exhibitions(query_result, asia_teacher) + end + end + def net_http_get_response(uri,headers={}) + http = Net::HTTP.new(uri.host, uri.port) + if uri.scheme == "https" + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + http.use_ssl = true + end + http.read_timeout = (@read_timeout.nil? ? 60 : @read_timeout) + res = http.get((uri.path.blank? ? "/" : uri.path)+(uri.query.blank? ? '' : "?#{uri.query}")) + res.uri = uri + res + end + def get_sync_data(email_id) + uri = URI.parse("https://webap.asia.edu.tw/TchEportfolio/API/Research/Load") + @read_timeout = 300 + data = "id=#{email_id}" + cipher = OpenSSL::Cipher::Cipher.new("des-cbc").encrypt.tap do |obj| + obj.iv = AsiaDatabasePlugin::IV + obj.key = AsiaDatabasePlugin::KEY + end + encrypt = cipher.update(data) + cipher.final() + encrypt_base64 = Base64.encode64(encrypt).strip + res = net_http_get_response(uri + "?#{encrypt_base64}") + return JSON.parse(res.body,{object_class: AsiaDatabasePlugin::SafeHash}) + end +end \ No newline at end of file diff --git a/modules/asia_database/index.html.erb b/modules/asia_database/index.html.erb new file mode 100644 index 0000000..e6a443a --- /dev/null +++ b/modules/asia_database/index.html.erb @@ -0,0 +1,23 @@ + + + + + + + + + + + + +

    {{widget-title}}

    {{head-title}}
    {{value}}
    +{{pagination_goes_here}} + + \ No newline at end of file diff --git a/modules/asia_database/index_search0.html.erb b/modules/asia_database/index_search0.html.erb new file mode 100644 index 0000000..07fcbbb --- /dev/null +++ b/modules/asia_database/index_search0.html.erb @@ -0,0 +1,54 @@ + +

    {{widget-title}}

    +
    +
    + + {{unit_trans}} + + {{select_field_text}} + + {{search_text}} + + + Clear +
    +
    + + + + + + + + + + + + +

    {{widget-title}}

    {{head-title}}
    {{value}}
    +{{pagination_goes_here}} + + \ No newline at end of file diff --git a/modules/asia_database/index_search1.html.erb b/modules/asia_database/index_search1.html.erb new file mode 100644 index 0000000..f10a129 --- /dev/null +++ b/modules/asia_database/index_search1.html.erb @@ -0,0 +1,126 @@ + +
    + +

    {{widget-title}}

    +
    +
    + + {{unit_trans}} + + {{select_field_text}} + + {{search_text}} + + + Clear + Export +
    +
    + + + + + + + + + + + + +

    {{widget-title}}

    {{head-title}}
    {{value}}
    + {{pagination_goes_here}} + +
    \ No newline at end of file diff --git a/modules/asia_database/info.json b/modules/asia_database/info.json new file mode 100644 index 0000000..73dab69 --- /dev/null +++ b/modules/asia_database/info.json @@ -0,0 +1,12 @@ +{ + "frontend": [ + { + "filename" : "index_search1", + "name" : { + "zh_tw" : "1. 列表(含搜尋)", + "en" : "1. List which includes search" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/modules/asia_database/show.html.erb b/modules/asia_database/show.html.erb new file mode 100644 index 0000000..58a66d2 --- /dev/null +++ b/modules/asia_database/show.html.erb @@ -0,0 +1,8 @@ + + + + + + + +
    {{title}}{{value}}
    \ No newline at end of file diff --git a/modules/asia_database/thumbs/thumb.png b/modules/asia_database/thumbs/thumb.png new file mode 100644 index 0000000000000000000000000000000000000000..266af5606742714c262a949cd58aedc2b84b1959 GIT binary patch literal 4075 zcmcgvYdBPE`=8Q@or=MZk}-~jIXD}qFebzhVvsZ#jA2HMW=0OFFbKQkR5@2;7{)1- z&=wM+oMYofvU8{uIS&7&UHkuj*w_2v{qU~qTI;!=weH`2-_Lz|o)v3@JtZh0Apin_ z1kKIRw!l~h+!g!w0MC|jUMDb!Q%!MHJBk;Th7Tlwj65ms1cm?>ZoCb zunI6C_z=xP0tt2@SbL8Ul825b)X)H;M@Iny{0US%gzoQ04nooOq2J}A0DAj1918i) zLM7=#|1t_^Wdkvx1QH+`FocQ+LK6wmREHte5jyHR$`Dlq5&=i5!Vy|3NCZkl3xz;J zeq2yMTcD>G$`+0Jp$nMlLw%^!02CZfqtReAH5et(8;;b`(SajW;i{@C0EbEtgG|NK zRmedyKP8|EK^}p`04k9}hHOj3yHkRx`cS~qzn0)1U}g2UU~4vB3<+^0l07N3pzZMdwOTYGka&sUi3z0mL%#bLMf?Z- z>ZS-JMhk;Ms+p<-HXx1FOpGw9+S;btnx?86+SLrFqmAt8Lvxw>O#9Ok(U(6adi=}!UB|h@GFIv~ z3by;zyIaw_j2w*cMtljDe@vCYYBBN{3B_}Vjo?=y5{HRi5Qzi{pS+umos~BYBNJa& zkB#!~P<#uqTbUmXSksK04_O}zQA=O@9o_oaC^d(oz7rtA`(Fz|ZJl&3e@9oBUHof} zii!$-7EjmN-Q6)UF+u6`U4kzeZoO$!*c@J5RNonGEUj;m*6pneu6?<%aM4#VPAhUf8>TQU zggnVU*>r`u;}8-A-Gko$zozhV-1BvXNA*K07ecJnTNzBq!E9)tfjr4yJM48svB1DR(~qCqDFK6W{c3 zH6;U@u$qM5KnN;IP3F7D9z3f3I$hbkK$rIMoRCAwHLHipoCjs(ktYRPYby(rqTtfW z7fFr>j_DmvnAA>kT~$YLGg+S9*wr7Xw)3Wu%pe!sRi1%Rt_BUV0-C(c?B3zSEr zhH7b)e3<)El-#ka)_#IVH0^z&`U1{dmX%seHb(vOMs!!~hq<>EFU{{XL5-qiu9m3X zFi*!wq?oQAXfH&aIseu9xKWe7vpau}vc;d8={1&3PO#V}#$-#v`?2zx+$FnvMUGs| zhQY zv|2uUKg)>djjunlqw$VPb5YP@ElI^eek&T)dwhI1&|~8+I@^icFhGv8YH{sS`ceUPyi9m3ekAZ*W@Ati|`yP&xel^fU=*AW>a4 zZd+$%EfR$e`To`2gg9oV&u7IB z#kt*zr*$^sOlv~URCa1ng@WEaP4^*orb@Z^)1CXE(e8Gsbz+utIg27K!o$f7J@3wY zv7@|OQj)MC7FL>e`PN|K+=^ZIcmS!ofLH8wBz(!GNSAiWMlF@>x3BuHDEoOS8&z6< zpPc=oigpP$V+ES6>G{z?!vor#COgNcSD`y-ofGsk~b~sChbDiXtak z(l;uY@`kK%IhUv~48$w>qUehm1rA^4`F_RsUs-8Yp&tj!JWP)&B_~~D){0ovg8BV@ z7M9oRPUqk&q@dpz$#hv&FcYhKM542fki29$&)6rmJ0~Cz?l)Q2cB>GaGDZt=+bis? zXqNo~cTbhFQzAAtbD3}Ng3pPDmj+L>BpqG_hS|y_=(8HvpJnz&E=LZt`J`AK&|?`r zox)c%&@*rB8F{&HH~K$^)NzW|gdTzo`(~a^TxZ<6o4=77#<$TLhr7L+<6&`wk)Svp zD}vr1rqJ~~ue|>JvtoHRlP(&Y@75|OAl21J3K`wo5IEHq_tN$4Dxr6GKR3CF*BIZH z`ut1YTvC9_eWpp|>Ym~BPC)9;e2iU$tybvJ<->-vV?vcch8R{jw$sK{7C5ty zf`oNblLmwJ>JQxZqE|Gr#EY&C5~uB*i`%3gY8Ck3y>}_P`#I73Lhw$I5Ff-Hgx=3Q z3{dYn3;&2)UHv-U*2A(^k}?eU+o-!VKh*XzS>ZBvxxd&YWxItZ9@V*8erUm>vXwW{ z98VbYAF57n z524D!g-bbHbpCSq#jQ;qX47-ZZs1M9zsB&QOx(`Vy34f5icu@Y@{(_1x@Pt~k$_si zvHH3%z#i06u(POF0od>&Oj;?UPl<83yztEpM$dH0(r7isjR5Qn?aDb>va)`P)d%p3 z`ax%V%{^B|J2l%YXZe)wH6%{Ar@^bFau(K?KaD9R9n*JCJviki+4;?AwxZ2rwe+d@ zcyQxdsXEV0 z+UkxzW!Q8li3R$euYdX9dw%Fdp*GY zog?xFXZ#%Ww<{`H5~T&!%?l3tnu{@+T64SD>Qmv2=*NqL{156qSS@P5RC;%1JxuaT zsPZ4KYB>a;##o$Eil@f?iR-EDs4LZ1oKm~uUrm?=@D4|HbUQnFtoA?hXlJ}PP?QWR zTeQ`azZ6#abhJC2>l0qYbMtmOvwCaPvE$39-rp`wN=HxBhpv`O?}1||BTG*852Fdi zf=bq!Y)hxw^KZ}{@?OYaIJ4|?Z86-WfT&Z+h7^$wIQ)6H8xhTE`Qp%t27{yI5x&}n zjGJe_fr|$Pt|~uDnhZ1N{|vMz!Q7S573!lkX`w*`M_tsqp5B&;jQ4iu-%6ZvY&d?S z(Yb!KKCBjcBfE4hloZ^UW{2r=yHy0PzyN)UnCjQ^&}bh?xwb$$BT+V%+b{b zq?WOa<=b6)e-`d$?21O2jFEohz$tKYMmUzXr zv!G#9d=mkj!$T|>;o(^`Q6(9fne#dcS*H7Knqnn^b1|?Q$rake doc:app. diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js new file mode 100644 index 0000000..a1873dd --- /dev/null +++ b/test/dummy/app/assets/javascripts/application.js @@ -0,0 +1,13 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require_tree . diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/test/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/mailers/.keep b/test/dummy/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/.keep b/test/dummy/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..593a778 --- /dev/null +++ b/test/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle new file mode 100644 index 0000000..66e9889 --- /dev/null +++ b/test/dummy/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails new file mode 100644 index 0000000..728cd85 --- /dev/null +++ b/test/dummy/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake new file mode 100644 index 0000000..1724048 --- /dev/null +++ b/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000..2217afe --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,23 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +Bundler.require(*Rails.groups) +require "personal_course" + +module Dummy + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000..6266cfc --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/test/dummy/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: sqlite3 + pool: 5 + timeout: 5000 + +development: + <<: *default + database: db/development.sqlite3 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + <<: *default + database: db/test.sqlite3 + +production: + <<: *default + database: db/production.sqlite3 diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..ddf0e90 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,37 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..b93a877 --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,78 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,39 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb new file mode 100644 index 0000000..d2f4ec3 --- /dev/null +++ b/test/dummy/config/initializers/assets.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/test/dummy/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/test/dummy/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000..e766b67 --- /dev/null +++ b/test/dummy/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/test/dummy/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000..752cab9 --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + + mount PersonalCourse::Engine => "/personal_course" +end diff --git a/test/dummy/config/secrets.yml b/test/dummy/config/secrets.yml new file mode 100644 index 0000000..7973e7d --- /dev/null +++ b/test/dummy/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 7c3d6006ba19a38b126337be5c954acc76ea069fc59ab3b64ddb42e42883655978b5162d26bdcfeb9f363e5626a2c34e2036a9b0a010c9adceabbcdc01daa3cd + +test: + secret_key_base: f25e944e4db0a66681fe04d9a9f325978e481cabf76235247d86f881ab7c1616d542fb4a80306c539569becaeb9fee301d583845d11860df915e14e2224712b9 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/log/.keep b/test/dummy/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/test/dummy/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
    +
    +

    The page you were looking for doesn't exist.

    +

    You may have mistyped the address or the page may have moved.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/test/dummy/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
    +
    +

    The change you wanted was rejected.

    +

    Maybe you tried to change something you didn't have access to.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/test/dummy/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
    +
    +

    We're sorry, but something went wrong.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb new file mode 100644 index 0000000..97a94c9 --- /dev/null +++ b/test/integration/navigation_test.rb @@ -0,0 +1,10 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest + fixtures :all + + # test "the truth" do + # assert true + # end +end + diff --git a/test/personal_asia_database_test.rb b/test/personal_asia_database_test.rb new file mode 100644 index 0000000..e35e7da --- /dev/null +++ b/test/personal_asia_database_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PersonalAsiaDatabaseTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, PersonalAsiaDatabase + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..a553d9a --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,19 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] +ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__) +require "rails/test_help" + +# Filter out Minitest backtrace while allowing backtrace from other libraries +# to be shown. +Minitest.backtrace_filter = Minitest::BacktraceFilter.new + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } + +# Load fixtures from the engine +if ActiveSupport::TestCase.method_defined?(:fixture_path=) + ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) +end