Rails.application.routes.draw do
  locales = Site.first.in_use_locales rescue I18n.available_locales
  scope "(:locale)", locale: Regexp.new(locales.join("|")) do
    get "/xhr/custom_galleries/theater/:id" => "custom_galleries#theater"
    namespace :admin do
      get "custom_galleries/get_photoData_json" => "custom_galleries#get_photoData_json"
      get "custom_galleries/recreate_image" => "custom_galleries#recreate_image"
      get "custom_galleries/crop_process" => "custom_images#crop_process"
      post "custom_galleries/recreate_image/recreate_progress" => "custom_galleries#recreate_progress"
      get "custom_galleries/recreate_image/finish_recreate" => "custom_galleries#finish_recreate"
      get "custom_galleries/batch_crop" => "custom_images#batch_crop"
      get "custom_galleries/new_images" => "custom_galleries#new_images"
      get "custom_galleries/last_image_id" => "custom_galleries#last_image_id"
      post "custom_galleries/set_cover" => "custom_galleries#set_cover"
      post "custom_galleries/delete_photos" => "custom_images#delete_photos"
      post "custom_galleries/update_image" => "custom_images#update_image"
      post "custom_galleries/image_tagging" => "custom_images#image_tagging"
      post "custom_galleries/order" => "custom_images#changeorder"
      post "custom_galleries/translate" => "custom_galleries#call_translate"
      post "custom_galleries/save_crop" => "custom_galleries#save_crop"
      get "custom_galleries/rotate_images" => "custom_galleries#rotate_images"
      get "custom_galleries/upload_process" => "custom_galleries#upload_process"
      post "custom_galleries/start_upload_process" => "custom_galleries#start_upload_process"
      post "custom_galleries/init_upload" => "custom_galleries#init_upload"
      post "custom_galleries/get_tag" => "custom_galleries#get_tag"
      post "custom_galleries/update_custom_album_setting" => "custom_galleries#update_custom_album_setting"
      get "custom_galleries/setting" => "custom_galleries#setting"
      resources :custom_galleries do
        get "imgs" => "custom_galleries#imgs"
        member do
          get "import"
          get "excel_format"
          post "importimages"
        end
        collection do
          get "/:custom_module-:bind_uid" => "custom_galleries#index"
          get "/:custom_module-:bind_uid/new" => "custom_galleries#new"
          get "/:custom_module-:bind_uid/:id/edit" => "custom_galleries#edit"
          delete "/:custom_module-:bind_uid/:id/destroy" => "custom_galleries#destroy"

          get "/:custom_module" => "custom_galleries#index", constraints: {custom_module: /.{1,23}/}
        end
      end
      resources :custom_images
      post "custom_galleries/upload_image" => "custom_galleries#upload_image"
      # match "image_tagging" => "custom_album_images#image_tagging"
    end
  end
end
