Skip to content

Commit abb295b

Browse files
committed
runs 'mix format lib/ret_web/controllers/page_controller.ex /Users/doug/git/reticulum/lib/ret/media_search.ex'
Why: to match pretty-printing standard
1 parent d64f3f6 commit abb295b

File tree

2 files changed

+104
-62
lines changed

2 files changed

+104
-62
lines changed

lib/ret/media_search.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ defmodule Ret.MediaSearch do
418418
end
419419
end
420420

421-
def available?(:icosa), do: true # Icosa does not currently require an API key
421+
# Icosa does not currently require an API key
422+
def available?(:icosa), do: true
422423
def available?(:bing_images), do: has_resolver_config?(:bing_search_api_key)
423424
def available?(:bing_videos), do: has_resolver_config?(:bing_search_api_key)
424425
def available?(:youtube_videos), do: has_resolver_config?(:youtube_api_key)
@@ -601,6 +602,7 @@ defmodule Ret.MediaSearch do
601602

602603
defp created_rooms_search(cursor, account_id, _query) do
603604
page_number = (cursor || "1") |> Integer.parse() |> elem(0)
605+
604606
ecto_query =
605607
from h in Hub,
606608
where: h.created_by_account_id == ^account_id,

lib/ret_web/controllers/page_controller.ex

Lines changed: 101 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,24 @@ defmodule RetWeb.PageController do
6565
defp render_scene_content(%t{} = scene, conn) when t in [Scene, SceneListing] do
6666
{app_config, app_config_script} = generate_app_config()
6767

