Sha256: ac93950c75bf6139b0294628c39b23cab919aba272da802f113a255ec5849c77
Contents?: true
Size: 1.51 KB
Versions: 3
Compression:
Stored size: 1.51 KB
Contents
module Orange class SubsiteResource < Orange::ModelResource use OrangeSubsite call_me :subsites def afterLoad 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 end class Mapper < Resource def route_to(packet, resource, *args) opts = args.extract_options! packet = DefaultHash.new unless packet context = opts[:context] || packet['route.context', nil] 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
3 entries across 3 versions & 1 rubygems