Sha256: 0b7a8781fc5b690a03ef773688b6c6283568ad290b019287e36633cb51c0cd77

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

class Lolita::InfoController < ApplicationController
  @@properties = []

  def index
    if Lolita.mappings.any?
      return redirect_to(lolita_resources_path(Lolita.mappings.values.first))
    end
    render :layout => false
  end

  def properties
    if request.local?
      render :inline => to_html
    else
      render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
    end
  end

  private

  def self.property(name, value = nil)
    value ||= yield
    @@properties << [name, value] if value
    rescue Exception
  end

  def to_html
    (table = '<table>').tap do
      @@properties.each do |(name, value)|
        table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
        formatted_value = if value.kind_of?(Array)
              "<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
            else
              CGI.escapeHTML(value.to_s)
            end
        table << %(<td class="value">#{formatted_value}</td></tr>)
      end
      table << '</table>'
    end
  end
    
  property 'Lolita version', "#{LOLITA_VERSION}"

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lolita-3.2.0.rc.6 app/controllers/lolita/info_controller.rb
lolita-3.2.0.rc.5 app/controllers/lolita/info_controller.rb
lolita-3.2.0.rc.4 app/controllers/lolita/info_controller.rb
lolita-3.2.0.rc.3 app/controllers/lolita/info_controller.rb
lolita-3.2.0.rc2 app/controllers/lolita/info_controller.rb
lolita-3.2.0.rc1 app/controllers/lolita/info_controller.rb
lolita-3.1.17 app/controllers/lolita/info_controller.rb
lolita-3.1.16 app/controllers/lolita/info_controller.rb
lolita-3.1.15 app/controllers/lolita/info_controller.rb