hoist ImageNavigator, ImageScope, ImageSorter to web namespace

This commit is contained in:
byte[] 2020-05-07 22:10:54 -04:00
parent 1168ba86f6
commit 00415b062c
11 changed files with 16 additions and 14 deletions

View file

@ -2,7 +2,7 @@ defmodule PhilomenaWeb.Api.Json.Search.ImageController do
use PhilomenaWeb, :controller use PhilomenaWeb, :controller
alias PhilomenaWeb.ImageLoader alias PhilomenaWeb.ImageLoader
alias Philomena.ImageSorter alias PhilomenaWeb.ImageSorter
alias Philomena.Interactions alias Philomena.Interactions
alias Philomena.Images.Image alias Philomena.Images.Image
import Ecto.Query import Ecto.Query

View file

@ -3,8 +3,8 @@ defmodule PhilomenaWeb.GalleryController do
alias PhilomenaWeb.ImageLoader alias PhilomenaWeb.ImageLoader
alias PhilomenaWeb.NotificationCountPlug alias PhilomenaWeb.NotificationCountPlug
alias PhilomenaWeb.ImageSorter
alias Philomena.Elasticsearch alias Philomena.Elasticsearch
alias Philomena.ImageSorter
alias Philomena.Interactions alias Philomena.Interactions
alias Philomena.Galleries.Gallery alias Philomena.Galleries.Gallery
alias Philomena.Galleries alias Philomena.Galleries

View file

@ -2,9 +2,10 @@ defmodule PhilomenaWeb.Image.NavigateController do
use PhilomenaWeb, :controller use PhilomenaWeb, :controller
alias PhilomenaWeb.ImageLoader alias PhilomenaWeb.ImageLoader
alias PhilomenaWeb.ImageNavigator
alias PhilomenaWeb.ImageScope
alias Philomena.Images.Image alias Philomena.Images.Image
alias Philomena.Images.Query alias Philomena.Images.Query
alias Philomena.ImageNavigator
plug PhilomenaWeb.CanaryMapPlug, index: :show plug PhilomenaWeb.CanaryMapPlug, index: :show
plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true plug :load_and_authorize_resource, model: Image, id_name: "image_id", persisted: true
@ -15,7 +16,7 @@ defmodule PhilomenaWeb.Image.NavigateController do
rel = String.to_existing_atom(rel) rel = String.to_existing_atom(rel)
next_image = ImageNavigator.find_consecutive(image, rel, params, compile_query(conn), filter) next_image = ImageNavigator.find_consecutive(image, rel, params, compile_query(conn), filter)
scope = Philomena.ImageScope.scope(conn) scope = ImageScope.scope(conn)
conn conn
|> redirect(to: Routes.image_path(conn, :show, next_image, scope)) |> redirect(to: Routes.image_path(conn, :show, next_image, scope))

View file

@ -1,16 +1,17 @@
defmodule PhilomenaWeb.Image.RandomController do defmodule PhilomenaWeb.Image.RandomController do
use PhilomenaWeb, :controller use PhilomenaWeb, :controller
alias PhilomenaWeb.ImageSorter
alias PhilomenaWeb.ImageScope
alias Philomena.Elasticsearch alias Philomena.Elasticsearch
alias Philomena.Images.Query alias Philomena.Images.Query
alias Philomena.Images.Image alias Philomena.Images.Image
alias Philomena.ImageSorter
def index(conn, params) do def index(conn, params) do
user = conn.assigns.current_user user = conn.assigns.current_user
filter = conn.assigns.compiled_filter filter = conn.assigns.compiled_filter
scope = Philomena.ImageScope.scope(conn) scope = ImageScope.scope(conn)
query = query(user, params) query = query(user, params)
random_id = random_image_id(query, filter) random_id = random_image_id(query, filter)

View file

@ -2,7 +2,7 @@ defmodule PhilomenaWeb.SearchController do
use PhilomenaWeb, :controller use PhilomenaWeb, :controller
alias PhilomenaWeb.ImageLoader alias PhilomenaWeb.ImageLoader
alias Philomena.ImageSorter alias PhilomenaWeb.ImageSorter
alias Philomena.Interactions alias Philomena.Interactions
def index(conn, params) do def index(conn, params) do

View file

@ -1,5 +1,5 @@
defmodule Philomena.ImageNavigator do defmodule PhilomenaWeb.ImageNavigator do
alias Philomena.ImageSorter alias PhilomenaWeb.ImageSorter
alias Philomena.Images.{Image, ElasticsearchIndex} alias Philomena.Images.{Image, ElasticsearchIndex}
alias Philomena.Elasticsearch alias Philomena.Elasticsearch
alias Philomena.Repo alias Philomena.Repo

View file

@ -1,4 +1,4 @@
defmodule Philomena.ImageScope do defmodule PhilomenaWeb.ImageScope do
def scope(conn) do def scope(conn) do
[] []
|> scope(conn, "q", :q) |> scope(conn, "q", :q)

View file

@ -1,4 +1,4 @@
defmodule Philomena.ImageSorter do defmodule PhilomenaWeb.ImageSorter do
@allowed_fields ~W( @allowed_fields ~W(
created_at created_at
updated_at updated_at

View file

@ -1,7 +1,7 @@
defmodule PhilomenaWeb.GalleryView do defmodule PhilomenaWeb.GalleryView do
use PhilomenaWeb, :view use PhilomenaWeb, :view
alias Philomena.ImageScope alias PhilomenaWeb.ImageScope
def scope(conn), do: ImageScope.scope(conn) def scope(conn), do: ImageScope.scope(conn)

View file

@ -157,7 +157,7 @@ defmodule PhilomenaWeb.ImageView do
def username(%{name: name}), do: name def username(%{name: name}), do: name
def username(_user), do: nil def username(_user), do: nil
def scope(conn), do: Philomena.ImageScope.scope(conn) def scope(conn), do: PhilomenaWeb.ImageScope.scope(conn)
def anonymous_by_default?(conn) do def anonymous_by_default?(conn) do
conn.assigns.current_user.anonymous_by_default conn.assigns.current_user.anonymous_by_default

View file

@ -1,6 +1,6 @@
defmodule PhilomenaWeb.SearchView do defmodule PhilomenaWeb.SearchView do
use PhilomenaWeb, :view use PhilomenaWeb, :view
def scope(conn), do: Philomena.ImageScope.scope(conn) def scope(conn), do: PhilomenaWeb.ImageScope.scope(conn)
def hides_images?(conn), do: can?(conn, :hide, %Philomena.Images.Image{}) def hides_images?(conn), do: can?(conn, :hide, %Philomena.Images.Image{})
end end