Use html_for_upload instead of broken v8 stuff

This commit is contained in:
michael@discoursehosting.com 2017-04-02 20:25:08 +00:00
parent e788ac3351
commit 332d655a1d

View File

@ -391,30 +391,8 @@ class ImportScripts::Smf2 < ImportScripts::Base
return opts[:ignore_quotes] ? body : convert_quotes(body) return opts[:ignore_quotes] ? body : convert_quotes(body)
end end
def v8
@ctx ||= begin
ctx = PrettyText.create_new_context
PrettyText.decorate_context(ctx)
# provides toHumanSize but restores I18n.t which we need to fix again
ctx.load(Rails.root + "app/assets/javascripts/locales/i18n.js")
helper = PrettyText::Helpers.new
ctx['I18n']['t'] = proc {|_,key,opts| helper.t(key, opts) }
# from i18n_helpers.js -- can't load it directly because Ember is missing
ctx.eval(<<-'end')
var oldI18ntoHumanSize = I18n.toHumanSize;
I18n.toHumanSize = function(number, options) {
options = options || {};
options.format = I18n.t("number.human.storage_units.format");
return oldI18ntoHumanSize.apply(this, [number, options]);
};
end
ctx
end
end
def get_upload_markdown(upload) def get_upload_markdown(upload)
@func ||= v8.eval("Discourse.Utilities.getUploadMarkdown") html_for_upload(upload, upload.original_filename)
return @func.call(upload).to_s
end end
def convert_quotes(body) def convert_quotes(body)