From 62a8e98cedc3ff9831a8406ef9c0ac00a9497714 Mon Sep 17 00:00:00 2001 From: bohung Date: Sat, 27 Feb 2021 12:19:24 +0800 Subject: [PATCH] First push. --- .gitignore | 8 + Gemfile | 14 + MIT-LICENSE | 20 ++ README.rdoc | 3 + Rakefile | 34 +++ app/assets/images/personal_course/.keep | 0 .../personal_course/application.js | 13 + .../personal_course/application.css | 15 ++ .../personal_plugin_fields_controller.rb | 226 ++++++++++++++++ .../admin/personal_plugin_fields_helper.rb | 5 + app/models/personal_plugin_field.rb | 14 + .../personal_plugin_fields/_form.html.erb | 255 ++++++++++++++++++ .../_form_file.html.erb | 55 ++++ .../_personal_plugin_fields.html.erb | 9 + .../_render_fields_check_table.html.erb | 39 +++ .../_render_table.html.erb | 39 +++ .../personal_plugin_fields/edit.html.erb | 5 + .../fields_setting.html.erb | 44 +++ .../personal_plugin_fields/index.html.erb | 20 ++ .../admin/personal_plugin_fields/new.html.erb | 5 + .../template_generator/.gitignore | 8 + .../template_generator/Gemfile | 14 + .../template_generator/MIT-LICENSE | 20 ++ .../template_generator/README.rdoc | 3 + .../template_generator/Rakefile | 34 +++ .../app/assets/images/personal_course/.keep | 0 .../personal_course/application.js | 13 + .../personal_course/application.css | 15 ++ .../plugin_template_relateds_controller.rb | 43 +++ .../admin/plugin_templates_controller.rb | 126 +++++++++ .../personal_plugin_templates_controller.rb | 36 +++ .../helpers/admin/plugin_templates_helper.rb | 63 +++++ .../app/models/plugin_template.rb | 89 ++++++ .../app/models/plugin_template_file.rb | 12 + .../app/models/plugin_template_intro.rb | 4 + .../app/models/plugin_template_related.rb | 8 + .../plugin_template_relateds/_form.html.erb | 24 ++ .../plugin_template_relateds/create.js.erb | 2 + .../plugin_template_relateds/destroy.js.erb | 2 + .../plugin_template_relateds/edit.js.erb | 1 + .../admin/plugin_template_relateds/new.js.erb | 1 + .../plugin_template_relateds/update.js.erb | 2 + .../_course_category.html.erb | 8 + .../admin/plugin_templates/_form.html.erb | 229 ++++++++++++++++ .../plugin_templates/_form_file.html.erb | 55 ++++ .../_plugin_template_related.html.erb | 7 + .../_plugin_templates.html.erb | 17 ++ .../admin/plugin_templates/analysis.html.erb | 115 ++++++++ .../plugin_templates/analysis_report.html.erb | 1 + .../course_assignments.html.erb | 82 ++++++ .../download_excel.xlsx.axlsx | 39 +++ .../admin/plugin_templates/edit.html.erb | 5 + .../frontend_setting.html.erb | 94 +++++++ .../admin/plugin_templates/index.html.erb | 20 ++ .../views/admin/plugin_templates/new.html.erb | 5 + .../admin/plugin_templates/setting.html.erb | 74 +++++ .../personal_plugin_templates/index.html.erb | 1 + .../personal_plugin_templates/show.html.erb | 1 + .../_profile.html.erb | 82 ++++++ .../template_generator/bin/rails | 12 + .../template_generator/config/locales/en.yml | 7 + .../config/locales/zh_tw.yml | 7 + .../template_generator/config/routes.rb | 31 +++ .../lib/personal_plugin_template.rb | 4 + .../lib/personal_plugin_template/engine.rb | 21 ++ .../lib/personal_plugin_template/version.rb | 3 + .../tasks/personal_plugin_template_tasks.rake | 4 + .../personal_plugin_template.gemspec | 19 ++ .../template_generator/test/dummy/README.rdoc | 28 ++ .../template_generator/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 .../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 + .../template_generator/test/dummy/bin/bundle | 3 + .../template_generator/test/dummy/bin/rails | 4 + .../template_generator/test/dummy/bin/rake | 4 + .../template_generator/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 + .../dummy/config/environments/development.rb | 37 +++ .../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 + .../dummy/config/initializers/inflections.rb | 16 ++ .../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 .../template_generator/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_plugin_template_test.rb | 7 + .../template_generator/test/test_helper.rb | 19 ++ bin/rails | 12 + config/locales/en.yml | 36 +++ config/locales/zh_tw.yml | 36 +++ config/routes.rb | 13 + lib/personal_plugin_generator.rb | 4 + lib/personal_plugin_generator/engine.rb | 23 ++ lib/personal_plugin_generator/version.rb | 3 + .../personal_plugin_generator_tasks.rake | 4 + personal_plugin_generator.gemspec | 19 ++ 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_plugin_field_test.rb | 7 + test/test_helper.rb | 19 ++ 163 files changed, 3744 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_course/.keep create mode 100644 app/assets/javascripts/personal_course/application.js create mode 100644 app/assets/stylesheets/personal_course/application.css create mode 100644 app/controllers/admin/personal_plugin_fields_controller.rb create mode 100644 app/helpers/admin/personal_plugin_fields_helper.rb create mode 100644 app/models/personal_plugin_field.rb create mode 100644 app/views/admin/personal_plugin_fields/_form.html.erb create mode 100644 app/views/admin/personal_plugin_fields/_form_file.html.erb create mode 100644 app/views/admin/personal_plugin_fields/_personal_plugin_fields.html.erb create mode 100644 app/views/admin/personal_plugin_fields/_render_fields_check_table.html.erb create mode 100644 app/views/admin/personal_plugin_fields/_render_table.html.erb create mode 100644 app/views/admin/personal_plugin_fields/edit.html.erb create mode 100644 app/views/admin/personal_plugin_fields/fields_setting.html.erb create mode 100644 app/views/admin/personal_plugin_fields/index.html.erb create mode 100644 app/views/admin/personal_plugin_fields/new.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/.gitignore create mode 100644 app/views/admin/personal_plugin_fields/template_generator/Gemfile create mode 100644 app/views/admin/personal_plugin_fields/template_generator/MIT-LICENSE create mode 100644 app/views/admin/personal_plugin_fields/template_generator/README.rdoc create mode 100644 app/views/admin/personal_plugin_fields/template_generator/Rakefile create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/assets/images/personal_course/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/assets/javascripts/personal_course/application.js create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/assets/stylesheets/personal_course/application.css create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_template_relateds_controller.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_templates_controller.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/controllers/personal_plugin_templates_controller.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/helpers/admin/plugin_templates_helper.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_file.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_intro.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_related.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/_form.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/create.js.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/edit.js.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/new.js.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/update.js.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_course_category.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form_file.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis_report.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/course_assignments.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/edit.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/index.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/new.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/setting.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/index.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/show.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/bin/rails create mode 100644 app/views/admin/personal_plugin_fields/template_generator/config/locales/en.yml create mode 100644 app/views/admin/personal_plugin_fields/template_generator/config/locales/zh_tw.yml create mode 100644 app/views/admin/personal_plugin_fields/template_generator/config/routes.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/engine.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/version.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/lib/tasks/personal_plugin_template_tasks.rake create mode 100644 app/views/admin/personal_plugin_fields/template_generator/personal_plugin_template.gemspec create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/README.rdoc create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/Rakefile create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/images/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/javascripts/application.js create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/stylesheets/application.css create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/controllers/application_controller.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/controllers/concerns/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/helpers/application_helper.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/mailers/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/models/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/models/concerns/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/views/layouts/application.html.erb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/bundle create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/rails create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/rake create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config.ru create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/application.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/boot.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/database.yml create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environment.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/development.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/production.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/test.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/assets.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/backtrace_silencers.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/cookies_serializer.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/filter_parameter_logging.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/inflections.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/mime_types.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/session_store.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/wrap_parameters.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/locales/en.yml create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/routes.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/secrets.yml create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/lib/assets/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/log/.keep create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/404.html create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/422.html create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/500.html create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/favicon.ico create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/integration/navigation_test.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/personal_plugin_template_test.rb create mode 100644 app/views/admin/personal_plugin_fields/template_generator/test/test_helper.rb create mode 100644 bin/rails 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/personal_plugin_generator.rb create mode 100644 lib/personal_plugin_generator/engine.rb create mode 100644 lib/personal_plugin_generator/version.rb create mode 100644 lib/tasks/personal_plugin_generator_tasks.rake create mode 100644 personal_plugin_generator.gemspec 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_plugin_field_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..1e4beb8 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2015 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..1ec78f8 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += PersonalCourse + +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..78646ad --- /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 = 'PersonalCourse' + 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_course/.keep b/app/assets/images/personal_course/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/personal_course/application.js b/app/assets/javascripts/personal_course/application.js new file mode 100644 index 0000000..a1873dd --- /dev/null +++ b/app/assets/javascripts/personal_course/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_course/application.css b/app/assets/stylesheets/personal_course/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/app/assets/stylesheets/personal_course/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/personal_plugin_fields_controller.rb b/app/controllers/admin/personal_plugin_fields_controller.rb new file mode 100644 index 0000000..4d6201b --- /dev/null +++ b/app/controllers/admin/personal_plugin_fields_controller.rb @@ -0,0 +1,226 @@ +class Admin::PersonalPluginFieldsController < OrbitAdminController + require 'fileutils' + include Admin::PersonalPluginFieldsHelper + before_action :set_personal_plugin_field, only: [:show, :edit , :update, :destroy, :fields_setting, :update_fields_setting,:generate_plugin] + + def index + @personal_plugin_fields = PersonalPluginField.order_by(:created_at=>'desc').page(params[:page]).per(10) + end + + def new + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @personal_plugin_field = PersonalPluginField.new + end + + def create + personal_plugin_field = PersonalPluginField.create(personal_plugin_field_params) + redirect_to params[:referer_url] + end + + def edit + end + + def destroy + @personal_plugin_field.destroy + redirect_to admin_personal_plugin_fields_path(:page => params[:page]) + end + + def update + @personal_plugin_field.update_attributes(personal_plugin_field_params) + @personal_plugin_field.save + redirect_to params[:referer_url] + end + def fields_setting + end + def update_fields_setting + field_params = params.require(:personal_plugin_field).permit! rescue {} + @personal_plugin_field.update_attributes(field_params) + @personal_plugin_field.save + redirect_to params[:referer_url] + end + def generate_plugin + template_dir_path = File.expand_path("../../../views/admin/personal_plugin_fields/template_generator/", __FILE__) + "/" + cp_template_dir_path = "#{Rails.root}/tmp/#{@personal_plugin_field.module_name}/" + FileUtils.rm_rf(cp_template_dir_path) + FileUtils.cp_r(template_dir_path,cp_template_dir_path) + + dirs = Dir.glob("#{cp_template_dir_path}*/") + files = Dir.glob("#{cp_template_dir_path}*").select { |fn| File.file?(fn) } + + in_use_locales = Site.first.in_use_locales + + yml_files = Dir.glob("#{cp_template_dir_path}config/locales/*.yml") + yml_files.each do |yml_file| + locale = yml_file.split("/").last.split(".yml").first + yml_text = File.read(yml_file) + translate_hash = {} + @personal_plugin_field.primary_modal_fields.each do |field_value| + if field_value[:field_name] && (field_value[:translation_name][locale].present? rescue false) + translate_hash[field_value[:field_name]] = field_value[:translation_name][locale] + end + end + @personal_plugin_field.related_modal_name.each_with_index do |related_modal_name,i| + field_values = @personal_plugin_field.related_modal_fields[i].to_a rescue [] + sub_hash = {} + field_values.each do |field_value| + if field_value[:field_name] && (field_value[:translation_name][locale].present? rescue false) + sub_hash[field_value[:field_name]] = field_value[:translation_name][locale] + end + end + if related_modal_name.present? && sub_hash.present? + translate_hash[related_modal_name] = sub_hash + end + end + col_name_translate_yaml = "" + if translate_hash.present? + col_name_translate_yaml = translate_hash.to_yaml.gsub("---\n", '') + end + blank_text = yml_text.split(/(\r\n|\n)/).select{|t| t.include?"col_name_translate_yaml"}.first.split('col_name_translate_yaml').first rescue "" + col_name_translate_yaml = col_name_translate_yaml.gsub("\n","\n#{blank_text}") + yml_text = yml_text.gsub("col_name_translate_yaml",col_name_translate_yaml) + File.open(yml_file,'w+') do |f| + f.write(yml_text) + end + end + plugin_template_related_files_fields = @personal_plugin_field.primary_modal_fields.select{|field_value| field_value[:field_type] == "file" rescue false}.map{|v| v[:field_name]} + plugin_template_related_files_fields = plugin_template_related_files_fields.map{|field_name| + "has_many :#{field_name.pluralize}, :dependent => :destroy, :autosave => true\n" + + "accepts_nested_attributes_for :#{field_name.pluralize}, :allow_destroy => true\n" + }.join("\n") + col_name_to_show = @personal_plugin_field.frontend_fields["member_show"] rescue [] + col_name_to_show_in_show_page = @personal_plugin_field.frontend_fields["show"] rescue [] + col_name_to_show_in_index_page = @personal_plugin_field.frontend_fields["index"] rescue [] + extra_translate_title = col_name_to_show_in_index_page.map{|field_name| #在個人外掛前台index頁面的欄位翻譯名稱hash + ["th-#{field_name}","I18n.locale(\"#{@personal_plugin_field.module_name}.#{field_name}\")"] + }.to_h + col_fields = "" + col_fields = @personal_plugin_field.primary_modal_fields.map do |field_value| + type = "String" if field_value[:field_type] + field_text = "field :#{field_value[:field_name]}, :type => #{type}, :default => {}" + field_text += ", :localize => true" if field_value[:localize] + end + col_fields = col_fields.join("\r\n ") + col_related_fields = "" + @match_pattern = {"personal_plugin_template" => @personal_plugin_field.module_name, + "plugin_template" => @personal_plugin_field.primary_modal_name, + "plugin_template_related" => @personal_plugin_field.related_modal_name.select{|n| n.present?}, + "plugin_template_related_files_fields" => plugin_template_related_files_fields, + "col_name_to_show" => col_name_to_show.to_s, #在會員前台頁面的顯示欄位 + "col_name_to_show_in_show_page" => col_name_to_show_in_show_page.to_s, #在個人外掛前台show頁面的顯示欄位 + "col_name_to_show_in_index_page" => col_name_to_show_in_index_page.to_s, #在個人外掛前台index頁面的顯示欄位 + "extra_translate_title" => extra_translate_title.to_s, + "col_fields" => col_fields + } + @match_pattern = @match_pattern.sort_by{|k,v| -k.length}.sort_by{|k,v| (v.class != Array) ? 1 : 0} + replace_files(files) + #Thread.new do + dirs.each do |dir| + replace_dir(dir) + end + #end + render :html => @match_pattern + end + def replace_dir(dir) + dir = replace_file(dir) + return true if dir.blank? + sub_dirs = Dir.glob("#{dir}/*/") + files = Dir.glob("#{dir}/*").select { |fn| File.file?(fn) } + replace_files(files) + if sub_dirs.present? + sub_dirs.each do |sub_dir| + replace_dir(sub_dir) + end + else + return true + end + end + def replace_files(files) + files.each do |file| + replace_file(file) + end + end + def replace_file(file) + isfile = File.file?(file) + path = File.dirname(file) + file_name = File.basename(file) + new_filename = replace_text_with_pattern(file_name,true) + if new_filename.blank? + FileUtils.rm_rf("#{path}/#{file_name}") + elsif file_name != new_filename + FileUtils.mv("#{path}/#{file_name}", "#{path}/#{new_filename}") + end + if new_filename.blank? + return "" + else + if isfile + file_text = File.read("#{path}/#{new_filename}") + file_text = replace_text_with_pattern(file_text) + File.open("#{path}/#{new_filename}",'w+'){|f| f.write(file_text)} + end + return "#{path}/#{new_filename}" + end + end + def replace_text_with_pattern(text,is_file=false,i = nil) + new_text = text + @match_pattern.each do |k,v| + vv = v + vv = vv[i] if i + if vv.class == String + if i && vv == "" + new_text = "" + puts k + else + new_text = gsub_text_by_key_value(new_text,k,vv) + end + elsif vv.class == Array + if is_file && v.count == 0 && (new_text.include?(k) || new_text.include?(k.classify)) + new_text = "" + break + end + new_text = new_text.gsub(/<%[ ]*parse_again_start[ ]*%>((?:(?!<%[ ]*parse_again_start[ ]*%>).)+)<%[ ]*parse_again_end[ ]*%>/m) do |ff| + puts ff + ff = ff.strip + result = (0...vv.count).map {|i| replace_text_with_pattern(ff,false,i) }.join("\r\n") + end + end + end + return new_text + end + def gsub_text_by_key_value(text,k,v) + text = text.gsub(k + "s",v.pluralize) + text = text.gsub(k ,v ) + text = text.gsub(k.classify + "s",v.pluralize.classify) + text = text.gsub(k.classify,v.classify) + end + private + def personal_plugin_field_params + personal_plugin_field_params = params.require(:personal_plugin_field).permit! rescue {} + if personal_plugin_field_params[:related_modal_name].nil? + personal_plugin_field_params[:related_modal_name] = [] + end + if personal_plugin_field_params[:primary_modal_fields] + personal_plugin_field_params[:primary_modal_fields] = personal_plugin_field_params[:primary_modal_fields].values + else + personal_plugin_field_params[:primary_modal_fields] = [] + end + if personal_plugin_field_params[:related_modal_fields] + personal_plugin_field_params[:related_modal_fields] = personal_plugin_field_params[:related_modal_fields].values.map{|h| h.values} + else + personal_plugin_field_params[:related_modal_fields] = [] + end + return personal_plugin_field_params + end + + + def set_personal_plugin_field + path = request.path.split('/') + if path.last.include? '-' + uid = path[-1].split("-").last + uid = uid.split("?").first + else + uid = path[-2].split("-").last + uid = uid.split("?").first + end + @personal_plugin_field = PersonalPluginField.find_by(:uid => uid) rescue PersonalPluginField.find(params[:id] || params[:personal_plugin_field_id]) + end +end \ No newline at end of file diff --git a/app/helpers/admin/personal_plugin_fields_helper.rb b/app/helpers/admin/personal_plugin_fields_helper.rb new file mode 100644 index 0000000..8db3643 --- /dev/null +++ b/app/helpers/admin/personal_plugin_fields_helper.rb @@ -0,0 +1,5 @@ +module Admin::PersonalPluginFieldsHelper + def thead_field(field) + return I18n.t("personal_plugin_generator.#{field}") + end +end \ No newline at end of file diff --git a/app/models/personal_plugin_field.rb b/app/models/personal_plugin_field.rb new file mode 100644 index 0000000..9a3a3e9 --- /dev/null +++ b/app/models/personal_plugin_field.rb @@ -0,0 +1,14 @@ +class PersonalPluginField + include Mongoid::Document + include Mongoid::Timestamps + include OrbitModel::Status + include MemberHelper + field :title, :type => String, :default => "",:localize => true + field :module_name, :type => String, :default => "" + field :primary_modal_name, :type => String, :default => "" + field :related_modal_name, :type => Array, :default => [] + field :primary_modal_fields, :type => Array, :default => [] + field :related_modal_fields, :type => Array, :default => [] #ex: [[],[]] + field :backend_fields, :type => Hash, :default => {} + field :frontend_fields, :type => Hash, :default => {} +end diff --git a/app/views/admin/personal_plugin_fields/_form.html.erb b/app/views/admin/personal_plugin_fields/_form.html.erb new file mode 100644 index 0000000..7977917 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/_form.html.erb @@ -0,0 +1,255 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> + <%= stylesheet_link_tag "lib/main-form-col2" %> + +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + +
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_plugin_generator.personal_plugin_name"), value: (@personal_plugin_field.title_translations[locale] rescue nil) %> + <% end %> +
+
+
+ <% end %> +
+ + + + +
+ + +
+
+ +
+ <%= f.text_field :module_name, placeholder: thead_field("module_name") %> +
+
+
+ +
+ <%= f.text_field :primary_modal_name, placeholder: thead_field("primary_modal_name"), class: "primary_modal_name" %> +
+
+
+ +
+ <% f.object.related_modal_name.each_with_index do |related_modal_name,i| %> +
+ <%= text_field_tag "#{f.object_name}[related_modal_name][]", related_modal_name,placeholder: thead_field("related_modal_name"), class: "related_modal_name" %> + +
+ <% end %> + +
+
+ +
+ + +
+
+ +
+ +
+
+
+
+ <% field_types = ["text_field","text_editor","file","select","year","date","time","date_time"].map{|field| [thead_field(field),field]} + field_types1 = field_types.select{|a| a[1] != "file"} + %> +
+
+

<%=thead_field("primary_modal_name")%> : <%= f.object.primary_modal_name%>

+ <% if f.object.primary_modal_fields.present? %> + <%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => f.object.primary_modal_fields,:field_types => field_types } %> + <% else %> + <%= render :partial => 'render_table',locals: {:f => f,:root_name => "primary_modal_fields",:field_values => [nil,nil],:field_types => field_types,:@include_blank => true} %> + <% end %> + +
+ +
+
+ +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), request.referer, :class=>"btn" %> +
+ + \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/_form_file.html.erb b/app/views/admin/personal_plugin_fields/_form_file.html.erb new file mode 100644 index 0000000..8628623 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/_form_file.html.erb @@ -0,0 +1,55 @@ +<% if form_file.new_record? %> +
+<% else %> +
+ <% if form_file.file.blank? %> + <%= t(:no_file) %> + <% else %> + <%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %> + <% end %> +<% end %> +
+ + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :description_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + <% if form_file.new_record? %> + + + + <% else %> + + <%= f.hidden_field :id %> + + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + + <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/_personal_plugin_fields.html.erb b/app/views/admin/personal_plugin_fields/_personal_plugin_fields.html.erb new file mode 100644 index 0000000..680f2c2 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/_personal_plugin_fields.html.erb @@ -0,0 +1,9 @@ +<% @personal_plugin_fields.each do |personal_plugin_field| %> + + <%= personal_plugin_field.title %> + <%= link_to t(:edit) ,edit_admin_personal_plugin_field_path(personal_plugin_field.id),:class=> "btn btn-primary" %> + <%= link_to thead_field('fields_display_setting') ,admin_personal_plugin_field_fields_setting_path(personal_plugin_field.id),:class=> "btn btn-primary" %> + <%= link_to thead_field('generate_plugin') ,admin_personal_plugin_field_generate_plugin_path(personal_plugin_field.id),:class=> "btn btn-primary" %> + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/_render_fields_check_table.html.erb b/app/views/admin/personal_plugin_fields/_render_fields_check_table.html.erb new file mode 100644 index 0000000..0f26282 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/_render_fields_check_table.html.erb @@ -0,0 +1,39 @@ +<% object = f.object +%> +
<%=thead_field(page_name)%>
+ + + + <% object.primary_modal_fields.each do |field_value| %> + + <% end %> + <% f.object.related_modal_name.each_with_index do |related_modal_name,i| %> + <% field_values = f.object.related_modal_fields[i].to_a %> + <% field_values.each do |field_value| %> + + <% end %> + <% end %> + + + + + <%= f.fields_for root_name do |f| %> + <%= f.fields_for page_name do |f| %> + <% object.primary_modal_fields.each do |field_value| %> + + <% end %> + <% object.related_modal_name.each_with_index do |related_modal_name,i| %> + <% field_values = object.related_modal_fields[i].to_a %> + <% field_values.each do |field_value| %> + + <% end %> + <% end %> + <% end %> + <% end %> + + +
<%="#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}"%><%="#{related_modal_name}-#{field_value[:translation_name][I18n.locale] rescue ""}-#{field_value[:field_name]}"%>
+ <%= check_box_tag "#{f.object_name}[]", field_value[:field_name] , (object.send(root_name)[page_name].include?(field_value[:field_name]) rescue false),:id=>nil %> + + <%= check_box_tag "#{f.object_name}[]", "#{related_modal_name+'.'+field_value[:field_name]}" , (object.send(root_name)[page_name].include?(related_modal_name+'.'+field_value[:field_name]) rescue false),:id=>nil %> +
\ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/_render_table.html.erb b/app/views/admin/personal_plugin_fields/_render_table.html.erb new file mode 100644 index 0000000..04c6857 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/_render_table.html.erb @@ -0,0 +1,39 @@ + + + + + + + + + + + <%= f.fields_for root_name do |f| %> + <% field_values.each_with_index do |field_value,i| %> + <% i = "new_field_index" if field_value.nil? && !@include_blank %> + + + + + + + + + <% end %> + <% end %> + +
<%= t(:remove) %><%= thead_field("field_name") %><%= thead_field("translation_name") %><%= thead_field("field_type") %><%= thead_field("localize") %><%= thead_field("slug_title") %>
X<%= text_field_tag "#{f.object_name}[#{i}][field_name]",(field_value["field_name"] rescue nil) %> + <% @site_in_use_locales.each_with_index do |locale, ii| %> + "> + <%= f.fields_for "#{i}][translation_name" do |f| %> + <%= text_field_tag "#{f.object_name}[#{locale}]", (field_value["translation_name"][locale] rescue nil) , class: "input-block-level" %> + <% end %> + + <% end %> + <%= select_tag "#{f.object_name}[#{i}][field_type]",options_for_select(field_types,(field_value["field_type"] rescue nil)) %> + <%= hidden_field_tag "#{f.object_name}[#{i}][localize]", "0",:id=>nil %> + <%= check_box_tag "#{f.object_name}[#{i}][localize]", "1" , (field_value["localize"] == "1" rescue false),:id=>nil %> + + <%= hidden_field_tag "#{f.object_name}[#{i}][slug_title]", "0",:id=>nil %> + <%= check_box_tag "#{f.object_name}[#{i}][slug_title]", "1" , (field_value["slug_title"] == "1" rescue false),:id=>nil,:class=>"slug_title" %> +
\ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/edit.html.erb b/app/views/admin/personal_plugin_fields/edit.html.erb new file mode 100644 index 0000000..4ef61c5 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @personal_plugin_field, url: admin_personal_plugin_field_path(@personal_plugin_field), html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/fields_setting.html.erb b/app/views/admin/personal_plugin_fields/fields_setting.html.erb new file mode 100644 index 0000000..932b285 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/fields_setting.html.erb @@ -0,0 +1,44 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> + <%= stylesheet_link_tag "lib/main-form-col2" %> + +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> +<%= form_for @personal_plugin_field, url: admin_personal_plugin_field_update_fields_setting_path(@personal_plugin_field), html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ + +
+

