routes.rb 7.27 KB
Newer Older
danielgrippi's avatar
danielgrippi committed
1
#   Copyright (c) 2010-2011, Diaspora Inc.  This file is
Raphael's avatar
Raphael committed
2
#   licensed under the Affero General Public License version 3 or later.  See
Raphael's avatar
Raphael committed
3
#   the COPYRIGHT file.
4

Jonne Haß's avatar
Jonne Haß committed
5
require 'sidekiq/web'
6
require 'sidetiq/web'
Jonne Haß's avatar
Jonne Haß committed
7

maxwell's avatar
maxwell committed
8
Diaspora::Application.routes.draw do
Lukas Matt's avatar
Lukas Matt committed
9

10
  resources :report, :except => [:edit, :new]
Lukas Matt's avatar
Lukas Matt committed
11

12
  if Rails.env.production?
13 14
    mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin'
  end
15

Jonne Haß's avatar
Jonne Haß committed
16 17 18 19
  constraints ->(req) { req.env["warden"].authenticate?(scope: :user) &&
                        req.env['warden'].user.admin? } do
    mount Sidekiq::Web => '/sidekiq', :as => 'sidekiq'
  end
danielgrippi's avatar
danielgrippi committed
20

21 22
  mount DiasporaFederation::Engine => "/"

23
  get "/atom.xml" => redirect('http://blog.diasporafoundation.org/feed/atom') #too many stupid redirects :()
Florian Staudacher's avatar
Florian Staudacher committed
24

Maxwell Salzberg's avatar
Maxwell Salzberg committed
25
  get 'oembed' => 'posts#oembed', :as => 'oembed'
MrZYX's avatar
MrZYX committed
26
  # Posting and Reading
Maxwell Salzberg's avatar
Maxwell Salzberg committed
27 28
  resources :reshares

MrZYX's avatar
MrZYX committed
29
  resources :status_messages, :only => [:new, :create]
Raphael Sofaer's avatar
Raphael Sofaer committed
30

danielgrippi's avatar
danielgrippi committed
31
  resources :posts do
32 33 34
    member do
      get :next
      get :previous
35
      get :interactions
36
    end
37

38 39
    resources :poll_participations, :only => [:create]

40
    resources :likes, :only => [:create, :destroy, :index ]
41
    resource :participation, :only => [:create, :destroy]
42
    resources :comments, :only => [:new, :create, :destroy, :index]
43
  end
Dennis Collinson's avatar
Dennis Collinson committed
44

45 46


47
  get 'p/:id' => 'posts#show', :as => 'short_post'
48
  get 'posts/:id/iframe' => 'posts#iframe', :as => 'iframe'
49

50 51 52 53 54
  # roll up likes into a nested resource above
  resources :comments, :only => [:create, :destroy] do
    resources :likes, :only => [:create, :destroy, :index]
  end

55
  # Streams
Jonne Haß's avatar
Jonne Haß committed
56 57
  get "participate" => "streams#activity" # legacy
  get "explore" => "streams#multi"        # legacy
58 59 60

  get "activity" => "streams#activity", :as => "activity_stream"
  get "stream" => "streams#multi", :as => "stream"
61 62 63 64 65 66
  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"
Florian Staudacher's avatar
Florian Staudacher committed
67

68 69
  resources :aspects do
    put :toggle_contact_visibility
70
    put :toggle_chat_privilege
71 72 73
    collection do
      put "order" => :update_order
    end
74
  end
75

76
  get 'bookmarklet' => 'status_messages#bookmarklet'
77

78
  resources :photos, :except => [:index, :show] do
MrZYX's avatar
MrZYX committed
79
    put :make_profile_photo
80
  end
81

82 83
	#Search
	get 'search' => "search#search"
84

85
  resources :conversations do
86
    resources :messages, :only => [:create, :show]
MrZYX's avatar
MrZYX committed
87
    delete 'visibility' => 'conversation_visibilities#destroy'
