- if params[:user] && @projects.empty?
  = haml :not_found
-else
  .wrap
    %h1= "#{@project_count || @projects.count} projects #{(params[:user] ? "by " + params[:user] : '')}"

    - unless params[:user]
      #search
        %p
          Filter:
          %select{:id => 'state_filter', :onchange => 'window.location="?state=" + this.options[this.selectedIndex].value'}
            %option{:value => ''} All
            %option{:value => 'maintained', :selected => params[:state] == 'maintained'} Maintained
            %option{:value => 'searching', :selected => params[:state] == 'searching'} Looking for a new maintainer
            %option{:value => 'abandoned', :selected => params[:state] == 'abandoned'} Abandoned

        %p
          Search:
          %form{:action => '/projects', :method => 'GET'}
            %input{:type => 'text', :name => 'q', :value => '', :placeholder => 'find a project'}
            %input{:type => 'submit', :value => 'Search', :class => "button"}

    = haml :projects

    - unless params[:user] || params[:q] || params[:state]
      #pagination
        - (1..@projects.total_pages).each do |page|
          %a{:href => "?page=#{page}"}= page


- if params[:user] && @projects.empty?
  = haml :not_found
-else
  .wrap
    %h1= "#{@project_count || @projects.count} projects #{(params[:user] ? "by " + params[:user] : '')}"

    - unless params[:user]
      #search
        %p
          Filter:
          %select{:id => 'state_filter', :onchange => 'window.location="?state=" + this.options[this.selectedIndex].value'}
            %option{:value => ''} All
            %option{:value => 'maintained', :selected => params[:state] == 'maintained'} Maintained
            %option{:value => 'searching', :selected => params[:state] == 'searching'} Looking for a new maintainer
            %option{:value => 'abandoned', :selected => params[:state] == 'abandoned'} Abandoned

        %p
          Search:
          %form{:action => '/projects', :method => 'GET'}
            %input{:type => 'text', :name => 'q', :value => '', :placeholder => 'find a project'}
            %input{:type => 'submit', :value => 'Search', :class => "button"}

    = haml :projects

    - unless params[:user] || params[:q]
      #pagination
        - (1..@projects.total_pages).each do |page|
          %a{:href => "?page=#{page}#{params[:state] ? "&amp;state=" + params[:state] : ''}"}= page


Add pagination when filtering projects by state.
Add pagination when filtering projects by state.
