mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 18:05:48 +08:00
Update SourceURL to work better
This commit is contained in:
parent
e83bf7dc07
commit
788b66e4a3
|
@ -1,3 +1,5 @@
|
||||||
require 'discourse_iife'
|
require 'discourse_iife'
|
||||||
|
require 'source_url'
|
||||||
|
|
||||||
Rails.application.assets.register_preprocessor('application/javascript', DiscourseIIFE)
|
Rails.application.assets.register_preprocessor('application/javascript', DiscourseIIFE)
|
||||||
|
Rails.application.assets.register_postprocessor('application/javascript', SourceURL)
|
||||||
|
|
|
@ -32,7 +32,6 @@ class DiscourseIIFE < Sprockets::Processor
|
||||||
.sub("/app/assets/javascripts", "")
|
.sub("/app/assets/javascripts", "")
|
||||||
.sub("/test/javascripts", "")
|
.sub("/test/javascripts", "")
|
||||||
res << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['/assets#{req_path}'] = #{data.to_json};\n"
|
res << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['/assets#{req_path}'] = #{data.to_json};\n"
|
||||||
res << "\n//@ sourceURL=/#{context.logical_path}\n"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
res
|
res
|
||||||
|
|
|
@ -127,7 +127,6 @@ module Tilt
|
||||||
req_path = "/assets/#{scope.logical_path}.#{extension}"
|
req_path = "/assets/#{scope.logical_path}.#{extension}"
|
||||||
|
|
||||||
@output << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['#{req_path}'] = #{data.to_json};\n"
|
@output << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['#{req_path}'] = #{data.to_json};\n"
|
||||||
@output << "\n//@ sourceURL=/#{scope.logical_path}\n"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@output
|
@output
|
||||||
|
|
15
lib/source_url.rb
Normal file
15
lib/source_url.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
class SourceURL < Tilt::Template
|
||||||
|
self.default_mime_type = 'application/javascript'
|
||||||
|
|
||||||
|
def prepare
|
||||||
|
end
|
||||||
|
|
||||||
|
def evaluate(scope, locals, &block)
|
||||||
|
code = ''
|
||||||
|
code << 'eval('
|
||||||
|
code << data.inspect
|
||||||
|
code << " + \"\\n//@ sourceURL=/#{scope.logical_path}\""
|
||||||
|
code << ");\n"
|
||||||
|
code
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user