From d0641cd677503327f09dc135146e7fa4f4dbd8e4 Mon Sep 17 00:00:00 2001 From: bohung Date: Sun, 28 Feb 2021 17:19:14 +0800 Subject: [PATCH] Finish a lot. --- README.rdoc | 2 +- .../personal_plugin_fields_controller.rb | 216 +++++++++++++++--- .../_course_category.html.erb | 8 - .../_plugin_templates.html.erb | 17 -- .../course_assignments.html.erb | 82 ------- .../lib/personal_plugin_template/version.rb | 3 - .../.gitignore | 0 .../Gemfile | 0 .../MIT-LICENSE | 0 .../README.rdoc | 0 .../Rakefile | 0 .../app/assets/images/personal_course/.keep | 0 .../personal_course/application.js | 0 .../personal_course/application.css | 0 .../plugin_template_relateds_controller.rb | 0 .../admin/plugin_templates_controller.rb | 0 .../personal_plugin_templates_controller.rb | 0 .../helpers/admin/plugin_templates_helper.rb | 0 .../app/models/plugin_template.rb | 0 .../app/models/plugin_template_file.rb | 0 .../app/models/plugin_template_intro.rb | 0 .../app/models/plugin_template_related.rb | 0 .../plugin_template_relateds/_form.html.erb | 0 .../plugin_template_relateds/create.js.erb | 0 .../plugin_template_relateds/destroy.js.erb | 0 .../plugin_template_relateds/edit.js.erb | 0 .../admin/plugin_template_relateds/new.js.erb | 0 .../plugin_template_relateds/update.js.erb | 0 .../admin/plugin_templates/_form.html.erb | 82 ++----- .../plugin_templates/_form_file.html.erb | 0 .../_plugin_template_related.html.erb | 0 .../_plugin_templates.html.erb | 7 + .../admin/plugin_templates/analysis.html.erb | 0 .../plugin_templates/analysis_report.html.erb | 0 .../download_excel.xlsx.axlsx | 0 .../admin/plugin_templates/edit.html.erb | 0 .../frontend_setting.html.erb | 0 .../admin/plugin_templates/index.html.erb | 6 +- .../views/admin/plugin_templates/new.html.erb | 0 .../admin/plugin_templates/setting.html.erb | 0 .../personal_plugin_templates/index.html.erb | 0 .../personal_plugin_templates/show.html.erb | 0 .../_profile.html.erb | 0 .../bin/rails | 0 .../config/locales/en.yml | 0 .../config/locales/zh_tw.yml | 0 .../config/routes.rb | 0 .../lib/personal_plugin_template.rb | 0 .../lib/personal_plugin_template/engine.rb | 0 .../lib/personal_plugin_template/version.rb | 3 + .../tasks/personal_plugin_template_tasks.rake | 0 .../personal_plugin_template/index.html.erb | 27 +++ .../personal_plugin_template/info.json | 12 + .../personal_plugin_template/show.html.erb | 8 + .../personal_plugin_template/thumbs/thumb.png | Bin 0 -> 4075 bytes .../personal_plugin_template.gemspec | 0 .../test/dummy/README.rdoc | 0 .../test/dummy/Rakefile | 0 .../test/dummy/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 0 .../app/assets/stylesheets/application.css | 0 .../app/controllers/application_controller.rb | 0 .../test/dummy/app/controllers/concerns/.keep | 0 .../dummy/app/helpers/application_helper.rb | 0 .../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 | 0 .../test/dummy/bin/bundle | 0 .../test/dummy/bin/rails | 0 .../test/dummy/bin/rake | 0 .../test/dummy/config.ru | 0 .../test/dummy/config/application.rb | 0 .../test/dummy/config/boot.rb | 0 .../test/dummy/config/database.yml | 0 .../test/dummy/config/environment.rb | 0 .../dummy/config/environments/development.rb | 0 .../dummy/config/environments/production.rb | 0 .../test/dummy/config/environments/test.rb | 0 .../test/dummy/config/initializers/assets.rb | 0 .../initializers/backtrace_silencers.rb | 0 .../config/initializers/cookies_serializer.rb | 0 .../initializers/filter_parameter_logging.rb | 0 .../dummy/config/initializers/inflections.rb | 0 .../dummy/config/initializers/mime_types.rb | 0 .../config/initializers/session_store.rb | 0 .../config/initializers/wrap_parameters.rb | 0 .../test/dummy/config/locales/en.yml | 0 .../test/dummy/config/routes.rb | 0 .../test/dummy/config/secrets.yml | 0 .../test/dummy/lib/assets/.keep | 0 .../test/dummy/log/.keep | 0 .../test/dummy/public/404.html | 0 .../test/dummy/public/422.html | 0 .../test/dummy/public/500.html | 0 .../test/dummy/public/favicon.ico | 0 .../test/integration/navigation_test.rb | 0 .../test/personal_plugin_template_test.rb | 0 .../test/test_helper.rb | 0 99 files changed, 263 insertions(+), 210 deletions(-) delete mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_course_category.html.erb delete mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb delete mode 100644 app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/course_assignments.html.erb delete mode 100644 app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/version.rb rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/.gitignore (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/Gemfile (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/MIT-LICENSE (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/README.rdoc (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/Rakefile (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/assets/images/personal_course/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/assets/javascripts/personal_course/application.js (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/assets/stylesheets/personal_course/application.css (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/controllers/admin/plugin_template_relateds_controller.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/controllers/admin/plugin_templates_controller.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/controllers/personal_plugin_templates_controller.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/helpers/admin/plugin_templates_helper.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/models/plugin_template.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/models/plugin_template_file.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/models/plugin_template_intro.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/models/plugin_template_related.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_template_relateds/_form.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_template_relateds/create.js.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_template_relateds/destroy.js.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_template_relateds/edit.js.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_template_relateds/new.js.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_template_relateds/update.js.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/_form.html.erb (60%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/_form_file.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/_plugin_template_related.html.erb (100%) create mode 100644 template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/analysis.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/analysis_report.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/download_excel.xlsx.axlsx (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/edit.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/frontend_setting.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/index.html.erb (80%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/new.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/admin/plugin_templates/setting.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/personal_plugin_templates/index.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/personal_plugin_templates/show.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/app/views/plugin/personal_plugin_template/_profile.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/bin/rails (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/config/locales/en.yml (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/config/locales/zh_tw.yml (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/config/routes.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/lib/personal_plugin_template.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/lib/personal_plugin_template/engine.rb (100%) create mode 100644 template_generator/lib/personal_plugin_template/version.rb rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/lib/tasks/personal_plugin_template_tasks.rake (100%) create mode 100644 template_generator/modules/personal_plugin_template/index.html.erb create mode 100644 template_generator/modules/personal_plugin_template/info.json create mode 100644 template_generator/modules/personal_plugin_template/show.html.erb create mode 100644 template_generator/modules/personal_plugin_template/thumbs/thumb.png rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/personal_plugin_template.gemspec (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/README.rdoc (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/Rakefile (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/assets/images/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/assets/javascripts/application.js (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/assets/stylesheets/application.css (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/controllers/application_controller.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/controllers/concerns/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/helpers/application_helper.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/mailers/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/models/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/models/concerns/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/app/views/layouts/application.html.erb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/bin/bundle (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/bin/rails (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/bin/rake (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config.ru (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/application.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/boot.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/database.yml (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/environment.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/environments/development.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/environments/production.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/environments/test.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/assets.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/backtrace_silencers.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/cookies_serializer.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/filter_parameter_logging.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/inflections.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/mime_types.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/session_store.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/initializers/wrap_parameters.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/locales/en.yml (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/routes.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/config/secrets.yml (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/lib/assets/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/log/.keep (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/public/404.html (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/public/422.html (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/public/500.html (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/dummy/public/favicon.ico (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/integration/navigation_test.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/personal_plugin_template_test.rb (100%) rename {app/views/admin/personal_plugin_fields/template_generator => template_generator}/test/test_helper.rb (100%) diff --git a/README.rdoc b/README.rdoc index 1ec78f8..12404e2 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,3 @@ -= PersonalCourse += PersonalPluginGenerator This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/app/controllers/admin/personal_plugin_fields_controller.rb b/app/controllers/admin/personal_plugin_fields_controller.rb index 4d6201b..f0ad69a 100644 --- a/app/controllers/admin/personal_plugin_fields_controller.rb +++ b/app/controllers/admin/personal_plugin_fields_controller.rb @@ -39,7 +39,7 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController redirect_to params[:referer_url] end def generate_plugin - template_dir_path = File.expand_path("../../../views/admin/personal_plugin_fields/template_generator/", __FILE__) + "/" + template_dir_path = File.expand_path("../../../../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) @@ -78,51 +78,159 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController 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) + yml_text = yml_text.gsub("personal_plugin_template_translate",@personal_plugin_field.title_translations[locale]) 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") + @blank_text = " " + slug_title = @personal_plugin_field.primary_modal_fields.select{|field_value| field_value[:slug_title] == "1" rescue false}.first[:field_name].to_s rescue "" + plugin_template_related_files = @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_text = plugin_template_related_files.to_s + plugin_template_related_files_fields = plugin_template_related_files.map{|field_name| + "has_many :#{field_name.pluralize}, :dependent => :destroy, :autosave => true\r\n" + + "#{@blank_text}accepts_nested_attributes_for :#{field_name.pluralize}, :allow_destroy => true" + }.join("\r\n#{@blank_text}") + plugin_template = @personal_plugin_field.primary_modal_name + backend_index_fields = @personal_plugin_field.backend_fields["index"] rescue [] + backend_index_fields_contents = backend_index_fields.map do |field_name| + if field_name == slug_title + "<%= link_to #{plugin_template}.#{field_name}, page_for_#{plugin_template}(#{plugin_template}), target: \"blank\" %>\r\n " + + "
+ +
\r\n " + else + "<%= #{plugin_template}.#{field_name} %>" + end + end 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] + } + col_fields = get_fields_text(@personal_plugin_field.primary_modal_fields) + col_related_fields = @personal_plugin_field.related_modal_fields.map{|field_values| get_fields_text(field_values)} + locale_fields = [] + none_locale_fields = [] + locale_fields_input_fields = [] + none_locale_fields_input_fields = [] + plugin_template_related = @personal_plugin_field.related_modal_name.select{|n| n.present?} + plugin_template_related_main_field = @personal_plugin_field.related_modal_fields.map{|field_values| field_values.map{|field_value| field_value[:field_name]}.select{|t| t.present?}.first } + @personal_plugin_field.primary_modal_fields.each do |field_value| + field_name = field_value[:field_name] + field_type = field_value[:field_type] + next if field_name.blank? + next if field_type == "file" + if (field_value[:localize] == "1" rescue false) + locale_fields << field_name + input_field = generate_input_field(field_type,field_name,true) + locale_fields_input_fields << input_field + else + none_locale_fields << field_name + input_field = generate_input_field(field_type,field_name) + none_locale_fields_input_fields << input_field + end 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" => plugin_template, + "plugin_template_related" => plugin_template_related, "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 + "extra_translate_title" => extra_translate_title.map{|k,v| "\"#{k}\" => #{v}"}.join(", ").prepend("{").concat("}"), + "col_fields" => col_fields, + "col_related_fields" => col_related_fields, + "plugin_template_file" => plugin_template_related_files, + "plugin_template_sort_hash" => "nil", + "col_name_to_show_in_index_page_arr" => col_name_to_show_in_index_page, + "backend_index_fields" => backend_index_fields, + "slug_title" => slug_title, + "backend_index_fields_contents" => backend_index_fields_contents, + "plugin_template_related_files_text" => plugin_template_related_files_text, + "locale_fields" => locale_fields, + "none_locale_fields" => none_locale_fields, + "none_locale_fields_input_fields" => none_locale_fields_input_fields, + "locale_fields_input_fields" => locale_fields_input_fields, + "plugin_template_related_main_field" => plugin_template_related_main_field } - @match_pattern = @match_pattern.sort_by{|k,v| -k.length}.sort_by{|k,v| (v.class != Array) ? 1 : 0} + max_length = @match_pattern.keys.map{|k| k.length}.max + @match_pattern = @match_pattern.sort_by{|k,v| (v.class != Array) ? (max_length - k.length) : -k.length} + @logs = [] replace_files(files) #Thread.new do dirs.each do |dir| replace_dir(dir) end #end - render :html => @match_pattern + render :html => @logs.join("
").html_safe#@match_pattern + end + def generate_input_field(field_type,field_name,localize = false) + personal_plugin_template = @personal_plugin_field.module_name + plugin_template = @personal_plugin_field.primary_modal_name + input_field = "" + field_value_text = "@#{plugin_template}.#{field_name}" + field_name_text = ":#{field_name}" + field_name_text = "locale" if localize + if localize + field_value_text = "@#{plugin_template}.#{field_name}_translations[locale]" + end + case field_type + when "year" + input_field = "<%= select_year((#{field_value_text} ? #{field_value_text}.to_i : DateTime.now.year), {:start_year => DateTime.now.year + 5, :end_year => 1930}, {:name => '#{plugin_template}[#{field_name}]',:class => 'span1'} ) %>" + when "date" + when "time" + when "date_time" + input_field = "<%= f.text_area #{field_name_text}, class: \"input-block-level ckeditor\", placeholder: t(\"#{personal_plugin_template}.#{field_name}\"), value: (#{field_value_text} rescue nil) %>" + when "text_editor" + else #text_field + input_field = "<%= f.text_field #{field_name_text}, class: \"input-block-level\", placeholder: t(\"#{personal_plugin_template}.#{field_name}\"), value: (#{field_value_text} rescue nil) %>" + end + if localize + input_field.prepend("<%= f.fields_for :#{field_name}_translations do |f| %>\r\n ").concat("<% end %>\r\n ") + end + input_field + end + def get_fields_text(field_values) + fields_text = field_values.map do |field_value| + next if field_value[:field_type] == "file" || field_value[:field_name].blank? + type = "String" + default = "\"\"" + case field_value[:field_type] + when "date" + type = "Date" + default = "Date.parse(DateTime.now.to_s)" + when "time" + type = "Time" + default = "Time.now" + when "date_time" + type = "DateTime" + default = "DateTime.now" + end + no_localize_types = ["date","time","date_time"] + field_text = "field :#{field_value[:field_name]}, :type => #{type}, :default => #{default}" + field_text += ", :localize => true" if field_value[:localize] && !no_localize_types.include?(field_value[:field_type]) + field_text += ", as: :slug_title" if field_value[:slug_title] + end + fields_text.join("\r\n#{@blank_text}") + end + def replace_dirs(dirs) + dirs.each do |dir| + replace_dir(dir) + end end def replace_dir(dir) dir = replace_file(dir) - return true if dir.blank? + return true if dir.select{|d| d.present?}.blank? + if dir.count > 1 + replace_dirs(dir) + else + dir = dir[0] + end sub_dirs = Dir.glob("#{dir}/*/") files = Dir.glob("#{dir}/*").select { |fn| File.file?(fn) } replace_files(files) @@ -147,49 +255,81 @@ class Admin::PersonalPluginFieldsController < OrbitAdminController if new_filename.blank? FileUtils.rm_rf("#{path}/#{file_name}") elsif file_name != new_filename - FileUtils.mv("#{path}/#{file_name}", "#{path}/#{new_filename}") + if new_filename.class == Array + new_filename.each do |f| + FileUtils.cp_r("#{path}/#{file_name}", "#{path}/#{f}") + end + FileUtils.rm_rf("#{path}/#{file_name}") + else + FileUtils.mv("#{path}/#{file_name}", "#{path}/#{new_filename}") + end end if new_filename.blank? - return "" + return [""] else + is_array = new_filename.class == Array + new_filename = Array(new_filename) 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)} + new_filename.each_with_index do |sub_file,i| + next if File.extname(sub_file).match(/(png|jpg)/i) + file_text = File.read("#{path}/#{sub_file}") + if is_array + file_text = replace_text_with_pattern(file_text,false,i) + else + file_text = replace_text_with_pattern(file_text) + end + File.open("#{path}/#{sub_file}",'w+'){|f| f.write(file_text)} + end end - return "#{path}/#{new_filename}" + return new_filename.map{|sub_file| "#{path}/#{sub_file}" if sub_file.present?} end end def replace_text_with_pattern(text,is_file=false,i = nil) new_text = text @match_pattern.each do |k,v| + next if !include_key(new_text,k) vv = v - vv = vv[i] if i + vv = vv[i] if i && vv.class == Array if vv.class == String - if i && vv == "" + if i && vv == "" && is_file 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 + if is_file + if v.count == 0 + new_text = "" + break + else + new_text = vv.map{|sub_v| gsub_text_by_key_value(new_text,k,sub_v)} + break + end 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") + new_text = new_text.gsub(/<% parse_again_start %>((?:(?!<% parse_again_start %>).)+)<% parse_again_end %>/m) do |ff| + parse_content = $1 #last match + result = ff + if include_key($1,k) + start_index = 0 + end_index = parse_content.length + start_index = 2 if parse_content[0..1] == "\r\n" + end_index = end_index - 2 if parse_content[(end_index - 2)..(end_index - 1)] == "\r\n" + parse_content = parse_content.slice(start_index,end_index) + result = (0...vv.count).map {|i| replace_text_with_pattern(parse_content,false,i) }.join("") + end + result end end end return new_text end + def include_key(text,key) + return text.include?(key) || text.include?(key.classify) + 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 + "s",v.classify.pluralize) text = text.gsub(k.classify,v.classify) end private 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 deleted file mode 100644 index 7e4bd83..0000000 --- a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_course_category.html.erb +++ /dev/null @@ -1,8 +0,0 @@ - - <%= 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/_plugin_templates.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb deleted file mode 100644 index 772c7c4..0000000 --- a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<% @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/course_assignments.html.erb b/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/course_assignments.html.erb deleted file mode 100644 index fe349d6..0000000 --- a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/course_assignments.html.erb +++ /dev/null @@ -1,82 +0,0 @@ -

<%=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/lib/personal_plugin_template/version.rb b/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/version.rb deleted file mode 100644 index c446c96..0000000 --- a/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module PersonalCourse - VERSION = "0.0.1" -end diff --git a/app/views/admin/personal_plugin_fields/template_generator/.gitignore b/template_generator/.gitignore similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/.gitignore rename to template_generator/.gitignore diff --git a/app/views/admin/personal_plugin_fields/template_generator/Gemfile b/template_generator/Gemfile similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/Gemfile rename to template_generator/Gemfile diff --git a/app/views/admin/personal_plugin_fields/template_generator/MIT-LICENSE b/template_generator/MIT-LICENSE similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/MIT-LICENSE rename to template_generator/MIT-LICENSE diff --git a/app/views/admin/personal_plugin_fields/template_generator/README.rdoc b/template_generator/README.rdoc similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/README.rdoc rename to template_generator/README.rdoc diff --git a/app/views/admin/personal_plugin_fields/template_generator/Rakefile b/template_generator/Rakefile similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/Rakefile rename to template_generator/Rakefile diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/assets/images/personal_course/.keep b/template_generator/app/assets/images/personal_course/.keep similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/assets/images/personal_course/.keep rename to template_generator/app/assets/images/personal_course/.keep diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/assets/javascripts/personal_course/application.js b/template_generator/app/assets/javascripts/personal_course/application.js similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/assets/javascripts/personal_course/application.js rename to template_generator/app/assets/javascripts/personal_course/application.js diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/assets/stylesheets/personal_course/application.css b/template_generator/app/assets/stylesheets/personal_course/application.css similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/assets/stylesheets/personal_course/application.css rename to template_generator/app/assets/stylesheets/personal_course/application.css diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_template_relateds_controller.rb b/template_generator/app/controllers/admin/plugin_template_relateds_controller.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_template_relateds_controller.rb rename to template_generator/app/controllers/admin/plugin_template_relateds_controller.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_templates_controller.rb b/template_generator/app/controllers/admin/plugin_templates_controller.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/controllers/admin/plugin_templates_controller.rb rename to template_generator/app/controllers/admin/plugin_templates_controller.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/controllers/personal_plugin_templates_controller.rb b/template_generator/app/controllers/personal_plugin_templates_controller.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/controllers/personal_plugin_templates_controller.rb rename to template_generator/app/controllers/personal_plugin_templates_controller.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/helpers/admin/plugin_templates_helper.rb b/template_generator/app/helpers/admin/plugin_templates_helper.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/helpers/admin/plugin_templates_helper.rb rename to template_generator/app/helpers/admin/plugin_templates_helper.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template.rb b/template_generator/app/models/plugin_template.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template.rb rename to template_generator/app/models/plugin_template.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_file.rb b/template_generator/app/models/plugin_template_file.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_file.rb rename to template_generator/app/models/plugin_template_file.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_intro.rb b/template_generator/app/models/plugin_template_intro.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_intro.rb rename to template_generator/app/models/plugin_template_intro.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_related.rb b/template_generator/app/models/plugin_template_related.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/models/plugin_template_related.rb rename to template_generator/app/models/plugin_template_related.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/_form.html.erb b/template_generator/app/views/admin/plugin_template_relateds/_form.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/_form.html.erb rename to template_generator/app/views/admin/plugin_template_relateds/_form.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/create.js.erb b/template_generator/app/views/admin/plugin_template_relateds/create.js.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/create.js.erb rename to template_generator/app/views/admin/plugin_template_relateds/create.js.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb b/template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb rename to template_generator/app/views/admin/plugin_template_relateds/destroy.js.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/edit.js.erb b/template_generator/app/views/admin/plugin_template_relateds/edit.js.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/edit.js.erb rename to template_generator/app/views/admin/plugin_template_relateds/edit.js.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/new.js.erb b/template_generator/app/views/admin/plugin_template_relateds/new.js.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/new.js.erb rename to template_generator/app/views/admin/plugin_template_relateds/new.js.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/update.js.erb b/template_generator/app/views/admin/plugin_template_relateds/update.js.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_template_relateds/update.js.erb rename to template_generator/app/views/admin/plugin_template_relateds/update.js.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form.html.erb b/template_generator/app/views/admin/plugin_templates/_form.html.erb similarity index 60% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form.html.erb rename to template_generator/app/views/admin/plugin_templates/_form.html.erb index 3b3bc5b..0b68dbf 100644 --- a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form.html.erb +++ b/template_generator/app/views/admin/plugin_templates/_form.html.erb @@ -40,51 +40,34 @@ <% @site_in_use_locales.each_with_index do |locale, i| %>
"> - +<% parse_again_start %> +
- +
- <%= 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 %> + locale_fields_input_fields
+<% parse_again_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| + plugin_template_related_files_text.each do |file| hash = {} hash["html"] = add_attribute("form_file", f, file.pluralize.to_sym) - hash["count"] = @course.send(file.pluralize).count rescue 0 + hash["count"] = @plugin_template.send(file.pluralize).count rescue 0 files_hash[file] = hash %>
- +
- <% if !@course.new_record? && hash["count"] > 0 %> + <% if !@plugin_template.new_record? && hash["count"] > 0 %>
- <% @course.send(file.pluralize).each_with_index do |obj, i| %> + <% @plugin_template.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} %> @@ -115,9 +98,6 @@
  • <%= t(:status) %>
  • -
  • - <%= t("personal_course.students") %> -
  • @@ -141,58 +121,42 @@
    - <% 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'} %> + <% members = !@plugin_template.member_profile.nil? ? @plugin_template.member_profile.to_a : [] %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'plugin_template[member_profile_id]', email_members: members,index:'0',select_name:'member_profile_id'} %>
    <% end %> - - +<% parse_again_start %> +
    - +
    - <%= 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'} ) %> + none_locale_fields_input_fields
    - - +<% parse_again_end %> +<% parse_again_start %> +
    - +
    - <%= f.select :course_category_id, CourseCategory.all.collect {|t| [ t.title, t.id ]} %> + <%= f.select :plugin_template_related_id, plugin_template_related.all.collect {|t| [ t.plugin_template_related_main_field, t.id ]} %>
    - - -
    - -
    - <%= f.select :course_semester_id, CourseSemester.all.collect {|t| [ t.title, t.id ]} %> -
    -
    - +<% parse_again_end %>
    -
    -
    -
    -
    - -
    - <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'course[student_ids][]', email_members: @course.students,index:'1',select_name:'student_ids'} %> -
    -
    -
    diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form_file.html.erb b/template_generator/app/views/admin/plugin_templates/_form_file.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_form_file.html.erb rename to template_generator/app/views/admin/plugin_templates/_form_file.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb b/template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb rename to template_generator/app/views/admin/plugin_templates/_plugin_template_related.html.erb diff --git a/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb b/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb new file mode 100644 index 0000000..312a64a --- /dev/null +++ b/template_generator/app/views/admin/plugin_templates/_plugin_templates.html.erb @@ -0,0 +1,7 @@ +<% @plugin_templates.each do |plugin_template| %> + +<% parse_again_start %> + backend_index_fields_contents +<% parse_again_end %> + +<% 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/template_generator/app/views/admin/plugin_templates/analysis.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis.html.erb rename to template_generator/app/views/admin/plugin_templates/analysis.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis_report.html.erb b/template_generator/app/views/admin/plugin_templates/analysis_report.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/analysis_report.html.erb rename to template_generator/app/views/admin/plugin_templates/analysis_report.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx b/template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx rename to template_generator/app/views/admin/plugin_templates/download_excel.xlsx.axlsx diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/edit.html.erb b/template_generator/app/views/admin/plugin_templates/edit.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/edit.html.erb rename to template_generator/app/views/admin/plugin_templates/edit.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb b/template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb rename to template_generator/app/views/admin/plugin_templates/frontend_setting.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/index.html.erb b/template_generator/app/views/admin/plugin_templates/index.html.erb similarity index 80% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/index.html.erb rename to template_generator/app/views/admin/plugin_templates/index.html.erb index 46fece1..4d10a89 100644 --- a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/index.html.erb +++ b/template_generator/app/views/admin/plugin_templates/index.html.erb @@ -1,11 +1,13 @@ - + <% parse_again_start %> + + <% parse_again_end %> - <%= render 'personal_plugin_templates' %> + <%= render 'plugin_templates' %>
    <%= t('personal_plugin_template.year') %><%= t('personal_plugin_template.backend_index_fields') %>
    diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/new.html.erb b/template_generator/app/views/admin/plugin_templates/new.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/new.html.erb rename to template_generator/app/views/admin/plugin_templates/new.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/setting.html.erb b/template_generator/app/views/admin/plugin_templates/setting.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/admin/plugin_templates/setting.html.erb rename to template_generator/app/views/admin/plugin_templates/setting.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/index.html.erb b/template_generator/app/views/personal_plugin_templates/index.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/index.html.erb rename to template_generator/app/views/personal_plugin_templates/index.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/show.html.erb b/template_generator/app/views/personal_plugin_templates/show.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/personal_plugin_templates/show.html.erb rename to template_generator/app/views/personal_plugin_templates/show.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb b/template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb rename to template_generator/app/views/plugin/personal_plugin_template/_profile.html.erb diff --git a/app/views/admin/personal_plugin_fields/template_generator/bin/rails b/template_generator/bin/rails similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/bin/rails rename to template_generator/bin/rails diff --git a/app/views/admin/personal_plugin_fields/template_generator/config/locales/en.yml b/template_generator/config/locales/en.yml similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/config/locales/en.yml rename to template_generator/config/locales/en.yml diff --git a/app/views/admin/personal_plugin_fields/template_generator/config/locales/zh_tw.yml b/template_generator/config/locales/zh_tw.yml similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/config/locales/zh_tw.yml rename to template_generator/config/locales/zh_tw.yml diff --git a/app/views/admin/personal_plugin_fields/template_generator/config/routes.rb b/template_generator/config/routes.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/config/routes.rb rename to template_generator/config/routes.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template.rb b/template_generator/lib/personal_plugin_template.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template.rb rename to template_generator/lib/personal_plugin_template.rb diff --git a/app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/engine.rb b/template_generator/lib/personal_plugin_template/engine.rb similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/lib/personal_plugin_template/engine.rb rename to template_generator/lib/personal_plugin_template/engine.rb diff --git a/template_generator/lib/personal_plugin_template/version.rb b/template_generator/lib/personal_plugin_template/version.rb new file mode 100644 index 0000000..9054351 --- /dev/null +++ b/template_generator/lib/personal_plugin_template/version.rb @@ -0,0 +1,3 @@ +module PersonalPluginTemplate + VERSION = "0.0.1" +end diff --git a/app/views/admin/personal_plugin_fields/template_generator/lib/tasks/personal_plugin_template_tasks.rake b/template_generator/lib/tasks/personal_plugin_template_tasks.rake similarity index 100% rename from app/views/admin/personal_plugin_fields/template_generator/lib/tasks/personal_plugin_template_tasks.rake rename to template_generator/lib/tasks/personal_plugin_template_tasks.rake diff --git a/template_generator/modules/personal_plugin_template/index.html.erb b/template_generator/modules/personal_plugin_template/index.html.erb new file mode 100644 index 0000000..f777f69 --- /dev/null +++ b/template_generator/modules/personal_plugin_template/index.html.erb @@ -0,0 +1,27 @@ + + + + + <% parse_again_start %> + + <% parse_again_end %> + + + + + <% parse_again_start %> + + <% parse_again_end %> + + +

    {{widget-title}}

    {{th_col_name_to_show_in_index_page_arr}}
    {{col_name_to_show_in_index_page_arr}}
    +{{pagination_goes_here}} + + \ No newline at end of file diff --git a/template_generator/modules/personal_plugin_template/info.json b/template_generator/modules/personal_plugin_template/info.json new file mode 100644 index 0000000..cda3d13 --- /dev/null +++ b/template_generator/modules/personal_plugin_template/info.json @@ -0,0 +1,12 @@ +{ + "frontend": [ + { + "filename" : "index", + "name" : { + "zh_tw" : "1. 列表", + "en" : "1. List" + }, + "thumbnail" : "thumb.png" + } + ] +} \ No newline at end of file diff --git a/template_generator/modules/personal_plugin_template/show.html.erb b/template_generator/modules/personal_plugin_template/show.html.erb new file mode 100644 index 0000000..58a66d2 --- /dev/null +++ b/template_generator/modules/personal_plugin_template/show.html.erb @@ -0,0 +1,8 @@ + + + + + + + +
    {{title}}{{value}}
    \ No newline at end of file diff --git a/template_generator/modules/personal_plugin_template/thumbs/thumb.png b/template_generator/modules/personal_plugin_template/thumbs/thumb.png new file mode 100644 index 0000000000000000000000000000000000000000..266af5606742714c262a949cd58aedc2b84b1959 GIT binary patch literal 4075 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