mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 12:11:16 -05:00
Revert "eliminate a class of v8 initialization bugs due to concurrency in sidekiq"
This reverts commit 883db5798b
.
This commit is contained in:
parent
2e640baffd
commit
f1a693c8b7
1 changed files with 16 additions and 29 deletions
|
@ -77,7 +77,6 @@ module PrettyText
|
||||||
end
|
end
|
||||||
|
|
||||||
@mutex = Mutex.new
|
@mutex = Mutex.new
|
||||||
@ctx_init = Mutex.new
|
|
||||||
|
|
||||||
def self.mention_matcher
|
def self.mention_matcher
|
||||||
Regexp.new("(\@[a-zA-Z0-9_]{#{User.username_length.begin},#{User.username_length.end}})")
|
Regexp.new("(\@[a-zA-Z0-9_]{#{User.username_length.begin},#{User.username_length.end}})")
|
||||||
|
@ -87,13 +86,14 @@ module PrettyText
|
||||||
Rails.root
|
Rails.root
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_new_context
|
def self.v8
|
||||||
ctx = V8::Context.new
|
return @ctx unless @ctx.nil?
|
||||||
|
|
||||||
ctx["helpers"] = Helpers.new
|
@ctx = V8::Context.new
|
||||||
|
|
||||||
ctx_load(ctx,
|
@ctx["helpers"] = Helpers.new
|
||||||
"app/assets/javascripts/external/md5.js",
|
|
||||||
|
ctx_load( "app/assets/javascripts/external/md5.js",
|
||||||
"app/assets/javascripts/external/lodash.js",
|
"app/assets/javascripts/external/lodash.js",
|
||||||
"app/assets/javascripts/external/Markdown.Converter.js",
|
"app/assets/javascripts/external/Markdown.Converter.js",
|
||||||
"app/assets/javascripts/external/twitter-text-1.5.0.js",
|
"app/assets/javascripts/external/twitter-text-1.5.0.js",
|
||||||
|
@ -101,40 +101,27 @@ module PrettyText
|
||||||
"app/assets/javascripts/external/rsvp.js",
|
"app/assets/javascripts/external/rsvp.js",
|
||||||
Rails.configuration.ember.handlebars_location)
|
Rails.configuration.ember.handlebars_location)
|
||||||
|
|
||||||
ctx.eval("var Discourse = {}; Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
|
@ctx.eval("var Discourse = {}; Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
|
||||||
ctx.eval("var window = {}; window.devicePixelRatio = 2;") # hack to make code think stuff is retina
|
@ctx.eval("var window = {}; window.devicePixelRatio = 2;") # hack to make code think stuff is retina
|
||||||
ctx.eval("var I18n = {}; I18n.t = function(a,b){ return helpers.t(a,b); }");
|
@ctx.eval("var I18n = {}; I18n.t = function(a,b){ return helpers.t(a,b); }");
|
||||||
|
|
||||||
ctx_load(ctx,
|
ctx_load( "app/assets/javascripts/discourse/components/bbcode.js",
|
||||||
"app/assets/javascripts/discourse/components/bbcode.js",
|
|
||||||
"app/assets/javascripts/discourse/components/utilities.js",
|
"app/assets/javascripts/discourse/components/utilities.js",
|
||||||
"app/assets/javascripts/discourse/components/markdown.js")
|
"app/assets/javascripts/discourse/components/markdown.js")
|
||||||
|
|
||||||
# Load server side javascripts
|
# Load server side javascripts
|
||||||
if DiscoursePluginRegistry.server_side_javascripts.present?
|
if DiscoursePluginRegistry.server_side_javascripts.present?
|
||||||
DiscoursePluginRegistry.server_side_javascripts.each do |ssjs|
|
DiscoursePluginRegistry.server_side_javascripts.each do |ssjs|
|
||||||
ctx.load(ssjs)
|
@ctx.load(ssjs)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ctx['quoteTemplate'] = File.open(app_root + 'app/assets/javascripts/discourse/templates/quote.js.shbrs') {|f| f.read}
|
@ctx['quoteTemplate'] = File.open(app_root + 'app/assets/javascripts/discourse/templates/quote.js.shbrs') {|f| f.read}
|
||||||
ctx['quoteEmailTemplate'] = File.open(app_root + 'lib/assets/quote_email.js.shbrs') {|f| f.read}
|
@ctx['quoteEmailTemplate'] = File.open(app_root + 'lib/assets/quote_email.js.shbrs') {|f| f.read}
|
||||||
ctx.eval("HANDLEBARS_TEMPLATES = {
|
@ctx.eval("HANDLEBARS_TEMPLATES = {
|
||||||
'quote': Handlebars.compile(quoteTemplate),
|
'quote': Handlebars.compile(quoteTemplate),
|
||||||
'quote_email': Handlebars.compile(quoteEmailTemplate),
|
'quote_email': Handlebars.compile(quoteEmailTemplate),
|
||||||
};")
|
};")
|
||||||
|
|
||||||
ctx
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.v8
|
|
||||||
return @ctx if @ctx
|
|
||||||
|
|
||||||
# ensure we only init one of these
|
|
||||||
@ctx_init.synchronize do
|
|
||||||
return @ctx if @ctx
|
|
||||||
@ctx = create_new_context
|
|
||||||
end
|
|
||||||
@ctx
|
@ctx
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -276,9 +263,9 @@ module PrettyText
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def self.ctx_load(ctx, *files)
|
def self.ctx_load(*files)
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
ctx.load(app_root + file)
|
@ctx.load(app_root + file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue