/
routes.rb
231 lines (205 loc) · 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
230
231
# frozen_string_literal: true
require "sidekiq/web"
require "sidekiq/cron/web"
Rails.application.routes.draw do
use_doorkeeper do
controllers applications: "oauth/applications",
authorized_applications: "oauth/authorized_applications"
end
resources :comments
resources :devices
resources :teams
root to: "topics#index"
match "/uploads/:path(![large|lg|md|sm|xs])", to: "home#uploads", via: :get, constraints: {
path: /[\w\d.\/-]+/i
}
get "status", to: "home#status"
get "manifest.webmanifest", to: "home#manifest"
devise_for :users, path: "account", controllers: {
registrations: "users/registrations",
sessions: "users/sessions",
passwords: "users/passwords",
omniauth_callbacks: "users/omniauth_callbacks"
}
resource :setting do
member do
get :account
get :password
get :profile
get :reward
end
end
# SSO
namespace :auth do
resource :sso, controller: "sso" do
collection do
get :login
get :provider
end
end
end
delete "setting/auth/:provider", to: "settings#auth_unbind", as: "auth_unbind_setting"
resources :nodes do
member do
post :block
post :unblock
end
end
get "topics/node:id", to: "topics#node", as: "node_topics"
get "topics/node:id/feed", to: "topics#node_feed", as: "feed_node_topics", defaults: {format: "xml"}
resources :topics do
member do
post :favorite
delete :unfavorite
post :follow
delete :unfollow
post :action
# ban popup window
get :ban
post :read
end
collection do
get :no_reply
get :popular
get :last
get :last_reply
get :banned
get :excellent
get :favorites
get :feed, defaults: {format: "xml"}
post :preview
end
resources :replies do
member do
get :reply_to
end
end
end
resources :photos
resources :likes
get "/search", to: "search#index", as: "search"
get "/search/users", to: "search#users", as: "search_users"
namespace :admin do
root to: "dashboards#index", as: "root"
resource :dashboards do
collection do
post :reboot
end
end
resources :site_configs
resources :replies do
member do
post :revert
end
end
resources :topics do
member do
post :suggest
post :unsuggest
post :revert
end
end
resources :nodes
resources :users, constraints: {id: /[#{User::LOGIN_FORMAT}]*/o} do
member do
delete :clean
end
end
resources :photos
resources :comments
resources :locations
resources :applications
resources :stats
resources :plugins
end
get "api", to: "home#api", as: "api"
get "markdown", to: "home#markdown", as: "markdown"
namespace :api do
namespace :v3 do
get "hello", to: "root#hello"
resource :devices
resource :likes
resources :nodes
resources :photos
resources :notifications do
collection do
post :read
get :unread_count
delete :all
end
end
resources :topics do
member do
post :update
get :replies
post :replies
post :follow
post :unfollow
post :favorite
post :unfavorite
post :ban
post :action
end
end
resources :replies do
member do
post :update
end
end
resources :users do
collection do
get :me
end
member do
get :topics
get :replies
get :favorites
get :followers
get :following
get :blocked
post :follow
post :unfollow
post :block
post :unblock
end
end
match "*path", to: "root#not_found", via: :all
end
end
authenticate :user, ->(u) { u.admin? } do
mount Sidekiq::Web, at: "sidekiq"
mount PgHero::Engine, at: "pghero"
mount ExceptionTrack::Engine, at: "exception-track"
end
mount Notifications::Engine, at: "notifications"
# WARRING!请保持 User 的 routes 在所有路由的最后,以便于可以让用户名在根目录下面使用,而又不影响到其他的 routes
# 比如 http://localhost:3000/huacnlee
get "users/city/:id", to: "users#city", as: "location_users"
get "users", to: "users#index", as: "users"
constraints(id: /[#{User::LOGIN_FORMAT}]*/o) do
resources :users, path: "", as: "users" do
member do
get :feed
# User only
get :topics
get :replies
get :favorites
get :blocked
post :block
post :unblock
post :follow
post :unfollow
get :followers
get :following
get :reward
end
resources :team_users, path: "people" do
member do
post :accept
post :reject
end
end
end
end
match "*path", to: "home#error_404", via: :all
end