Sha256: 7e2c24ffd5e3c07f4086483447458038dcba1f7525a3597838d8256467238827
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
module Footnotes module Notes class FilesNote < AbstractNote def initialize(controller) @files = scan_text(controller.response.body) parse_files! end def row :edit end def content if @files.empty? "" else "<ul><li>%s</li></ul>" % @files.join("</li><li>") end end def valid? prefix? end protected def scan_text(text) [] end def parse_files! asset_paths = Rails.application.config.assets.paths linked_files = [] @files.collect do |file| base_name = File.basename(file) asset_paths.each do |asset_path| results = Dir[File.expand_path(base_name, asset_path) + '*'] results.each do |r| linked_files << %[<a href="#{Footnotes::Filter.prefix(r, 1, 1)}">#{File.basename(r)}</a>] end break if results.present? end end @files = linked_files end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rails-footnotes-4.1.8 | lib/rails-footnotes/notes/files_note.rb |
rails-footnotes-4.1.7 | lib/rails-footnotes/notes/files_note.rb |
rails-footnotes-4.1.6 | lib/rails-footnotes/notes/files_note.rb |