From ae918976a30f8c9b561e216206dd309397c69017 Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Mon, 5 Apr 2021 21:53:34 +0530 Subject: [PATCH] DEV: add sprockets directive to require discourse folders --- assets/javascripts/wizard-custom.js | 71 +---------------------------- plugin.rb | 12 +++++ 2 files changed, 14 insertions(+), 69 deletions(-) diff --git a/assets/javascripts/wizard-custom.js b/assets/javascripts/wizard-custom.js index 5d18328f..8b30ad94 100644 --- a/assets/javascripts/wizard-custom.js +++ b/assets/javascripts/wizard-custom.js @@ -1,43 +1,4 @@ -//= require discourse/app/lib/autocomplete -//= require discourse/app/lib/utilities -//= require discourse/app/lib/offset-calculator -//= require discourse/app/lib/lock-on -//= require discourse/app/lib/text-direction -//= require discourse/app/lib/to-markdown -//= require discourse/app/lib/load-script -//= require discourse/app/lib/url -//= require discourse/app/lib/ajax -//= require discourse/app/lib/ajax-error -//= require discourse/app/lib/page-visible -//= require discourse/app/lib/logout -//= require discourse/app/lib/render-tag -//= require discourse/app/lib/notification-levels -//= require discourse/app/lib/computed -//= require discourse/app/lib/user-search -//= require discourse/app/lib/text -//= require discourse/app/lib/formatter -//= require discourse/app/lib/quote -//= require discourse/app/lib/link-mentions -//= require discourse/app/lib/link-hashtags -//= require discourse/app/lib/category-hashtags -//= require discourse/app/lib/tag-hashtags -//= require discourse/app/lib/uploads -//= require discourse/app/lib/category-tag-search -//= require discourse/app/lib/intercept-click -//= require discourse/app/lib/show-modal -//= require discourse/app/lib/key-value-store -//= require discourse/app/lib/settings -//= require discourse/app/lib/user-presence -//= require discourse/app/lib/hash -//= require discourse/app/lib/bookmark -//= require discourse/app/lib/put-cursor-at-end -//= require discourse/app/lib/safari-hacks -//= require discourse/app/lib/preload-store -//= require discourse/app/lib/topic-fancy-title -//= require discourse/app/lib/cookie -//= require discourse/app/lib/public-js-versions -//= require discourse/app/lib/load-oneboxes -//= require discourse/app/lib/highlight-syntax +//= require_tree_discourse discourse/app/lib //= require discourse/app/mixins/singleton //= require discourse/app/mixins/upload @@ -46,35 +7,7 @@ //= require message-bus -//= require discourse/app/models/login-method -//= require discourse/app/models/permission-type -//= require discourse/app/models/archetype -//= require discourse/app/models/rest -//= require discourse/app/models/site -//= require discourse/app/models/category -//= require discourse/app/models/session -//= require discourse/app/models/post-action-type -//= require discourse/app/models/trust-level -//= require discourse/app/models/store -//= require discourse/app/models/result-set -//= require discourse/app/models/bookmark -//= require discourse/app/models/user -//= require discourse/app/models/user-stream -//= require discourse/app/models/user-action -//= require discourse/app/models/user-action-group -//= require discourse/app/models/user-posts-stream -//= require discourse/app/models/badge -//= require discourse/app/models/badge-grouping -//= require discourse/app/models/user-badge -//= require discourse/app/models/topic -//= require discourse/app/models/action-summary -//= require discourse/app/models/user-action-stat -//= require discourse/app/models/user-drafts-stream -//= require discourse/app/models/user-draft -//= require discourse/app/models/composer -//= require discourse/app/models/draft -//= require discourse/app/models/group -//= require discourse/app/models/group-history +//= require_tree_discourse discourse/app/models //= require discourse/app/helpers/category-link //= require discourse/app/helpers/user-avatar diff --git a/plugin.rb b/plugin.rb index 0a272aed..48f0e0ef 100644 --- a/plugin.rb +++ b/plugin.rb @@ -97,6 +97,18 @@ after_initialize do load File.expand_path(path, __FILE__) end + add_to_class(::Sprockets::DirectiveProcessor, :process_require_tree_discourse_directive ) do |path = "."| + discourse_asset_path = "#{Rails.root}/app/assets/javascripts/" + path = File.expand_path(path, discourse_asset_path) + stat = @environment.stat(path) + + if stat && stat.directory? + require_paths(*@environment.stat_sorted_tree_with_dependencies(path)) + else + raise ArgumentError, "#{path} not found in discourse core" + end + end + add_class_method(:wizard, :user_requires_completion?) do |user| wizard_result = self.new(user).requires_completion? return wizard_result if wizard_result