devel #106
8 changed files with 62 additions and 44 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -34,9 +34,6 @@ chiya-*.tar
|
||||||
!/priv/static/site.webmanifest
|
!/priv/static/site.webmanifest
|
||||||
!/priv/static/browserconfig.xml
|
!/priv/static/browserconfig.xml
|
||||||
|
|
||||||
/log/*
|
|
||||||
!/log/.gitkeep
|
|
||||||
|
|
||||||
# Ignore digested assets cache.
|
# Ignore digested assets cache.
|
||||||
/priv/static/cache_manifest.json
|
/priv/static/cache_manifest.json
|
||||||
|
|
||||||
|
|
4
assets/package-lock.json
generated
4
assets/package-lock.json
generated
|
@ -21,14 +21,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"../deps/phoenix": {
|
"../deps/phoenix": {
|
||||||
"version": "1.7.1",
|
"version": "1.7.3",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"../deps/phoenix_html": {
|
"../deps/phoenix_html": {
|
||||||
"version": "3.3.1"
|
"version": "3.3.1"
|
||||||
},
|
},
|
||||||
"../deps/phoenix_live_view": {
|
"../deps/phoenix_live_view": {
|
||||||
"version": "0.18.16",
|
"version": "0.19.0",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@babel/runtime": {
|
"node_modules/@babel/runtime": {
|
||||||
|
|
|
@ -77,18 +77,3 @@ config :phoenix, :plug_init_mode, :runtime
|
||||||
|
|
||||||
# Disable swoosh api client as it is only required for production adapters.
|
# Disable swoosh api client as it is only required for production adapters.
|
||||||
config :swoosh, :api_client, false
|
config :swoosh, :api_client, false
|
||||||
|
|
||||||
log_directory = Path.join(File.cwd!(), "log")
|
|
||||||
|
|
||||||
config :logger,
|
|
||||||
backends: [{LoggerFileBackend, :info_log}, {LoggerFileBackend, :error_log}]
|
|
||||||
|
|
||||||
config :logger, :info_log,
|
|
||||||
path: Path.join(log_directory, "chiya-info.log"),
|
|
||||||
level: :info,
|
|
||||||
format: "[$date] [$time] [$level] $message\n"
|
|
||||||
|
|
||||||
config :logger, :error_log,
|
|
||||||
path: Path.join(log_directory, "chiya-error.log"),
|
|
||||||
level: :error,
|
|
||||||
format: "[$date] [$time] [$level] $message\n"
|
|
|
@ -72,27 +72,7 @@ if config_env() == :prod do
|
||||||
|
|
||||||
config :waffle,
|
config :waffle,
|
||||||
storage_dir_prefix: upload_dir
|
storage_dir_prefix: upload_dir
|
||||||
|
|
||||||
log_directory =
|
|
||||||
System.get_env("LOG_DIR") ||
|
|
||||||
raise """
|
|
||||||
environment variable LOG_DIR is missing.
|
|
||||||
It should look like: /path/to/chiya/logs
|
|
||||||
"""
|
|
||||||
|
|
||||||
config :logger,
|
|
||||||
backends: [{LoggerFileBackend, :info_log}, {LoggerFileBackend, :error_log}]
|
|
||||||
|
|
||||||
config :logger, :info_log,
|
|
||||||
path: Path.join(log_directory, "chiya-info.log"),
|
|
||||||
level: :info,
|
|
||||||
format: "[$date] [$time] [$level] $message\n"
|
|
||||||
|
|
||||||
config :logger, :error_log,
|
|
||||||
path: Path.join(log_directory, "chiya-error.log"),
|
|
||||||
level: :error,
|
|
||||||
format: "[$date] [$time] [$level] $message\n"
|
|
||||||
|
|
||||||
# ## SSL Support
|
# ## SSL Support
|
||||||
#
|
#
|
||||||
# To get SSL working, you will need to add the `https` key
|
# To get SSL working, you will need to add the `https` key
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule ChiyaWeb.Indie.MicropubHandler do
|
defmodule ChiyaWeb.Indie.MicropubHandler do
|
||||||
@behaviour PlugMicropub.HandlerBehaviour
|
@behaviour ChiyaWeb.Indie.PlugMicropub.HandlerBehaviour
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
alias ChiyaWeb.Indie.Properties, as: Props
|
alias ChiyaWeb.Indie.Properties, as: Props
|
||||||
|
|
57
lib/chiya_web/indie/plug_micropub/handler_behaviour.ex
Normal file
57
lib/chiya_web/indie/plug_micropub/handler_behaviour.ex
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
defmodule ChiyaWeb.Indie.PlugMicropub.HandlerBehaviour do
|
||||||
|
@moduledoc """
|
||||||
|
Behaviour defining the interface for a PlugMicropub Handler
|
||||||
|
"""
|
||||||
|
|
||||||
|
@type access_token :: String.t()
|
||||||
|
@type handler_error_atom :: :invalid_request | :forbidden | :insufficient_scope
|
||||||
|
@type handler_error ::
|
||||||
|
{:error, handler_error_atom} | {:error, handler_error_atom, description :: String.t()}
|
||||||
|
|
||||||
|
@callback handle_create(type :: String.t(), properties :: map, access_token) ::
|
||||||
|
{:ok, :created | :accepted, url :: String.t()}
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_update(
|
||||||
|
url :: String.t(),
|
||||||
|
replace :: map,
|
||||||
|
add :: map,
|
||||||
|
delete :: map,
|
||||||
|
access_token
|
||||||
|
) ::
|
||||||
|
:ok
|
||||||
|
| {:ok, url :: String.t()}
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_delete(url :: String.t(), access_token) ::
|
||||||
|
:ok
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_undelete(url :: String.t(), access_token) ::
|
||||||
|
:ok
|
||||||
|
| {:ok, url :: String.t()}
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_config_query(access_token) ::
|
||||||
|
{:ok, map}
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_config_query(access_token) ::
|
||||||
|
{:ok, map}
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_syndicate_to_query(access_token) ::
|
||||||
|
{:ok, map}
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_source_query(
|
||||||
|
url :: String.t(),
|
||||||
|
properties :: [String.t()],
|
||||||
|
access_token
|
||||||
|
) ::
|
||||||
|
{:ok, map}
|
||||||
|
| handler_error
|
||||||
|
|
||||||
|
@callback handle_media(file :: Plug.Upload.t(), access_token) ::
|
||||||
|
{:ok, url :: String.t()} | handler_error
|
||||||
|
end
|
3
mix.exs
3
mix.exs
|
@ -19,7 +19,7 @@ defmodule Chiya.MixProject do
|
||||||
def application do
|
def application do
|
||||||
[
|
[
|
||||||
mod: {Chiya.Application, []},
|
mod: {Chiya.Application, []},
|
||||||
extra_applications: [:logger, :logger_file_backend, :runtime_tools]
|
extra_applications: [:logger, :runtime_tools]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ defmodule Chiya.MixProject do
|
||||||
{:floki, ">= 0.30.0", only: :test},
|
{:floki, ">= 0.30.0", only: :test},
|
||||||
{:gettext, "~> 0.22"},
|
{:gettext, "~> 0.22"},
|
||||||
{:jason, "~> 1.2"},
|
{:jason, "~> 1.2"},
|
||||||
{:logger_file_backend, "~> 0.0.13"},
|
|
||||||
{:oban, "~> 2.14"},
|
{:oban, "~> 2.14"},
|
||||||
{:phoenix, "~> 1.7.1"},
|
{:phoenix, "~> 1.7.1"},
|
||||||
{:phoenix_ecto, "~> 4.4"},
|
{:phoenix_ecto, "~> 4.4"},
|
||||||
|
|
Loading…
Reference in a new issue