Sha256: ef6a6f0320816e7cbd1a556bdd234dfdb3c8a11550b1495310cdca96b23fe0d1

Contents?: true

Size: 951 Bytes

Versions: 25

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

25 entries across 25 versions & 8 rubygems

Version Path
artofmission-rails-footnotes-3.6.0.1 lib/rails-footnotes/notes/files_note.rb
artofmission-rails-footnotes-3.6.2 lib/rails-footnotes/notes/files_note.rb
ceritium-rails-footnotes-3.4.1.1 lib/rails-footnotes/notes/files_note.rb
ceritium-rails-footnotes-3.4.1 lib/rails-footnotes/notes/files_note.rb
ceritium-rails-footnotes-3.4 lib/rails-footnotes/notes/files_note.rb
josevalim-rails-footnotes-3.3.1 lib/notes/files_note.rb
josevalim-rails-footnotes-3.3.2 lib/notes/files_note.rb
josevalim-rails-footnotes-3.4.1 lib/rails-footnotes/notes/files_note.rb
josevalim-rails-footnotes-3.4 lib/rails-footnotes/notes/files_note.rb
josevalim-rails-footnotes-3.5.0 lib/rails-footnotes/notes/files_note.rb
josevalim-rails-footnotes-3.6.0 lib/rails-footnotes/notes/files_note.rb
josevalim-rails-footnotes-3.6.1 lib/rails-footnotes/notes/files_note.rb
josevalim-rails-footnotes-3.6.2 lib/rails-footnotes/notes/files_note.rb
lexrupy-rails-footnotes-3.3.2 lib/rails-footnotes/notes/files_note.rb
lexrupy-rails-footnotes-3.4.1 lib/rails-footnotes/notes/files_note.rb
lexrupy-rails-footnotes-3.4 lib/rails-footnotes/notes/files_note.rb
omghax-rails-footnotes-3.6.1 lib/rails-footnotes/notes/files_note.rb
omghax-rails-footnotes-3.6.2 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.6.7 lib/rails-footnotes/notes/files_note.rb
rails-footnotes-3.6.6 lib/rails-footnotes/notes/files_note.rb