h1 Tags

= form_for :tags, ~p"/tags", [method: "get", class: "hform", enforce_utf8: false], fn f ->
  .field
    = text_input f, :tq, name: :tq, value: @conn.params["tq"] || "*", class: "input hform__text", placeholder: "Search tags", autocapitalize: "none"
    = submit "Search", class: "hform__button button"

  .fieldlabel
    ' For more information, see the
    a href="/pages/search_syntax" search syntax documentation
    ' . Wildcards are supported in all literal fields.
    ' Search results are sorted by image count, then by name alphabetically.

h2 Search Results

= cond do
  - Enum.any?(@tags) ->
    - route = fn p -> ~p"/tags?#{p}" end
    - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @tags, route: route, params: [tq: @conn.params["tq"] || "*"]

    = render PhilomenaWeb.TagView, "_tag_list.html", tags: @tags, conn: @conn

    .block
      .block__header.block__header--light.page__header
        .page__pagination = pagination
        .page__info
          span
            = render PhilomenaWeb.PaginationView, "_pagination_info.html", page: @tags

  - assigns[:error] ->
    .block.block--fixed.block--danger
      ' Oops, there was an error parsing your query! Check for mistakes like mismatched parentheses. The error was:
    pre = assigns[:error]

  - true ->
    p
      ' No tags found!

h3 Default search
p
  ' If you do not specify a field to search over, the search engine will
  ' search for tags with a name that is equal to the query string.

h3 Allowed fields
table.table
  thead
    tr
      th Field Selector
      th Type
      th Description
      th Example
  tbody
    tr
      td
        code alias_of
      td Literal
      td Matches the name of the target tag, if this tag is aliased.
      td
        code = link "alias_of:twilight sparkle", to: ~p"/tags?#{[tq: "alias_of:twilight sparkle"]}"
    tr
      td
        code aliased
      td Boolean
      td Matches when this tag is aliased.
      td
        code = link "aliased:true", to: ~p"/tags?#{[tq: "aliased:true"]}"
    tr
      td
        code aliases
      td Literal
      td Matches the name of any of this tag's aliases.
      td
        code = link "aliases:ts", to: ~p"/tags?#{[tq: "aliases:ts"]}"
    tr
      td
        code analyzed_name
      td Full Text
      td Matches the name of this tag. This is the default field.
      td
        code = link "analyzed_name:wing", to: ~p"/tags?#{[tq: "analyzed_name:wing"]}"
    tr
      td
        code category
      td Literal
      td Matches the category this tag belongs to.
      td
        code = link "category:origin", to: ~p"/tags?#{[tq: "category:origin"]}"
    tr
      td
        code description
      td Full Text
      td Matches the text of the full description for this tag.
      td
        code = link "description:species", to: ~p"/tags?#{[tq: "description:species"]}"
    tr
      td
        code id
      td Numeric Range
      td Matches the numeric surrogate key for this tag.
      td
        code = link "id:40482", to: ~p"/tags?#{[tq: "id:40482"]}"
    tr
      td
        code images
      td Numeric Range
      td Matches tags with the specified image count.
      td
        code = link "images.lte:1000", to: ~p"/tags?#{[tq: "images.lte:1000"]}"
    tr
      td
        code implied_by
      td Literal
      td Matches this tag if it is implied by the given tag.
      td
        code = link "implied_by:transparent background", to: ~p"/tags?#{[tq: "implied_by:transparent background"]}"
    tr
      td
        code implies
      td Literal
      td Matches this tag if it implies the given tag.
      td
        code = link "implies:shipping", to: ~p"/tags?#{[tq: "implies:shipping"]}"
    tr
      td
        code name
      td Literal
      td Matches the exact name of this tag.
      td
        code = link "name:safe", to: ~p"/tags?#{[tq: "name:safe"]}"
    tr
      td
        code name_in_namespace
      td Literal
      td Matches the name of this tag with any namespace component removed.
      td
        code = link "name_in_namespace:johnjoseco", to: ~p"/tags?#{[tq: "name_in_namespace:johnjoseco"]}"
    tr
      td
        code namespace
      td Literal
      td Matches tags with the given namespace.
      td
        code = link "namespace:artist", to: ~p"/tags?#{[tq: "namespace:artist"]}"
    tr
      td
        code short_description
      td Full Text
      td Matches the text of the short description for this tag.
      td
        code = link "short_description:gender", to: ~p"/tags?#{[tq: "short_description:gender"]}"
    tr
      td
        code slug
      td Literal
      td Matches the slug of this tag.
      td
        code = link "slug:-fwslash-mlp-fwslash-", to: ~p"/tags?#{[tq: "slug:-fwslash-mlp-fwslash-"]}"
