pull the prefix path in to a config so that its reasonable to work with

main
Ryan 2020-08-26 17:17:19 -07:00
parent a5409042f7
commit 30d289581f
3 changed files with 16 additions and 7 deletions

View File

@ -12,6 +12,13 @@ config :arcology, ArcologyWeb.Endpoint,
render_errors: [view: ArcologyWeb.ErrorView, accepts: ~w(html json)],
pubsub: [name: Arcology.PubSub, adapter: Phoenix.PubSub.PG2]
config :arcology, :env,
arcology_directory:
if(System.get_env("HOSTNAME") == "kusanagi",
do: "/srv/files/rrix/org/org",
else: "/home/rrix/org"
)
# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",

View File

@ -115,12 +115,13 @@ defmodule Arcology.Page do
# in the real case here we would full domain rewrite here, instead, just the key
def rewrite_local(match, page) do
arc_dir = Application.get_env(:arcology, :env)[:arcology_directory]
key =
if String.starts_with?(page, "/home/rrix/") do
page
else
"/home/rrix/org/#{page}"
end
if(String.starts_with?(page, "/"),
do: page,
else: "#{arc_dir}/#{page}"
)
|> Arcology.Roam.Keyword.get_file("ARCOLOGY_KEY")
cond do
@ -178,7 +179,7 @@ defmodule Arcology.Page do
defp hydrate_ref(page) do
Map.merge(
page,
%{ref: page |> reference() |> Map.drop([:file])}
%{ref: page |> reference()}
)
end

View File

@ -37,6 +37,7 @@ defmodule Arcology.Roam do
end
def clean_file_name(fname) do
fname |> String.trim_leading("/home/rrix/org/")
arc_dir = Application.get_env(:arcology, :env)[:arcology_directory]
fname |> String.trim_leading(arc_dir)
end
end