def find_pages(filter)
      filter = filter.downcase
      if filter =~ /\//
        path = filter.split('/').map{|segment| segment.gsub(/[^0-9a-z_-]/, '')}
        path_str = path.join('/')
        if (page = @pages_by_path[path_str])
          page
        elsif matched_path = @page_paths.grep(/#{Regexp.escape(path_str)}/).first
          @pages_by_path[matched_path]
        elsif page = @pages_by_name[path.last]
          page
        else
          nil
        end
      elsif @pages_by_path[filter]
        @pages_by_path[filter]
      else
        @pages_by_name[filter]
      end
    end
def find_pages(filter)
      filter = filter.downcase
      if filter =~ /\//
        path = filter.split('/').map{|segment| segment.gsub(/[^0-9a-z_-]/, '')}
        path_str = path.join('/')
        if (page = @pages_by_path[path_str])
          page
        elsif matched_path = @page_paths.grep(/#{Regexp.escape(path_str)}/).first
          @pages_by_path[matched_path]
        elsif page = @pages_by_name[path.last]
          page
        else
          nil
        end
      elsif @pages_by_path[filter]
        @pages_by_path[filter]
      else
        @pages_by_name[filter]
      end
    end
find pages by a filter.
 filter is a string composing a path segment.
 For example:
   "chat/security"
 Which would match "/services/chat/security" but not "/services/security"