2018-10-11 15:37:39 +00:00
|
|
|
defmodule MobilizonWeb.Router do
|
2018-01-14 16:56:50 +00:00
|
|
|
@moduledoc """
|
2018-10-11 15:37:39 +00:00
|
|
|
Router for mobilizon app
|
2018-01-14 16:56:50 +00:00
|
|
|
"""
|
2018-10-11 15:37:39 +00:00
|
|
|
use MobilizonWeb, :router
|
2017-12-08 08:58:14 +00:00
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
pipeline :graphql do
|
2018-07-27 08:45:35 +00:00
|
|
|
plug(:accepts, ["json"])
|
2018-11-06 09:30:27 +00:00
|
|
|
plug(MobilizonWeb.AuthPipeline)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
|
|
|
|
2018-05-17 09:32:23 +00:00
|
|
|
pipeline :well_known do
|
2018-11-07 15:45:11 +00:00
|
|
|
plug(:accepts, ["json", "jrd-json"])
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
pipeline :activity_pub_signature do
|
2018-11-12 08:05:31 +00:00
|
|
|
plug(:accepts, ["activity-json", "html"])
|
2018-10-11 15:37:39 +00:00
|
|
|
plug(MobilizonWeb.HTTPSignaturePlug)
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2018-11-12 17:17:53 +00:00
|
|
|
pipeline :activity_pub do
|
2019-03-04 16:20:18 +00:00
|
|
|
plug(:accepts, ["activity-json"])
|
|
|
|
end
|
|
|
|
|
|
|
|
pipeline :activity_pub_and_html do
|
2019-03-05 11:24:29 +00:00
|
|
|
plug(:accepts, ["html", "activity-json"])
|
2018-11-12 17:17:53 +00:00
|
|
|
end
|
|
|
|
|
2019-03-01 11:57:22 +00:00
|
|
|
pipeline :rss do
|
|
|
|
plug(:accepts, ["atom", "html"])
|
2019-02-27 15:28:09 +00:00
|
|
|
end
|
|
|
|
|
2018-01-09 16:52:26 +00:00
|
|
|
pipeline :browser do
|
2018-07-27 08:45:35 +00:00
|
|
|
plug(:accepts, ["html"])
|
|
|
|
plug(:fetch_session)
|
|
|
|
plug(:fetch_flash)
|
|
|
|
plug(:protect_from_forgery)
|
|
|
|
plug(:put_secure_browser_headers)
|
2018-01-09 16:52:26 +00:00
|
|
|
end
|
|
|
|
|
2018-09-03 15:53:31 +00:00
|
|
|
pipeline :nodeinfo do
|
|
|
|
plug(:accepts, ["html", "application/json"])
|
|
|
|
end
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
scope "/api" do
|
|
|
|
pipe_through(:graphql)
|
2018-07-27 08:45:35 +00:00
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
forward("/", Absinthe.Plug, schema: MobilizonWeb.Schema)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
forward("/graphiql", Absinthe.Plug.GraphiQL, schema: MobilizonWeb.Schema)
|
2018-05-17 09:32:23 +00:00
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
scope "/.well-known", MobilizonWeb do
|
2018-07-27 08:45:35 +00:00
|
|
|
pipe_through(:well_known)
|
2018-05-17 09:32:23 +00:00
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/host-meta", WebFingerController, :host_meta)
|
|
|
|
get("/webfinger", WebFingerController, :webfinger)
|
2018-11-06 09:30:27 +00:00
|
|
|
get("/nodeinfo", NodeInfoController, :schemas)
|
|
|
|
get("/nodeinfo/:version", NodeInfoController, :nodeinfo)
|
2018-05-17 09:32:23 +00:00
|
|
|
end
|
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
scope "/", MobilizonWeb do
|
2019-03-01 11:57:22 +00:00
|
|
|
pipe_through(:rss)
|
2018-07-27 08:45:35 +00:00
|
|
|
|
2019-03-01 11:57:22 +00:00
|
|
|
get("/@:name/feed/:format", FeedController, :actor)
|
2019-02-27 15:28:09 +00:00
|
|
|
end
|
|
|
|
|
2019-03-05 11:07:58 +00:00
|
|
|
scope "/", MobilizonWeb do
|
|
|
|
pipe_through(:browser)
|
|
|
|
|
|
|
|
# Because the "/events/:uuid" route caches all these, we need to force them
|
|
|
|
get("/events/create", PageController, :index)
|
|
|
|
get("/events/list", PageController, :index)
|
|
|
|
get("/events/:uuid/edit", PageController, :index)
|
|
|
|
end
|
|
|
|
|
2019-03-04 16:20:18 +00:00
|
|
|
scope "/", MobilizonWeb do
|
|
|
|
pipe_through(:activity_pub_and_html)
|
|
|
|
get("/@:name", PageController, :actor)
|
|
|
|
get("/events/:uuid", PageController, :event)
|
|
|
|
get("/comments/:uuid", PageController, :comment)
|
|
|
|
end
|
|
|
|
|
2019-02-27 15:28:09 +00:00
|
|
|
scope "/", MobilizonWeb do
|
|
|
|
pipe_through(:activity_pub)
|
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/@:name/outbox", ActivityPubController, :outbox)
|
|
|
|
get("/@:name/following", ActivityPubController, :following)
|
|
|
|
get("/@:name/followers", ActivityPubController, :followers)
|
2018-11-12 17:17:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scope "/", MobilizonWeb do
|
|
|
|
pipe_through(:activity_pub_signature)
|
2018-07-27 08:45:35 +00:00
|
|
|
post("/@:name/inbox", ActivityPubController, :inbox)
|
|
|
|
post("/inbox", ActivityPubController, :inbox)
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
2018-01-09 16:52:26 +00:00
|
|
|
|
2018-07-27 08:45:35 +00:00
|
|
|
if Mix.env() == :dev do
|
2018-07-04 12:29:17 +00:00
|
|
|
# If using Phoenix
|
2018-07-27 08:45:35 +00:00
|
|
|
forward("/sent_emails", Bamboo.SentEmailViewerPlug)
|
2018-07-04 12:29:17 +00:00
|
|
|
end
|
|
|
|
|
2018-10-11 15:37:39 +00:00
|
|
|
scope "/", MobilizonWeb do
|
2018-07-27 08:45:35 +00:00
|
|
|
pipe_through(:browser)
|
2018-01-09 16:52:26 +00:00
|
|
|
|
2018-11-06 09:30:27 +00:00
|
|
|
forward("/uploads", UploadPlug)
|
2018-07-27 08:45:35 +00:00
|
|
|
get("/*path", PageController, :index)
|
2018-01-09 16:52:26 +00:00
|
|
|
end
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|