diff --git a/README.md b/README.md index b998f34..a7b1c8c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PlugMicropub +# PlugIndie A small library for helping build a Plug-based Micropub server. @@ -15,20 +15,20 @@ plug Plug.Parsers, pass: ["*/*"], json_decoder: Poison -plug PlugMicropub, +plug PlugIndie, handler: MyApp.MicropubHandler, json_encoder: Poison ``` ### Forwarding -If you want `PlugMicropub` to serve only a particular route, configure your router like: +If you want `PlugIndie` to serve only a particular route, configure your router like: #### Plug.Router ```elixir forward "/micropub", - to: PlugMicropub, + to: PlugIndie, init_opts: [ handler: MyApp.MicropubHandler, json_encoder: Poison @@ -39,7 +39,7 @@ forward "/micropub", ```elixir forward "/micropub", - PlugMicropub, + PlugIndie, handler: MyApp.MicropubHandler, json_encoder: Poison ``` diff --git a/lib/handler.ex b/lib/handler.ex index e098c5f..7b961a0 100644 --- a/lib/handler.ex +++ b/lib/handler.ex @@ -1,6 +1,6 @@ -defmodule PlugMicropub.Handler do +defmodule PlugIndie.Handler do import Plug.Conn - alias PlugMicropub.{Response, Parser, Properties} + alias PlugIndie.{Response, Parser, Properties} def handle_action(:create, access_token, conn) do content_type = conn |> get_req_header("content-type") |> List.first() diff --git a/lib/parser.ex b/lib/parser.ex index 86b1ed9..57c23a1 100644 --- a/lib/parser.ex +++ b/lib/parser.ex @@ -1,4 +1,4 @@ -defmodule PlugMicropub.Parser do +defmodule PlugIndie.Parser do import Plug.Conn def get_action(conn) do diff --git a/lib/plug_micropub.ex b/lib/plug_micropub.ex index dfabb70..24f466a 100644 --- a/lib/plug_micropub.ex +++ b/lib/plug_micropub.ex @@ -1,4 +1,4 @@ -defmodule PlugMicropub do +defmodule PlugIndie do @moduledoc """ A Plug for building a Micropub server. @@ -7,7 +7,7 @@ defmodule PlugMicropub do """ require Logger use Plug.Router - alias PlugMicropub.{Parser, Handler, Response} + alias PlugIndie.{Parser, Handler, Response} plug :match plug :dispatch @@ -44,7 +44,7 @@ defmodule PlugMicropub do Keyword.get(opts, :scopes) || @default_scopes token_handler = - Keyword.get(opts, :token_handler) || PlugMicropub.Token + Keyword.get(opts, :token_handler) || PlugIndie.Token [ hostname: hostname, diff --git a/lib/plug_micropub/handler_behaviour.ex b/lib/plug_micropub/handler_behaviour.ex index e324d8d..833e41f 100644 --- a/lib/plug_micropub/handler_behaviour.ex +++ b/lib/plug_micropub/handler_behaviour.ex @@ -1,6 +1,6 @@ -defmodule PlugMicropub.HandlerBehaviour do +defmodule PlugIndie.HandlerBehaviour do @moduledoc """ - Behaviour defining the interface for a PlugMicropub Handler + Behaviour defining the interface for a PlugIndie Handler """ @type access_token :: String.t() diff --git a/lib/post.ex b/lib/post.ex index f54014c..92a9597 100644 --- a/lib/post.ex +++ b/lib/post.ex @@ -1,3 +1,3 @@ -defmodule PlugMicropub.Post do +defmodule PlugIndie.Post do defstruct [:type, :title, :content] end diff --git a/lib/properties.ex b/lib/properties.ex index e4f02b2..895fa21 100644 --- a/lib/properties.ex +++ b/lib/properties.ex @@ -1,4 +1,4 @@ -defmodule PlugMicropub.Properties do +defmodule PlugIndie.Properties do def parse(properties) do {:ok, type} = get_post_type(properties) content = get_content(properties) @@ -7,7 +7,7 @@ defmodule PlugMicropub.Properties do case type do :note -> {:ok, - %PlugMicropub.Post{ + %PlugIndie.Post{ type: type, title: title, content: content diff --git a/lib/response.ex b/lib/response.ex index f1a2c32..3537678 100644 --- a/lib/response.ex +++ b/lib/response.ex @@ -1,4 +1,4 @@ -defmodule PlugMicropub.Response do +defmodule PlugIndie.Response do import Plug.Conn def send_content(conn, content) do diff --git a/lib/test_handler.ex b/lib/test_handler.ex index 1ba819b..6a898f3 100644 --- a/lib/test_handler.ex +++ b/lib/test_handler.ex @@ -1,8 +1,8 @@ defmodule TestHandler do - @behaviour PlugMicropub.HandlerBehaviour + @behaviour PlugIndie.HandlerBehaviour @impl true - def handle_create(_type, properties, _access_token) do + def handle_create(_type, %PlugIndie.Post{} = properties, _access_token) do case properties.type do :note -> {:ok, :created, "/notes/4711"} diff --git a/lib/token.ex b/lib/token.ex index b2d5204..ba9444d 100644 --- a/lib/token.ex +++ b/lib/token.ex @@ -1,4 +1,4 @@ -defmodule PlugMicropub.Token do +defmodule PlugIndie.Token do require Logger def verify( diff --git a/mix.exs b/mix.exs index 0149c43..e84c7e6 100644 --- a/mix.exs +++ b/mix.exs @@ -1,4 +1,4 @@ -defmodule PlugMicropub.MixProject do +defmodule PlugIndie.MixProject do use Mix.Project def project do diff --git a/test/parser_test.exs b/test/parser_test.exs index 0ca6818..0d9712b 100644 --- a/test/parser_test.exs +++ b/test/parser_test.exs @@ -1,7 +1,7 @@ defmodule ParserTest do use ExUnit.Case - doctest PlugMicropub.Parser - import PlugMicropub.Parser, only: [parse_create_body: 2] + doctest PlugIndie.Parser + import PlugIndie.Parser, only: [parse_create_body: 2] test "parse_create_body with content-type json" do params = %{ diff --git a/test/plug_micropub_test.exs b/test/plug_micropub_test.exs index eda5842..9c88ccc 100644 --- a/test/plug_micropub_test.exs +++ b/test/plug_micropub_test.exs @@ -1,10 +1,10 @@ -defmodule PlugMicropubTest do +defmodule PlugIndieTest do use ExUnit.Case, async: true use Plug.Test - doctest PlugMicropub + doctest PlugIndie - @opts PlugMicropub.init( + @opts PlugIndie.init( hostname: "example.com", handler: TestHandler, token_endpoint: "http://example.com/token", @@ -21,7 +21,7 @@ defmodule PlugMicropubTest do }) # Invoke the plug - conn = PlugMicropub.call(conn, @opts) + conn = PlugIndie.call(conn, @opts) # Assert the response and status assert conn.state == :sent