Rails.application.routes.draw do

  # Facebook Connect Callback
  get 'auth/facebook/callback', to: 'public/annonce_accounts_auths#facebook_connect_callback'

  scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do

    get 'mail_assets/:token.png' => "admin/mail_trackings#update", :as => :image_tracking

    constraints subdomain: 'affiliation' do
      get "/:mlm_token" => "public/home#affiliation"
      get "/" => "public/home#affiliation"
    end

    get "affiliation/:mlm_token" => "public/home#affiliation"
    get "affiliation" => "public/home#affiliation"


    constraints domain: ['sideplace-affiliation.dev', 'affiliation-sideplace.com'] do
      get "/:mlm_token" => "public/home#redirect_affiliation"
      get "/" => "public/home#redirect_affiliation"

    end

    get 'p/:mlm_token' => "public/annonce_accounts#parrainage", :as => :mlm_token

    namespace :public do
      resources :hipay_virements
      resources :annonce_account_favs
      resources :annonce_account_ribs do

      end
      resources :annonce_cats do
        collection do
          get :search
        end
      end
      resources :commissions
      resources :orders do
        collection do
          get :e_trans_cancel
          get :e_trans_ipn
          get :e_trans_refuse
          get :e_trans_effectue

          post :hipay_ipn

          get :billing
          get :bills
        end

        member do
          get :bill_print
          get :paid
          get :paid_force
          get :paid_by_hipay
          get :hipay_decline
          get :hipay_confirm


        end
      end
      resources :credit_products
      resources :cities do
        collection do
          get :search
        end
      end
      resources :credits
      resources :mlm_points

      resources :annonce_photos do
        member do
         get :rotate
        end
      end
      resources :annonces do
        collection do



          get :geocode
        end
        member do
          get :photos
          get :specific
          get :publish
          get :contact
          get :options
          get :buy_option
        end
      end

      get 'my_account/favoris', :as => "favs"
      get 'my_account/filleuls', :as => "filleuls"
      get 'my_account/binary', :as => "binary"
      get 'my_account/index', :as => "my_account"
      get 'my_account/edit_infos', :as => "edit_infos"
      get 'my_account/my_annonces', :as => "my_annonces"
      get 'my_account/reconfirm', :as => "reconfirm_email"
    end



    get "evenements/:id.html" => "public/events#show", :as => "public_event"
    get "evenements.html" => "public/events#index", :as => "public_events"


    post "search.:f" => "public/annonces#search", :as => :search_public_annonces, :f => "html"
    get "search.:f" => "public/annonces#search", :f => "html"


    constraints subdomain: 'blog' do
        get "blog/archives/:year/:month.html"=> "public/articles#archives", :as => :archive_public_article
        get "blog/tags/:id.html"=> "public/articles#tags", :as => :public_tag
        get "blog/categorie/:slug.:f"=> "public/articles#category", :as => :category_public_article, :f => "html"
        get 'blog/:id.html' => "public/articles#show", :as => "public_article"
      	get 'blog/:slug.:f' => 'public/articles#show', :as => :article, :f => "html"
      	get 'blog.:f' => 'public/articles#index', :as => :articles, :f => "html"
        get '/' => 'public/articles#index'

    end





    get "/" => "public/ebooks#show",:id => "arreter-de-fumer" ,:constraints => {:domain => ["arreter-de-fumer-avec-eft.dev", "bally.me", "arreter-de-fumer-avec-eft.com"]}




    get "categorie/:id.:f" => "public/annonces#search", :as => :public_annonce_category, :f => "html"
    post "categorie/:id.:f" => "public/annonces#search", :as => :post_public_annonce_category


  	get "acheter-des-credits.html" => "public/credit_products#index", :f => "html"

    get "sitemap.:f" => "public/sitemap#sitemap"
    namespace :public do
      resources :virements
      resources :comments
      resources :annonce_messages do
        member do
          get :answer
          post :answer_save
        end
      end
      resources :annonce_accounts do
        member do
          get :confirm
          get :mail
          get :mail_confirm
          get :show_details
        end

        collection do
          get :find_parrain
        end

      end

      resources :annonce_accounts_auths do

        collection do

          get :logout

        end
      end

      resources :password_resets

    end

    namespace :portlet do
      resources :event_contents
      resources :break_contents
      resources :download_contents
      resources :dynamic_contents
      resources :gallery_contents
      resources :gallery_images do
        collection do
          get :reorder
        end
      end
      resources :html_contents
      resources :image_contents
      resources :link_contents
      resources :img_link_contents
      resources :text_contents
      resources :map_contents
      resources :title_contents
      resources :table_contents
      resources :block_contents
      resources :table_rows
      resources :table_cols
      resources :portlets do
        collection do
          post :reorder
        end
      end
    end

    namespace :admin do
      resources :registrants
      resources :annonces do

      end

      resources :orders do
        member do
          get :cancel
          get :force_pref
          post :force
        end
      end

      resources :hipay_virements do
        member do

          get :valid
          get :paid
          
        end
      end


      resources :virements do
        member do

          get :valid
        end
      end
      resources :virement_remises do
        member do

          get :sended
        end
      end
      resources :annonces
      resources :annonce_photos
      resources :annonce_account_ribs do
        member do

          get :valid
        end
      end
      resources :newsletters do
        member do
          get :history
          get :history_detail

          get "select_recipients"
          put "select_recipients"
          post "send_test"
          post "send_newsletter"
        end
      end


      resources :annonce_accounts do
        member do
          post :reconfirm
          post :add_parent

        end

      end

  		resources :categories do
  			collection do
  				post :reorder
  			end
  		end
      resources :annonce_cats
      resources :comments
      resources :articles
      resources :events

      resources :tags
      resources :password_resets

      resources :admin_auths do
        
          collection do
            get :logout
            get :stats
          end
      end

      resources :admins



      resources :external_links do
        collection do
          get :cible
        end
      end


      resources :menus
      resources :menu_items do
        collection do
          get :cible
          post :reorder
          get :import
        end
        member do
          get :clone
        end
      end
      resources :image_files do
        member do
          get :rotate
        end
      end
      resources :file_folders
      resources :data_files
      resources :pages
      resources :menu_urls
      resources :menu_aliases
      resources :blocks
      resources :albums
      resources :cibles


    end

    resources :download_data_files



    get 'admin' => "admin/admin_auths#index"
    get 'admin/stats' => "admin/admin_auths#stats", :as => :stats_admin_auths





    get '*url.html' => 'public/menu_items#show', :as => :menu_item, :f => "html"
    get '*url.:f' => 'public/menu_items#redirect',  :f => "html"

    root 'public/annonces#index'

  end

end
