diff --git a/lib/philomena/comments/query.ex b/lib/philomena/comments/query.ex index 4a3ace7f..21df1ed1 100644 --- a/lib/philomena/comments/query.ex +++ b/lib/philomena/comments/query.ex @@ -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 diff --git a/lib/philomena/galleries/query.ex b/lib/philomena/galleries/query.ex index 71827d5f..8fd38c31 100644 --- a/lib/philomena/galleries/query.ex +++ b/lib/philomena/galleries/query.ex @@ -1,5 +1,5 @@ defmodule Philomena.Galleries.Query do - alias Search.Parser + alias Philomena.Search.Parser defp fields do [ diff --git a/lib/philomena/images/query.ex b/lib/philomena/images/query.ex index 2a2d77a3..c1107352 100644 --- a/lib/philomena/images/query.ex +++ b/lib/philomena/images/query.ex @@ -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 diff --git a/lib/philomena/posts/query.ex b/lib/philomena/posts/query.ex index bca23c4c..ce9e3353 100644 --- a/lib/philomena/posts/query.ex +++ b/lib/philomena/posts/query.ex @@ -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 diff --git a/lib/relative_date/parser.ex b/lib/philomena/relative_date.ex similarity index 98% rename from lib/relative_date/parser.ex rename to lib/philomena/relative_date.ex index 4d8e24b3..3d3aaaf5 100644 --- a/lib/relative_date/parser.ex +++ b/lib/philomena/relative_date.ex @@ -1,4 +1,4 @@ -defmodule RelativeDate.Parser do +defmodule Philomena.RelativeDate do import NimbleParsec number_words = diff --git a/lib/philomena/reports/query.ex b/lib/philomena/reports/query.ex index b2a76517..c085a604 100644 --- a/lib/philomena/reports/query.ex +++ b/lib/philomena/reports/query.ex @@ -1,5 +1,5 @@ defmodule Philomena.Reports.Query do - alias Search.Parser + alias Philomena.Search.Parser defp fields do [ diff --git a/lib/philomena/schema/search.ex b/lib/philomena/schema/search.ex index 46de1c06..47887b75 100644 --- a/lib/philomena/schema/search.ex +++ b/lib/philomena/schema/search.ex @@ -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 diff --git a/lib/philomena/schema/time.ex b/lib/philomena/schema/time.ex index 86b29e39..af36538a 100644 --- a/lib/philomena/schema/time.ex +++ b/lib/philomena/schema/time.ex @@ -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) diff --git a/lib/search/bool_parser.ex b/lib/philomena/search/bool_parser.ex similarity index 89% rename from lib/search/bool_parser.ex rename to lib/philomena/search/bool_parser.ex index 547b16cf..bb389096 100644 --- a/lib/search/bool_parser.ex +++ b/lib/philomena/search/bool_parser.ex @@ -1,4 +1,4 @@ -defmodule Search.BoolParser do +defmodule Philomena.Search.BoolParser do import NimbleParsec space = diff --git a/lib/search/date_parser.ex b/lib/philomena/search/date_parser.ex similarity index 99% rename from lib/search/date_parser.ex rename to lib/philomena/search/date_parser.ex index 2ed8b0a4..1434b970 100644 --- a/lib/search/date_parser.ex +++ b/lib/philomena/search/date_parser.ex @@ -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 diff --git a/lib/search/evaluator.ex b/lib/philomena/search/evaluator.ex similarity index 99% rename from lib/search/evaluator.ex rename to lib/philomena/search/evaluator.ex index 51f483e2..25ef2337 100644 --- a/lib/search/evaluator.ex +++ b/lib/philomena/search/evaluator.ex @@ -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? diff --git a/lib/search/float_parser.ex b/lib/philomena/search/float_parser.ex similarity index 83% rename from lib/search/float_parser.ex rename to lib/philomena/search/float_parser.ex index c9be9eeb..018d14ca 100644 --- a/lib/search/float_parser.ex +++ b/lib/philomena/search/float_parser.ex @@ -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")]) diff --git a/lib/search/helpers.ex b/lib/philomena/search/helpers.ex similarity index 93% rename from lib/search/helpers.ex rename to lib/philomena/search/helpers.ex index 92a6db70..e6a95e11 100644 --- a/lib/search/helpers.ex +++ b/lib/philomena/search/helpers.ex @@ -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 diff --git a/lib/search/int_parser.ex b/lib/philomena/search/int_parser.ex similarity index 78% rename from lib/search/int_parser.ex rename to lib/philomena/search/int_parser.ex index 5499bd62..9114159c 100644 --- a/lib/search/int_parser.ex +++ b/lib/philomena/search/int_parser.ex @@ -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")]) diff --git a/lib/search/ip_parser.ex b/lib/philomena/search/ip_parser.ex similarity index 99% rename from lib/search/ip_parser.ex rename to lib/philomena/search/ip_parser.ex index 2cf301be..f587c715 100644 --- a/lib/search/ip_parser.ex +++ b/lib/philomena/search/ip_parser.ex @@ -1,4 +1,4 @@ -defmodule Search.IpParser do +defmodule Philomena.Search.IpParser do import NimbleParsec ipv4_octet = diff --git a/lib/search/lexer.ex b/lib/philomena/search/lexer.ex similarity index 95% rename from lib/search/lexer.ex rename to lib/philomena/search/lexer.ex index 0a2bab7b..ef75b537 100644 --- a/lib/search/lexer.ex +++ b/lib/philomena/search/lexer.ex @@ -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")]) diff --git a/lib/search/literal_parser.ex b/lib/philomena/search/literal_parser.ex similarity index 91% rename from lib/search/literal_parser.ex rename to lib/philomena/search/literal_parser.ex index 934a4967..905e7f72 100644 --- a/lib/search/literal_parser.ex +++ b/lib/philomena/search/literal_parser.ex @@ -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) diff --git a/lib/search/ngram_parser.ex b/lib/philomena/search/ngram_parser.ex similarity index 58% rename from lib/search/ngram_parser.ex rename to lib/philomena/search/ngram_parser.ex index 65857b22..dd8d41ca 100644 --- a/lib/search/ngram_parser.ex +++ b/lib/philomena/search/ngram_parser.ex @@ -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) diff --git a/lib/search/parser.ex b/lib/philomena/search/parser.ex similarity index 99% rename from lib/search/parser.ex rename to lib/philomena/search/parser.ex index 92ff2578..00bbed6a 100644 --- a/lib/search/parser.ex +++ b/lib/philomena/search/parser.ex @@ -1,5 +1,5 @@ -defmodule Search.Parser do - alias Search.{ +defmodule Philomena.Search.Parser do + alias Philomena.Search.{ BoolParser, DateParser, FloatParser, diff --git a/lib/search/string.ex b/lib/philomena/search/string.ex similarity index 85% rename from lib/search/string.ex rename to lib/philomena/search/string.ex index 8437b784..a7f1441c 100644 --- a/lib/search/string.ex +++ b/lib/philomena/search/string.ex @@ -1,4 +1,4 @@ -defmodule Search.String do +defmodule Philomena.Search.String do def normalize(nil) do "" end diff --git a/lib/search/term_range_parser.ex b/lib/philomena/search/term_range_parser.ex similarity index 92% rename from lib/search/term_range_parser.ex rename to lib/philomena/search/term_range_parser.ex index eaa6b5ba..e956aed5 100644 --- a/lib/search/term_range_parser.ex +++ b/lib/philomena/search/term_range_parser.ex @@ -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. diff --git a/lib/philomena/tags/query.ex b/lib/philomena/tags/query.ex index 56a78544..6688d1f1 100644 --- a/lib/philomena/tags/query.ex +++ b/lib/philomena/tags/query.ex @@ -1,5 +1,5 @@ defmodule Philomena.Tags.Query do - alias Search.Parser + alias Philomena.Search.Parser defp fields do [ diff --git a/lib/textile/lexer.ex b/lib/philomena/textile/lexer.ex similarity index 99% rename from lib/textile/lexer.ex rename to lib/philomena/textile/lexer.ex index 0be3308f..baef3286 100644 --- a/lib/textile/lexer.ex +++ b/lib/philomena/textile/lexer.ex @@ -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)) diff --git a/lib/textile/parser.ex b/lib/philomena/textile/parser.ex similarity index 99% rename from lib/textile/parser.ex rename to lib/philomena/textile/parser.ex index e1c2f09d..3f022c6f 100644 --- a/lib/textile/parser.ex +++ b/lib/philomena/textile/parser.ex @@ -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 diff --git a/lib/philomena_web/plugs/image_filter_plug.ex b/lib/philomena_web/plugs/image_filter_plug.ex index 37e33032..b313d8c6 100644 --- a/lib/philomena_web/plugs/image_filter_plug.ex +++ b/lib/philomena_web/plugs/image_filter_plug.ex @@ -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 diff --git a/lib/philomena_web/textile_renderer.ex b/lib/philomena_web/textile_renderer.ex index 9b445f2b..f8ff12f3 100644 --- a/lib/philomena_web/textile_renderer.ex +++ b/lib/philomena_web/textile_renderer.ex @@ -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 diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index 7b178b47..f0d8a8b3 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -259,6 +259,6 @@ defmodule PhilomenaWeb.ImageView do } } - Search.Evaluator.hits?(doc, query) + Philomena.Search.Evaluator.hits?(doc, query) end end diff --git a/lib/philomena_web/views/layout_view.ex b/lib/philomena_web/views/layout_view.ex index 82a8b301..17e5b560 100644 --- a/lib/philomena_web/views/layout_view.ex +++ b/lib/philomena_web/views/layout_view.ex @@ -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), diff --git a/lib/philomena_web/views/post_view.ex b/lib/philomena_web/views/post_view.ex index bc28a461..5aaa0644 100644 --- a/lib/philomena_web/views/post_view.ex +++ b/lib/philomena_web/views/post_view.ex @@ -1,6 +1,6 @@ defmodule PhilomenaWeb.PostView do alias Philomena.Attribution - alias Textile.Parser + alias Philomena.Textile.Parser use PhilomenaWeb, :view