big cleanup

This commit is contained in:
Mayel 2021-06-05 21:05:51 +02:00
parent bbd9bd6f2e
commit 96235877a7
6 changed files with 42 additions and 28 deletions

View file

@ -1,5 +1,5 @@
[
import_deps: [:ecto, :phoenix, :ecto_sql, :surface],
import_deps: [:phoenix, :ecto_sql, :surface],
inputs: ["*.{ex,exs,sface}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs,sface}", "forks/*/{config,lib,test}/**/*.{ex,exs,sface}"],
subdirectories: ["priv/*/migrations"]
]

View file

@ -9,5 +9,5 @@ config :bonfire_me, Bonfire.Me.Identity.Mails,
#### Pointer class configuration
config :bonfire_me, Bonfire.Me.Users.Follows,
config :bonfire_me, Bonfire.Me.Follows,
followable_types: [Bonfire.Data.Identity.User]

View file

@ -1,17 +1,18 @@
import Config
flavour = System.get_env("BONFIRE_FLAVOUR", "flavours/classic")
default_flavour = "classic"
flavour_path = System.get_env("BONFIRE_FLAVOUR", "flavours/"<>System.get_env("FLAVOUR", default_flavour))
flavour = System.get_env("FLAVOUR", flavour_path |> String.split("/") |> List.last())
#### Basic configuration
config :bonfire, Bonfire.Repo, priv: flavour <> "/repo"
# You probably won't want to touch these. You might override some in
# other config files.
config :bonfire,
otp_app: :bonfire,
env: config_env(),
flavour: flavour,
app_name: System.get_env("APP_NAME", "Bonfire"),
repo_module: Bonfire.Repo,
web_module: Bonfire.Web,
@ -39,7 +40,9 @@ config :bonfire, Bonfire.Web.Endpoint,
config :phoenix, :json_library, Jason
config :bonfire, :ecto_repos, [Bonfire.Repo]
config :bonfire, Bonfire.Repo, types: Bonfire.PostgresTypes
config :bonfire, Bonfire.Repo,
types: Bonfire.PostgresTypes,
priv: flavour_path <> "/repo"
# ecto query filtering
# config :query_elf, :id_types, [:id, :binary_id, Pointers.ULID]

View file

@ -9,6 +9,17 @@ defmodule Bonfire.Application do
use Application
def start(_type, _args) do
applications(Application.fetch_env!(:bonfire, :flavour)) #|> IO.inspect
|> Supervisor.start_link(strategy: :one_for_one, name: @sup_name)
end
def applications(flavour) when flavour in ["coordination", "reflow"] do
[
{Absinthe.Schema, Bonfire.GraphQL.Schema} # use persistent_term backend for Absinthe
] ++ applications(nil)
end
def applications(_) do
[ Bonfire.Web.Telemetry, # Metrics
Bonfire.Repo, # Database
{Phoenix.PubSub, name: Bonfire.PubSub}, # PubSub
@ -17,10 +28,9 @@ defmodule Bonfire.Application do
Bonfire.Data.AccessControl.Accesses,
Bonfire.Data.AccessControl.Verbs,
# Stuff that uses all the above
Bonfire.Web.Endpoint, # Webapp
{Oban, Application.get_env(:bonfire, Oban)} # Job Queue
Bonfire.Web.Endpoint, # Web app
{Oban, Application.fetch_env!(:bonfire, Oban)} # Job Queue
]
|> Supervisor.start_link(strategy: :one_for_one, name: @sup_name)
end
# Tell Phoenix to update the endpoint configuration

View file

@ -3,6 +3,7 @@ if Bonfire.Common.Utils.module_enabled?(Bonfire.GraphQL) and Bonfire.Common.Util
defmodule Bonfire.GraphQL.Schema do
@moduledoc "Root GraphQL Schema"
use Absinthe.Schema
@schema_provider Absinthe.Schema.PersistentTerm
# import Bonfire.GraphQL.SchemaUtils

View file

