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