mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
move search, textile, date parser to app namespace
This commit is contained in:
parent
8e9d6285e4
commit
a1b8ed9d33
29 changed files with 43 additions and 43 deletions
|
@ -1,5 +1,5 @@
|
|||
defmodule Philomena.Comments.Query do
|
||||
alias Search.Parser
|
||||
alias Philomena.Search.Parser
|
||||
|
||||
defp user_id_transform(_ctx, data) do
|
||||
case Integer.parse(data) do
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Philomena.Galleries.Query do
|
||||
alias Search.Parser
|
||||
alias Philomena.Search.Parser
|
||||
|
||||
defp fields do
|
||||
[
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Philomena.Images.Query do
|
||||
alias Search.Parser
|
||||
alias Philomena.Search.Parser
|
||||
alias Philomena.Repo
|
||||
|
||||
defp gallery_id_transform(_ctx, value),
|
||||
|
@ -53,7 +53,7 @@ defmodule Philomena.Images.Query do
|
|||
do: {:error, "Unknown `my' value."}
|
||||
|
||||
defp invalid_filter_guard(ctx, search_string) do
|
||||
case parse(user_fields(), ctx, Search.String.normalize(search_string)) do
|
||||
case parse(user_fields(), ctx, Philomena.Search.String.normalize(search_string)) do
|
||||
{:ok, query} -> query
|
||||
_error -> %{match_all: %{}}
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Philomena.Posts.Query do
|
||||
alias Search.Parser
|
||||
alias Philomena.Search.Parser
|
||||
|
||||
defp user_id_transform(_ctx, data) do
|
||||
case Integer.parse(data) do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
defmodule RelativeDate.Parser do
|
||||
defmodule Philomena.RelativeDate do
|
||||
import NimbleParsec
|
||||
|
||||
number_words =
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Philomena.Reports.Query do
|
||||
alias Search.Parser
|
||||
alias Philomena.Search.Parser
|
||||
|
||||
defp fields do
|
||||
[
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
defmodule Philomena.Schema.Search do
|
||||
alias Philomena.Images.Query
|
||||
alias Search.String
|
||||
alias Philomena.Search.String
|
||||
import Ecto.Changeset
|
||||
|
||||
def validate_search(changeset, field, user, watched \\ false) do
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
defmodule Philomena.Schema.Time do
|
||||
alias RelativeDate.Parser
|
||||
alias Philomena.RelativeDate
|
||||
import Ecto.Changeset
|
||||
|
||||
def assign_time(changeset, field, target_field) do
|
||||
changeset
|
||||
|> get_field(field)
|
||||
|> Parser.parse()
|
||||
|> RelativeDate.parse()
|
||||
|> case do
|
||||
{:ok, time} ->
|
||||
put_change(changeset, target_field, time)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Search.BoolParser do
|
||||
defmodule Philomena.Search.BoolParser do
|
||||
import NimbleParsec
|
||||
|
||||
space =
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Search.DateParser do
|
||||
defmodule Philomena.Search.DateParser do
|
||||
import NimbleParsec
|
||||
|
||||
defp build_datetime(naive, tz_off, tz_hour, tz_minute) do
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Search.Evaluator do
|
||||
defmodule Philomena.Search.Evaluator do
|
||||
# TODO: rethink the necessity of this module.
|
||||
# Can we do this in elasticsearch instead?
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
defmodule Search.FloatParser do
|
||||
defmodule Philomena.Search.FloatParser do
|
||||
import NimbleParsec
|
||||
|
||||
defp to_number(input), do: Search.Helpers.to_number(input)
|
||||
defp range(input), do: Search.Helpers.range(input)
|
||||
defp to_number(input), do: Philomena.Search.Helpers.to_number(input)
|
||||
defp range(input), do: Philomena.Search.Helpers.range(input)
|
||||
|
||||
space =
|
||||
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Search.Helpers do
|
||||
defmodule Philomena.Search.Helpers do
|
||||
# Apparently, it's too hard for the standard library to to parse a number
|
||||
# as a float if it doesn't contain a decimal point. WTF
|
||||
def to_number(term) do
|
|
@ -1,8 +1,8 @@
|
|||
defmodule Search.IntParser do
|
||||
defmodule Philomena.Search.IntParser do
|
||||
import NimbleParsec
|
||||
|
||||
defp to_int(input), do: Search.Helpers.to_int(input)
|
||||
defp range(input), do: Search.Helpers.range(input)
|
||||
defp to_int(input), do: Philomena.Search.Helpers.to_int(input)
|
||||
defp range(input), do: Philomena.Search.Helpers.range(input)
|
||||
|
||||
space =
|
||||
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Search.IpParser do
|
||||
defmodule Philomena.Search.IpParser do
|
||||
import NimbleParsec
|
||||
|
||||
ipv4_octet =
|
|
@ -1,7 +1,7 @@
|
|||
defmodule Search.Lexer do
|
||||
defmodule Philomena.Search.Lexer do
|
||||
import NimbleParsec
|
||||
|
||||
defp to_number(input), do: Search.Helpers.to_number(input)
|
||||
defp to_number(input), do: Philomena.Search.Helpers.to_number(input)
|
||||
|
||||
space =
|
||||
choice([string(" "), string("\t"), string("\n"), string("\r"), string("\v"), string("\f")])
|
|
@ -1,7 +1,7 @@
|
|||
defmodule Search.LiteralParser do
|
||||
defmodule Philomena.Search.LiteralParser do
|
||||
import NimbleParsec
|
||||
|
||||
defp to_number(input), do: Search.Helpers.to_number(input)
|
||||
defp to_number(input), do: Philomena.Search.Helpers.to_number(input)
|
||||
|
||||
float =
|
||||
ascii_string([?0..?9], min: 1)
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Search.NgramParser do
|
||||
alias Search.LiteralParser
|
||||
defmodule Philomena.Search.NgramParser do
|
||||
alias Philomena.Search.LiteralParser
|
||||
|
||||
# Dummy stub. Used for convenient parser implementation.
|
||||
def parse(input), do: LiteralParser.parse(input)
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Search.Parser do
|
||||
alias Search.{
|
||||
defmodule Philomena.Search.Parser do
|
||||
alias Philomena.Search.{
|
||||
BoolParser,
|
||||
DateParser,
|
||||
FloatParser,
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Search.String do
|
||||
defmodule Philomena.Search.String do
|
||||
def normalize(nil) do
|
||||
""
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
defmodule Search.TermRangeParser do
|
||||
alias Search.LiteralParser
|
||||
alias Search.NgramParser
|
||||
defmodule Philomena.Search.TermRangeParser do
|
||||
alias Philomena.Search.LiteralParser
|
||||
alias Philomena.Search.NgramParser
|
||||
|
||||
# Unfortunately, we can't use NimbleParsec here. It requires
|
||||
# the compiler, and we're not in a macro environment.
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Philomena.Tags.Query do
|
||||
alias Search.Parser
|
||||
alias Philomena.Search.Parser
|
||||
|
||||
defp fields do
|
||||
[
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
defmodule Textile.Lexer do
|
||||
defmodule Philomena.Textile.Lexer do
|
||||
import NimbleParsec
|
||||
|
||||
space = utf8_char('\f \r\t\u00a0\u1680\u180e\u202f\u205f\u3000' ++ Enum.to_list(0x2000..0x200A))
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Textile.Parser do
|
||||
alias Textile.Lexer
|
||||
defmodule Philomena.Textile.Parser do
|
||||
alias Philomena.Textile.Lexer
|
||||
alias Phoenix.HTML
|
||||
|
||||
def parse(parser, input) do
|
|
@ -1,6 +1,6 @@
|
|||
defmodule PhilomenaWeb.ImageFilterPlug do
|
||||
import Plug.Conn
|
||||
import Search.String
|
||||
import Philomena.Search.String
|
||||
|
||||
alias Philomena.Images.Query
|
||||
alias Pow.Plug
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
defmodule PhilomenaWeb.TextileRenderer do
|
||||
alias Textile.Parser
|
||||
alias Philomena.Textile.Parser
|
||||
alias Philomena.Images.Image
|
||||
alias Philomena.Repo
|
||||
import Phoenix.HTML
|
||||
|
|
|
@ -259,6 +259,6 @@ defmodule PhilomenaWeb.ImageView do
|
|||
}
|
||||
}
|
||||
|
||||
Search.Evaluator.hits?(doc, query)
|
||||
Philomena.Search.Evaluator.hits?(doc, query)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,9 +40,9 @@ defmodule PhilomenaWeb.LayoutView do
|
|||
data = [
|
||||
filter_id: filter.id,
|
||||
hidden_tag_list: Jason.encode!(filter.hidden_tag_ids),
|
||||
hidden_filter: Search.String.normalize(filter.hidden_complex_str || ""),
|
||||
hidden_filter: Philomena.Search.String.normalize(filter.hidden_complex_str || ""),
|
||||
spoilered_tag_list: Jason.encode!(filter.spoilered_tag_ids),
|
||||
spoilered_filter: Search.String.normalize(filter.spoilered_complex_str || ""),
|
||||
spoilered_filter: Philomena.Search.String.normalize(filter.spoilered_complex_str || ""),
|
||||
user_id: if(user, do: user.id, else: nil),
|
||||
user_name: if(user, do: user.name, else: nil),
|
||||
user_slug: if(user, do: user.slug, else: nil),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
defmodule PhilomenaWeb.PostView do
|
||||
alias Philomena.Attribution
|
||||
alias Textile.Parser
|
||||
alias Philomena.Textile.Parser
|
||||
|
||||
use PhilomenaWeb, :view
|
||||
|
||||
|
|
Loading…
Reference in a new issue