Sha256: b425b44df8ff4a348cb13a0ec8268c093863276a36134dbfe722c210b96ce63c

Contents?: true

Size: 1.52 KB

Versions: 10

Compression:

Stored size: 1.52 KB

Contents

module Tenon
  class WarningGenerator
    def self.generate(root_path)
      new.warnings(root_path)
    end

    def warnings(root_path)
      warnings = []
      warnings << "Your site needs a title.<br /><br /><a class='btn btn-comp btn-block' href='#{root_path}settings'>OK</a>".html_safe if Tenon::MySettings.site_title.blank?
      warnings << "Your site needs an address.<br /><br /><a class='btn btn-comp btn-block' href='#{root_path}settings'>OK</a>".html_safe if Tenon::MySettings.site_url.blank?
      warnings << "You haven't entered an email address to receive contact messages.<br /><br /><a class='btn btn-comp btn-block' href='#{root_path}settings'>Correct This</a>".html_safe  if Tenon::MySettings.contact_email.blank?
      warnings << "You haven't entered an email address from which to send contact messages and other site notices.<br /><br /><a class='btn btn-comp btn-block' href='#{root_path}settings'>Correct This</a>".html_safe  if Tenon::MySettings.from_email.blank?
      warnings << "You haven't entered the Google Analytics code.<br /><br /><a class='btn btn-comp btn-block' href='#{root_path}settings'>Correct This</a>".html_safe if Tenon::MySettings.google_analytics.blank?
      warnings << 'You have not included a custom favicon.' unless favicon && favicon.size > 0
      warnings
    end

    private

    def favicon
      return @favicon if @favicon
      begin
        @favicon = File.read(File.join(Rails.root, 'public', 'favicon.ico'))
      rescue Errno::ENOENT
        @favicon = nil
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tenon-1.1.8 lib/tenon/warning_generator.rb
tenon-1.1.7 lib/tenon/warning_generator.rb
tenon-1.1.6 lib/tenon/warning_generator.rb
tenon-1.1.5 lib/tenon/warning_generator.rb
tenon-1.1.4 lib/tenon/warning_generator.rb
tenon-1.1.3 lib/tenon/warning_generator.rb
tenon-1.1.2 lib/tenon/warning_generator.rb
tenon-1.1.1 lib/tenon/warning_generator.rb
tenon-1.0.76 lib/tenon/warning_generator.rb
tenon-1.0.75 lib/tenon/warning_generator.rb