diff options
Diffstat (limited to '')
-rw-r--r-- | lib/lsg_web/controllers/alcoolog_controller.ex | 44 | ||||
-rw-r--r-- | lib/lsg_web/controllers/gpt_controller.ex | 14 | ||||
-rw-r--r-- | lib/lsg_web/controllers/icecast_see_controller.ex | 8 | ||||
-rw-r--r-- | lib/lsg_web/controllers/irc_auth_sse_controller.ex | 6 | ||||
-rw-r--r-- | lib/lsg_web/controllers/irc_controller.ex | 12 | ||||
-rw-r--r-- | lib/lsg_web/controllers/network_controller.ex | 6 | ||||
-rw-r--r-- | lib/lsg_web/controllers/open_id_controller.ex | 8 | ||||
-rw-r--r-- | lib/lsg_web/controllers/page_controller.ex | 12 | ||||
-rw-r--r-- | lib/lsg_web/controllers/sms_controller.ex | 6 | ||||
-rw-r--r-- | lib/lsg_web/controllers/untappd_controller.ex | 4 |
10 files changed, 60 insertions, 60 deletions
diff --git a/lib/lsg_web/controllers/alcoolog_controller.ex b/lib/lsg_web/controllers/alcoolog_controller.ex index 6542f15..3081762 100644 --- a/lib/lsg_web/controllers/alcoolog_controller.ex +++ b/lib/lsg_web/controllers/alcoolog_controller.ex @@ -1,12 +1,12 @@ -defmodule LSGWeb.AlcoologController do - use LSGWeb, :controller +defmodule NolaWeb.AlcoologController do + use NolaWeb, :controller require Logger - plug LSGWeb.ContextPlug when action not in [:token] - plug LSGWeb.ContextPlug, [restrict: :public] when action in [:token] + plug NolaWeb.ContextPlug when action not in [:token] + plug NolaWeb.ContextPlug, [restrict: :public] when action in [:token] def token(conn, %{"token" => token}) do - case LSG.Token.lookup(token) do + case Nola.Token.lookup(token) do {:ok, {:alcoolog, :index, network, channel}} -> index(conn, nil, network, channel) err -> Logger.debug("AlcoologControler: token #{inspect err} invalid") @@ -21,8 +21,8 @@ defmodule LSGWeb.AlcoologController do days = String.to_integer(Map.get(params, "days", "180")) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - stats = LSG.IRC.AlcoologPlugin.get_full_statistics(profile_account.id) - history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- LSG.IRC.AlcoologPlugin.nick_history(profile_account) do + stats = Nola.IRC.AlcoologPlugin.get_full_statistics(profile_account.id) + history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- Nola.IRC.AlcoologPlugin.nick_history(profile_account) do %{ at: ts |> DateTime.from_unix!(:millisecond), points: points, @@ -50,7 +50,7 @@ defmodule LSGWeb.AlcoologController do profile_account = IRC.Account.find_always_by_nick(network, nick, nick) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - stats = LSG.IRC.AlcoologPlugin.get_full_statistics(profile_account.id) + stats = Nola.IRC.AlcoologPlugin.get_full_statistics(profile_account.id) conn |> put_resp_content_type("application/json") @@ -67,7 +67,7 @@ defmodule LSGWeb.AlcoologController do friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) count = String.to_integer(Map.get(params, "days", "180")) if friend? do - data = LSG.IRC.AlcoologPlugin.user_over_time_gl(profile_account, count) + data = Nola.IRC.AlcoologPlugin.user_over_time_gl(profile_account, count) delay = count*((24 * 60)*60) now = DateTime.utc_now() start_date = DateTime.utc_now() @@ -101,7 +101,7 @@ defmodule LSGWeb.AlcoologController do friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) count = String.to_integer(Map.get(params, "days", "180")) if friend? do - data = LSG.IRC.AlcoologPlugin.user_over_time(profile_account, count) + data = Nola.IRC.AlcoologPlugin.user_over_time(profile_account, count) delay = count*((24 * 60)*60) now = DateTime.utc_now() start_date = DateTime.utc_now() @@ -132,7 +132,7 @@ defmodule LSGWeb.AlcoologController do profile_account = IRC.Account.find_always_by_nick(network, nick, nick) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- LSG.IRC.AlcoologPlugin.nick_history(profile_account) do + history = for {{nick, ts}, points, active, cl, deg, type, descr, meta} <- Nola.IRC.AlcoologPlugin.nick_history(profile_account) do %{ at: ts |> DateTime.from_unix!(:millisecond) |> DateTime.to_iso8601(), points: points, @@ -145,7 +145,7 @@ defmodule LSGWeb.AlcoologController do } end last = List.last(history) - {_, active} = LSG.IRC.AlcoologPlugin.user_stats(profile_account) + {_, active} = Nola.IRC.AlcoologPlugin.user_stats(profile_account) last = %{last | active: active, at: DateTime.utc_now() |> DateTime.to_iso8601()} history = history ++ [last] @@ -163,7 +163,7 @@ defmodule LSGWeb.AlcoologController do profile_account = IRC.Account.find_always_by_nick(network, nick, nick) friend? = Enum.member?(IRC.Membership.friends(account), profile_account.id) if friend? do - history = for {_, date, value} <- LSG.IRC.AlcoologAnnouncerPlugin.log(profile_account) do + history = for {_, date, value} <- Nola.IRC.AlcoologAnnouncerPlugin.log(profile_account) do %{date: DateTime.to_iso8601(date), value: value} end conn @@ -177,7 +177,7 @@ defmodule LSGWeb.AlcoologController do end def index(conn = %{assigns: %{account: account}}, %{"network" => network, "chan" => channel}) do - index(conn, account, network, LSGWeb.reformat_chan(channel)) + index(conn, account, network, NolaWeb.reformat_chan(channel)) end def index(conn = %{assigns: %{account: account}}, _) do @@ -187,7 +187,7 @@ defmodule LSGWeb.AlcoologController do #def index(conn, params) do # network = Map.get(params, "network") # chan = if c = Map.get(params, "chan") do - # LSGWeb.reformat_chan(c) + # NolaWeb.reformat_chan(c) # end # irc_conn = if network do # IRC.Connection.get_network(network, chan) @@ -223,12 +223,12 @@ defmodule LSGWeb.AlcoologController do members = IRC.Membership.expanded_members_or_friends(account, network, channel) members_ids = Enum.map(members, fn({account, _, nick}) -> account.id end) member_names = Enum.reduce(members, %{}, fn({account, _, nick}, acc) -> Map.put(acc, account.id, nick) end) - drinks = :ets.select(LSG.IRC.AlcoologPlugin.ETS, match) + drinks = :ets.select(Nola.IRC.AlcoologPlugin.ETS, match) |> Enum.filter(fn({{account, _}, _vol, _cur, _cl, _deg, _name, _cmt, _meta}) -> Enum.member?(members_ids, account) end) |> Enum.map(fn({{account, _}, _, _, _, _, _, _, _} = object) -> {object, Map.get(member_names, account)} end) |> Enum.sort_by(fn({{{_, ts}, _, _, _, _, _, _, _}, _}) -> ts end, &>/2) - stats = LSG.IRC.AlcoologPlugin.get_channel_statistics(account, network, channel) + stats = Nola.IRC.AlcoologPlugin.get_channel_statistics(account, network, channel) top = Enum.reduce(drinks, %{}, fn({{{account_id, _}, vol, _, _, _, _, _, _}, _}, acc) -> nick = Map.get(member_names, account_id) @@ -245,7 +245,7 @@ defmodule LSGWeb.AlcoologController do def index_gls_json(conn = %{assigns: %{account: account}}, %{"network" => network, "chan" => channel}) do count = 30 - channel = LSGWeb.reformat_chan(channel) + channel = NolaWeb.reformat_chan(channel) members = IRC.Membership.expanded_members_or_friends(account, network, channel) members_ids = Enum.map(members, fn({account, _, nick}) -> account.id end) member_names = Enum.reduce(members, %{}, fn({account, _, nick}, acc) -> Map.put(acc, account.id, nick) end) @@ -266,7 +266,7 @@ defmodule LSGWeb.AlcoologController do |> Enum.into(Map.new) gls = Enum.reduce(members, filled, fn({account, _, _}, gls) -> - Enum.reduce(LSG.IRC.AlcoologPlugin.user_over_time_gl(account, count), gls, fn({date, gl}, gls) -> + Enum.reduce(Nola.IRC.AlcoologPlugin.user_over_time_gl(account, count), gls, fn({date, gl}, gls) -> u = Map.get(gls, date, %{}) |> Map.put(Map.get(member_names, account.id, account.id), gl) Map.put(gls, date, u) @@ -302,12 +302,12 @@ defmodule LSGWeb.AlcoologController do def minisync(conn, %{"user_id" => user_id, "key" => key, "value" => value}) do account = IRC.Account.get(user_id) if account do - ds = LSG.IRC.AlcoologPlugin.data_state() - meta = LSG.IRC.AlcoologPlugin.get_user_meta(ds, account.id) + ds = Nola.IRC.AlcoologPlugin.data_state() + meta = Nola.IRC.AlcoologPlugin.get_user_meta(ds, account.id) case Float.parse(value) do {val, _} -> new_meta = Map.put(meta, String.to_existing_atom(key), val) - LSG.IRC.AlcoologPlugin.put_user_meta(ds, account.id, new_meta) + Nola.IRC.AlcoologPlugin.put_user_meta(ds, account.id, new_meta) _ -> conn |> put_status(:unprocessable_entity) diff --git a/lib/lsg_web/controllers/gpt_controller.ex b/lib/lsg_web/controllers/gpt_controller.ex index acf9b27..038b235 100644 --- a/lib/lsg_web/controllers/gpt_controller.ex +++ b/lib/lsg_web/controllers/gpt_controller.ex @@ -1,14 +1,14 @@ -defmodule LSGWeb.GptController do - use LSGWeb, :controller +defmodule NolaWeb.GptController do + use NolaWeb, :controller require Logger - plug LSGWeb.ContextPlug + plug NolaWeb.ContextPlug def result(conn, params = %{"id" => result_id}) do - case LSG.IRC.GptPlugin.get_result(result_id) do + case Nola.IRC.GptPlugin.get_result(result_id) do {:ok, result} -> network = Map.get(params, "network") - channel = if c = Map.get(params, "chan"), do: LSGWeb.reformat_chan(c) + channel = if c = Map.get(params, "chan"), do: NolaWeb.reformat_chan(c) render(conn, "result.html", network: network, channel: channel, result: result) {:error, :not_found} -> conn @@ -18,10 +18,10 @@ defmodule LSGWeb.GptController do end def prompt(conn, params = %{"id" => prompt_id}) do - case LSG.IRC.GptPlugin.get_prompt(prompt_id) do + case Nola.IRC.GptPlugin.get_prompt(prompt_id) do {:ok, prompt} -> network = Map.get(params, "network") - channel = if c = Map.get(params, "chan"), do: LSGWeb.reformat_chan(c) + channel = if c = Map.get(params, "chan"), do: NolaWeb.reformat_chan(c) render(conn, "prompt.html", network: network, channel: channel, prompt: prompt) {:error, :not_found} -> conn diff --git a/lib/lsg_web/controllers/icecast_see_controller.ex b/lib/lsg_web/controllers/icecast_see_controller.ex index 1eecca1..877ad4e 100644 --- a/lib/lsg_web/controllers/icecast_see_controller.ex +++ b/lib/lsg_web/controllers/icecast_see_controller.ex @@ -1,5 +1,5 @@ -defmodule LSGWeb.IcecastSseController do - use LSGWeb, :controller +defmodule NolaWeb.IcecastSseController do + use NolaWeb, :controller require Logger @ping_interval 20_000 @@ -11,13 +11,13 @@ defmodule LSGWeb.IcecastSseController do |> send_chunked(200) |> subscribe |> send_sse_message("ping", "ping") - |> send_sse_message("icecast", LSG.IcecastAgent.get) + |> send_sse_message("icecast", Nola.IcecastAgent.get) |> sse_loop end def subscribe(conn) do :timer.send_interval(@ping_interval, {:event, :ping}) - {:ok, _} = Registry.register(LSG.BroadcastRegistry, "icecast", []) + {:ok, _} = Registry.register(Nola.BroadcastRegistry, "icecast", []) conn end diff --git a/lib/lsg_web/controllers/irc_auth_sse_controller.ex b/lib/lsg_web/controllers/irc_auth_sse_controller.ex index f370d97..62ee2b5 100644 --- a/lib/lsg_web/controllers/irc_auth_sse_controller.ex +++ b/lib/lsg_web/controllers/irc_auth_sse_controller.ex @@ -1,5 +1,5 @@ -defmodule LSGWeb.IrcAuthSseController do - use LSGWeb, :controller +defmodule NolaWeb.IrcAuthSseController do + use NolaWeb, :controller require Logger @ping_interval 20_000 @@ -36,7 +36,7 @@ defmodule LSGWeb.IrcAuthSseController do {:event, :expire} -> {"expire", "expire", true} {:irc, :text, %{account: account, text: token} = m} -> if String.downcase(String.trim(token)) == conn.assigns.token do - path = LSG.AuthToken.new_path(account.id, conn.assigns.perks) + path = Nola.AuthToken.new_path(account.id, conn.assigns.perks) m.replyfun.("ok!") {"authenticated", path, true} else diff --git a/lib/lsg_web/controllers/irc_controller.ex b/lib/lsg_web/controllers/irc_controller.ex index d518481..90d9853 100644 --- a/lib/lsg_web/controllers/irc_controller.ex +++ b/lib/lsg_web/controllers/irc_controller.ex @@ -1,11 +1,11 @@ -defmodule LSGWeb.IrcController do - use LSGWeb, :controller +defmodule NolaWeb.IrcController do + use NolaWeb, :controller - plug LSGWeb.ContextPlug + plug NolaWeb.ContextPlug def index(conn, params) do network = Map.get(params, "network") - channel = if c = Map.get(params, "chan"), do: LSGWeb.reformat_chan(c) + channel = if c = Map.get(params, "chan"), do: NolaWeb.reformat_chan(c) commands = for mod <- Enum.uniq([IRC.Account.AccountPlugin] ++ IRC.Plugin.enabled()) do if is_atom(mod) do identifier = Module.split(mod) |> List.last |> String.replace("Plugin", "") |> Macro.underscore @@ -42,7 +42,7 @@ defmodule LSGWeb.IrcController do defp do_txt(conn, nil) do - doc = LSG.IRC.TxtPlugin.irc_doc() + doc = Nola.IRC.TxtPlugin.irc_doc() data = data() main = Enum.filter(data, fn({trigger, _}) -> !String.contains?(trigger, ".") end) |> Enum.into(Map.new) system = Enum.filter(data, fn({trigger, _}) -> String.contains?(trigger, ".") end) |> Enum.into(Map.new) @@ -55,7 +55,7 @@ defmodule LSGWeb.IrcController do defp do_txt(conn, txt) do data = data() base_url = cond do - conn.assigns[:chan] -> "/#{conn.assigns.network}/#{LSGWeb.format_chan(conn.assigns.chan)}" + conn.assigns[:chan] -> "/#{conn.assigns.network}/#{NolaWeb.format_chan(conn.assigns.chan)}" true -> "/-" end if lines = Map.get(data, txt) do diff --git a/lib/lsg_web/controllers/network_controller.ex b/lib/lsg_web/controllers/network_controller.ex index 537c2f6..800294f 100644 --- a/lib/lsg_web/controllers/network_controller.ex +++ b/lib/lsg_web/controllers/network_controller.ex @@ -1,6 +1,6 @@ -defmodule LSGWeb.NetworkController do - use LSGWeb, :controller - plug LSGWeb.ContextPlug +defmodule NolaWeb.NetworkController do + use NolaWeb, :controller + plug NolaWeb.ContextPlug def index(conn, %{"network" => network}) do conn diff --git a/lib/lsg_web/controllers/open_id_controller.ex b/lib/lsg_web/controllers/open_id_controller.ex index d5af318..94166eb 100644 --- a/lib/lsg_web/controllers/open_id_controller.ex +++ b/lib/lsg_web/controllers/open_id_controller.ex @@ -1,6 +1,6 @@ -defmodule LSGWeb.OpenIdController do - use LSGWeb, :controller - plug LSGWeb.ContextPlug, restrict: :public +defmodule NolaWeb.OpenIdController do + use NolaWeb, :controller + plug NolaWeb.ContextPlug, restrict: :public require Logger def login(conn, _) do @@ -58,7 +58,7 @@ defmodule LSGWeb.OpenIdController do site: config[:base_url], authorize_url: config[:authorize_url], token_url: config[:token_url], - redirect_uri: Routes.open_id_url(LSGWeb.Endpoint, :callback) + redirect_uri: Routes.open_id_url(NolaWeb.Endpoint, :callback) ]) end end diff --git a/lib/lsg_web/controllers/page_controller.ex b/lib/lsg_web/controllers/page_controller.ex index 94c9c70..2ac4d0a 100644 --- a/lib/lsg_web/controllers/page_controller.ex +++ b/lib/lsg_web/controllers/page_controller.ex @@ -1,12 +1,12 @@ -defmodule LSGWeb.PageController do - use LSGWeb, :controller +defmodule NolaWeb.PageController do + use NolaWeb, :controller - plug LSGWeb.ContextPlug when action not in [:token] - plug LSGWeb.ContextPlug, [restrict: :public] when action in [:token] + plug NolaWeb.ContextPlug when action not in [:token] + plug NolaWeb.ContextPlug, [restrict: :public] when action in [:token] def token(conn, %{"token" => token}) do with \ - {:ok, account, perks} <- LSG.AuthToken.lookup(token) + {:ok, account, perks} <- Nola.AuthToken.lookup(token) do IO.puts("Authenticated account #{inspect account}") conn = put_session(conn, :account, account) @@ -33,7 +33,7 @@ defmodule LSGWeb.PageController do end def irc(conn, _) do - bot_helps = for mod <- LSG.IRC.env(:handlers) do + bot_helps = for mod <- Nola.IRC.env(:handlers) do mod.irc_doc() end render conn, "irc.html", bot_helps: bot_helps diff --git a/lib/lsg_web/controllers/sms_controller.ex b/lib/lsg_web/controllers/sms_controller.ex index 00c6352..575655c 100644 --- a/lib/lsg_web/controllers/sms_controller.ex +++ b/lib/lsg_web/controllers/sms_controller.ex @@ -1,9 +1,9 @@ -defmodule LSGWeb.SmsController do - use LSGWeb, :controller +defmodule NolaWeb.SmsController do + use NolaWeb, :controller require Logger def ovh_callback(conn, %{"senderid" => from, "message" => message}) do - spawn(fn() -> LSG.IRC.SmsPlugin.incoming(from, String.trim(message)) end) + spawn(fn() -> Nola.IRC.SmsPlugin.incoming(from, String.trim(message)) end) text(conn, "") end diff --git a/lib/lsg_web/controllers/untappd_controller.ex b/lib/lsg_web/controllers/untappd_controller.ex index 1c3ceb1..d3a540d 100644 --- a/lib/lsg_web/controllers/untappd_controller.ex +++ b/lib/lsg_web/controllers/untappd_controller.ex @@ -1,5 +1,5 @@ -defmodule LSGWeb.UntappdController do - use LSGWeb, :controller +defmodule NolaWeb.UntappdController do + use NolaWeb, :controller def callback(conn, %{"code" => code}) do with \ |