0
@@ -15,15 +15,15 @@ class FootnoteFilter
0
cattr_accessor :no_style, :abs_root, :textmate_prefix
0
self.textmate_prefix = "txmt://open?url=file://"
0
attr_accessor :body, :abs_root
0
def self.filter(controller)
0
return if controller.render_without_footnotes
0
filter = FootnoteFilter.new(controller)
0
def initialize(controller)
0
@controller = controller
0
@template = controller.instance_variable_get("@template")
0
@@ -31,7 +31,7 @@ class FootnoteFilter
0
self.abs_root = File.expand_path(RAILS_ROOT)
0
if performed_render? and first_render?
0
if ["html.erb", "haml", "rhtml", "rxhtml"].include?(template_extension) && (content_type =~ /html/ || content_type.nil?) && !xhr?
0
@@ -44,70 +44,70 @@ class FootnoteFilter
0
# Discard footnotes if there are any problems
0
RAILS_DEFAULT_LOGGER.error "Textmate Footnotes Exception: #{e}\n#{e.backtrace.join("\n")}"
0
# Some controller classes come with the Controller:: module and some don't
0
# (anyone know why? -- Duane)
0
def controller_filename
0
File.join(abs_root, "app", "controllers", "#{@controller.class.to_s.underscore}.rb").
0
sub('/controllers/controllers/', '/controllers/')
0
@controller_text ||= IO.read(controller_filename)
0
(controller_text =~ /def\s+#{@controller.action_name}[\s\(]/)
0
def controller_line_number
0
controller_text.line_from_index(index_of_method)
0
@controller.instance_variable_get("@performed_render")
0
@template.respond_to?(:first_render) and @template.first_render
0
@controller.request.xhr?
0
@template.first_render.sub(/\.(html\.erb|rhtml|rxhtml|rxml|rjs)$/, "")
0
@template.first_render.scan(/\.(html\.erb|rhtml|rxhtml|rxml|rjs)$/).flatten.first ||
0
@template.pick_template_extension(template_path).to_s
0
File.expand_path(@template.send(:full_template_path, template_path, template_extension))
0
["html.erb", "rhtml"].each do |extension|
0
path = File.expand_path(@template.send(:full_template_path, @controller.active_layout, extension))
0
return path if File.exist?(path)
0
@controller.response.headers['Content-Type']
0
@stylesheet_files ||= @body.scan(/<link[^>]+href\s*=\s*['"]([^>?'"]+)/im).flatten
0
@javascript_files ||= @body.scan(/<script[^>]+src\s*=\s*['"]([^>?'"]+)/im).flatten
0
@@ -115,15 +115,15 @@ class FootnoteFilter
0
(index_of_method ? "&line=#{controller_line_number + 1}&column=3" : "")
0
escape(textmate_prefix + template_file_name)
0
escape(textmate_prefix + layout_file_name)
0
insert_text :before, /<\/head>/i, <<-HTML
0
<!-- TextMate Footnotes Style -->
0
@@ -136,13 +136,13 @@ class FootnoteFilter
0
<!-- End TextMate Footnotes Style -->
0
def tm_footnotes_toggle(id)
0
"s = document.getElementById('#{id}').style; if(s.display == 'none') { s.display = '' } else { s.display = 'none' }"
0
footnotes_html = <<-HTML
0
<!-- TextMate Footnotes -->
0
<div style="clear:both"></div>
0
@@ -182,7 +182,7 @@ class FootnoteFilter
0
insert_text :before, /<\/body>/i, footnotes_html
0
@@ -198,7 +198,7 @@ class FootnoteFilter
0
def asset_file_links(link_text, files)
0
return '' if files.size == 0
0
links = files.map do |filename|
0
@@ -218,7 +218,7 @@ class FootnoteFilter
0
# Return the link that will open the 'extra html' div
0
%{ | <a href="#" onclick="#{tm_footnotes_toggle('tm_footnotes_' + link_text.underscore.gsub(' ', '_') )}; return false">#{link_text}</a>}
0
def indent(indentation, text)
0
initial_indentation = lines.first.scan(/^(\s+)/).flatten.first
0
@@ -250,7 +250,7 @@ class FootnoteFilter
0
@body.insert index, indent(indentation, new_text)
0
text.gsub("&", "&").gsub("<", "<").gsub(">", ">")
Comments
No one has commented yet.