167 lines
5.0 KiB
Ruby
167 lines
5.0 KiB
Ruby
# typed: strict
|
|
Rails.application.routes.draw do
|
|
mount ActionCable.server => "/cable"
|
|
|
|
# Authentication routes
|
|
devise_for :users,
|
|
controllers: {
|
|
registrations: "users/registrations",
|
|
sessions: "users/sessions",
|
|
}
|
|
root to: "pages#root"
|
|
|
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
|
namespace :api do
|
|
namespace :fa do
|
|
get :similar_users, to: "/domain/fa/api#similar_users"
|
|
get :search_user_names, to: "/domain/fa/api#search_user_names"
|
|
get :object_statuses, to: "/domain/fa/api#object_statuses"
|
|
end
|
|
end
|
|
|
|
resources :users,
|
|
only: %i[show],
|
|
controller: "domain/users",
|
|
constraints: {
|
|
id: %r{[^/]+/[^/]+},
|
|
} do
|
|
get :search_by_name, on: :collection
|
|
|
|
resources :posts, only: [], controller: "domain/posts", path: "" do
|
|
get :favorites, on: :collection, action: :user_favorite_posts
|
|
get :posts, on: :collection, action: :user_created_posts
|
|
end
|
|
end
|
|
|
|
resources :posts,
|
|
only: %i[index show],
|
|
controller: "domain/posts",
|
|
constraints: {
|
|
id: %r{[^/]+/[^/]+},
|
|
} do
|
|
resources :users, only: %i[], controller: "domain/users", path: "" do
|
|
get :faved_by, on: :collection, action: :users_faving_post
|
|
end
|
|
end
|
|
|
|
resources :post_groups,
|
|
path: "pools",
|
|
only: %i[],
|
|
controller: "domain/post_groups",
|
|
constraints: {
|
|
id: %r{[^/]+/[^/]+},
|
|
} do
|
|
resources :posts, only: %i[], controller: "domain/posts" do
|
|
get "/", on: :collection, action: :posts_in_group
|
|
end
|
|
end
|
|
|
|
# Domain::RouteHelper::DOMAIN_POST_RESOURCES.each do |resource_data|
|
|
# resolve resource_data.klass.name do |post|
|
|
# domain_post_path(post)
|
|
# end
|
|
# end
|
|
|
|
# Domain::RouteHelper::DOMAIN_USER_RESOURCES.each do |resource_data|
|
|
# resources resource_data.resource_name,
|
|
# only: [:show],
|
|
# param: resource_data.param,
|
|
# controller: resource_data.controller,
|
|
# path: "users/#{resource_data.subpath}" do
|
|
# resources :posts,
|
|
# controller: "domain/posts",
|
|
# only: %i[index],
|
|
# path: "posts"
|
|
# end
|
|
# end
|
|
|
|
# Domain::RouteHelper::DOMAIN_POST_RESOURCES.each do |resource_data|
|
|
# resources resource_data.resource_name,
|
|
# only: %i[show],
|
|
# param: resource_data.param,
|
|
# controller: resource_data.controller,
|
|
# path: "posts/#{resource_data.subpath}" do
|
|
# get :faved_by, on: :member
|
|
# end
|
|
# end
|
|
|
|
namespace :domain do
|
|
namespace :fa do
|
|
resources :users,
|
|
param: :url_name,
|
|
only: [:show],
|
|
constraints: {
|
|
url_name: %r{[^/]+},
|
|
} do
|
|
resources :posts, controller: "/domain/fa/posts", only: %i[index]
|
|
end
|
|
resources :posts, param: :fa_id, only: %i[show] do
|
|
post :scan_post, on: :member
|
|
get :favorites, on: :member
|
|
end
|
|
end
|
|
namespace :e621 do
|
|
resources :posts, param: :e621_id, only: [:show]
|
|
end
|
|
|
|
namespace :inkbunny, path: "ib" do
|
|
resources :users, param: :name, only: [:show] do
|
|
resources :posts, controller: "/domain/inkbunny/posts", only: %i[index]
|
|
end
|
|
resources :posts, param: :ib_post_id, only: %i[show]
|
|
end
|
|
end
|
|
|
|
resources :blobs, controller: :blob_entries, only: [:show], param: :sha256
|
|
|
|
resources :indexed_posts, only: [:index]
|
|
|
|
get "us/:script", to: "user_scripts#get", constraints: { script: /.*/ }
|
|
|
|
resources :global_states, path: "state" do
|
|
collection do
|
|
get "fa-cookies", to: "global_states#fa_cookies"
|
|
get "fa-cookies/edit", to: "global_states#edit_fa_cookies"
|
|
patch "fa-cookies", to: "global_states#update_fa_cookies"
|
|
|
|
get "ib-cookies", to: "global_states#ib_cookies"
|
|
get "ib-cookies/edit", to: "global_states#edit_ib_cookies"
|
|
patch "ib-cookies", to: "global_states#update_ib_cookies"
|
|
end
|
|
end
|
|
|
|
authenticate :user, ->(user) { user.admin? } do
|
|
mount GoodJob::Engine => "jobs"
|
|
mount PgHero::Engine => "pghero"
|
|
|
|
match "grafana(/*path)", to: "admin/proxy#grafana", via: :all, as: :grafana
|
|
match "prometheus(/*path)",
|
|
to: "admin/proxy#prometheus",
|
|
via: :all,
|
|
as: :prometheus
|
|
|
|
namespace :api do
|
|
get "search/user/:prefix", to: "search#user"
|
|
|
|
namespace :fa do
|
|
post :enqueue_objects, to: "/domain/fa/api#enqueue_objects"
|
|
end
|
|
namespace :twitter do
|
|
post :enqueue_objects, to: "/domain/twitter/api#enqueue_objects"
|
|
post :object_statuses, to: "/domain/twitter/api#object_statuses"
|
|
end
|
|
end
|
|
|
|
resources :log_entries, only: %i[index show] do
|
|
get :stats, on: :collection
|
|
|
|
get "filter/*filter",
|
|
on: :collection,
|
|
action: :index,
|
|
constraints: {
|
|
filter: /.*/,
|
|
}
|
|
end
|
|
end
|
|
end
|