Skip to content
Extraits de code Groupes Projets
routes.rb 7,27 ko
Newer Older
  • Learn to ignore specific revisions
  • danielgrippi's avatar
    danielgrippi a validé
    #   Copyright (c) 2010-2011, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3 or later.  See
    
    Raphael's avatar
    Raphael a validé
    #   the COPYRIGHT file.
    
    Jonne Haß's avatar
    Jonne Haß a validé
    require 'sidekiq/web'
    
    require 'sidetiq/web'
    
    maxwell's avatar
    maxwell a validé
    Diaspora::Application.routes.draw do
    
      resources :report, :except => [:edit, :new]
    
        mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin'
      end
    
    Jonne Haß's avatar
    Jonne Haß a validé
      constraints ->(req) { req.env["warden"].authenticate?(scope: :user) &&
                            req.env['warden'].user.admin? } do
        mount Sidekiq::Web => '/sidekiq', :as => 'sidekiq'
      end
    
      mount DiasporaFederation::Engine => "/"
    
    
      get "/atom.xml" => redirect('http://blog.diasporafoundation.org/feed/atom') #too many stupid redirects :()
    
    Maxwell Salzberg's avatar
    Maxwell Salzberg a validé
      get 'oembed' => 'posts#oembed', :as => 'oembed'
    
      # Posting and Reading
    
    Maxwell Salzberg's avatar
    Maxwell Salzberg a validé
      resources :reshares
    
    
    MrZYX's avatar
    MrZYX a validé
      resources :status_messages, :only => [:new, :create]
    
      resources :posts do
    
        member do
          get :next
          get :previous
    
          get :interactions
    
        resources :poll_participations, :only => [:create]
    
    
        resources :likes, :only => [:create, :destroy, :index ]
    
        resource :participation, :only => [:create, :destroy]
    
        resources :comments, :only => [:new, :create, :destroy, :index]
    
    Dennis Collinson's avatar
    Dennis Collinson a validé
    
    
      get 'p/:id' => 'posts#show', :as => 'short_post'
    
      get 'posts/:id/iframe' => 'posts#iframe', :as => 'iframe'
    
      # roll up likes into a nested resource above
      resources :comments, :only => [:create, :destroy] do
        resources :likes, :only => [:create, :destroy, :index]
      end
    
    
    Jonne Haß's avatar
    Jonne Haß a validé
      get "participate" => "streams#activity" # legacy
      get "explore" => "streams#multi"        # legacy
    
    
      get "activity" => "streams#activity", :as => "activity_stream"
      get "stream" => "streams#multi", :as => "stream"
    
      get "public" => "streams#public", :as => "public_stream"
      get "followed_tags" => "streams#followed_tags", :as => "followed_tags_stream"
      get "mentions" => "streams#mentioned", :as => "mentioned_stream"
      get "liked" => "streams#liked", :as => "liked_stream"
      get "commented" => "streams#commented", :as => "commented_stream"
      get "aspects" => "streams#aspects", :as => "aspects_stream"
    
      resources :aspects do
        put :toggle_contact_visibility
    
        put :toggle_chat_privilege
    
        collection do
          put "order" => :update_order
        end
    
      get 'bookmarklet' => 'status_messages#bookmarklet'
    
      resources :photos, :except => [:index, :show] do
    
    MrZYX's avatar
    MrZYX a validé
        put :make_profile_photo
    
    	#Search
    	get 'search' => "search#search"
    
      resources :conversations do
    
        resources :messages, :only => [:create, :show]
    
        delete 'visibility' => 'conversation_visibilities#destroy'
    
      resources :notifications, :only => [:index, :update] do
    
        collection do
          get :read_all
        end
    
    MrZYX's avatar
    MrZYX a validé
      resources :tags, :only => [:index]
    
      resources "tag_followings", only: %i(create destroy index) do
        collection do
          get :manage
        end
      end
    
    MrZYX's avatar
    MrZYX a validé
      get 'tags/:name' => 'tags#show', :as => 'tag'
    
    MrZYX's avatar
    MrZYX a validé
    
    
      # Users and people
    
      resource :user, :only => [:edit, :update, :destroy], :shallow => true do
    
        get :getting_started_completed
    
        post :export_profile
    
        get :download_profile
    
        post :export_photos
    
        get :download_photos
    
      end
    
      controller :users do
    
        get 'public/:username'          => :public,           :as => 'users_public'
    
    Jonne Haß's avatar
    Jonne Haß a validé
        get 'getting_started'           => :getting_started,  :as => 'getting_started'
        get 'privacy'                   => :privacy_settings, :as => 'privacy_settings'
    
        get 'getting_started_completed' => :getting_started_completed
    
        get 'confirm_email/:token'      => :confirm_email,    :as => 'confirm_email'
    
    
      # This is a hack to overide a route created by devise.
      # I couldn't find anything in devise to skip that route, see Bug #961
    
    Jonne Haß's avatar
    Jonne Haß a validé
      get 'users/edit' => redirect('/user/edit')
    
    Raphael's avatar
    Raphael a validé
      devise_for :users, :controllers => {:registrations => "registrations",
    
                                          :sessions      => "sessions"}
    
      #legacy routes to support old invite routes
    
      get 'users/invitation/accept' => 'invitations#edit'
      get 'invitations/email' => 'invitations#email', :as => 'invite_email'
    
      get 'users/invitations' => 'invitations#new', :as => 'new_user_invitation'
    
    Jonne Haß's avatar
    Jonne Haß a validé
      post 'users/invitations' => 'invitations#create', :as => 'user_invitation'
    
      get 'login' => redirect('/users/sign_in')
    
      scope 'admins', :controller => :admins do
    
    Jonne Haß's avatar
    Jonne Haß a validé
        match :user_search, via: [:get, :post]
    
    MrZYX's avatar
    MrZYX a validé
        get   :admin_inviter
    
        get   :weekly_user_stats
    
    MrZYX's avatar
    MrZYX a validé
        get   :stats, :as => 'pod_stats'
    
        get   "add_invites/:invite_code_id" => 'admins#add_invites', :as => 'add_invites'
    
      namespace :admin do
        post 'users/:id/close_account' => 'users#close_account', :as => 'close_account'
    
    Akash Agrawall's avatar
    Akash Agrawall a validé
        post 'users/:id/lock_account' => 'users#lock_account', :as => 'lock_account'
        post 'users/:id/unlock_account' => 'users#unlock_account', :as => 'unlock_account'
    
      resource :profile, :only => [:edit, :update]
    
      resources :profiles, :only => [:show]
    
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
      resources :contacts,           :except => [:update, :create] do
    
      resources :aspect_memberships, :only  => [:destroy, :create]
    
      resources :share_visibilities,  :only => [:update]
      resources :blocks, :only => [:create, :destroy]
    
      get 'i/:id' => 'invitation_codes#show', :as => 'invite_code'
    
      get 'people/refresh_search' => "people#refresh_search"
    
      resources :people, :except => [:edit, :update] do
        resources :status_messages
        resources :photos
    
    MrZYX's avatar
    MrZYX a validé
        get "aspect_membership_button" => :aspect_membership_dropdown, :as => "aspect_membership_button"
    
    Florian Staudacher's avatar
    Florian Staudacher a validé
        get :hovercard
    
    MrZYX's avatar
    MrZYX a validé
        collection do
          post 'by_handle' => :retrieve_remote, :as => 'person_by_handle'
          get :tag_index
        end
    
      get '/u/:username' => 'people#show', :as => 'user_profile', :constraints => { :username => /[^\/]+/ }
      get '/u/:username/profile_photo' => 'users#user_photo', :constraints => { :username => /[^\/]+/ }
    
      # Federation
    
      controller :publics do
    
        post 'receive/users/:guid'  => :receive
    
        post 'receive/public'       => :receive_public
    
        get 'hub'                   => :hub
    
    maxwell's avatar
    maxwell a validé
      end
    
    
    Your Name's avatar
    Your Name a validé
    
    
      # External
    
      resources :services, :only => [:index, :destroy]
      controller :services do
    
    MrZYX's avatar
    MrZYX a validé
        scope "/auth", :as => "auth" do
    
    Jonne Haß's avatar
    Jonne Haß a validé
          get ':provider/callback' => :create
          get :failure
    
    MrZYX's avatar
    MrZYX a validé
        end
    
      end
    
      scope 'api/v0', :controller => :apis do
    
    MrZYX's avatar
    MrZYX a validé
        get :me
    
      namespace :api do
        namespace :v0 do
          get "/users/:username" => 'users#show', :as => 'user'
    
    Maxwell Salzberg's avatar
    Maxwell Salzberg a validé
          get "/tags/:name" => 'tags#show', :as => 'tag'
    
        namespace :v1 do
          resources :tokens, :only => [:create, :destroy]
        end
    
      get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight'
    
      # Mobile site
    
    
      get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
    
    Jonne Haß's avatar
    Jonne Haß a validé
      # Help
    
      get 'help' => 'help#faq', :as => 'help'
    
      get 'help/:topic' => 'help#faq'
    
    Jonne Haß's avatar
    Jonne Haß a validé
      get 'protocol' => redirect("http://wiki.diasporafoundation.org/Federation_Protocol_Overview")
    
    Jonne Haß's avatar
    Jonne Haß a validé
      # NodeInfo
      get ".well-known/nodeinfo", to: "node_info#jrd"
      get "nodeinfo/:version",    to: "node_info#document", as: "node_info", constraints: {version: /\d+\.\d+/}
    
      get "statistics",           to: "node_info#statistics"
    
      # Terms
      if AppConfig.settings.terms.enable?
        get 'terms' => 'terms#index'
      end
    
    Raphael Sofaer's avatar
    Raphael Sofaer a validé
    end