88
  end
89

MrZYX's avatar
MrZYX committed
90
  resources :notifications, :only => [:index, :update] do
91 92 93
    collection do
      get :read_all
    end
94
  end
95

96

MrZYX's avatar
MrZYX committed
97
  resources :tags, :only => [:index]
98

99 100 101 102 103
  resources "tag_followings", only: %i(create destroy index) do
    collection do
      get :manage
    end
  end
104

MrZYX's avatar
MrZYX committed
105
  get 'tags/:name' => 'tags#show', :as => 'tag'
106

107
  resources :apps, :only => [:show]
MrZYX's avatar
MrZYX committed
108

MrZYX's avatar
MrZYX committed
109
  # Users and people
110

MrZYX's avatar
MrZYX committed
111
  resource :user, :only => [:edit, :update, :destroy], :shallow => true do
112
    get :getting_started_completed
113
    post :export_profile
114
    get :download_profile
115
    post :export_photos
116
    get :download_photos
MrZYX's avatar
MrZYX committed
117 118 119
  end

  controller :users do
120
    get 'public/:username'          => :public,           :as => 'users_public'
Jonne Haß's avatar
Jonne Haß committed
121 122
    get 'getting_started'           => :getting_started,  :as => 'getting_started'
    get 'privacy'                   => :privacy_settings, :as => 'privacy_settings'
MrZYX's avatar
MrZYX committed
123
    get 'getting_started_completed' => :getting_started_completed
124
    get 'confirm_email/:token'      => :confirm_email,    :as => 'confirm_email'
MrZYX's avatar
MrZYX committed
125
  end
126 127 128

  # 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ß committed
129
  get 'users/edit' => redirect('/user/edit')
130

Raphael's avatar
Raphael committed
131
  devise_for :users, :controllers => {:registrations => "registrations",
132 133 134
                                      :sessions      => "sessions"}

  #legacy routes to support old invite routes
135 136
  get 'users/invitation/accept' => 'invitations#edit'
  get 'invitations/email' => 'invitations#email', :as => 'invite_email'
137
  get 'users/invitations' => 'invitations#new', :as => 'new_user_invitation'
Jonne Haß's avatar
Jonne Haß committed
138
  post 'users/invitations' => 'invitations#create', :as => 'user_invitation'
Florian Staudacher's avatar
Florian Staudacher committed
139

MrZYX's avatar
MrZYX committed
140
  get 'login' => redirect('/users/sign_in')
141

142 143
  # Admin backend routes

144
  scope 'admins', :controller => :admins do
Jonne Haß's avatar
Jonne Haß committed
145
    match :user_search, via: [:get, :post]
MrZYX's avatar
MrZYX committed
146
    get   :admin_inviter
147
    get   :weekly_user_stats
MrZYX's avatar
MrZYX committed
148
    get   :stats, :as => 'pod_stats'
149
    get   "add_invites/:invite_code_id" => 'admins#add_invites', :as => 'add_invites'
MrZYX's avatar
MrZYX committed
150
  end
151

152 153
  namespace :admin do
    post 'users/:id/close_account' => 'users#close_account', :as => 'close_account'
Akash Agrawall's avatar
Akash Agrawall committed
154 155
    post 'users/:id/lock_account' => 'users#lock_account', :as => 'lock_account'
    post 'users/:id/unlock_account' => 'users#unlock_account', :as => 'unlock_account'
156 157
  end

158
  resource :profile, :only => [:edit, :update]
159 160
  resources :profiles, :only => [:show]

161

Raphael Sofaer's avatar
Raphael Sofaer committed
162
  resources :contacts,           :except => [:update, :create] do
163
  end
164
  resources :aspect_memberships, :only  => [:destroy, :create]
165 166
  resources :share_visibilities,  :only => [:update]
  resources :blocks, :only => [:create, :destroy]
MrZYX's avatar
MrZYX committed
167

168
  get 'i/:id' => 'invitation_codes#show', :as => 'invite_code'
