plugin.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # name: discourse-custom-wizard
  2. # about: Allows the admins to create custom user input forms
  3. # version: 0.1
  4. # authors: Angus McLeod
  5. register_asset 'stylesheets/custom-wizard.scss'
  6. config = Rails.application.config
  7. config.assets.paths << Rails.root.join("plugins", "discourse-custom-wizard", "assets", "javascripts")
  8. after_initialize do
  9. require_dependency "application_controller"
  10. module ::CustomWizard
  11. class Engine < ::Rails::Engine
  12. engine_name "custom_wizard"
  13. isolate_namespace CustomWizard
  14. end
  15. end
  16. load File.expand_path('../lib/builder.rb', __FILE__)
  17. load File.expand_path('../lib/wizard.rb', __FILE__)
  18. load File.expand_path('../app/controllers/wizard.rb', __FILE__)
  19. load File.expand_path('../app/controllers/steps.rb', __FILE__)
  20. load File.expand_path('../app/controllers/admin.rb', __FILE__)
  21. CustomWizard::Engine.routes.draw do
  22. get ':name' => 'wizard#index'
  23. get ':name/steps' => 'steps#index'
  24. get ':name/steps/:id' => 'wizard#index'
  25. put ':name/steps/:id' => 'steps#update'
  26. end
  27. require_dependency 'admin_constraint'
  28. Discourse::Application.routes.append do
  29. namespace :wizard do
  30. mount ::CustomWizard::Engine, at: 'custom'
  31. end
  32. scope module: 'custom_wizard', constraints: AdminConstraint.new do
  33. get 'admin/wizards/custom' => 'admin#index'
  34. get 'admin/wizards/custom/new' => 'admin#index'
  35. get 'admin/wizards/custom/all' => 'admin#all'
  36. get 'admin/wizards/custom/:id' => 'admin#find'
  37. put 'admin/wizards/custom/save' => 'admin#save'
  38. delete 'admin/wizards/custom/remove' => 'admin#remove'
  39. end
  40. end
  41. end