Sha256: be4cb8e9e836eb42de22c4f94ba6c0764f1d916394e3627889066a42a53398cd

Contents?: true

Size: 901 Bytes

Versions: 7

Compression:

Stored size: 901 Bytes

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>#{@files.join("</li><li>")}</li></ul>"
        end
      end

      def valid?
        prefix?
      end

      protected
        def scan_text(text)
          []
        end

        def parse_files!
          @files.collect! do |filename|
            if filename =~ %r{^/}
              full_filename = File.join(File.expand_path(Rails.root), 'public', filename)
              %[<a href="#{Footnotes::Filter.prefix(full_filename, 1, 1)}">#{filename}</a>]
            else
              %[<a href="#{filename}">#{filename}</a>]
            end
          end
        end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails-footnotes-3.7.5 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.5.rc4 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.5.rc3 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.5.rc2 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.5.rc1 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.4 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.3 lib/rails-footnotes/notes/files_note.rb