mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
move textile renderer to web namespace
This commit is contained in:
parent
00415b062c
commit
8e9d6285e4
18 changed files with 52 additions and 50 deletions
|
@ -1,7 +1,7 @@
|
|||
defmodule PhilomenaWeb.Admin.DnpEntryController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.DnpEntries.DnpEntry
|
||||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Admin.DnpEntryController do
|
|||
bodies =
|
||||
dnp_entries
|
||||
|> Enum.map(&%{body: &1.conditions})
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|
||||
dnp_entries = %{dnp_entries | entries: Enum.zip(bodies, dnp_entries.entries)}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
defmodule PhilomenaWeb.Admin.ModNoteController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.ModNotes.ModNote
|
||||
alias Philomena.Polymorphic
|
||||
alias Philomena.ModNotes
|
||||
|
@ -29,7 +29,7 @@ defmodule PhilomenaWeb.Admin.ModNoteController do
|
|||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
bodies = Renderer.render_collection(mod_notes, conn)
|
||||
bodies = TextileRenderer.render_collection(mod_notes, conn)
|
||||
preloaded = Polymorphic.load_polymorphic(mod_notes, notable: [notable_id: :notable_type])
|
||||
mod_notes = %{mod_notes | entries: Enum.zip(bodies, preloaded)}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ defmodule PhilomenaWeb.Admin.ReportController do
|
|||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.Elasticsearch
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Reports.Report
|
||||
alias Philomena.Reports.Query
|
||||
alias Philomena.Polymorphic
|
||||
|
@ -73,7 +73,7 @@ defmodule PhilomenaWeb.Admin.ReportController do
|
|||
reportable: [reportable_id: :reportable_type]
|
||||
)
|
||||
|
||||
body = Renderer.render_one(%{body: report.reason}, conn)
|
||||
body = TextileRenderer.render_one(%{body: report.reason}, conn)
|
||||
|
||||
render(conn, "show.html", title: "Showing Report", report: report, body: body)
|
||||
end
|
||||
|
@ -125,7 +125,7 @@ defmodule PhilomenaWeb.Admin.ReportController do
|
|||
|
||||
mod_notes =
|
||||
mod_notes
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|> Enum.zip(mod_notes)
|
||||
|
||||
assign(conn, :mod_notes, mod_notes)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
defmodule PhilomenaWeb.CommentController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Elasticsearch
|
||||
alias Philomena.{Comments.Query, Comments.Comment, Textile.Renderer}
|
||||
alias Philomena.{Comments.Query, Comments.Comment}
|
||||
import Ecto.Query
|
||||
|
||||
def index(conn, params) do
|
||||
|
@ -36,7 +37,7 @@ defmodule PhilomenaWeb.CommentController do
|
|||
Comment |> preload([:deleted_by, image: [:tags], user: [awards: :badge]])
|
||||
)
|
||||
|
||||
rendered = Renderer.render_collection(comments.entries, conn)
|
||||
rendered = TextileRenderer.render_collection(comments.entries, conn)
|
||||
|
||||
comments = %{comments | entries: Enum.zip(rendered, comments.entries)}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule PhilomenaWeb.ConversationController do
|
|||
|
||||
alias PhilomenaWeb.NotificationCountPlug
|
||||
alias Philomena.{Conversations, Conversations.Conversation, Conversations.Message}
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
||||
|
@ -67,7 +67,7 @@ defmodule PhilomenaWeb.ConversationController do
|
|||
|
||||
rendered =
|
||||
messages.entries
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|
||||
messages = %{messages | entries: Enum.zip(messages.entries, rendered)}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ defmodule PhilomenaWeb.DnpEntryController do
|
|||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.DnpEntries.DnpEntry
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.DnpEntries
|
||||
alias Philomena.Tags.Tag
|
||||
alias Philomena.ModNotes.ModNote
|
||||
|
@ -43,7 +43,7 @@ defmodule PhilomenaWeb.DnpEntryController do
|
|||
bodies =
|
||||
dnp_entries
|
||||
|> Enum.map(&%{body: &1.conditions || "-"})
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|
||||
dnp_entries = %{dnp_entries | entries: Enum.zip(bodies, dnp_entries.entries)}
|
||||
|
||||
|
@ -60,7 +60,7 @@ defmodule PhilomenaWeb.DnpEntryController do
|
|||
dnp_entry = conn.assigns.dnp_entry
|
||||
|
||||
[conditions, reason, instructions] =
|
||||
Renderer.render_collection(
|
||||
TextileRenderer.render_collection(
|
||||
[
|
||||
%{body: dnp_entry.conditions || "-"},
|
||||
%{body: dnp_entry.reason || "-"},
|
||||
|
@ -165,7 +165,7 @@ defmodule PhilomenaWeb.DnpEntryController do
|
|||
|
||||
mod_notes =
|
||||
mod_notes
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|> Enum.zip(mod_notes)
|
||||
|
||||
assign(conn, :mod_notes, mod_notes)
|
||||
|
|
|
@ -2,7 +2,8 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
use PhilomenaWeb, :controller
|
||||
|
||||
alias PhilomenaWeb.CommentLoader
|
||||
alias Philomena.{Images.Image, Comments.Comment, Textile.Renderer}
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.{Images.Image, Comments.Comment}
|
||||
alias Philomena.UserStatistics
|
||||
alias Philomena.Comments
|
||||
alias Philomena.Images
|
||||
|
@ -37,7 +38,7 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
def index(conn, _params) do
|
||||
comments = CommentLoader.load_comments(conn, conn.assigns.image)
|
||||
|
||||
rendered = Renderer.render_collection(comments.entries, conn)
|
||||
rendered = TextileRenderer.render_collection(comments.entries, conn)
|
||||
|
||||
comments = %{comments | entries: Enum.zip(comments.entries, rendered)}
|
||||
|
||||
|
@ -45,7 +46,7 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
end
|
||||
|
||||
def show(conn, _params) do
|
||||
rendered = Renderer.render_one(conn.assigns.comment, conn)
|
||||
rendered = TextileRenderer.render_one(conn.assigns.comment, conn)
|
||||
|
||||
render(conn, "show.html",
|
||||
layout: false,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
defmodule PhilomenaWeb.Image.DescriptionController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Images.Image
|
||||
alias Philomena.Images
|
||||
|
||||
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.DescriptionController do
|
|||
{:ok, image} ->
|
||||
Images.reindex_image(image)
|
||||
|
||||
body = Renderer.render_one(%{body: image.description}, conn)
|
||||
body = TextileRenderer.render_one(%{body: image.description}, conn)
|
||||
|
||||
conn
|
||||
|> put_view(PhilomenaWeb.ImageView)
|
||||
|
|
|
@ -4,13 +4,13 @@ defmodule PhilomenaWeb.ImageController do
|
|||
alias PhilomenaWeb.ImageLoader
|
||||
alias PhilomenaWeb.CommentLoader
|
||||
alias PhilomenaWeb.NotificationCountPlug
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
|
||||
alias Philomena.{
|
||||
Images,
|
||||
Images.Image,
|
||||
Comments.Comment,
|
||||
Galleries.Gallery,
|
||||
Textile.Renderer
|
||||
Galleries.Gallery
|
||||
}
|
||||
|
||||
# alias Philomena.Servers.ImageProcessor
|
||||
|
@ -56,13 +56,13 @@ defmodule PhilomenaWeb.ImageController do
|
|||
|
||||
comments = CommentLoader.load_comments(conn, image)
|
||||
|
||||
rendered = Renderer.render_collection(comments.entries, conn)
|
||||
rendered = TextileRenderer.render_collection(comments.entries, conn)
|
||||
|
||||
comments = %{comments | entries: Enum.zip(comments.entries, rendered)}
|
||||
|
||||
description =
|
||||
%{body: image.description}
|
||||
|> Renderer.render_one(conn)
|
||||
|> TextileRenderer.render_one(conn)
|
||||
|
||||
interactions = Interactions.user_interactions([image], conn.assigns.current_user)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
defmodule PhilomenaWeb.Post.PreviewController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Posts.Post
|
||||
alias Philomena.Repo
|
||||
|
||||
|
@ -11,7 +11,7 @@ defmodule PhilomenaWeb.Post.PreviewController do
|
|||
anonymous = params["anonymous"] == true
|
||||
|
||||
post = %Post{user: user, body: body, anonymous: anonymous}
|
||||
rendered = Renderer.render_one(post, conn)
|
||||
rendered = TextileRenderer.render_one(post, conn)
|
||||
|
||||
render(conn, "create.html", layout: false, post: post, body: rendered)
|
||||
end
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
defmodule PhilomenaWeb.PostController do
|
||||
use PhilomenaWeb, :controller
|
||||
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Elasticsearch
|
||||
alias Philomena.{Posts.Query, Posts.Post, Textile.Renderer}
|
||||
alias Philomena.{Posts.Query, Posts.Post}
|
||||
import Ecto.Query
|
||||
|
||||
def index(conn, params) do
|
||||
|
@ -33,7 +34,7 @@ defmodule PhilomenaWeb.PostController do
|
|||
Post |> preload([:deleted_by, topic: :forum, user: [awards: :badge]])
|
||||
)
|
||||
|
||||
rendered = Renderer.render_collection(posts.entries, conn)
|
||||
rendered = TextileRenderer.render_collection(posts.entries, conn)
|
||||
|
||||
posts = %{posts | entries: Enum.zip(rendered, posts.entries)}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
|
||||
alias Philomena.Commissions.Commission
|
||||
alias Philomena.Commissions
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Users.User
|
||||
|
||||
plug PhilomenaWeb.FilterBannedUsersPlug when action in [:new, :create, :edit, :update, :delete]
|
||||
|
@ -33,15 +33,15 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
item_descriptions =
|
||||
items
|
||||
|> Enum.map(&%{body: &1.description})
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|
||||
item_add_ons =
|
||||
items
|
||||
|> Enum.map(&%{body: &1.add_ons})
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|
||||
[information, contact, will_create, will_not_create] =
|
||||
Renderer.render_collection(
|
||||
TextileRenderer.render_collection(
|
||||
[
|
||||
%{body: commission.information || ""},
|
||||
%{body: commission.contact || ""},
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule PhilomenaWeb.Profile.DetailController do
|
|||
|
||||
alias Philomena.UserNameChanges.UserNameChange
|
||||
alias Philomena.ModNotes.ModNote
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Polymorphic
|
||||
alias Philomena.Users.User
|
||||
alias Philomena.Repo
|
||||
|
@ -30,7 +30,7 @@ defmodule PhilomenaWeb.Profile.DetailController do
|
|||
|
||||
mod_notes =
|
||||
mod_notes
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|> Enum.zip(mod_notes)
|
||||
|
||||
name_changes =
|
||||
|
|
|
@ -3,7 +3,7 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
|
||||
alias PhilomenaWeb.ImageLoader
|
||||
alias Philomena.Elasticsearch
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.UserStatistics.UserStatistic
|
||||
alias Philomena.Users.User
|
||||
alias Philomena.Bans
|
||||
|
@ -98,7 +98,7 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
|
||||
recent_comments =
|
||||
recent_comments
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|> Enum.zip(recent_comments)
|
||||
|
||||
recent_posts =
|
||||
|
@ -122,9 +122,9 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
)
|
||||
|> Enum.filter(&Canada.Can.can?(current_user, :show, &1.topic))
|
||||
|
||||
about_me = Renderer.render_one(%{body: user.description || ""}, conn)
|
||||
about_me = TextileRenderer.render_one(%{body: user.description || ""}, conn)
|
||||
|
||||
scratchpad = Renderer.render_one(%{body: user.scratchpad || ""}, conn)
|
||||
scratchpad = TextileRenderer.render_one(%{body: user.scratchpad || ""}, conn)
|
||||
|
||||
commission_information = commission_info(user.commission, conn)
|
||||
|
||||
|
@ -199,7 +199,7 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
defp map_fetch(map, field_name), do: Map.get(map, field_name)
|
||||
|
||||
defp commission_info(%{information: info}, conn) when info not in [nil, ""],
|
||||
do: Renderer.render_one(%{body: info}, conn)
|
||||
do: TextileRenderer.render_one(%{body: info}, conn)
|
||||
|
||||
defp commission_info(_commission, _conn), do: ""
|
||||
|
||||
|
@ -264,7 +264,7 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
|
||||
mod_notes =
|
||||
mod_notes
|
||||
|> Renderer.render_collection(conn)
|
||||
|> TextileRenderer.render_collection(conn)
|
||||
|> Enum.zip(mod_notes)
|
||||
|
||||
assign(conn, :mod_notes, mod_notes)
|
||||
|
|
|
@ -4,7 +4,7 @@ defmodule PhilomenaWeb.TagController do
|
|||
alias PhilomenaWeb.ImageLoader
|
||||
alias Philomena.Elasticsearch
|
||||
alias Philomena.{Tags, Tags.Tag}
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Interactions
|
||||
|
||||
plug PhilomenaWeb.RecodeParameterPlug, [name: "id"] when action in [:show]
|
||||
|
@ -57,10 +57,10 @@ defmodule PhilomenaWeb.TagController do
|
|||
|
||||
interactions = Interactions.user_interactions(images, user)
|
||||
|
||||
body = Renderer.render_one(%{body: tag.description || ""}, conn)
|
||||
body = TextileRenderer.render_one(%{body: tag.description || ""}, conn)
|
||||
|
||||
dnp_bodies =
|
||||
Renderer.render_collection(Enum.map(tag.dnp_entries, &%{body: &1.conditions || ""}), conn)
|
||||
TextileRenderer.render_collection(Enum.map(tag.dnp_entries, &%{body: &1.conditions || ""}), conn)
|
||||
|
||||
dnp_entries = Enum.zip(dnp_bodies, tag.dnp_entries)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ defmodule PhilomenaWeb.TopicController do
|
|||
alias Philomena.{Forums.Forum, Topics.Topic, Posts.Post, Polls.Poll, PollOptions.PollOption}
|
||||
alias Philomena.{Forums, Topics, Posts}
|
||||
alias Philomena.PollVotes
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
||||
|
@ -56,7 +56,7 @@ defmodule PhilomenaWeb.TopicController do
|
|||
|> preload([:deleted_by, :topic, topic: :forum, user: [awards: :badge]])
|
||||
|> Repo.all()
|
||||
|
||||
rendered = Renderer.render_collection(posts, conn)
|
||||
rendered = TextileRenderer.render_collection(posts, conn)
|
||||
|
||||
posts = Enum.zip(posts, rendered)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
defmodule PhilomenaWeb.ImageLoader do
|
||||
alias Philomena.Elasticsearch
|
||||
alias Philomena.Images.{Image, Query}
|
||||
alias Philomena.Textile.Renderer
|
||||
alias PhilomenaWeb.TextileRenderer
|
||||
alias Philomena.Tags.Tag
|
||||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
@ -135,11 +135,11 @@ defmodule PhilomenaWeb.ImageLoader do
|
|||
|
||||
defp render_bodies([tag], conn) do
|
||||
dnp_bodies =
|
||||
Renderer.render_collection(Enum.map(tag.dnp_entries, &%{body: &1.conditions || ""}), conn)
|
||||
TextileRenderer.render_collection(Enum.map(tag.dnp_entries, &%{body: &1.conditions || ""}), conn)
|
||||
|
||||
dnp_entries = Enum.zip(dnp_bodies, tag.dnp_entries)
|
||||
|
||||
description = Renderer.render_one(%{body: tag.description || ""}, conn)
|
||||
description = TextileRenderer.render_one(%{body: tag.description || ""}, conn)
|
||||
|
||||
[{tag, description, dnp_entries}]
|
||||
end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
defmodule Philomena.Textile.Renderer do
|
||||
# todo: belongs in PhilomenaWeb
|
||||
defmodule PhilomenaWeb.TextileRenderer do
|
||||
alias Textile.Parser
|
||||
alias Philomena.Images.Image
|
||||
alias Philomena.Repo
|
Loading…
Reference in a new issue