diff --git a/lib/philomena/tags/tag.ex b/lib/philomena/tags/tag.ex index 5468e6a1..eec67df4 100644 --- a/lib/philomena/tags/tag.ex +++ b/lib/philomena/tags/tag.ex @@ -2,6 +2,7 @@ defmodule Philomena.Tags.Tag do use Ecto.Schema import Ecto.Changeset + alias Philomena.Channels.Channel alias Philomena.DnpEntries.DnpEntry alias Philomena.UserLinks.UserLink alias Philomena.Tags.Tag @@ -46,6 +47,8 @@ defmodule Philomena.Tags.Tag do belongs_to :aliased_tag, Tag, source: :aliased_tag_id has_many :aliases, Tag, foreign_key: :aliased_tag_id + has_many :channels, Channel, foreign_key: :associated_artist_tag_id + many_to_many :implied_tags, Tag, join_through: "tags_implied_tags", join_keys: [tag_id: :id, implied_tag_id: :id], diff --git a/lib/philomena_web/controllers/tag_controller.ex b/lib/philomena_web/controllers/tag_controller.ex index 11d6d34a..03f613a9 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -20,6 +20,7 @@ defmodule PhilomenaWeb.TagController do :implied_tags, :implied_by_tags, :dnp_entries, + :channels, public_links: :user, hidden_links: :user ] diff --git a/lib/philomena_web/image_loader.ex b/lib/philomena_web/image_loader.ex index 78a3f04e..5769c005 100644 --- a/lib/philomena_web/image_loader.ex +++ b/lib/philomena_web/image_loader.ex @@ -122,6 +122,7 @@ defmodule PhilomenaWeb.ImageLoader do :implied_tags, :implied_by_tags, :dnp_entries, + :channels, public_links: :user, hidden_links: :user ]) diff --git a/lib/philomena_web/templates/tag/_tag_info_row.html.slime b/lib/philomena_web/templates/tag/_tag_info_row.html.slime index 8de6c9b3..46779553 100644 --- a/lib/philomena_web/templates/tag/_tag_info_row.html.slime +++ b/lib/philomena_web/templates/tag/_tag_info_row.html.slime @@ -50,7 +50,7 @@ br - = if present?(@tag.public_links) or present?(@tag.implied_by_tags) or present?(@tag.description) do + = if present?(@tag.public_links) or present?(@tag.channels) or present?(@tag.implied_by_tags) or present?(@tag.description) do br = link "Toggle detailed information", to: "#", data: [click_toggle: ".tag-info__more"] @@ -74,6 +74,11 @@ br + = if Enum.any?(@tag.channels) do + strong> Associated streams: + = for channel <- @tag.channels do + => link channel.title, to: Routes.channel_path(@conn, :show, channel) + = if Enum.any?(@tag.implied_by_tags) do input.toggle-box id="implied_by" type="checkbox" label for="implied_by"