mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
add detailed descriptions to tag pages
This commit is contained in:
parent
ca1036088f
commit
70bbe6df81
7 changed files with 114 additions and 2 deletions
|
@ -17,6 +17,7 @@ config :philomena,
|
||||||
avatar_url_root: "/avatars",
|
avatar_url_root: "/avatars",
|
||||||
advert_url_root: "/spns",
|
advert_url_root: "/spns",
|
||||||
badge_url_root: "/media",
|
badge_url_root: "/media",
|
||||||
|
tag_url_root: "/media",
|
||||||
image_file_root: "priv/static/system/images",
|
image_file_root: "priv/static/system/images",
|
||||||
cdn_host: "",
|
cdn_host: "",
|
||||||
proxy_host: nil,
|
proxy_host: nil,
|
||||||
|
|
|
@ -25,6 +25,7 @@ config :philomena,
|
||||||
image_url_root: System.get_env("IMAGE_URL_ROOT"),
|
image_url_root: System.get_env("IMAGE_URL_ROOT"),
|
||||||
badge_url_root: System.get_env("BADGE_URL_ROOT"),
|
badge_url_root: System.get_env("BADGE_URL_ROOT"),
|
||||||
mailer_address: System.get_env("MAILER_ADDRESS"),
|
mailer_address: System.get_env("MAILER_ADDRESS"),
|
||||||
|
tag_url_root: System.get_env("TAG_URL_ROOT"),
|
||||||
proxy_host: System.get_env("PROXY_HOST"),
|
proxy_host: System.get_env("PROXY_HOST"),
|
||||||
camo_host: System.get_env("CAMO_HOST"),
|
camo_host: System.get_env("CAMO_HOST"),
|
||||||
camo_key: System.get_env("CAMO_KEY"),
|
camo_key: System.get_env("CAMO_KEY"),
|
||||||
|
|
|
@ -7,6 +7,9 @@ defmodule Philomena.Tags.Tag do
|
||||||
index_name: "tags",
|
index_name: "tags",
|
||||||
doc_type: "tag"
|
doc_type: "tag"
|
||||||
|
|
||||||
|
alias Philomena.DnpEntries.DnpEntry
|
||||||
|
alias Philomena.UserLinks.UserLink
|
||||||
|
alias Philomena.Users.User
|
||||||
alias Philomena.Tags.Tag
|
alias Philomena.Tags.Tag
|
||||||
alias Philomena.Slug
|
alias Philomena.Slug
|
||||||
|
|
||||||
|
@ -48,6 +51,8 @@ defmodule Philomena.Tags.Tag do
|
||||||
has_many :aliases, Tag, foreign_key: :aliased_tag_id
|
has_many :aliases, Tag, foreign_key: :aliased_tag_id
|
||||||
many_to_many :implied_tags, Tag, join_through: "tags_implied_tags", join_keys: [tag_id: :id, implied_tag_id: :id]
|
many_to_many :implied_tags, Tag, join_through: "tags_implied_tags", join_keys: [tag_id: :id, implied_tag_id: :id]
|
||||||
many_to_many :implied_by_tags, Tag, join_through: "tags_implied_tags", join_keys: [implied_tag_id: :id, tag_id: :id]
|
many_to_many :implied_by_tags, Tag, join_through: "tags_implied_tags", join_keys: [implied_tag_id: :id, tag_id: :id]
|
||||||
|
has_many :public_links, UserLink, where: [public: true, aasm_state: "verified"]
|
||||||
|
has_many :dnp_entries, DnpEntry, where: [aasm_state: "listed"]
|
||||||
|
|
||||||
field :slug, :string
|
field :slug, :string
|
||||||
field :name, :string
|
field :name, :string
|
||||||
|
|
|
@ -2,7 +2,9 @@ defmodule PhilomenaWeb.TagController do
|
||||||
use PhilomenaWeb, :controller
|
use PhilomenaWeb, :controller
|
||||||
|
|
||||||
alias Philomena.{Images.Image, Tags, Tags.Tag}
|
alias Philomena.{Images.Image, Tags, Tags.Tag}
|
||||||
|
alias Philomena.Textile.Renderer
|
||||||
alias Philomena.Interactions
|
alias Philomena.Interactions
|
||||||
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
def index(conn, params) do
|
def index(conn, params) do
|
||||||
|
@ -28,7 +30,11 @@ defmodule PhilomenaWeb.TagController do
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(conn, %{"id" => slug}) do
|
def show(conn, %{"id" => slug}) do
|
||||||
tag = Tags.get_tag!(slug)
|
tag =
|
||||||
|
Tag
|
||||||
|
|> where(slug: ^slug)
|
||||||
|
|> preload([:aliases, :implied_tags, :implied_by_tags, :dnp_entries, public_links: :user])
|
||||||
|
|> Repo.one()
|
||||||
|
|
||||||
query = conn.assigns.compiled_filter
|
query = conn.assigns.compiled_filter
|
||||||
user = conn.assigns.current_user
|
user = conn.assigns.current_user
|
||||||
|
@ -51,6 +57,15 @@ defmodule PhilomenaWeb.TagController do
|
||||||
interactions =
|
interactions =
|
||||||
Interactions.user_interactions(images, user)
|
Interactions.user_interactions(images, user)
|
||||||
|
|
||||||
render(conn, "show.html", tag: tag, interactions: interactions, images: images, layout_class: "layout--wide")
|
body =
|
||||||
|
Renderer.render_one(%{body: tag.description || ""})
|
||||||
|
|
||||||
|
dnp_bodies =
|
||||||
|
Renderer.render_collection(Enum.map(tag.dnp_entries, &%{body: &1.conditions || ""}))
|
||||||
|
|
||||||
|
dnp_entries =
|
||||||
|
Enum.zip(dnp_bodies, tag.dnp_entries)
|
||||||
|
|
||||||
|
render(conn, "show.html", tag: tag, body: body, dnp_entries: dnp_entries, interactions: interactions, images: images, layout_class: "layout--wide")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
81
lib/philomena_web/templates/tag/_tag_info_row.html.slime
Normal file
81
lib/philomena_web/templates/tag/_tag_info_row.html.slime
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
.block__content.js-imagelist-info.flex
|
||||||
|
.flex__fixed.tag-info__image.thumb-tiny-container.spacing-right
|
||||||
|
= if @tag.image do
|
||||||
|
img src=tag_image(@tag) alt="spoiler image"
|
||||||
|
- else
|
||||||
|
| no spoiler image
|
||||||
|
|
||||||
|
.flex__grow
|
||||||
|
= render PhilomenaWeb.TagView, "_tag.html", tag: @tag
|
||||||
|
|
||||||
|
= if @tag.short_description not in [nil, ""] do
|
||||||
|
strong> Short description:
|
||||||
|
= @tag.short_description
|
||||||
|
br
|
||||||
|
|
||||||
|
= if Enum.any?(@tag.aliases) do
|
||||||
|
strong> Aliases:
|
||||||
|
= Enum.map_join(@tag.aliases, ", ", & &1.name)
|
||||||
|
br
|
||||||
|
|
||||||
|
= if Enum.any?(@tag.implied_tags) do
|
||||||
|
strong> Implies:
|
||||||
|
= Enum.map_join(@tag.implied_tags, ", ", & &1.name)
|
||||||
|
br
|
||||||
|
|
||||||
|
br
|
||||||
|
= link "Toggle details", to: "#", data: [click_toggle: ".tag-info__more"]
|
||||||
|
|
||||||
|
.tag-info__more
|
||||||
|
hr
|
||||||
|
|
||||||
|
= if Enum.any?(@tag.public_links) do
|
||||||
|
strong> Associated links:
|
||||||
|
|
||||||
|
= for link <- @tag.public_links do
|
||||||
|
a> href=link.uri = link.uri
|
||||||
|
|
||||||
|
br
|
||||||
|
|
||||||
|
= if Enum.any?(@tag.public_links) do
|
||||||
|
strong> Associated users:
|
||||||
|
- users = Enum.map(@tag.public_links, & &1.user) |> Enum.uniq()
|
||||||
|
|
||||||
|
= for user <- users do
|
||||||
|
=> link user.name, to: Routes.profile_path(@conn, :show, user)
|
||||||
|
|
||||||
|
br
|
||||||
|
|
||||||
|
= if Enum.any?(@tag.implied_by_tags) do
|
||||||
|
input.toggle-box id="implied_by" type="checkbox" checked="false"
|
||||||
|
label for="implied_by"
|
||||||
|
' Implied by (warning: unfiltered)
|
||||||
|
|
||||||
|
.toggle-box-container
|
||||||
|
.toggle-box-container__content
|
||||||
|
= for tag <- @tag.implied_by_tags do
|
||||||
|
=> link tag.name, to: Routes.tag_path(@conn, :show, tag)
|
||||||
|
|
||||||
|
br
|
||||||
|
|
||||||
|
= if @tag.description not in [nil, ""] do
|
||||||
|
strong> Detailed description:
|
||||||
|
br
|
||||||
|
== @body
|
||||||
|
|
||||||
|
= if Enum.any?(@dnp_entries) do
|
||||||
|
hr
|
||||||
|
strong.comment_deleted This artist is on the Do-Not-Post List with the following restrictions:
|
||||||
|
|
||||||
|
= for {body, entry} <- @dnp_entries do
|
||||||
|
br
|
||||||
|
' •
|
||||||
|
|
||||||
|
strong
|
||||||
|
=> entry.dnp_type
|
||||||
|
|
||||||
|
==> body
|
||||||
|
|
||||||
|
| (
|
||||||
|
= link "more info", to: "#"
|
||||||
|
| )
|
|
@ -1 +1,2 @@
|
||||||
|
= render PhilomenaWeb.TagView, "_tag_info_row.html", tag: @tag, body: @body, dnp_entries: @dnp_entries, conn: @conn
|
||||||
= render PhilomenaWeb.ImageView, "index.html", conn: @conn, images: @images
|
= render PhilomenaWeb.ImageView, "index.html", conn: @conn, images: @images
|
|
@ -6,6 +6,10 @@ defmodule PhilomenaWeb.TagView do
|
||||||
alias Philomena.Repo
|
alias Philomena.Repo
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
|
def tag_image(%{image: image}) do
|
||||||
|
tag_url_root() <> "/" <> image
|
||||||
|
end
|
||||||
|
|
||||||
def quick_tags(conn) do
|
def quick_tags(conn) do
|
||||||
case Application.get_env(:philomena, :quick_tags) do
|
case Application.get_env(:philomena, :quick_tags) do
|
||||||
nil ->
|
nil ->
|
||||||
|
@ -117,4 +121,8 @@ defmodule PhilomenaWeb.TagView do
|
||||||
Tag |> preload(:implied_tags)
|
Tag |> preload(:implied_tags)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp tag_url_root do
|
||||||
|
Application.get_env(:philomena, :tag_url_root)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue