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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# encoding: UTF-8
# config/routes.rb:
# Mapping URLs to controllers for FOIFA.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: hello@mysociety.org; WWW: http://www.mysociety.org/
# Allow easy extension from themes. Note these will have the highest priority.
$alaveteli_route_extensions.each do |f|
load File.join('config', f)
end
Alaveteli::Application.routes.draw do
#### General contoller
match '/' => 'general#frontpage', :as => :frontpage
match '/blog' => 'general#blog', :as => :blog
match '/search' => 'general#search_redirect', :as => :search_redirect
match '/search/all' => 'general#search_redirect', :as => :search_redirect
# `combined` is the search query, and then if sorted a "/newest" at the end.
# Couldn't find a way to do this in routes which also picked up multiple other slashes
# and dots and other characters that can appear in search query. So we sort it all
# out in the controller.
match '/search/*combined/all' => 'general#search', :as => :search_general, :view => 'all'
match '/search(/*combined)' => 'general#search', :as => :search_general
match '/advancedsearch' => 'general#search_redirect', :as => :advanced_search, :advanced => true
match '/version.:format' => 'general#version', :as => :version
#####
##### Request controller
match '/list/recent' => 'request#list', :as => :request_list_recent, :view => 'recent'
match '/list/all' => 'request#list', :as => :request_list_all, :view => 'all'
match '/list/successful' => 'request#list', :as => :request_list_successful, :view => 'successful'
match '/list/unsuccessful' => 'request#list', :as => :request_list_unsuccessful, :view => 'unsuccessful'
match '/list/awaiting' => 'request#list', :as => :request_list_awaiting, :view => 'awaiting'
match '/list' => 'request#list', :as => :request_list
match '/select_authority' => 'request#select_authority', :as => :select_authority
match '/select_authorities' => 'request#select_authorities', :as => :select_authorities
match '/new' => 'request#new', :as => :new_request
match '/new/:url_name' => 'request#new', :as => :new_request_to_body
match '/new_batch' => 'request#new_batch', :as => :new_batch
match '/request/search_ahead' => 'request#search_typeahead', :as => :search_ahead
match '/request/:url_title' => 'request#show', :as => :show_request
match '/request/:url_title/new' => 'request#show', :as => :show_new_request
match '/details/request/:url_title' => 'request#details', :as => :details_request
match '/similar/request/:url_title' => 'request#similar', :as => :similar_request
match '/request/:id/describe' => 'request#describe_state', :as => :describe_state
match '/request/:url_title/describe/:described_state' => 'request#describe_state_message', :as => :describe_state_message
match '/request/:id/response' => 'request#show_response', :as => :show_response_no_followup
match '/request/:id/response/:incoming_message_id' => 'request#show_response', :as => :show_response
match '/request/:id/response/:incoming_message_id/attach/html/:part/*file_name' => 'request#get_attachment_as_html', :format => false, :as => :get_attachment_as_html
match '/request/:id/response/:incoming_message_id/attach/:part(/*file_name)' => 'request#get_attachment', :format => false, :as => :get_attachment
match '/request_event/:info_request_event_id' => 'request#show_request_event', :as => :info_request_event
match '/upload/request/:url_title' => 'request#upload_response', :as => :upload_response
match '/request/:url_title/download' => 'request#download_entire_request', :as => :download_entire_request
####
resources :health_checks, :only => [:index]
resources :request, :only => [] do
resource :report, :only => [:new, :create]
end
resources :info_request_batch, :only => :show
#### User controller
# Use /profile for things to do with the currently signed in user.
# Use /user/XXXX for things that anyone can see about that user.
# Note that /profile isn't indexed by search (see robots.txt)
match '/profile/sign_in' => 'user#signin', :as => :signin
match '/profile/sign_up' => 'user#signup', :as => :signup, :via => :post
match '/profile/sign_up' => 'user#signin', :via => :get
match '/profile/sign_out' => 'user#signout', :as => :signout
match '/c/:email_token' => 'user#confirm', :as => :confirm
match '/user/:url_name' => 'user#show', :as => :show_user
match '/user/:url_name/profile' => 'user#show', :as => :show_user_profile, :view => 'profile'
match '/user/:url_name/requests' => 'user#show', :as => :show_user_requests, :view => 'requests'
match '/user/:url_name/wall' => 'user#wall', :as => :show_user_wall
match '/user/contact/:id' => 'user#contact', :as => :contact_user
match '/profile/change_password' => 'user#signchangepassword', :as => :signchangepassword
match '/profile/change_email' => 'user#signchangeemail', :as => :signchangeemail
match '/profile/set_photo' => 'user#set_profile_photo', :as => :set_profile_photo
match '/profile/clear_photo' => 'user#clear_profile_photo', :as => :clear_profile_photo
match '/user/:url_name/photo.png' => 'user#get_profile_photo', :as => :get_profile_photo
match '/profile/draft_photo/:id.png' => 'user#get_draft_profile_photo', :as => :get_draft_profile_photo
match '/profile/set_about_me' => 'user#set_profile_about_me', :as => :set_profile_about_me
match '/profile/set_receive_alerts' => 'user#set_receive_email_alerts', :as => :set_receive_email_alerts
match '/profile/river' => 'user#river', :as => :river
####
#### PublicBody controller
match '/body/search_ahead' => 'public_body#search_typeahead', :as => :search_ahead_bodies
match '/body' => 'public_body#list', :as => :list_public_bodies
match '/body/list/all' => 'public_body#list', :as => :list_public_bodies_default
match '/body/list/:tag' => 'public_body#list', :as => :list_public_bodies
match '/local/:tag' => 'public_body#list_redirect', :as => :list_public_bodies_redirect
match '/body/all-authorities.csv' => 'public_body#list_all_csv', :as => :all_public_bodies_csv
match '/body/:url_name' => 'public_body#show', :as => :show_public_body, :view => 'all'
match '/body/:url_name/all' => 'public_body#show', :as => :show_public_body_all, :view => 'all'
match '/body/:url_name/successful' => 'public_body#show', :as => :show_public_body_successful, :view => 'successful'
match '/body/:url_name/unsuccessful' => 'public_body#show', :as => :show_public_body_unsuccessful, :view => 'unsuccessful'
match '/body/:url_name/awaiting' => 'public_body#show', :as => :show_public_body_awaiting, :view => 'awaiting'
match '/body/:url_name/view_email' => 'public_body#view_email', :as => :view_public_body_email
match '/body/:url_name/:tag' => 'public_body#show', :as => :show_public_body_tag
match '/body/:url_name/:tag/:view' => 'public_body#show', :as => :show_public_body_tag_view
match '/body_statistics' => 'public_body#statistics', :as => :public_bodies_statistics
####
resource :change_request, :only => [:new, :create], :controller => 'public_body_change_requests'
#### Comment controller
match '/annotate/request/:url_title' => 'comment#new', :as => :new_comment, :type => 'request'
####
#### Services controller
match '/country_message' => 'services#other_country_message', :as => :other_country_message
match '/hidden_user_explanation' => 'services#hidden_user_explanation', :as => :hidden_user_explanation
####
#### Track controller
# /track/ is for setting up an email alert for the item
# /feed/ is a direct RSS feed of the item
match '/:feed/request/:url_title' => 'track#track_request', :as => :track_request, :feed => /(track|feed)/
match '/:feed/list/:view' => 'track#track_list', :as => :track_list, :view => nil, :feed => /(track|feed)/
match '/:feed/body/:url_name' => 'track#track_public_body', :as => :track_public_body, :feed => /(track|feed)/
match '/:feed/user/:url_name' => 'track#track_user', :as => :track_user, :feed => /(track|feed)/
# TODO: :format doesn't work. See hacky code in the controller that makes up for this.
match '/:feed/search/:query_array' => 'track#track_search_query',
:as => :track_search,
:feed => /(track|feed)/,
:constraints => { :query_array => /.*/ }
match '/track/update/:track_id' => 'track#update', :as => :update
match '/track/delete_all_type' => 'track#delete_all_type', :as => :delete_all_type
match '/track/feed/:track_id' => 'track#atom_feed', :as => :atom_feed
####
#### Help controller
match '/help/unhappy/:url_title' => 'help#unhappy', :as => :help_unhappy
match '/help/about' => 'help#about', :as => :help_about
match '/help/alaveteli' => 'help#alaveteli', :as => :help_alaveteli
match '/help/contact' => 'help#contact', :as => :help_contact
match '/help/officers' => 'help#officers', :as => :help_officers
match '/help/requesting' => 'help#requesting', :as => :help_requesting
match '/help/privacy' => 'help#privacy', :as => :help_privacy
match '/help/api' => 'help#api', :as => :help_api
match '/help/credits' => 'help#credits', :as => :help_credits
match '/help/:action' => 'help#action', :as => :help_general
match '/help' => 'help#index'
####
#### Holiday controller
match '/due_date/:holiday' => 'holiday#due_date', :as => :due_date
####
#### RequestGame controller
match '/categorise/play' => 'request_game#play', :as => :categorise_play
match '/categorise/request/:url_title' => 'request_game#show', :as => :categorise_request
match '/categorise/stop' => 'request_game#stop', :as => :categorise_stop
####
#### AdminPublicBody controller
scope '/admin', :as => 'admin' do
resources :bodies,
:controller => 'admin_public_body' do
get 'missing_scheme', :on => :collection
post 'mass_tag_add', :on => :collection
get 'import_csv', :on => :collection
post 'import_csv', :on => :collection
end
end
####
#### AdminPublicBodyCategory controller
scope '/admin', :as => 'admin' do
resources :categories,
:controller => 'admin_public_body_categories'
end
####
#### AdminPublicBodyHeading controller
scope '/admin', :as => 'admin' do
resources :headings,
:controller => 'admin_public_body_headings',
:except => [:index] do
post 'reorder', :on => :collection
post 'reorder_categories', :on => :member
end
end
####
#### AdminPublicBodyChangeRequest controller
scope '/admin', :as => 'admin' do
resources :change_requests,
:controller => 'admin_public_body_change_requests',
:only => [:edit, :update]
end
####
#### AdminGeneral controller
match '/admin' => 'admin_general#index', :as => :admin_general_index
match '/admin/timeline' => 'admin_general#timeline', :as => :admin_timeline
match '/admin/debug' => 'admin_general#debug', :as => :admin_debug
match '/admin/stats' => 'admin_general#stats', :as => :admin_stats
####
#### AdminRequest controller
scope '/admin', :as => 'admin' do
resources :requests,
:controller => 'admin_request',
:except => [:new, :create] do
post 'move', :on => :member
post 'generate_upload_url', :on => :member
post 'hide', :on => :member
end
end
####
#### AdminComment controller
scope '/admin', :as => 'admin' do
resources :comments,
:controller => 'admin_comment',
:only => [:edit, :update]
end
####
#### AdminRawEmail controller
scope '/admin', :as => 'admin' do
resources :raw_emails,
:controller => 'admin_raw_email',
:only => [:show]
end
####
#### AdminInfoRequestEvent controller
scope '/admin', :as => 'admin' do
resources :info_request_events,
:controller => 'admin_info_request_event',
:only => [:update]
end
#### AdminIncomingMessage controller
scope '/admin', :as => 'admin' do
resources :incoming_messages,
:controller => 'admin_incoming_message',
:only => [:edit, :update, :destroy] do
post 'redeliver', :on => :member
end
end
####
#### AdminOutgoingMessage controller
scope '/admin', :as => 'admin' do
resources :outgoing_messages,
:controller => 'admin_outgoing_message',
:only => [:edit, :update, :destroy] do
post 'resend', :on => :member
end
end
####
#### AdminUser controller
scope '/admin', :as => 'admin' do
resources :users,
:controller => 'admin_user',
:except => [:new, :create, :destroy] do
get 'banned', :on => :collection
get 'show_bounce_message', :on => :member
post 'clear_bounce', :on => :member
post 'destroy_track', :on => :member
post 'login_as', :on => :member
post 'clear_profile_photo', :on => :member
end
end
match '/admin/user/modify_comment_visibility/:id' => 'admin_user#modify_comment_visibility', :as => 'admin_user_modify_comment_visibility'
####
#### AdminTrack controller
match '/admin/track/list' => 'admin_track#list', :as => :admin_track_list
####
#### AdminCensorRule controller
match '/admin/censor/new' => 'admin_censor_rule#new', :as => :admin_rule_new
match '/admin/censor/create' => 'admin_censor_rule#create', :as => :admin_rule_create
match '/admin/censor/edit/:id' => 'admin_censor_rule#edit', :as => :admin_rule_edit
match '/admin/censor/update/:id' => 'admin_censor_rule#update', :as => :admin_rule_update
match '/admin/censor/destroy/:censor_rule_id' => 'admin_censor_rule#destroy', :as => :admin_rule_destroy
scope '/admin', :as => 'admin' do
resources :info_requests, :only => [] do
resources :censor_rules,
:controller => 'admin_censor_rule',
:only => [:new, :create],
:name_prefix => 'info_request_'
end
end
scope '/admin', :as => 'admin' do
resources :users, :only => [] do
resources :censor_rules,
:controller => 'admin_censor_rule',
:only => [:new, :create],
:name_prefix => 'user_'
end
end
####
#### AdminSpamAddresses controller
scope '/admin', :as => 'admin' do
resources :spam_addresses,
:controller => 'admin_spam_addresses',
:only => [:index, :create, :destroy]
end
####
#### Api controller
match '/api/v2/request.json' => 'api#create_request', :as => :api_create_request, :via => :post
match '/api/v2/request/:id.json' => 'api#show_request', :as => :api_show_request, :via => :get
match '/api/v2/request/:id.json' => 'api#add_correspondence', :as => :api_add_correspondence, :via => :post
match '/api/v2/request/:id/update.json' => 'api#update_state', :as => :api_update_state, :via => :post
match '/api/v2/body/:id/request_events.:feed_type' => 'api#body_request_events', :as => :api_body_request_events, :feed_type => '^(json|atom)$'
####
filter :conditionallyprependlocale
end
|