<%= thead_field('backend_page') %>

+
+ <%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'backend_fields',:page_name=>'index'} %> +
+

<%= thead_field('frontend_page') %>

+
+ <%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'index'} %> + <%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'show'} %> + <%= render :partial => 'render_fields_check_table',locals: {:f=>f,:root_name=>'frontend_fields',:page_name=>'member_show'} %> +
+
+ +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), request.referer, :class=>"btn" %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/index.html.erb b/app/views/admin/personal_plugin_fields/index.html.erb new file mode 100644 index 0000000..519b9eb --- /dev/null +++ b/app/views/admin/personal_plugin_fields/index.html.erb @@ -0,0 +1,20 @@ + + + + + + + + + <%= render 'personal_plugin_fields' %> + +
<%= thead_field("personal_plugin_name") %><%= thead_field("action") %>
+ +
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_personal_plugin_field_path, :class => 'btn btn-primary' %> +
+ +
\ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/new.html.erb b/app/views/admin/personal_plugin_fields/new.html.erb new file mode 100644 index 0000000..32ac43c --- /dev/null +++ b/app/views/admin/personal_plugin_fields/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @personal_plugin_field, url: admin_personal_plugin_fields_path, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/.gitignore b/app/views/admin/personal_plugin_fields/template_generator/.gitignore new file mode 100644 index 0000000..de5d954 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/.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/app/views/admin/personal_plugin_fields/template_generator/Gemfile b/app/views/admin/personal_plugin_fields/template_generator/Gemfile new file mode 100644 index 0000000..d97db1e --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/MIT-LICENSE b/app/views/admin/personal_plugin_fields/template_generator/MIT-LICENSE new file mode 100644 index 0000000..1e4beb8 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2015 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/app/views/admin/personal_plugin_fields/template_generator/README.rdoc b/app/views/admin/personal_plugin_fields/template_generator/README.rdoc new file mode 100644 index 0000000..975440f --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/README.rdoc @@ -0,0 +1,3 @@ += PersonalPluginTemplate + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/Rakefile b/app/views/admin/personal_plugin_fields/template_generator/Rakefile new file mode 100644 index 0000000..182be0d --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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 = 'PersonalPluginTemplate' + 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/views/admin/personal_plugin_fields/template_generator/app/assets/images/personal_course/.keep b/app/views/admin/personal_plugin_fields/template_generator/app/assets/images/personal_course/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/assets/javascripts/personal_course/application.js b/app/views/admin/personal_plugin_fields/template_generator/app/assets/javascripts/personal_course/application.js new file mode 100644 index 0000000..a1873dd --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/assets/javascripts/personal_course/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/views/admin/personal_plugin_fields/template_generator/app/assets/stylesheets/personal_course/application.css b/app/views/admin/personal_plugin_fields/template_generator/app/assets/stylesheets/personal_course/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/assets/stylesheets/personal_course/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/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_template_relateds_controller.rb b/app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_template_relateds_controller.rb new file mode 100644 index 0000000..a75f892 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_template_relateds_controller.rb @@ -0,0 +1,43 @@ +class Admin::PluginTemplateRelatedsController < OrbitMemberController + + def index + end + + def new + @plugin_template_related = PluginTemplateRelated.new + @url = admin_course_semesters_path + end + + def edit + @plugin_template_related = PluginTemplateRelated.find(params[:id]) + @url = admin_plugin_template_related_path(@plugin_template_related) + end + + def create + plugin_template_related = PluginTemplateRelated.create(plugin_template_related_params) + @plugin_template_relateds = PluginTemplateRelated.all + end + + def update + plugin_template_related = PluginTemplateRelated.find(params[:id]) rescue nil + if !plugin_template_related.nil? + plugin_template_related.update_attributes(course_semester_params) + end + @plugin_template_relateds = PluginTemplateRelated.all + end + + def destroy + plugin_template_related = PluginTemplateRelated.find(params[:id]) rescue nil + if !plugin_template_related.nil? + plugin_template_related.destroy + end + @plugin_template_relateds = PluginTemplateRelated.all + end + + private + + def plugin_template_related_params + params.require(:plugin_template_related).permit! + end + +end \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_templates_controller.rb b/app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_templates_controller.rb new file mode 100644 index 0000000..2c69b49 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_templates_controller.rb @@ -0,0 +1,126 @@ +class Admin::PluginTemplatesController < OrbitMemberController + include Admin::PluginTemplatesHelper + layout "member_plugin" + before_action :set_plugin_template, only: [:show, :edit , :update, :destroy] + before_action :set_plugin + before_action :get_settings,:only => [:new, :edit, :setting] + + before_action :need_access_right + before_action :allow_admin_only, :only => [:index, :setting] + + def index + @plugin_templates = PluginTemplate.order_by(:created_at=>'desc').page(params[:page]).per(10) + end + + def new + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @plugin_template = PluginTemplate.new + end + + def create + plugin_template = PluginTemplate.create(plugin_template_params) + redirect_to params[:referer_url] + end + + def show + end + def analysis_report + role = params[:role_id] + year_start = params[:year_start].to_i + year_end = params[:year_end].to_i + graph_by = params[:graph_by] + + @data = get_chart_data(year_start,year_end,role,params[:graph_by]) + + render :layout => false + end + + def download_excel + year_start = params[:year_start].to_i + year_end = params[:year_end].to_i + @data = get_data_for_excel(year_start,year_end) + respond_to do |format| + format.xlsx { + response.headers['Content-Disposition'] = 'attachment; filename="plugin_templates.xlsx"' + } + end + end + + def edit + end + + def destroy + @plugin_template.destroy + redirect_to admin_plugin_templates_path(:page => params[:page]) + end + + def update + @plugin_template.update_attributes(plugin_template_params) + @plugin_template.save + redirect_to params[:referer_url] + end + + + def setting + end + + def frontend_setting + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @intro = PluginTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? PluginTemplateIntro.new({:member_profile_id=>@member.id}) : @intro + end + + def update_frontend_setting + @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil + @intro = PluginTemplateIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? PluginTemplateIntro.new({:member_profile_id=>@member.id}) : @intro + @intro.update_attributes(intro_params) + @intro.save + redirect_to URI.encode('/admin/members/'+@member.to_param+'/PluginTemplate') + end + + def toggle_hide + if params[:ids] + @projects = PluginTemplate.any_in(_id: params[:ids]) + + @projects.each do |project| + project.is_hidden = params[:disable] + project.save + end + end + + render json: {"success"=>true} + end + + private + + def plugin_template_params + params.require(:plugin_template).permit! + end + + def intro_params + params.require(:plugin_template_intro).permit! rescue nil + end + + def get_settings + <% parse_again_start %> + @plugin_template_relateds = PluginTemplateRelated.all + <% parse_again_end %> + end + + def set_plugin + @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'PluginTemplate'}.first + end + + def set_plugin_template + path = request.path.split('/') + if path.last.include? '-' + uid = path[-1].split("-").last + uid = uid.split("?").first + else + uid = path[-2].split("-").last + uid = uid.split("?").first + end + @plugin_template = PluginTemplate.find_by(:uid => uid) rescue PluginTemplate.find(params[:id]) + end +end \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/controllers/personal_plugin_templates_controller.rb b/app/views/admin/personal_plugin_fields/template_generator/app/controllers/personal_plugin_templates_controller.rb new file mode 100644 index 0000000..059bf01 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/controllers/personal_plugin_templates_controller.rb @@ -0,0 +1,36 @@ +class PersonalPluginTemplatesController < ApplicationController + def index + plugin_templates = PluginTemplate.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + plugin_templates_list = plugin_templates.collect do |plugin_template| + member = plugin_template.member_profile + fields_to_show = col_name_to_show_in_index_page + + fields_hash = fields_to_show.map{|field| [field, get_display_field(field)]}.to_h + + path = OrbitHelper.url_to_plugin_show(member.to_param, 'member') rescue '#' + fields_hash["authors"] = "#{member.name}" + fields_hash["link_to_show"] = OrbitHelper.url_to_show(course.to_param) + end + + extras = extra_translate_title + + extras["widget-title"] = I18n.t("module_name.personal_plugin_template") + { + "plugin_templates" => plugin_templates_list, + "extras" => extras, + "total_pages" => plugin_templates.total_pages + } + end + + def show + params = OrbitHelper.params + plugin = PluginTemplate.where(:is_hidden=>false).find_by(uid: params[:uid]) + fields_to_show = col_name_to_show_in_show_page + {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} + end + + def get_display_field(field) + value_case_codes + return value + end +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/helpers/admin/plugin_templates_helper.rb b/app/views/admin/personal_plugin_fields/template_generator/app/helpers/admin/plugin_templates_helper.rb new file mode 100644 index 0000000..999d0ce --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/helpers/admin/plugin_templates_helper.rb @@ -0,0 +1,63 @@ +module Admin::PluginTemplatesHelper + def page_for_plugin_template(plugin_template_object) + page = Page.where(:module=>"personal_plugin_template").first + ("/#{I18n.locale}"+page.url+'/'+plugin_template_object.to_param).gsub('//','/') rescue "#" + end + + def get_data_for_excel(year_start,year_end) + data = [] + roles = Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key) + roles.each do |role| + d = {} + d["name"] = role.title + mps = role.member_profile_ids + d["data"] = PluginTemplate.where(:year.gte => year_start, :year.lte => year_end, :member_profile_id.in => mps) rescue [] + data << d + end + return data + end + + def get_chart_data(year_start,year_end,role,type) + case type + when "semester" + jls = CourseSemester.all + when "category" + jls = CourseCategory.all + end + + finaldata = [] + role = Role.find(role) rescue nil + mps = [] + if !role.nil? + mps = role.member_profile_ids + end + jls.each do |jl| + data = {} + data["name"] = jl.title + data["data"] = {} + (year_start..year_end).each do |year| + # d1 = DateTime.new(year,1,1,0,0) + # d2 = DateTime.new(year,12,31,23,59) + t = jl.courses.where(:year.gte => year, :year.lte => year, :member_profile_id.in => mps).count rescue 0 + data["data"][year.to_s] = t + end + finaldata << data + end + data = {"name" => "N/A", "data" => {}} + (year_start..year_end).each do |year| + # d1 = DateTime.new(year,1,1,0,0) + # d2 = DateTime.new(year,12,31,23,59) + case type + when "semester" + t = Course.where(:year.gte => year, :year.lte => year, :member_profile_id.in => mps, :course_semester_id => nil).count rescue 0 + when "category" + t = Course.where(:year.gte => year, :year.lte => year, :member_profile_id.in => mps, :course_category_id => nil).count rescue 0 + end + + data["data"][year.to_s] = t + end + finaldata << data + finaldata + end + +end \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template.rb b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template.rb new file mode 100644 index 0000000..39cd5a5 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template.rb @@ -0,0 +1,89 @@ +class PluginTemplate + include Mongoid::Document + include Mongoid::Timestamps + include OrbitModel::Status + include MemberHelper + include Slug + + + col_fields + + plugin_template_related_files_fields + + <% parse_again_start %> + belongs_to :plugin_template_related + <% parse_again_end %> + + belongs_to :member_profile + + scope :sort_for_frontend, ->{ where(:is_hidden=>false).order_by(plugin_template_sort_hash) } + + def self.get_plugin_datas_to_member(datas) + + fields_to_show = col_name_to_show + + fields_to_remove = [] + + pd_title = [] + + fields_to_show.each do |t| + if (self.fields[t].type.to_s == "String" || self.fields[t].type.to_s == "Object" rescue false) + fields_to_remove << t if (datas.where(t.to_sym.ne => nil, t.to_sym.ne => "").count == 0 rescue false) + else + fields_to_remove << t if (datas.where(t.to_sym.ne => nil).count == 0 rescue false) + end + pd_title << { + "plugin_data_title" => I18n.t("plugin_template.#{t}") + } if !fields_to_remove.include?(t) + end + + fields_to_show = fields_to_show - fields_to_remove + + plugin_datas = datas.sort_for_frontend.collect.with_index do |p,index| + + pd_data = [] + fields_to_show.collect do |t| + pd_data << { "data_title" => display_field(t) } + end + + { + "pd_datas" => pd_data, + "type-sort" => (p.course_category.sort_position.to_i rescue 1000), + "sort-index" => index + } + + end + plugin_datas = plugin_datas.sort_by{|pd| [pd["type-sort"], pd["sort-index"]]} + return [pd_title,plugin_datas] + + 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) + value_case_codes + + value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "#{value}" : value + + { + "key"=>field, + "title_class"=>"plugin_template-#{field.gsub('_','-')}-field", + "value_class"=>"plugin_template-#{field.gsub('_','-')}-value", + "title"=>I18n.t('personal_plugin_template.'+field), + "value"=>value + } + end + + def display_field(field) + display_field_code + end + +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_file.rb b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_file.rb new file mode 100644 index 0000000..520bb28 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_file.rb @@ -0,0 +1,12 @@ +class PluginTemplateFile + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + field :description, localize: true + field :should_destroy, :type => Boolean + + mount_uploader :file, AssetUploader + + belongs_to :plugin_template +end \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_intro.rb b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_intro.rb new file mode 100644 index 0000000..1ee94ef --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_intro.rb @@ -0,0 +1,4 @@ +class PluginTemplateIntro < PersonalPluginIntro + + +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_related.rb b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_related.rb new file mode 100644 index 0000000..5489453 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_related.rb @@ -0,0 +1,8 @@ +class PluginTemplateRelated + include Mongoid::Document + include Mongoid::Timestamps + + col_related_fields + + has_many :plugin_templates +end \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/_form.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/_form.html.erb new file mode 100644 index 0000000..07b442c --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@course_semester, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/create.js.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/create.js.erb new file mode 100644 index 0000000..d259481 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/create.js.erb @@ -0,0 +1,2 @@ +$("#course_semesters tbody").html("<%= j render :partial => '/admin/courses/course_semester', :collection => @course_semesters %>"); +$("#course_semester_modal").modal("hide"); diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb new file mode 100644 index 0000000..d259481 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb @@ -0,0 +1,2 @@ +$("#course_semesters tbody").html("<%= j render :partial => '/admin/courses/course_semester', :collection => @course_semesters %>"); +$("#course_semester_modal").modal("hide"); diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/edit.js.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/edit.js.erb new file mode 100644 index 0000000..6196cef --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/edit.js.erb @@ -0,0 +1 @@ +$('#course_semester_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/new.js.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/new.js.erb new file mode 100644 index 0000000..6196cef --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/new.js.erb @@ -0,0 +1 @@ +$('#course_semester_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/update.js.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/update.js.erb new file mode 100644 index 0000000..d259481 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/update.js.erb @@ -0,0 +1,2 @@ +$("#course_semesters tbody").html("<%= j render :partial => '/admin/courses/course_semester', :collection => @course_semesters %>"); +$("#course_semester_modal").modal("hide"); diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_course_category.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_course_category.html.erb new file mode 100644 index 0000000..7e4bd83 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_course_category.html.erb @@ -0,0 +1,8 @@ + + <%= course_category.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_course_category_path(course_category), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form.html.erb new file mode 100644 index 0000000..3b3bc5b --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form.html.erb @@ -0,0 +1,229 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> + <%= stylesheet_link_tag "lib/main-form-col2" %> + +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + +
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + +
+ +
+ <%= f.text_field :course_code, class: "input-block-level", placeholder: t("personal_course.course_code"), value: (@course.course_code rescue nil) %> +
+
+ +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t("personal_course.title"), value: (@course.title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :objective_translations do |f| %> + <%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t("personal_course.objective"), value: (@course.objective_translations[locale] rescue nil) %> + <% end %> +
+
+
+ <% end %> + + <% + files_hash = {} + ["course_syllabus_file", "course_progress_file", "course_activity_file", "course_multimedia_file", "course_material_file", "course_supplement_file", "course_evaluation_file"].each do |file| + hash = {} + hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym) + hash["count"] = @course.send(file.pluralize).count rescue 0 + files_hash[file] = hash + %> +
+ +
+ + + <% if !@course.new_record? && hash["count"] > 0 %> +
+ <% @course.send(file.pluralize).each_with_index do |obj, i| %> + <% if !obj.new_record? %> + <%= f.fields_for file.pluralize.to_sym, obj do |f| %> + <%= render :partial => "form_file", :object => obj, :locals => {:f => f, :i => i} %> + <% end %> + <% end %> + <% end %> +
+
+ <% end %> + + +
+
+

