Replace Vuetify with Bulma

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Remove vuetify and add Bulma

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-01-21 15:08:22 +01:00
parent 759a740625
commit 90fd0ff6b6
79 changed files with 3482 additions and 3369 deletions

View File

@@ -42,7 +42,7 @@ defmodule Mobilizon.Actors.Actor do
field(:shared_inbox_url, :string)
field(:type, Mobilizon.Actors.ActorTypeEnum, default: :Person)
field(:name, :string)
field(:domain, :string)
field(:domain, :string, default: nil)
field(:summary, :string)
field(:preferred_username, :string)
field(:keys, :string)

View File

@@ -77,9 +77,30 @@ defmodule Mobilizon.Actors do
Repo.all(from(a in Actor, where: a.user_id == ^user_id))
end
def get_actor_with_everything!(id) do
actor = Repo.get!(Actor, id)
Repo.preload(actor, [:organized_events, :followers, :followings])
@spec get_actor_with_everything(integer()) :: Ecto.Query
defp do_get_actor_with_everything(id) do
from(a in Actor, where: a.id == ^id, preload: [:organized_events, :followers, :followings])
end
@doc """
Returns an actor with every relation
"""
@spec get_actor_with_everything(integer()) :: Mobilizon.Actors.Actor.t()
def get_actor_with_everything(id) do
id
|> do_get_actor_with_everything
|> Repo.one()
end
@doc """
Returns an actor with every relation
"""
@spec get_local_actor_with_everything(integer()) :: Mobilizon.Actors.Actor.t()
def get_local_actor_with_everything(id) do
id
|> do_get_actor_with_everything
|> where([a], is_nil(a.domain))
|> Repo.one()
end
@doc """
@@ -610,6 +631,19 @@ defmodule Mobilizon.Actors do
{:error, hd(email_msg)}
end
@doc """
Create a new person actor
"""
def new_person(args) do
key = :public_key.generate_key({:rsa, 2048, 65_537})
entry = :public_key.pem_entry_encode(:RSAPrivateKey, key)
pem = [entry] |> :public_key.pem_encode() |> String.trim_trailing()
args = Map.put(args, :keys, pem)
actor = Mobilizon.Actors.Actor.registration_changeset(%Mobilizon.Actors.Actor{}, args)
Mobilizon.Repo.insert(actor)
end
def register_bot_account(%{name: name, summary: summary}) do
key = :public_key.generate_key({:rsa, 2048, 65_537})
entry = :public_key.pem_entry_encode(:RSAPrivateKey, key)

View File

@@ -24,10 +24,12 @@ defmodule Mobilizon.Actors.Service.ResetPassword do
{:ok, user}
else
{:error, %Ecto.Changeset{errors: [password: {"registration.error.password_too_short", _}]}} ->
{:error, :password_too_short}
{:error,
"The password you have choosen is too short. Please make sure your password contains at least 6 charaters."}
_err ->
{:error, :invalid_token}
{:error,
"The token you provided is invalid. Make sure that the URL is exactly the one provided inside the email you got."}
end
end

View File

@@ -68,11 +68,11 @@ defmodule Mobilizon.Events.Event do
:large_image,
:publish_at,
:online_address,
:phone_address
:phone_address,
:uuid
])
|> cast_assoc(:tags)
|> cast_assoc(:physical_address)
|> build_url()
|> validate_required([
:title,
:begins_on,
@@ -82,31 +82,4 @@ defmodule Mobilizon.Events.Event do
:uuid
])
end
@spec build_url(Ecto.Changeset.t()) :: Ecto.Changeset.t()
defp build_url(%Ecto.Changeset{changes: %{url: _url}} = changeset), do: changeset
defp build_url(%Ecto.Changeset{changes: %{organizer_actor: organizer_actor}} = changeset) do
organizer_actor
|> Actor.actor_acct_from_actor()
|> do_build_url(changeset)
end
defp build_url(%Ecto.Changeset{changes: %{organizer_actor_id: organizer_actor_id}} = changeset) do
organizer_actor_id
|> Mobilizon.Actors.get_actor!()
|> Actor.actor_acct_from_actor()
|> do_build_url(changeset)
end
defp build_url(%Ecto.Changeset{} = changeset), do: changeset
@spec do_build_url(String.t(), Ecto.Changeset.t()) :: Ecto.Changeset.t()
defp do_build_url(actor_acct, changeset) do
uuid = Ecto.UUID.generate()
changeset
|> put_change(:uuid, uuid)
|> put_change(:url, "#{MobilizonWeb.Endpoint.url()}/@#{actor_acct}/#{uuid}")
end
end

View File

@@ -220,7 +220,7 @@ defmodule Mobilizon.Events do
from(
e in Event,
where: e.visibility == ^:public,
preload: [:organizer_actor]
preload: [:organizer_actor, :participants]
)
|> paginate(page, limit)

View File

@@ -14,12 +14,12 @@ defmodule MobilizonWeb.API.Events do
%{
title: title,
description: description,
organizer_actor_username: organizer_actor_username,
organizer_actor_id: organizer_actor_id,
begins_on: begins_on,
category: category
} = args
) do
with %Actor{url: url} = actor <- Actors.get_local_actor_by_name(organizer_actor_username),
with %Actor{url: url} = actor <- Actors.get_local_actor_with_everything(organizer_actor_id),
title <- String.trim(title),
mentions <- Formatter.parse_mentions(description),
visibility <- Map.get(args, :visibility, "public"),

View File

@@ -39,8 +39,8 @@ defmodule MobilizonWeb.Resolvers.Event do
@doc """
List participants for event (through an event request)
"""
def list_participants_for_event(%{uuid: uuid}, %{page: page, limit: limit}, _resolution) do
{:ok, Mobilizon.Events.list_participants_for_event(uuid, page, limit)}
def list_participants_for_event(%Event{uuid: uuid}, _args, _resolution) do
{:ok, Mobilizon.Events.list_participants_for_event(uuid, 1, 10)}
end
@doc """
@@ -81,14 +81,7 @@ defmodule MobilizonWeb.Resolvers.Event do
"""
def create_event(_parent, args, %{context: %{current_user: user}}) do
with {:ok, %Activity{data: %{"object" => %{"type" => "Event"} = object}}} <-
args
# Set default organizer_actor_id if none set
|> Map.update(
:organizer_actor_username,
Actors.get_actor_for_user(user).preferred_username,
& &1
)
|> MobilizonWeb.API.Events.create_event() do
MobilizonWeb.API.Events.create_event(args) do
{:ok,
%Event{
title: object["name"],

View File

@@ -3,6 +3,7 @@ defmodule MobilizonWeb.Resolvers.Person do
Handles the person-related GraphQL calls
"""
alias Mobilizon.Actors
alias Mobilizon.Actors.Actor
alias Mobilizon.Service.ActivityPub
@deprecated "Use find_person/3 or find_group/3 instead"
@@ -39,4 +40,28 @@ defmodule MobilizonWeb.Resolvers.Person do
def get_current_person(_parent, _args, _resolution) do
{:error, "You need to be logged-in to view current person"}
end
@doc """
Returns the list of identities for the logged-in user
"""
def identities(_parent, _args, %{context: %{current_user: user}}) do
{:ok, Actors.get_actors_for_user(user)}
end
def identities(_parent, _args, _resolution) do
{:error, "You need to be logged-in to view your list of identities"}
end
def create_person(_parent, %{preferred_username: preferred_username} = args, %{
context: %{current_user: user}
}) do
args = Map.put(args, :user_id, user.id)
with {:ok, %Actor{} = new_person} <- Actors.new_person(args) do
{:ok, new_person}
else
{:error, %Ecto.Changeset{} = e} ->
{:error, "Unable to create a profile with this username"}
end
end
end