68-
app_name = app_config["translations"]["en"]["app-full-name"] || app_config["translations"]["en"]["app-name"] || RetWeb.Endpoint.host()
68+
app_name =
69+
app_config["translations"]["en"]["app-full-name"] ||
70+
app_config["translations"]["en"]["app-name"] || RetWeb.Endpoint.host()
71+
6972
scene_meta_tags =
7073
Phoenix.View.render_to_string(RetWeb.PageView, "scene-meta.html",
7174
scene: scene,
7275
ret_meta: Ret.Meta.get_meta(include_repo: false),
7376
translations: app_config["translations"]["en"],
74-
title: join_smart([ scene.name, app_name ]),
77+
title: join_smart([scene.name, app_name]),
7578
name: scene.name,
76-
description: join_smart([
77-
scene.description,
78-
"A scene you can use in the #{app_name} immersive spaces and others powered by Hubs",
79-
app_config["translations"]["en"]["app-description"]
80-
]) |> String.replace("\\n", " "),
79+
description:
80+
join_smart([
81+
scene.description,
82+
"A scene you can use in the #{app_name} immersive spaces and others powered by Hubs",
83+
app_config["translations"]["en"]["app-description"]
84+
])
85+
|> String.replace("\\n", " "),
8186
app_config_script: {:safe, app_config_script |> with_script_tags},
8287
extra_script: {:safe, get_extra_script(:scene) |> with_script_tags},
8388
extra_html: {:safe, get_extra_html(:scene) || ""}
@@ -106,13 +111,17 @@ defmodule RetWeb.PageController do
106111
defp render_avatar_content(%t{} = avatar, conn) when t in [Avatar, AvatarListing] do
107112
{app_config, app_config_script} = generate_app_config()
108113

109-
app_name = app_config["translations"]["en"]["app-full-name"] || app_config["translations"]["en"]["app-name"] || RetWeb.Endpoint.host()
114+
app_name =
115+
app_config["translations"]["en"]["app-full-name"] ||
116+
app_config["translations"]["en"]["app-name"] || RetWeb.Endpoint.host()
117+
110118
avatar_meta_tags =
111119
Phoenix.View.render_to_string(RetWeb.PageView, "avatar-meta.html",
112120
avatar: avatar,
113121
title: join_smart([avatar.name, app_name]),
114122
name: avatar.name,
115-
description: "An avatar you can use in the #{app_name} immersive spaces and others powered by Hubs.",
123+
description:
124+
"An avatar you can use in the #{app_name} immersive spaces and others powered by Hubs.",
116125
ret_meta: Ret.Meta.get_meta(include_repo: false),
117126
translations: app_config["translations"]["en"],
118127
root_url: RetWeb.Endpoint.url(),
@@ -144,7 +153,9 @@ defmodule RetWeb.PageController do
144153
defp render_homepage_content(conn, nil = _public_room_id) do
145154
{app_config, app_config_script} = generate_app_config()
146155

147-
app_name = app_config["translations"]["en"]["app-full-name"] || app_config["translations"]["en"]["app-name"] || RetWeb.Endpoint.host()
156+
app_name =
157+
app_config["translations"]["en"]["app-full-name"] ||
158+
app_config["translations"]["en"]["app-name"] || RetWeb.Endpoint.host()
148159

149160
index_meta_tags =
150161
Phoenix.View.render_to_string(
@@ -154,10 +165,11 @@ defmodule RetWeb.PageController do
154165
translations: app_config["translations"]["en"],
155166
app_name: app_name,
156167
title: join_smart([app_name, app_config["translations"]["en"]["app-tagline"]]),
157-
description: join_smart(
158-
[app_config["translations"]["en"]["app-description"],
159-
"Immersive spaces, right in your browser, powered by Hubs"
160-
]),
168+
description:
169+
join_smart([
170+
app_config["translations"]["en"]["app-description"],
171+
"Immersive spaces, right in your browser, powered by Hubs"
172+
]),
161173
images: app_config["images"],
162174
app_config_script: {:safe, app_config_script |> with_script_tags},
163175
extra_script: {:safe, get_extra_script(:index) |> with_script_tags},
@@ -291,11 +303,14 @@ defmodule RetWeb.PageController do
291303
manifest =
292304
Phoenix.View.render_to_string(RetWeb.PageView, "manifest.webmanifest",
293305
root_url: RetWeb.Endpoint.url(),
294-
app_name: get_app_config_value("translations|en|app-name") || RetWeb.Endpoint.host(),
295-
app_description: join_smart([
296-
get_app_config_value("translations|en|app-description"),
297-
"Immersive spaces, right in your browser, powered by Hubs"
298-
]) |> String.replace("\\n", " ")
306+
app_name:
307+
get_app_config_value("translations|en|app-name") || RetWeb.Endpoint.host(),
308+
app_description:
309+
join_smart([
310+
get_app_config_value("translations|en|app-description"),
311+
"Immersive spaces, right in your browser, powered by Hubs"
312+
])
313+
|> String.replace("\\n", " ")
299314
)
300315

301316
unless module_config(:skip_cache) do
@@ -484,12 +499,22 @@ defmodule RetWeb.PageController do
484499

485500
app_name = app_config["translations"]["en"]["app-name"] || RetWeb.Endpoint.host()
486501
scene = hub.scene || hub.scene_listing
487-
name = cond do
488-
hub.name && scene && scene.name && scene.name != hub.name -> join_smart([hub.name, scene.name])
489-
hub.name -> hub.name
490-
scene && scene.name -> scene.name
491-
true -> "a room on " <> app_name
492-
end
502+
503+
name =
504+
cond do
505+
hub.name && scene && scene.name && scene.name != hub.name ->
506+
join_smart([hub.name, scene.name])
507+
508+
hub.name ->
509+
hub.name
510+
511+
scene && scene.name ->
512+
scene.name
513+
514+
true ->
515+
"a room on " <> app_name
516+
end
517+
493518
hub_meta_tags =
494519
Phoenix.View.render_to_string(RetWeb.PageView, "hub-meta.html",
495520
hub: hub,
@@ -499,18 +524,22 @@ defmodule RetWeb.PageController do
499524
translations: app_config["translations"]["en"],
500525
title: join_smart([hub.name, app_name]),
501526
name: name,
502-
description: join_smart([
503-
hub.description,
504-
"an immersive space in #{app_name}, right in your browser",
505-
app_config["translations"]["en"]["app-description"],
506-
"powered by Hubs."
507-
]) |> String.replace("\\n", " "),
508-
description_social_media: join_smart([
509-
"Join others in an immersive space in #{app_name}, right in your browser",
510-
hub.description,
511-
app_config["translations"]["en"]["app-description"],
512-
"powered by Hubs."
513-
]) |> String.replace("\\n", " "),
527+
description:
528+
join_smart([
529+
hub.description,
530+
"an immersive space in #{app_name}, right in your browser",
531+
app_config["translations"]["en"]["app-description"],
532+
"powered by Hubs."
533+
])
534+
|> String.replace("\\n", " "),
535+
description_social_media:
536+
join_smart([
537+
"Join others in an immersive space in #{app_name}, right in your browser",
538+
hub.description,
539+
app_config["translations"]["en"]["app-description"],
540+
"powered by Hubs."
541+
])
542+
|> String.replace("\\n", " "),
514543
app_config_script: {:safe, app_config_script |> with_script_tags},
515544
extra_script: {:safe, get_extra_script(:room) |> with_script_tags},
516545
extra_html: {:safe, get_extra_html(:room) || ""}
@@ -726,7 +755,6 @@ defmodule RetWeb.PageController do
726755
end
727756

728757
defp cors_proxy_with_redirects(conn, url, redirect_count) do
729-
730758
%URI{authority: authority, host: host} = uri = URI.parse(url)
731759

732760
resolved_ip = HttpUtils.resolve_ip(host)
@@ -764,7 +792,10 @@ defmodule RetWeb.PageController do
764792
# Note that we have to convert the authority to a charlist, since this uses Erlang's `ssl` module
765793
# internally, which expects a charlist.
766794
client_options: [
767-
ssl: [{:server_name_indication, to_charlist(authority)}, {:versions, [:"tlsv1.2",:"tlsv1.3"]}]
795+
ssl: [
796+
{:server_name_indication, to_charlist(authority)},
797+
{:versions, [:"tlsv1.2", :"tlsv1.3"]}
798+
]
768799
]
769800
)
770801

@@ -773,15 +804,22 @@ defmodule RetWeb.PageController do
773804

774805
try do
775806
# First, make a HEAD request to check for redirects using HTTPoison
776-
case HTTPoison.head(url, [], [
777-
follow_redirect: false,
778-
ssl: [{:server_name_indication, to_charlist(authority)}, {:versions, [:"tlsv1.2", :"tlsv1.3"]}],
779-
timeout: 15_000,
780-
recv_timeout: 15_000
781-
]) do
782-
{:ok, %HTTPoison.Response{status_code: status_code, headers: headers}} when status_code in [301, 302, 303, 307, 308] ->
807+
case HTTPoison.head(url, [],
808+
follow_redirect: false,
809+
ssl: [
810+
{:server_name_indication, to_charlist(authority)},
811+
{:versions, [:"tlsv1.2", :"tlsv1.3"]}
812+
],
813+
timeout: 15_000,
814+
recv_timeout: 15_000
815+
) do
816+
{:ok, %HTTPoison.Response{status_code: status_code, headers: headers}}
817+
when status_code in [301, 302, 303, 307, 308] ->
783818
# Found a redirect
784-
location_header = headers |> Enum.find(fn {k, _v} -> String.downcase(k) == "location" end) |> elem(1)
819+
location_header =
820+
headers
821+
|> Enum.find(fn {k, _v} -> String.downcase(k) == "location" end)
822+
|> elem(1)
785823

786824
if location_header do
787825
# Resolve relative URLs against the current URL
@@ -810,6 +848,7 @@ defmodule RetWeb.PageController do
810848
:exit, reason ->
811849
Logger.error("CORS Proxy: Request exited with reason: #{inspect(reason)}")
812850
conn |> send_resp(500, "Proxy request timed out or failed")
851+
813852
kind, reason ->
814853
Logger.error("CORS Proxy: Request failed with #{kind}: #{inspect(reason)}")
815854
conn |> send_resp(500, "Proxy request failed")
@@ -822,20 +861,21 @@ defmodule RetWeb.PageController do
822861
end
823862

824863
defp make_reverse_proxy_request(conn, _url, body, is_head, opts) do
825-
proxy_conn = %Conn{}
826-
|> Map.merge(conn)
827-
|> Map.put(
828-
:method,
829-
if is_head do
830-
"HEAD"
831-
else
832-
conn.method
833-
end
834-
)
835-
# Need to strip path_info since proxy plug reads it
836-
|> Map.put(:path_info, [])
837-
|> ReverseProxyPlug.request(body, opts)
838-
|> ReverseProxyPlug.response(conn, opts)
864+
proxy_conn =
865+
%Conn{}
866+
|> Map.merge(conn)
867+
|> Map.put(
868+
:method,
869+
if is_head do
870+
"HEAD"
871+
else
872+
conn.method
873+
end
874+
)
875+
# Need to strip path_info since proxy plug reads it
876+
|> Map.put(:path_info, [])
877+
|> ReverseProxyPlug.request(body, opts)
878+
|> ReverseProxyPlug.response(conn, opts)
839879

840880
proxy_conn
841881
end

0 commit comments

Comments
 (0)