Sha256: 709accb4e94b8ac2ad46c4c4a44f3f2cb6ad3f3f70d5530bf749fa6c03833fa7

Contents?: true

Size: 882 Bytes

Versions: 8

Compression:

Stored size: 882 Bytes

Contents

require 'orange-core/middleware/base'
module Orange::Middleware
  # This will load information about the site to into the orange env
  # - packet['site'] will be an instance of the site object
  # 
  class SubsiteLoad < Base    
    def packet_call(packet)
      if packet['site']
        site = packet['site']
        path = packet['route.path'] || packet.request.path_info
        
        # Find the subsite in the sitemap table
        extras, matched = orange[:sitemap].find_route_info(packet, path)
        
        # If matched, update the loaded site and trim the path down a bit
        if !matched.resource.blank? && matched.resource.to_sym == :subsites
          if(m = site.subsites.first(:id => matched.resource_id))
            packet['route.path'] = extras
            packet['subsite'] = m
          end
        end
      end
      pass packet
    end
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
orange-0.2.6 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.2.5 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.2.4 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.2.3 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.1.10 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.1.8 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.1.7 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.1.4 lib/orange-more/subsites/middleware/subsite_load.rb