app/controllers/home_controller.rb
def site_pages    
    Rails.application.reload_routes!
    page_routes = Rails.application.routes.routes.select do |route|
      route.verb == "GET" && !route.name.blank? && !route.name.match(/^edit/) && !route.name.match("translat") && !route.name.match("external_author")
    end

    @paths = []
    @errors = []
    @errors << "Skipping translation and external author pages because these areas are in-progress."

    page_routes.each do |r|
      path = r.path.split('(').first
      while (path.match(/:([^\/]+)_id\//)) do
        id = get_id(path, current_user, $1.singularize)
        if id
          path.gsub!(":#{$1}_id", "#{id}") if id
          @last_id = id
        else
          @errors << "Couldn't find object for #{path}, #{$1}"
          break
        end
      end

      if (path.match(/\/([^\/]+)\/:id/))
        id = get_id(path, current_user, $1.singularize)
        if id
          path.gsub!(":id", "#{id}")
          @last_id = id
        else
          @errors << "Couldn't find object for #{path}, id"
        end
      end

      @paths << [path, r.name]
    end
    
    render :action => "site_pages", :layout => "application"
  end
# Generate links to all the pages on the site
Generate links to all the pages on the site
Generate links to all the pages on the site
def site_pages    
    Rails.application.reload_routes!
    page_routes = Rails.application.routes.routes.select do |route|
      route.verb == "GET" && !route.name.blank? && !route.name.match(/^edit/) && !route.name.match("translat") && !route.name.match("external_author")
    end
    @paths = []
    @errors = []
    @errors << "Skipping translation and external author pages because these areas are in-progress."
    page_routes.each do |r|
      path = r.path.split('(').first
      while (path.match(/:([^\/]+)_id\//)) do
        id = get_id(path, current_user, $1.singularize)
        if id
          path.gsub!(":#{$1}_id", "#{id}") if id
          @last_id = id
        else
          @errors << "Couldn't find object for #{path}, #{$1}"
          break
        end
      end
      if (path.match(/\/([^\/]+)\/:id/))
        id = get_id(path, current_user, $1.singularize)
        if id
          path.gsub!(":id", "#{id}")
          @last_id = id
        else
          @errors << "Couldn't find object for #{path}, id"
        end
      end
      @paths << [path, r.name]
    end
    render :action => "site_pages", :layout => "application"
  end
def site_pages Rails . application . reload_routes! page_routes = Rails . application . routes . routes . select do | route | route . verb == "GET" && ! route . name . blank? && ! route . name . match ( / ^edit / ) && ! route . name . match ( "translat" ) && ! route . name . match ( "external_author" ) end @paths = [ ] @errors = [ ] @errors << "Skipping translation and external author pages because these areas are in-progress." page_routes . each do | r | path = r . path . split ( '(' ) . first while ( path . match ( / :([^ \/ ]+)_id \/ / ) ) do id = get_id ( path , current_user , $1 . singularize ) if id path . gsub! ( ":#{$1}_id" , "#{id}" ) if id @last_id = id else @errors << "Couldn't find object for #{path}, #{$1}" break end end if ( path . match ( / \/ ([^ \/ ]+) \/ :id / ) ) id = get_id ( path , current_user , $1 . singularize ) if id path . gsub! ( ":id" , "#{id}" ) @last_id = id else @errors << "Couldn't find object for #{path}, id" end end @paths << [ path , r . name ] end render :action => "site_pages" , :layout => "application" end
Generate links to all the pages on the site
Generate links to all the pages on the site