Sha256: 0724ceae77355c07aad8d15513156bb7c2907b0f81198fdc013b9e1e1a929c5d

Contents?: true

Size: 951 Bytes

Versions: 15

Compression:

Stored size: 951 Bytes

Contents

require "#{File.dirname(__FILE__)}/abstract_note"

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

15 entries across 15 versions & 2 rubygems

Version Path
rails-footnotes-3.7.2 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.1 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.1.pre lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.10 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.9 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.8 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.7 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.6 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.5 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.4 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.3 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.7.0 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.2 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre.1 lib/rails-footnotes/notes/files_note.rb
rails3-footnotes-4.0.0.pre lib/rails-footnotes/notes/files_note.rb