plugin.rb 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # name: discourse-custom-wizard
  2. # about: Create custom wizards
  3. # version: 0.1
  4. # authors: Angus McLeod
  5. register_asset 'stylesheets/wizard_custom_admin.scss'
  6. config = Rails.application.config
  7. config.assets.paths << Rails.root.join("plugins", "discourse-custom-wizard", "assets", "javascripts")
  8. config.assets.paths << Rails.root.join("plugins", "discourse-custom-wizard", "assets", "stylesheets", "wizard")
  9. after_initialize do
  10. UserHistory.actions[:custom_wizard_step] = 100
  11. require_dependency "application_controller"
  12. module ::CustomWizard
  13. class Engine < ::Rails::Engine
  14. engine_name "custom_wizard"
  15. isolate_namespace CustomWizard
  16. end
  17. end
  18. CustomWizard::Engine.routes.draw do
  19. get ':wizard_id' => 'wizard#index'
  20. get ':wizard_id/steps' => 'steps#index'
  21. get ':wizard_id/steps/:step_id' => 'wizard#index'
  22. put ':wizard_id/steps/:step_id' => 'steps#update'
  23. end
  24. require_dependency 'admin_constraint'
  25. Discourse::Application.routes.append do
  26. mount ::CustomWizard::Engine, at: 'w'
  27. scope module: 'custom_wizard', constraints: AdminConstraint.new do
  28. get 'admin/wizards' => 'admin#index'
  29. get 'admin/wizards/field-types' => 'admin#field_types'
  30. get 'admin/wizards/custom' => 'admin#index'
  31. get 'admin/wizards/custom/new' => 'admin#index'
  32. get 'admin/wizards/custom/all' => 'admin#custom_wizards'
  33. get 'admin/wizards/custom/:wizard_id' => 'admin#find_wizard'
  34. put 'admin/wizards/custom/save' => 'admin#save'
  35. delete 'admin/wizards/custom/remove' => 'admin#remove'
  36. get 'admin/wizards/submissions' => 'admin#index'
  37. get 'admin/wizards/submissions/all' => 'admin#submissions'
  38. get 'admin/wizards/submissions/:wizard_id' => 'admin#find_submissions'
  39. end
  40. end
  41. load File.expand_path('../lib/builder.rb', __FILE__)
  42. load File.expand_path('../lib/field.rb', __FILE__)
  43. load File.expand_path('../lib/step_updater.rb', __FILE__)
  44. load File.expand_path('../lib/template.rb', __FILE__)
  45. load File.expand_path('../lib/wizard.rb', __FILE__)
  46. load File.expand_path('../lib/wizard_edits.rb', __FILE__)
  47. load File.expand_path('../controllers/wizard.rb', __FILE__)
  48. load File.expand_path('../controllers/steps.rb', __FILE__)
  49. load File.expand_path('../controllers/admin.rb', __FILE__)
  50. end