Sha256: 13e1934d9fae9378783616c521ba98c39613dcdf2ce980e4cc2a86d2db020a9f
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
module Orange class SubsiteResource < Orange::ModelResource use OrangeSubsite call_me :subsites def stack_init orange[:admin, true].add_link("Settings", :resource => @my_orange_name, :text => 'Subsites') end # Creates a new model object and saves it (if a post), then reroutes to the main page # @param [Orange::Packet] packet the packet being routed def new(packet, *opts) if packet.request.post? m = packet['site'].subsites.new(packet.request.params[@my_orange_name.to_s]) m.save orange[:sitemap].add_route_for(packet, :orange_site_id => packet['site'].id, :resource => :subsites, :resource_id => m.id, :slug => 'subsite', :link_text => 'Orange Subsite' ) end packet.reroute(@my_orange_name, :orange) end def url_for(packet) orange[:sitemap].url_for(packet, {:resource => 'subsites', :resource_id => packet['subsite'].id}) end def subsite_nav(packet, opts = {}) orange[:sitemap].one_level(packet, :model => orange[:sitemap].home(packet, :subsite => true)) end end class Mapper < Resource def route_to(packet, resource, *args) opts = args.extract_options! packet = DefaultHash.new unless packet context = opts[:context] context = packet['route.context', nil] unless (context || (packet['route.context'] == :live)) site = packet['route.faked_site'] ? packet['route.site_url', nil] : nil args.unshift(resource) args.unshift(orange[:subsites].url_for(packet).gsub(/^\//, '').gsub(/\/$/, '')) if(packet['subsite']) args.unshift(context) args.unshift(site) '/'+args.compact.join('/') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
orange-0.2.9 | lib/orange-more/subsites/resources/subsite_resource.rb |
orange-0.2.8 | lib/orange-more/subsites/resources/subsite_resource.rb |