Sha256: fed78cd9a0a23448dafe4ba7fe33bfc361257b103b737f47d3560fb506c3b1c9

Contents?: true

Size: 936 Bytes

Versions: 22

Compression:

Stored size: 936 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.main_site_route'] = matched
            packet['route.path'] = extras
            packet['subsite'] = m
          end
        end
      end
      pass packet
    end
  end
  
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
orange-more-0.5.8 lib/orange-more/subsites/middleware/subsite_load.rb
orange-more-0.5.7 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.5.5 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.5.4 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.5.3 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.5.2 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.5.1 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.4.0 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.9 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.8 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.7 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.6 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.5 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.4 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.3 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.2 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.1 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.3.0 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.2.11 lib/orange-more/subsites/middleware/subsite_load.rb
orange-0.2.9 lib/orange-more/subsites/middleware/subsite_load.rb