View File

@@ -36,7 +36,7 @@ defmodule MobilizonWeb.Resolvers.User do
{:error, "User with email not found"}
{:error, :unauthorized} ->
{:error, "Impossible to authenticate"}
{:error, "Impossible to authenticate, either your email or password are invalid."}
end
end

View File

@@ -104,7 +104,7 @@ defmodule MobilizonWeb.Schema do
end
def plugins do
[Absinthe.Middleware.Dataloader | Absinthe.Plugin.defaults()]
[Absinthe.Middleware.Dataloader] ++ Absinthe.Plugin.defaults()
end
@desc """
@@ -175,6 +175,11 @@ defmodule MobilizonWeb.Schema do
resolve(&Resolvers.Person.find_person/3)
end
@desc "Get the persons for an user"
field :identities, list_of(:person) do
resolve(&Resolvers.Person.identities/3)
end
@desc "Get the list of categories"
field :categories, non_null(list_of(:category)) do
arg(:page, :integer, default_value: 1)
@@ -201,7 +206,7 @@ defmodule MobilizonWeb.Schema do
arg(:publish_at, :datetime)
arg(:online_address, :string)
arg(:phone_address, :string)
arg(:organizer_actor_username, non_null(:string))
arg(:organizer_actor_id, non_null(:id))
arg(:category, non_null(:string))
resolve(&Resolvers.Event.create_event/3)
@@ -273,6 +278,16 @@ defmodule MobilizonWeb.Schema do
resolve(&Resolvers.User.change_default_actor/3)
end
@desc "Create a new person for user"
field :create_person, :person do
arg(:preferred_username, non_null(:string))
arg(:name, :string, description: "The displayed name for the new profile")
arg(:description, :string, description: "The summary for the new profile", default_value: "")
resolve(&Resolvers.Person.create_person/3)
end
@desc "Create a group"
field :create_group, :group do
arg(:preferred_username, non_null(:string), description: "The name for the group")

View File

@@ -5,12 +5,14 @@ defmodule MobilizonWeb.Schema.ActorInterface do
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
alias Mobilizon.Actors.Actor
alias Mobilizon.Events
import_types(MobilizonWeb.Schema.Actors.FollowerType)
import_types(MobilizonWeb.Schema.EventType)
@desc "An ActivityPub actor"
interface :actor do
field(:id, :id, description: "Internal ID for this actor")
field(:url, :string, description: "The ActivityPub actor's URL")
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
field(:name, :string, description: "The actor's displayed name")
@@ -51,6 +53,9 @@ defmodule MobilizonWeb.Schema.ActorInterface do
%Actor{type: :Group}, _ ->
:group
_, _ ->
nil
end)
end

View File

@@ -12,6 +12,7 @@ defmodule MobilizonWeb.Schema.Actors.GroupType do
object :group do
interfaces([:actor])
field(:id, :id, description: "Internal ID for this group")
field(:url, :string, description: "The ActivityPub actor's URL")
field(:type, :actor_type, description: "The type of Actor (Person, Group,…)")
field(:name, :string, description: "The actor's displayed name")

View File

@@ -5,12 +5,14 @@ defmodule MobilizonWeb.Schema.Actors.PersonType do
use Absinthe.Schema.Notation
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
import_types(MobilizonWeb.Schema.UserType)
alias Mobilizon.Events
@desc """
Represents a person identity
"""
object :person do
interfaces([:actor])
field(:id, :id, description: "Internal ID for this person")
field(:user, :user, description: "The user this actor is associated to")
field(:member_of, list_of(:member), description: "The list of groups this person is member of")

View File

@@ -6,6 +6,7 @@ defmodule MobilizonWeb.Schema.CommentType do
@desc "A comment"
object :comment do
field(:id, :id, description: "Internal ID for this comment")
field(:uuid, :uuid)
field(:url, :string)
field(:local, :boolean)

View File

@@ -3,6 +3,7 @@ defmodule MobilizonWeb.Schema.EventType do
Schema representation for Event
"""
use Absinthe.Schema.Notation
alias Mobilizon.Actors
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
import_types(MobilizonWeb.Schema.AddressType)
import_types(MobilizonWeb.Schema.Events.ParticipantType)
@@ -10,6 +11,7 @@ defmodule MobilizonWeb.Schema.EventType do
@desc "An event"
object :event do
field(:id, :id, description: "Internal ID for this event")
field(:uuid, :uuid, description: "The Event UUID")
field(:url, :string, description: "The ActivityPub Event URL")
field(:local, :boolean, description: "Whether the event is local or not")
@@ -28,7 +30,7 @@ defmodule MobilizonWeb.Schema.EventType do
field(:online_address, :online_address, description: "Online address of the event")
field(:phone_address, :phone_address, description: "Phone address for the event")
field(:organizer_actor, :person,
field(:organizer_actor, :actor,
resolve: dataloader(Actors),
description: "The event's organizer (as a person)"
)

View File

@@ -535,7 +535,8 @@ defmodule Mobilizon.Service.ActivityPub do
defp ical_event_to_activity(%ExIcal.Event{} = ical_event, %Actor{} = actor, _source) do
# Logger.debug(inspect ical_event)
# TODO : refactor me !
# TODO : Use MobilizonWeb.API instead
# TODO : refactor me and move me somewhere else!
# TODO : also, there should be a form of cache that allows this to be more efficient
category =
if is_nil(ical_event.categories) do

View File

@@ -118,7 +118,8 @@ defmodule Mobilizon.Service.ActivityPub.Utils do
"organizer_actor_id" => actor_id,
"begins_on" => object["begins_on"],
"category_id" => Events.get_category_by_title(object["category"]).id,
"url" => object["id"]
"url" => object["id"],
"uuid" => object["uuid"]
}
end