+ <%= t(:add) %> +

+ +
+
+ <% end %> +
+ + + + +
+ + +
+ + <% if !@member.nil? %> + +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id %> +
+
+ + <% else %> + +
+ +
+ <% members = !@course.member_profile.nil? ? @course.member_profile.to_a : [] %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'course[member_profile_id]', email_members: members,index:'0',select_name:'member_profile_id'} %> +
+
+ + <% end %> + + +
+ +
+ <%= select_year((@course.year ? @course.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year + 5, :end_year => 1930}, {:name => 'course[year]',:class => 'span1'} ) %> +
+
+ + +
+ +
+ <%= f.select :course_category_id, CourseCategory.all.collect {|t| [ t.title, t.id ]} %> +
+
+ + +
+ +
+ <%= f.select :course_semester_id, CourseSemester.all.collect {|t| [ t.title, t.id ]} %> +
+
+ +
+ + +
+
+ +
+ +
+
+
+
+
+ +
+ <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'course[student_ids][]', email_members: @course.students,index:'1',select_name:'student_ids'} %> +
+
+
+
+
+ +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), request.referer, :class=>"btn" %> +
+ \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form_file.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form_file.html.erb new file mode 100644 index 0000000..8628623 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form_file.html.erb @@ -0,0 +1,55 @@ +<% if form_file.new_record? %> +
+<% else %> +
+ <% if form_file.file.blank? %> + <%= t(:no_file) %> + <% else %> + <%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %> + <% end %> +<% end %> +
+ + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= locale %>"> + <%= f.fields_for :description_translations do |f| %> + <%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %> + <% end %> + + <% end %> + + + <% if form_file.new_record? %> + + + + <% else %> + + <%= f.hidden_field :id %> + + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + + <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb new file mode 100644 index 0000000..7f0eb2f --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb @@ -0,0 +1,7 @@ + + <%= plugin_template_related.title %> + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_plugin_template_related_path(plugin_template_related), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb new file mode 100644 index 0000000..772c7c4 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb @@ -0,0 +1,17 @@ +<% @courses.each do |course| %> + + <%= course.year %> + + <%= link_to course.title, page_for_course(course), target: "blank"%> +
+ +
+ + <%= link_to course.course_assignments.count,course_assignments_admin_courses_path(:id=> course.id) %> + <%= course.member_profile.name rescue "" %> + <%= course.display_students rescue "" %> + +<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis.html.erb new file mode 100644 index 0000000..3e6a09d --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis.html.erb @@ -0,0 +1,115 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> + <%= stylesheet_link_tag "lib/main-form-col2" %> + +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "//www.google.com/jsapi", "chartkick"%> + <%= javascript_include_tag "justgage.1.0.1.min" %> + <%= javascript_include_tag "raphael.2.1.0.min" %> + <%= javascript_include_tag "validator" %> +<% end %> +
+
+
+
+
+ +
+ <%= select_year(DateTime.now.year - 5, {:start_year => DateTime.now.year, :end_year => 1950}, {:name => 'start_year', :class => "span1"} ) %> + - + <%= select_year(DateTime.now.year, {:start_year => DateTime.now.year, :end_year => 1950}, {:name => 'end_year', :class => "span1"} ) %> +
+
+
+ +
+ <%= t("personal_course.course_semester") %> + <%= t("personal_course.course_category") %> +
+
+
+
+ + Export +
+
+
+
+ <% Role.where(:disabled => false, :title.ne => "", :title.ne => nil).asc(:key).each do |role| %> +
+