169

170
  get 'people/refresh_search' => "people#refresh_search"
MrZYX's avatar
MrZYX committed
171 172 173
  resources :people, :except => [:edit, :update] do
    resources :status_messages
    resources :photos
174
    get :contacts
MrZYX's avatar
MrZYX committed
175
    get "aspect_membership_button" => :aspect_membership_dropdown, :as => "aspect_membership_button"
176
    get :stream
Florian Staudacher's avatar
Florian Staudacher committed
177
    get :hovercard
178 179 180 181 182

    member do
      get :last_post
    end

MrZYX's avatar
d'oh  
MrZYX committed
183 184 185 186
    collection do
      post 'by_handle' => :retrieve_remote, :as => 'person_by_handle'
      get :tag_index
    end
187
  end
188 189
  get '/u/:username' => 'people#show', :as => 'user_profile', :constraints => { :username => /[^\/]+/ }
  get '/u/:username/profile_photo' => 'users#user_photo', :constraints => { :username => /[^\/]+/ }
190 191


MrZYX's avatar
MrZYX committed
192 193 194
  # Federation

  controller :publics do
195
    post 'receive/users/:guid'  => :receive
196
    post 'receive/public'       => :receive_public
MrZYX's avatar
MrZYX committed
197
    get 'hub'                   => :hub
maxwell's avatar
maxwell committed
198 199
  end

MrZYX's avatar
MrZYX committed
200

Your Name's avatar
wip  
Your Name committed
201

MrZYX's avatar
MrZYX committed
202 203 204 205
  # External

  resources :services, :only => [:index, :destroy]
  controller :services do
MrZYX's avatar
MrZYX committed
206
    scope "/auth", :as => "auth" do
Jonne Haß's avatar
Jonne Haß committed
207 208
      get ':provider/callback' => :create
      get :failure
MrZYX's avatar
MrZYX committed
209
    end
MrZYX's avatar
MrZYX committed
210 211 212
  end

  scope 'api/v0', :controller => :apis do
MrZYX's avatar
MrZYX committed
213
    get :me
MrZYX's avatar
MrZYX committed
214 215
  end

216 217 218
  namespace :api do
    namespace :v0 do
      get "/users/:username" => 'users#show', :as => 'user'
Maxwell Salzberg's avatar
Maxwell Salzberg committed
219
      get "/tags/:name" => 'tags#show', :as => 'tag'
220
    end
Lukas Matt's avatar
Lukas Matt committed
221 222 223
    namespace :v1 do
      resources :tokens, :only => [:create, :destroy]
    end
224 225
  end

226
  get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight'
MrZYX's avatar
MrZYX committed
227 228
  # Mobile site

229
  get 'mobile/toggle', :to => 'home#toggle_mobile', :as => 'toggle_mobile'
MrZYX's avatar
MrZYX committed
230

Jonne Haß's avatar
Jonne Haß committed
231
  # Help
232
  get 'help' => 'help#faq', :as => 'help'
233
  get 'help/:topic' => 'help#faq'
Steffen van Bergerem's avatar
Steffen van Bergerem committed
234

235
  #Protocol Url
Jonne Haß's avatar
Jonne Haß committed
236
  get 'protocol' => redirect("http://wiki.diasporafoundation.org/Federation_Protocol_Overview")
237

Jonne Haß's avatar
Jonne Haß committed
238 239 240
  # NodeInfo
  get ".well-known/nodeinfo", to: "node_info#jrd"
  get "nodeinfo/:version",    to: "node_info#document", as: "node_info", constraints: {version: /\d+\.\d+/}
241
  get "statistics",           to: "node_info#statistics"
242

243 244 245 246
  # Terms
  if AppConfig.settings.terms.enable?
    get 'terms' => 'terms#index'
  end
247

248
  # Startpage
249
  root :to => 'home#show'
Raphael Sofaer's avatar
Raphael Sofaer committed
250
end