Sha256: fc5082ef730836543fedc8d0d0b63a7efbf40b1d1ba9deb1812e56c8819c024a

Contents?: true

Size: 1.37 KB

Versions: 15

Compression:

Stored size: 1.37 KB

Contents

module Gluttonberg
    class Help
      # Default help paths
      @@gluttonberg_help_path = "help"
    
      # first find help in engine, if it founds return true
      # otherwise find in application. 
      def self.help_available?(opts)
        status = help_available_in(:engine , opts)
        status ? status : help_available_in(:application , opts)
      end
      
      # find help file in 'where'. if its :application then look into application 
      # otherwise look in engine
      def self.help_available_in(where , opts)
        if where == :application
          dir = template_dir_in_application(opts)
        else
          dir = template_dir_in_engine(opts)
        end
        
        if dir
          Dir.glob(File.join(dir ,  "/*") ).each do |template|
            return true if template.match(opts[:page].to_s)
          end
        end
        false
      end
    
      def self.path_to_template(opts)
        dir = template_dir(opts)
        "#{dir}/#{opts[:page]}"
      end
    
      def self.template_dir(opts)        
        "#{@@gluttonberg_help_path}/#{opts[:controller]}"
      end
      
      def self.template_dir_in_engine(opts)
        File.join(Engine.root , "app/views" , template_dir(opts)   )
      end
      
      def self.template_dir_in_application(opts)
        File.join(Rails.root , "app/views" , template_dir(opts)   )
      end
      
    end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gluttonberg-core-2.6.4 app/models/gluttonberg/help.rb
gluttonberg-core-2.6.3 app/models/gluttonberg/help.rb
gluttonberg-core-2.6.2 app/models/gluttonberg/help.rb
gluttonberg-core-2.6.1 app/models/gluttonberg/help.rb
gluttonberg-core-2.6.0 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.9 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.8 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.7 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.6 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.5 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.4 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.3 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.2 app/models/gluttonberg/help.rb
gluttonberg-core-2.5.1 app/models/gluttonberg/help.rb
gluttonberg-core-2.5 app/models/gluttonberg/help.rb