<%= role.title %>

+
+ loading +
+
+ <% end %> +
+
+ + + + + diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis_report.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis_report.html.erb new file mode 100644 index 0000000..b4e8aa4 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis_report.html.erb @@ -0,0 +1 @@ +<%= column_chart @data, :id => params[:role_id], :height => "350px", :xtitle => "Year", :ytitle => "Total number" %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/course_assignments.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/course_assignments.html.erb new file mode 100644 index 0000000..fe349d6 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/course_assignments.html.erb @@ -0,0 +1,82 @@ +

<%=t("personal_course.assignment_management")%>-<%=@course.title rescue "" %>

+<% student_assignment = (StudentAssignment rescue nil) %> + + + + + + + + + <% if !student_assignment.nil? %> + + <% end %> + + + + <% @course_assignments.each do |course_assignment| %> + + + + + + + <% if !student_assignment.nil? %> + + <% end %> + + <% end %> + +
<%= t("personal_course.name") %><%= t("personal_course.detail") %><%= t("personal_course.course_attachment") %> + <%= t("personal_course.assign_date") %> + + + + <%= t("personal_course.deadline") %> + + + <%=t("personal_course.already_deliver")%>
+ <%= course_assignment.name %> +
+ +
+
<%= course_assignment.detail.html_safe %><%= course_assignment.display_attachments %><%= course_assignment.display_assign_date %><%= course_assignment.display_deadline %><%= link_to course_assignment.deliver_count, show_assignments_admin_courses_path(:name=>course_assignment.name, :uid => course_assignment.uid ) %>
+ +
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_assignment_admin_courses_path(:id=>params[:id]), :class => 'btn btn-primary' %> +
+ +
+ \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx new file mode 100644 index 0000000..8a724d6 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx @@ -0,0 +1,39 @@ +# encoding: utf-8 + +wb = xlsx_package.workbook +@data.each_with_index do |role,idx| + data = role["data"] + wb.add_worksheet(name: role["name"] + "-" + idx.to_s) do |sheet| + + heading = sheet.styles.add_style(:b => true, :locked => true) + + row = ["Name"] + @site_in_use_locales.each do |locale| + row << t("personal_course.title") + " - " + t(locale.to_s) + end + @site_in_use_locales.each do |locale| + row << t("personal_course.objective") + " - " + t(locale.to_s) + end + + + row << t("personal_course.year") + row << t("personal_course.course_semester") + row << t("personal_course.course_category") + + sheet.add_row row, :style => heading + + data.each do |course| + row = [course.member_profile.name] + @site_in_use_locales.each do |locale| + row << course.title_translations[locale.to_s] + end + @site_in_use_locales.each do |locale| + row << course.objective_translations[locale.to_s] + end + row << course.year + row << course.course_semester.title rescue "" + row << course.course_category.title rescue "" + sheet.add_row row + end + end +end \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/edit.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/edit.html.erb new file mode 100644 index 0000000..49924b7 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @course, url: admin_course_path(@course), html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb new file mode 100644 index 0000000..a3650c8 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb @@ -0,0 +1,94 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> + +<%= form_for(:plugin_template_intro, :url => update_frontend_setting_admin_plugin_templates_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %> +
+ +
+ + + + + + +
+ +
+ <% if !@member.blank? %> +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id %> +
+
+ <% end %> + +
+ +
+ <%= f.check_box :brief_intro, :checked => @intro.brief_intro %> <%= t("personal_plugins.brief_intro") %> + <%= f.check_box :complete_list, :checked => @intro.complete_list %> <%= t("personal_plugins.complete_list") %> +
+
+
+
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+
+ <%= f.fields_for :text_translations do |f| %> + <%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@intro.text_translations[locale] rescue nil) %> + <% end %> +
+
+
+ + +
+ + <% end %> + + + +
+ + + +
+ + +
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %> + <%= hidden_field_tag :member_profile_id, @member.id.to_s %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/index.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/index.html.erb new file mode 100644 index 0000000..46fece1 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/index.html.erb @@ -0,0 +1,20 @@ + + + + + + + + <%= render 'personal_plugin_templates' %> + +
<%= t('personal_plugin_template.year') %>
+ +
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:new_), new_admin_plugin_template_path, :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_plugin_template_setting_path, :class => 'btn btn-primary pull-right' %> +
+ +
\ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/new.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/new.html.erb new file mode 100644 index 0000000..ab8aab3 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @plugin_template, url: admin_plugin_templates_path, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/setting.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/setting.html.erb new file mode 100644 index 0000000..23f04d1 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/setting.html.erb @@ -0,0 +1,74 @@ +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/jquery-ui-sortable.min" %> +<% end %> + + +
+ <% parse_again_start %> +
+
+