@ -4,8 +4,8 @@ defmodule Bonfire.Web.LiveHandler do
# start handler pattern matching
alias Bonfire.Me.Web.LiveHandlers.{Profiles, Circles}
alias Bonfire.Social.Web.LiveHandlers.{Flags, Boosts, Likes, Posts, Feeds, Follows}
alias Bonfire.Me.{Profiles, Circles}
alias Bonfire.Social.{Flags, Boosts, Likes, Posts, Feeds, Follows}
# TODO: make this whole thing config-driven
@profile_events ["profile_save"]
@ -30,42 +30,42 @@ defmodule Bonfire.Web.LiveHandler do
# Profiles
defp do_handle_event(event, attrs, socket) when event in @profile_events or binary_part(event, 0, 7) == "profile", do: Profiles.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) when event in @profile_events or binary_part(event, 0, 7) == "profile", do: Profiles.LiveHandler.handle_event(event, attrs, socket)
# Circles
defp do_handle_event(event, attrs, socket) when event in @circle_events or binary_part(event, 0, 6) == "circle", do: Circles.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) when event in @circle_events or binary_part(event, 0, 6) == "circle", do: Circles.LiveHandler.handle_event(event, attrs, socket)
# Boundaries
defp do_handle_event(event, attrs, socket) when event in @boundary_events or binary_part(event, 0, 8) == "boundary", do: Bonfire.Me.Web.LiveHandlers.Boundaries.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) when event in @boundary_events or binary_part(event, 0, 8) == "boundary", do: Bonfire.Me.Web.LiveHandlers.Boundaries.LiveHandler.handle_event(event, attrs, socket)
# Likes
defp do_handle_event(event, attrs, socket) when event in @like_events or binary_part(event, 0, 4) == "like", do: Likes.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) when event in @like_events or binary_part(event, 0, 4) == "like", do: Likes.LiveHandler.handle_event(event, attrs, socket)
# Boosts
defp do_handle_event(event, attrs, socket) when event in @boost_events or binary_part(event, 0, 5) == "boost", do: Boosts.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) when event in @boost_events or binary_part(event, 0, 5) == "boost", do: Boosts.LiveHandler.handle_event(event, attrs, socket)
# Flags
defp do_handle_event(event, attrs, socket) when event in @flag_events or binary_part(event, 0, 4) == "flag", do: Flags.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) when event in @flag_events or binary_part(event, 0, 4) == "flag", do: Flags.LiveHandler.handle_event(event, attrs, socket)
# Posts
defp do_handle_params(%{"post" => params}, uri, socket), do: Posts.handle_params(params, uri, socket)
defp do_handle_event(event, attrs, socket) when event in @post_events or binary_part(event, 0, 4) == "post", do: Posts.handle_event(event, attrs, socket)
defp do_handle_info({info, data}, socket) when info in @post_infos, do: Posts.handle_info({info, data}, socket)
defp do_handle_info({info, id, data}, socket) when info in @post_infos, do: Posts.handle_info({info, id, data}, socket)
defp do_handle_params(%{"post" => params}, uri, socket), do: Posts.LiveHandler.handle_params(params, uri, socket)
defp do_handle_event(event, attrs, socket) when event in @post_events or binary_part(event, 0, 4) == "post", do: Posts.LiveHandler.handle_event(event, attrs, socket)
defp do_handle_info({info, data}, socket) when info in @post_infos, do: Posts.LiveHandler.handle_info({info, data}, socket)
defp do_handle_info({info, id, data}, socket) when info in @post_infos, do: Posts.LiveHandler.handle_info({info, id, data}, socket)
# Feeds
defp do_handle_params(%{"feed" => params}, uri, socket), do: Feeds.handle_params(params, uri, socket)
defp do_handle_event(event, attrs, socket) when event in @feed_events or binary_part(event, 0, 4) == "feed", do: Feeds.handle_event(event, attrs, socket)
defp do_handle_info({info, data}, socket) when info in @feed_infos, do: Feeds.handle_info({info, data}, socket)
defp do_handle_params(%{"feed" => params}, uri, socket), do: Feeds.LiveHandler.handle_params(params, uri, socket)
defp do_handle_event(event, attrs, socket) when event in @feed_events or binary_part(event, 0, 4) == "feed", do: Feeds.LiveHandler.handle_event(event, attrs, socket)
defp do_handle_info({info, data}, socket) when info in @feed_infos, do: Feeds.LiveHandler.handle_info({info, data}, socket)
# Follows
defp do_handle_event(event, attrs, socket) when event in @follow_events or binary_part(event, 0, 6) == "follow", do: Follows.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) when event in @follow_events or binary_part(event, 0, 6) == "follow", do: Follows.LiveHandler.handle_event(event, attrs, socket)
# Search
# defp do_handle_event(event, attrs, socket) when binary_part(event, 0, 6) == "search", do: Bonfire.Search.LiveHandler.handle_event(event, attrs, socket)
# defp do_handle_event(event, attrs, socket) when binary_part(event, 0, 6) == "search", do: Bonfire.Search.LiveHandler.LiveHandler.handle_event(event, attrs, socket)
# ValueFlows
# defp do_handle_event(event, attrs, socket) when binary_part(event, 0, 10) == "valueflows", do: ValueFlows.Web.LiveHandler.handle_event(event, attrs, socket)
# defp do_handle_event(event, attrs, socket) when binary_part(event, 0, 10) == "valueflows", do: ValueFlows.Web.LiveHandler.LiveHandler.handle_event(event, attrs, socket)
defp do_handle_event(event, attrs, socket) do
# IO.inspect(handle_event: event)
@ -91,7 +91,7 @@ defmodule Bonfire.Web.LiveHandler do
def handle_params(params, uri, socket, _source_module \\ nil) do
undead(socket, fn ->
## IO.inspect(params: params)
do_handle_params(params, uri, socket |> assign(current_url: URI.parse(uri).path))
do_handle_params(params, uri, socket |> assign_global(current_url: URI.parse(uri).path))
end)
end