/
routes.rb
229 lines (186 loc) · 6.5 KB
/
routes.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
# License version 3 or later. See the COPYRIGHT file for details.
Quadbase::Application.routes.draw do
namespace :admin do
resources :logic_libraries do
resources :logic_library_versions, :shallow => true
post 'sort', :on => :collection
end
end
def commentable
resources :comments, :only => [:index, :new, :create] do
collection do
get 'subscribe', :to => 'comment_thread_subscriptions#create',
:as => 'subscribe'
get 'unsubscribe', :to => 'comment_thread_subscriptions#destroy',
:as => 'unsubscribe'
end
end
end
def flaggable
end
def sortable
collection do
post 'sort'
end
end
def votable
resources :votes, :only => [] do
collection do
post 'up'
post 'down'
end
end
end
# TODO check that we're using put and post correctly.
# From: http://stackoverflow.com/questions/630453/put-vs-post-in-rest ...
# "PUT is idempotent, so if you PUT an object twice, it has no effect.
# This is a nice property, so I would use PUT when possible."
resources :website_configurations, :only => [:index] do
collection do
get 'edit'
put 'update'
end
end
resources :announcements, :except => [:edit, :update]
get "admin", :to => 'admin#index', :as => "admin"
resources :licenses do
collection do
put 'make_default'
end
end
# For users, we mix devise with our own users controller. We have overriden
# some devise controller methods, so point that out here.
devise_for :users, :controllers => {:registrations => "registrations"}
post 'users/search'
get 'users/help', :to => 'users#help', :as => 'account_help'
resources :users, :only => [:index, :show, :edit, :update] do
post 'become'
end
resources :deputizations, :only => [:create, :destroy, :new] do
collection do
post 'search'
end
end
get "inbox", :to => 'inbox#index', :as => "inbox"
get 'help', :to => 'help#index', :as => 'help'
get 'help/faq', :to => 'help#faq', :as => 'faq'
get 'help/contact', :to => 'help#contact', :as => 'contact'
get 'help/beta', :to => 'help#beta', :as => 'beta'
get 'about', :to => 'help#about', :as => 'about'
get 'sitelicense', :to => 'home#sitelicense', :as => 'sitelicense'
get 'help/authoring', :to => 'help#authoring', :as => 'authoring'
get 'help/legal', :to => 'help#legal_faq', :as => 'legal'
get 'help/images', :to => 'help#image_help', :as => 'images'
get 'help/dialog', :to => 'help#dialog', :as => 'dialog'
get 'help/comments', :to => 'help#comments', :as => 'comments'
get 'help/messages', :to => 'help#message_help', :as => "messages"
get 'help/roles', :to => 'help#roles_help', :as => 'roles'
get 'help/topic/:topic_name', :to => 'help#topic', :as => 'topic_help'
resources :projects do
resources :project_members, :only => [:create, :new] do
collection do
post 'search'
end
end
commentable
end
resources :project_members, :only => [:destroy] do
put 'make_default'
end
resources :project_questions, :only => [] do
collection do
put 'update'
put 'copy'
put 'move'
put 'preview_publish', :to => 'project_questions#preview_publish'
put 'attribution'
delete 'destroy'
end
end
get 'questions/search'
resources :questions do
put 'preview'
get 'history'
get 'quickview'
resources :question_collaborators, :only => [:index, :create, :destroy, :new] do
collection do
post 'search'
end
sortable
end
resources :solutions, :only => [:index, :new]
get 'license/edit', :to => "questions#edit_license", :as => 'edit_license'
put 'license', :to => "questions#update_license", :as => 'license'
collection do
put 'publish', :to => 'questions#publish'
get 'publish', :to => 'questions#preview_publish'
get 'get_started'
end
get 'source'
put 'new_version'
get 'derivation_dialog'
put 'new_derivation'
put 'edit_now'
put 'edit_later'
get 'part/:part_id', :to => "questions#show_part", :as => 'show_part'
get 'tags', :on => :collection
post 'tags', :to => "questions#add_tags", :as => 'tags'
delete 'tags/:tag', :to => "questions#remove_tag", :as => 'tag'
get 'tagged/:tags', :to => "questions#tagged", :as => 'tagged', :on => :collection
get :autocomplete_tag_name, :on => :collection
commentable
end
post 'questions/simple', :to => 'questions#create_simple', :as => 'create_simple_question'
post 'questions/multipart', :to => 'questions#create_multipart', :as => 'create_multipart_question'
resources :multipart_questions, :only => [] do
put 'add_blank_part'
post 'add_existing_parts'
end
resources :question_parts, :only => [:destroy] do
sortable
end
resources :attachable_assets, :only => [:create, :destroy] do
get 'download'
get 'finish_create'
end
# Question subclasses need routes for create; however, they only need a
# controller that inherits from QuestionsController and that overrides
# the create method (see QuestionsController.rb). Any other question
# subclass route should be handled by the QuestionsController
#
# Note: the SimpleQuestions controller has been taken out b/c now everything
# can be handled by the Questions controller. Leaving these here for a while
# now until we're sure everything works.
# resources :simple_questions, :only => [:create]
# resources :simple_questions, :controller => 'questions'
resources :question_role_requests, :only => [:create, :destroy] do
put 'accept'
put 'reject'
put 'approve'
put 'veto'
end
resources :question_dependency_pairs, :only => [:create, :destroy]
resources :solutions, :except => [:index, :new, :create] do
commentable
votable
end
resources :comments, :only => [:show, :edit, :update, :destroy] do
votable
end
resources :messages, :only => [:new, :show, :update] do
get 'new_recipient'
post 'search_recipients'
post 'add_recipient'
get 'leave'
commentable
end
get "dev/toolbox"
put 'dev/reset_time'
post 'dev/freeze_time'
post 'dev/time_travel'
get 'subscriptions', :to => 'comment_thread_subscriptions#index', :as => 'subscriptions'
match '/', :to => 'home#index', :as => ''
match "/:id", :to => "home#shortcut", :constraints => {:id => /q(\d+)(v(\d+))?.*/}
root :to => 'home#index'
end