.archives.widget
  %h3 Archives du blog

  -if Article.before(Date.today).recents.size > 0
    %ul
      -first_month = Article.before(Date.today).recents.order(:published_at).first.published_at.beginning_of_month
      -last_month = Article.before(Date.today).recents.order(:published_at).last.published_at.beginning_of_month
      -the_month = last_month
  
      -while the_month >= first_month
        -articles = Article.before(Date.today).recents.where("enabled = ? and published_at > ? and published_at < ?", true, the_month.beginning_of_month, the_month.end_of_month ).count
      
        -if articles > 0
          %li=link_to l(the_month.to_date, :format => :only_month)+" (#{articles})", archive_public_article_path(:year => the_month.year, :month => the_month.month)
      
        -the_month = the_month.prev_month