+ <%= t('add')%> + <%= t("personal_plugin_template.plugin_template_related") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'plugin_template_related', :collection => @plugin_template_relateds %> + +
+
+
+
+
+
+ <% parse_again_end %> +
+ +<% parse_again_start %> +
+ +
+ +<% parse_again_end %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/index.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/index.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/index.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/show.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/show.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/show.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb new file mode 100644 index 0000000..1801366 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb @@ -0,0 +1,82 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/list-check" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/list-check" %> +<% end %> + +<% + if has_access? + @plugin_templates = PluginTemplate.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) + else + @plugin_templates = PluginTemplate.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10) + end +%> + +<% if has_access? %> +
+
+ <%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_courses_path(member_profile_id: @member.id.to_s, disable: 'true') ) %> + <%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_courses_path(member_profile_id: @member.id.to_s, disable: 'false') ) %> +
+
+<% end -%> + + + + + <% if has_access? %> + + <% end -%> + + + + + <% @plugin_templates.each do |plugin_template| %> + "> + <% if has_access? %> + + <% end %> + + + + <% end %> + +
<%= t('personal_plugin_template.col_name') %>
+ <%= check_box_tag 'to_change[]', plugin_template.id.to_s, false, :class => "list-check" %> + <%= plugin_template.year %> + <%= link_to plugin_template.title, OrbitHelper.url_to_plugin_show(plugin_template.to_param,'plugin_template').to_s, target: "blank"%> +
+ +
+
+ + +
+ <% if has_access? %> +
+ <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/plugin_templates/frontend_setting', :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'), + '/admin/members/'+@member.to_param+'/plugin_templates/new', :class => 'btn btn-primary' %> +
+ <% end %> + +
+ + \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/bin/rails b/app/views/admin/personal_plugin_fields/template_generator/bin/rails new file mode 100644 index 0000000..38c2a68 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/config/locales/en.yml b/app/views/admin/personal_plugin_fields/template_generator/config/locales/en.yml new file mode 100644 index 0000000..816d52c --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/config/locales/en.yml @@ -0,0 +1,7 @@ +en: + module_name: + personal_plugin_template: personal_plugin_template_translate + plugin_templates: personal_plugin_template_translate + plugin_template: personal_plugin_template_translate + personal_plugin_template: + col_name_translate_yaml \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/config/locales/zh_tw.yml b/app/views/admin/personal_plugin_fields/template_generator/config/locales/zh_tw.yml new file mode 100644 index 0000000..849a2b3 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/config/locales/zh_tw.yml @@ -0,0 +1,7 @@ +zh_tw: + module_name: + personal_plugin_template: personal_plugin_template_translate + plugin_templates: personal_plugin_template_translate + plugin_template: personal_plugin_template_translate + personal_plugin_template: + col_name_translate_yaml \ No newline at end of file diff --git a/app/views/admin/personal_plugin_fields/template_generator/config/routes.rb b/app/views/admin/personal_plugin_fields/template_generator/config/routes.rb new file mode 100644 index 0000000..ef0a501 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/config/routes.rb @@ -0,0 +1,31 @@ +Rails.application.routes.draw do + 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 'plugin_template_setting' => "plugin_templates#setting" + resources :plugin_templates do + collection do + get 'toggle_hide' => 'plugin_templates#toggle_hide' + get 'analysis' + get 'analysis_report' + get "download_excel" + end + end + + resources :members do + collection do + scope '(:name-:uid)' do + resources :plugin_templates do + collection do + get 'frontend_setting' => 'plugin_templates#frontend_setting' + post 'update_frontend_setting' => 'plugin_templates#update_frontend_setting' + end + end + end + end + end + + resources :plugin_template_relateds + end + end +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template.rb b/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template.rb new file mode 100644 index 0000000..ad07ca9 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template.rb @@ -0,0 +1,4 @@ +require "personal_plugin_template/engine" + +module PersonalPluginTemplate +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/engine.rb b/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/engine.rb new file mode 100644 index 0000000..7542eb6 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/engine.rb @@ -0,0 +1,21 @@ +module PersonalPluginTemplate + class Engine < ::Rails::Engine + initializer "personal_plugin_template" do + OrbitApp.registration "PersonalPluginTemplate",:type=> 'ModuleApp' do + module_label 'module_name.plugin_templates' + base_url File.expand_path File.dirname(__FILE__) + personal_plugin :enable => true, :sort_number => '35', :app_name=>"PluginTemplate", :intro_app_name=>"PluginTemplateIntro",:path=>"/plugin/personal_plugin_template/profile",:front_path=>"/profile",:admin_path=>"/admin/plugin_templates/",:i18n=>'module_name.plugin_templates', :module_app_name=>'PluginTemplate', :analysis => true, :analysis_path => "/admin/plugin_templates/analysis" + + version "0.1" + desktop_enabled true + organization "Rulingcom" + author "RD dep" + intro "I am intro" + update_info 'some update_info' + frontend_enabled + icon_class_no_sidebar "icons-user" + data_count 1..10 + end + end + end +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/version.rb b/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/version.rb new file mode 100644 index 0000000..c446c96 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/version.rb @@ -0,0 +1,3 @@ +module PersonalCourse + VERSION = "0.0.1" +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/lib/tasks/personal_plugin_template_tasks.rake b/app/views/admin/personal_plugin_fields/template_generator/lib/tasks/personal_plugin_template_tasks.rake new file mode 100644 index 0000000..381fdd7 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/lib/tasks/personal_plugin_template_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :personal_plugin_template do +# # Task goes here +# end diff --git a/app/views/admin/personal_plugin_fields/template_generator/personal_plugin_template.gemspec b/app/views/admin/personal_plugin_fields/template_generator/personal_plugin_template.gemspec new file mode 100644 index 0000000..12215a8 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/personal_plugin_template.gemspec @@ -0,0 +1,19 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "personal_plugin_template/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "personal_plugin_template" + s.version = PersonalPluginTemplate::VERSION + s.authors = ["Bohung"] + s.email = ["bohung@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "personal_plugin_template_description." + s.description = "personal_plugin_template_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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/README.rdoc b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +rake doc:app. diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/Rakefile b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/Rakefile new file mode 100644 index 0000000..ba6b733 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/images/.keep b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/images/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/javascripts/application.js b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/javascripts/application.js new file mode 100644 index 0000000..a1873dd --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/stylesheets/application.css b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..a443db3 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/controllers/application_controller.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..d83690e --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/controllers/concerns/.keep b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/controllers/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/helpers/application_helper.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/mailers/.keep b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/mailers/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/models/.keep b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/models/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/models/concerns/.keep b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/views/layouts/application.html.erb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..593a778 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/bundle b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/bundle new file mode 100644 index 0000000..66e9889 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/rails b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/rails new file mode 100644 index 0000000..728cd85 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/rake b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/rake new file mode 100644 index 0000000..1724048 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config.ru b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config.ru new file mode 100644 index 0000000..5bc2a61 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/application.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/application.rb new file mode 100644 index 0000000..2217afe --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/boot.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/boot.rb new file mode 100644 index 0000000..6266cfc --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/database.yml b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/database.yml new file mode 100644 index 0000000..1c1a37c --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environment.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environment.rb new file mode 100644 index 0000000..ee8d90d --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/development.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..ddf0e90 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/production.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..b93a877 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/test.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..053f5b6 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/assets.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/assets.rb new file mode 100644 index 0000000..d2f4ec3 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/backtrace_silencers.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/cookies_serializer.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..7a06a89 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/filter_parameter_logging.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/inflections.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/mime_types.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/session_store.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000..e766b67 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/wrap_parameters.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..33725e9 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/locales/en.yml b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/routes.rb b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/routes.rb new file mode 100644 index 0000000..752cab9 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + + mount PersonalCourse::Engine => "/personal_course" +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/secrets.yml b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/config/secrets.yml new file mode 100644 index 0000000..7973e7d --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/lib/assets/.keep b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/log/.keep b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/404.html b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/404.html new file mode 100644 index 0000000..b612547 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/422.html b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/422.html new file mode 100644 index 0000000..a21f82b --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/500.html b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/500.html new file mode 100644 index 0000000..061abc5 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/favicon.ico b/app/views/admin/personal_plugin_fields/template_generator/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/integration/navigation_test.rb b/app/views/admin/personal_plugin_fields/template_generator/test/integration/navigation_test.rb new file mode 100644 index 0000000..97a94c9 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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/app/views/admin/personal_plugin_fields/template_generator/test/personal_plugin_template_test.rb b/app/views/admin/personal_plugin_fields/template_generator/test/personal_plugin_template_test.rb new file mode 100644 index 0000000..d037a52 --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/test/personal_plugin_template_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PersonalPluginTemplateTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, PersonalPluginTemplate + end +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/test/test_helper.rb b/app/views/admin/personal_plugin_fields/template_generator/test/test_helper.rb new file mode 100644 index 0000000..a553d9a --- /dev/null +++ b/app/views/admin/personal_plugin_fields/template_generator/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 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/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..7573e6d --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,36 @@ +en: + module_name: + personal_plugin_generator: Personal Plugin Generator + restful_actions: + fields_setting: Fields Setting + personal_plugin_generator: + personal_plugin_generator: Personal Plugin Generate + personal_plugin_name: Personal Plugin Name Translation + module_name: Module Name + action: Action + primary_modal_name: Primary Modal Name + related_modal_name: Related Modal Name + field_name: Field Name + translation_name: translation_name + remove_text: Do you really want to delete this field? + field_type: Field Type + text_field: Text Field + text_editor: Text Editor + file: File + select: Select field + year: Year + date: Date + time: Time + date_time: Date time + localize: Localize + add_field: Add field + fields_display_setting: Fields display setting + backend_page: Backend Page + frontend_page: Frontend Page + index: Index Page + show: Show Page + member_show: Member show page + slug_title: Slug title + please_choose_one_slug_title: Please choose one Slug title! + slug_title_can_only_choose_one: Slug title can only choose one! + generate_plugin: Generate plugin \ 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..eaa4eee --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,36 @@ +zh_tw: + module_name: + personal_plugin_generator: 個人外掛生成器 + restful_actions: + fields_setting: 欄位設定 + personal_plugin_generator: + personal_plugin_generator: 個人外掛生成 + personal_plugin_name: 個人外掛翻譯名稱 + module_name: 模組名稱 + action: 動作 + primary_modal_name: 主要modal名稱(均英文小寫,可加底線) + related_modal_name: 關聯modal名稱(用來存論文類型、期刊等級...等) + field_name: 欄位名稱 + translation_name: 翻譯名稱 + remove_text: 您確定要刪除這個欄位嗎 + field_type: 欄位類型 + text_field: 文字欄位 + text_editor: 文字編輯器 + file: 檔案 + select: 選項欄位 + year: 年份 + date: 日期 + time: 時間 + date_time: 日期與時間 + localize: 隨語言變化 + add_field: 新增欄位 + fields_display_setting: 欄位顯示設定 + backend_page: 後台頁面 + frontend_page: 前台頁面 + index: Index 頁面 + show: Show 頁面 + member_show: 會員show頁面 + slug_title: 頭銜標題 + please_choose_one_slug_title: 請至少選擇一個頭銜標題! + slug_title_can_only_choose_one: 頭銜標題只能選擇一個! + generate_plugin: 生成個人外掛 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..626e17b --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,13 @@ +Rails.application.routes.draw do + 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 + resources :personal_plugin_fields do + get 'fields_setting' , to: 'personal_plugin_fields#fields_setting' + post 'update_fields_setting' , to: 'personal_plugin_fields#update_fields_setting' + patch 'update_fields_setting' , to: 'personal_plugin_fields#update_fields_setting' + get 'generate_plugin' , to: 'personal_plugin_fields#generate_plugin' + end + end + end +end diff --git a/lib/personal_plugin_generator.rb b/lib/personal_plugin_generator.rb new file mode 100644 index 0000000..1a8d2cd --- /dev/null +++ b/lib/personal_plugin_generator.rb @@ -0,0 +1,4 @@ +require "personal_plugin_generator/engine" + +module PersonalPluginGenerator +end diff --git a/lib/personal_plugin_generator/engine.rb b/lib/personal_plugin_generator/engine.rb new file mode 100644 index 0000000..fb6aa88 --- /dev/null +++ b/lib/personal_plugin_generator/engine.rb @@ -0,0 +1,23 @@ +require "yaml" +module PersonalPluginGenerator + class Engine < ::Rails::Engine + initializer "personal_plugin_generator" do + OrbitApp.registration "PersonalPluginGenerator", :type => "ModuleApp" do + base_url File.expand_path File.dirname(__FILE__) + categorizable + authorizable + side_bar do + head_label_i18n 'personal_plugin_generator.personal_plugin_generator', icon_class: "icons-graduation" + available_for "users" + active_for_controllers (['admin/personal_plugin_fields']) + head_link_path "admin_personal_plugin_fields_path" + context_link 'personal_plugin_generator.personal_plugin_generator', + :link_path=>"admin_personal_plugin_fields_path" , + :priority=>1, + :active_for_action=>{'admin/personal_plugin_fields'=>'index'}, + :available_for => 'users' + end + end + end + end +end \ No newline at end of file diff --git a/lib/personal_plugin_generator/version.rb b/lib/personal_plugin_generator/version.rb new file mode 100644 index 0000000..417e0d8 --- /dev/null +++ b/lib/personal_plugin_generator/version.rb @@ -0,0 +1,3 @@ +module PersonalPluginGenerator + VERSION = "0.0.1" +end diff --git a/lib/tasks/personal_plugin_generator_tasks.rake b/lib/tasks/personal_plugin_generator_tasks.rake new file mode 100644 index 0000000..5764b13 --- /dev/null +++ b/lib/tasks/personal_plugin_generator_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :personal_plugin_generator do +# # Task goes here +# end diff --git a/personal_plugin_generator.gemspec b/personal_plugin_generator.gemspec new file mode 100644 index 0000000..216a15c --- /dev/null +++ b/personal_plugin_generator.gemspec @@ -0,0 +1,19 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "personal_plugin_generator/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "personal_plugin_generator" + s.version = PersonalPluginGenerator::VERSION + s.authors = ["Bohung"] + s.email = ["bohung@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "A Generator for Personal plugin." + s.description = "A Generator for Personal plugin." + 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/test/dummy/README.rdoc b/test/dummy/README.rdoc new file mode 100644 index 0000000..dd4e97e --- /dev/null +++ b/test/dummy/README.rdoc @@ -0,0 +1,28 @@ +== README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... + + +Please feel free to use a different markup language if you do not plan to run +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_plugin_field_test.rb b/test/personal_plugin_field_test.rb new file mode 100644 index 0000000..40ea256 --- /dev/null +++ b/test/personal_plugin_field_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PersonalPluginFieldTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, PersonalPluginGenerator + 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