Update raw templating handling to new asset pipeline
Dieser Commit ist enthalten in:
Ursprung
39790bf11e
Commit
05f96beac1
5 geänderte Dateien mit 25 neuen und 12 gelöschten Zeilen
|
@ -1,7 +1,5 @@
|
|||
window.Discourse = {}
|
||||
window.Wizard = {};
|
||||
Wizard.SiteSettings = {};
|
||||
Wizard.RAW_TEMPLATES = {};
|
||||
Discourse.__widget_helpers = {};
|
||||
window.__DISCOURSE_RAW_TEMPLATES = {};
|
||||
Discourse.SiteSettings = Wizard.SiteSettings;
|
|
@ -117,6 +117,7 @@
|
|||
//= require discourse/app/templates/emoji-selector-autocomplete
|
||||
//= require discourse/app/templates/user-selector-autocomplete
|
||||
|
||||
//= require discourse/app/initializers/jquery-plugins
|
||||
//= require discourse/app/pre-initializers/sniff-capabilities
|
||||
|
||||
//= require ember-addons/decorator-alias
|
||||
|
|
|
@ -8,24 +8,30 @@ Discourse.unofficial_plugins.each do |plugin|
|
|||
files = []
|
||||
|
||||
plugin.each_globbed_asset do |f, is_dir|
|
||||
files.push(f) if f.include? "raw.hbs"
|
||||
files.push(f) if f.include? "hbr"
|
||||
end
|
||||
|
||||
Dir.glob("#{Rails.root}/app/assets/javascripts/discourse/templates/*.raw.hbs").each do |f|
|
||||
Dir.glob("#{Rails.root}/app/assets/javascripts/discourse/app/templates/*.hbr").each do |f|
|
||||
files.push(f)
|
||||
end
|
||||
|
||||
files.each do |f|
|
||||
name = File.basename(f, ".raw.hbs")
|
||||
name = File.basename(f, ".hbr")
|
||||
compiled = Barber::Precompiler.new().compile(File.read(f))
|
||||
result << "
|
||||
(function() {
|
||||
if ('Wizard' in window) {
|
||||
window.__DISCOURSE_RAW_TEMPLATES['javascripts/#{name}'] = requirejs('discourse-common/lib/raw-handlebars').template(#{compiled});
|
||||
}
|
||||
const { addRawTemplate } = requirejs('discourse-common/lib/raw-templates');
|
||||
addRawTemplate(#{compiled});
|
||||
})();
|
||||
"
|
||||
end
|
||||
|
||||
result << "
|
||||
(function() {
|
||||
const rawTemplates = requirejs('discourse-common/lib/raw-templates');
|
||||
window.__DISCOURSE_RAW_TEMPLATES = rawTemplates.__DISCOURSE_RAW_TEMPLATES;
|
||||
})();
|
||||
"
|
||||
end
|
||||
end
|
||||
result
|
||||
|
|
|
@ -3,7 +3,11 @@ import { default as computed, on } from "discourse-common/utils/decorators";
|
|||
import { findRawTemplate } from "discourse-common/lib/raw-templates";
|
||||
import { throttle } from "@ember/runloop";
|
||||
import { scheduleOnce } from "@ember/runloop";
|
||||
import { safariHacksDisabled } from "discourse/lib/utilities";
|
||||
import {
|
||||
safariHacksDisabled,
|
||||
caretPosition,
|
||||
inCodeBlock,
|
||||
} from "discourse/lib/utilities";
|
||||
import highlightSyntax from "discourse/lib/highlight-syntax";
|
||||
import { getToken } from "wizard/lib/ajax";
|
||||
import { validateUploadedFiles } from "discourse/lib/uploads";
|
||||
|
@ -29,14 +33,18 @@ export default ComposerEditor.extend({
|
|||
const $preview = $(this.element.querySelector(".d-editor-preview-wrapper"));
|
||||
|
||||
if (this.siteSettings.enable_mentions) {
|
||||
console.log('initializing autocomplete', findRawTemplate("user-selector-autocomplete"))
|
||||
$input.autocomplete({
|
||||
template: findRawTemplate("user-selector-autocomplete"),
|
||||
dataSource: (term) => this.userSearchTerm.call(this, term),
|
||||
key: "@",
|
||||
transformComplete: (v) => v.username || v.name,
|
||||
afterComplete() {
|
||||
afterComplete: (value) => {
|
||||
this.composer.set("reply", value);
|
||||
scheduleOnce("afterRender", () => $input.blur().focus());
|
||||
},
|
||||
triggerRule: (textarea) =>
|
||||
!inCodeBlock(textarea.value, caretPosition(textarea))
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
<%= preload_script "ember_jquery" %>
|
||||
<%= preload_script "wizard-vendor" %>
|
||||
<%= preload_script "wizard-application" %>
|
||||
<%= preload_script "wizard-custom-lib" %>
|
||||
<%= preload_script "wizard-custom-globals" %>
|
||||
<%= preload_script "wizard-raw-templates" %>
|
||||
<%= preload_script "wizard-custom" %>
|
||||
<%= preload_script "wizard-plugin" %>
|
||||
<%= preload_script "pretty-text-bundle" %>
|
||||
|
@ -41,7 +42,6 @@
|
|||
|
||||
<%- if current_user %>
|
||||
<%= preload_script 'wizard-custom-start' %>
|
||||
<%= preload_script 'wizard-raw-templates' %>
|
||||
<%- else %>
|
||||
<%= preload_script 'wizard-custom-guest' %>
|
||||
<%- end %>
|
||||
|
|
Laden …
In neuem Issue referenzieren