Skip to content

Commit

Permalink
Fix import function select wrong parser
Browse files Browse the repository at this point in the history
  • Loading branch information
bluzky committed Jan 21, 2020
1 parent d717f10 commit 58d52fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/chubi/content.ex
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ defmodule Chubi.Content do
end

defp parse_content(%{"content" => content} = params) do
format = Application.get_env(:chubi, :post_format) || "html"
format = params["format"] || Application.get_env(:chubi, :post_format) || "markdown"
parser = Keyword.get(@content_parser_map, String.to_atom(format))
attrs = parser.parse(content, params)
Map.merge(params, attrs)
Expand Down
11 changes: 8 additions & 3 deletions lib/chubi_web/controllers/admin/setting_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ defmodule ChubiWeb.Admin.SettingController do
with {:ok, files} <- :zip.extract(String.to_charlist(path), [:memory]) do
rs =
Enum.map(files, fn {file_path, content} ->
file_path = to_string(file_path)
file_path =
to_string(file_path)
|> IO.inspect()

attrs =
case Path.extname(file_path) do
".md" -> %{"content" => content, "format" => "markdown"}
_ -> Jason.decode!(content)
".md" ->
%{"content" => content, "format" => "markdown"}

_ext ->
Jason.decode!(content)
end

if String.starts_with?(file_path, "posts") do
Expand Down

0 comments on commit 58d52fc

Please sign in to comment.